5

I currently have small VM to do certain tests (it has multiple benefits - like testing on another distribution, Fedora 15, as well as running make distcheck without the problem of polluting /).

However I'd like to automate tests and I'd like to be able to programatically (eg., using sh, python, c, ...) do the following:

  • Boot headlessly a VM (qemu) from local image
  • Wait till VM is fully booted (that's hardest part - initially I thought about magic sleep)
  • Sync the repository between host and guest (not necessary at this point)
  • Execute ./autogen && make && sudo make install && sudo make distcheck on machine
  • Download the generated tarballs from machine

I started to read about libvirt and it might allow me to use an API for that. While this would require guest support and I cannot find documentation regarding it, such ability would seem to be a logical element of libvirt.

Is it possible to check if machine is fully booted? Is there a ready tool to do this?

EDIT: By fully booted I mean that the system rc scripts have finished execution/all systemd services which were suppose to start have started. I know that qemu cannot know when it happens but I assume the support on guest side.

  • Would you be interested in a xen specific answer? Yes, it's possible via Xenbus, It would take a while to write .. so if Xen's out of the question, probably not worth it. – Tim Post Sep 17 '11 at 14:08
7

Afaik, libvirt doesn't know what "fully booted" means (neither do I). You could make a service that connect to your host (or another machine) during boot. Or you could try connecting in a loop to your guest, for example with ssh.

Another solution would be to rely on an exisiting service that communicate with the host, such as vdagent. You could easily write a spice-gtk python script that would wait until the Spice agent channel is connected (see spicy.c example, the status bar indicate the presence of the agent)

Note, testing "make distcheck" shouldn't polute / and shouldn't need sudo. If it does, it looks like a problem in your makefile.

  • The explanation of fully-booted I gave in body of main question. As of make distcheck - please discuss it fully with GObject Introspecition developers. While I agree that is unfortunate a) I'm not willing to support non-standard configuration (i.e. other then blessed by gir devs) b) I understend why it was done in such way (to make ./configure && make && sudo make install work while if the GIR macros respected prefix it would not). – Maciej Piechotka Sep 16 '11 at 11:22
3

why not just make an rc script that runs after the others and logs a message of "FULLY BOOTED". Then make syslog forward to the vm host, and wait for the message to appear in the logfiles on the host.

thats what i'd do, anyhow.

2

You can install this tool in vm: http://wiki.libvirt.org/page/Qemu_guest_agent Qemu_guest_agent will tell you when vm is fully booted.

You can also install spice guest agent in vm.If spice guest agent has started,vm is fully booted.

0

This may not related to libvirt. For a fully booted guest, there may be some port listened, for Linux, it may be 22, for Windows, it may be some port listed here. You can use nc to test if the port is listened on guest.

Some times nc is not the best choice(the timeout option of nc does not work), write a simple TCP client to connect the port is more convenient.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.