[Libguestfs] Can I use libguestfs to pass some parameters into a KVM virtual machine

Richard W.M. Jones rjones at redhat.com
Tue Aug 4 05:55:55 UTC 2009


On Tue, Aug 04, 2009 at 09:26:31AM +0800, Zhang Qian wrote:
> I have installed KVM in my RHEL5.3 box, and created some VMs on it.
> I am wondering if I can use libguestfs to pass some parameters/files
> into my VMs. As you may know, for Xen, I can use xenstore command to
> do this job, can libguestfs do the same thing?
> 
> What I want to do includes:
> 1. Modify some configurations in my VM, such as editing
> /etc/sysconfig/network-scripts/ifcfg-eth0 to add a static IP for my
> VM.
> 2. Upload a script into my VM and run it in the guest OS.

Yes, this is precisely what libguestfs is for.  Make sure the virtual
machine is shut down before you try to modify it.

> Is here any sample C code I can refer to?

There are some very simple examples in the source:

  http://git.et.redhat.com/?p=libguestfs.git;a=tree;f=examples;hb=HEAD

And the documentation of the C API:

  http://libguestfs.org/guestfs.3.html

See in particular:

  http://libguestfs.org/guestfs.3.html#uploading
  http://libguestfs.org/guestfs.3.html#running_commands

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v




More information about the Libguestfs mailing list