[libvirt] Qemu guest agent to install RPMs in guest VM from host machine

Eric Blake eblake at redhat.com
Thu Jun 12 16:23:02 UTC 2014


On 06/12/2014 09:48 AM, Puneet Bakshi wrote:

> 
> 1. Whenever a new guest VM is created, take (predefined) RPM packages from
> host to guest VM and install them.

Install them before starting the guest - libguestfs is your friend.

> 
> 2. Start a script in guest VM (at certain events).
> 
> 3. Start a process in guest VM (at certain events).

How would you make a bare-metal machine do this? Existing solutions
include puppet, chef, ansible, and many more.  So why not just install
puppet in your guest in step 1, and then for step 2 and 3 connect to
your guest via puppet and provision your machine the same way you would
provision a bare-metal machine.  Then you don't have to worry about
extending the guest agent or waiting for new code, when you can already
use existing code.

But if you INSIST on extending qemu-guest-agent, that discussion belongs
first on the qemu list (as owner of the guest agent) and not here (since
libvirt can only expose what qemu already provides).

> 
> I thought to address above issues by having a QEMU guest agent running
> inside guest VM which has one new command, to which I somehow pass RPMs
> using "virsh qemu-guest-agent ..." command.

Note that the 'virsh qemu-guest-agent' command is explicitly unsupported
- it exists as a debugging/development aid, and should not be relied on
as a stable interface.  If you find yourself using a particular guest
agent frequently, it's better to turn that into a formal libvirt API
(witness how 1.2.5 added the virDomainSetTime command to formalize the
previous use of qemu-guest-agent guest-set-time).

> 
> In existing qemu-ga code, I saw some examples where they fork() and
> execle() some stuff. I though I can achieve [2] and [3] using the same way.

Yes, and there has been previous discussion on the qemu list about how
to add a guest agent command to fork an arbitrary process in the guest,
but it has not yet reached consensus and does not currently have anyone
trying to push it through.  You'd have to do the legwork yourself on the
qemu list to get it added.

> 
> But, I was getting stuck at [1] in how to transfer files from host to guest
> and do something with them. I thought I should be able to transfer files
> using channel like socket/virtio, but was not getting the clue on how to
> use them.

How would you transfer files to a bare-metal machine?  Via shared
filesystem (NFS, gluster, 9p, MTP, ...).  So do the same for your guest
- set up your host to export a shared filesystem that your guest can
then mount.  There's no need to shove the file through the guest-agent
when you can already access it in the guest via existing file systems.

> 
> Regards,
> ~Puneet
> [PS: What is meant by top-post. I am using gmail and using "reply all". How
> can I avoid top-post?]

You manually have to move your cursor to the bottom of the mail before
you start typing.  (Using non-web-mail agents like mutt or thunderbird
can make it easier to automatically avoid top-posting)
http://lmgtfy.com/?q=top-posting
http://www.caliburn.nl/topposting.html

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140612/f800c5eb/attachment-0001.sig>


More information about the libvir-list mailing list