[virt-tools-list] [PATCH] qemu:cpuid: speedup test by 3x times if grub2 is available

Eduardo Habkost ehabkost at redhat.com
Thu Feb 14 13:41:08 UTC 2013


(CCing virt-tools list in case they have any existing solutions or ideas
on how to make this easier for everybody)


On Thu, Feb 14, 2013 at 02:20:45PM +0100, Igor Mammedov wrote:
> On Thu, 14 Feb 2013 09:18:53 -0200
> Eduardo Habkost <ehabkost at redhat.com> wrote:
> 
> > On Wed, Feb 13, 2013 at 05:17:44PM +0100, Igor Mammedov wrote:
> > > qemu boots from disk image 3 times faster than direct kernel load.
> > 
> > That's surprising. Do you have any idea why that happens?
> > 
> > (CCing qemu-devel in case other QEMU developers can explain it)
> > 
> > 
> > > Use grub2-mkrescue tool to create boot image with test kernel if available
> > > and do image boot then.
> > > On FC17 it reduces 1 VM run from ~15 sec to ~5sec.
> > > 
> > > Signed-off-by: Igor Mammedov <imammedo at redhat.com>
> > > ---
> > >  qemu/tests/cpuid.py                    |   11 +++++++++--
> > >  shared/deps/cpuid_test_kernel/Makefile |   18 ++++++++++++++++--
> > >  shared/deps/cpuid_test_kernel/grub.cfg |    8 ++++++++
> > >  3 files changed, 33 insertions(+), 4 deletions(-)
> > >  create mode 100644 shared/deps/cpuid_test_kernel/grub.cfg
> > > 
> > > diff --git a/qemu/tests/cpuid.py b/qemu/tests/cpuid.py
> > > index 5065c6a..731411c 100644
> > > --- a/qemu/tests/cpuid.py
> > > +++ b/qemu/tests/cpuid.py
> > > @@ -118,13 +118,20 @@ def run_cpuid(test, params, env):
> > >                                         "cpuid_test_kernel")
> > >          os.chdir(test_kernel_dir)
> > >          utils.make("cpuid_dump_kernel.bin")
> > > +        utils.make("boot.img", ignore_status=True)
> > > +        cmdres = utils.run("cd %s && ls boot.img" % test_kernel_dir,
> > > ignore_status=True)
> > 
> > Why fork a shell just to check if a file exists? You can simply use
> > "os.path.exists('%s/boot.img' % (test_kernel_dir))" or
> > "os.path.exists(os.path.join(test_kernel_dir, 'boot.img'))".
> Thanks, I'll fix it.
> 
> > 
> > The rest of the patch looks good to me.
> > 
> > I wonder if we could make this a generic "boot kernel image" function,
> > that uses grub2-mkrescue if available, and -kernel otherwise. I believe
> > other test cases may benefit for a general mechanism to boot test
> > kernels.
> I'd make something like make_boot_image() a generic, which would
>   * take kernel, (optional initrd, kernel options), root tree directory
>   * create boot image using host available tools (which is greatly distro
>     specific depending on available tools)
> and leave decision what boot method to use to test cases.
> 
> But due to lack of free time, I went through easy road.

I understand. Maybe one day somebody will volunteer to write a more
generic solution.  :-)


> I'd glad to amend patch, if there are suggestions how to generalize it and
> improve "create boot image" process for distros that doesn't have
> grub2-mkrescue.

A reusable tool/script would be useful even outside virt-test. Anybody
who uses -kernel/-initrd today may want a more efficient solution (IIRC,
virt-install uses -kernel/-initrd when installing from a Fedora
repository URL).

But if we made that an independent tool we would have the additional
problem of having the new tool packaged and installed on the host. So
having something specific inside virt-test makes sense by now.

-- 
Eduardo




More information about the virt-tools-list mailing list