Taimur Al Said
2014-Mar-24 16:36 UTC
[libvirt-users] Starting processes inside VMs using Libvirt?
Hi there, I am a beginner with Libvirt. I was practicing using Python bindings with libvirt to do some basic stuff like starting a VM, rebooting a VM, displaying the number of domain,etc. I was wondering since the hypervisor has control over the VMs, it is possible to use Libvirt to inject code into the VM? Is it possible to start processes inside a particular VM using the Libvirt API. If not, what would you recommend instead? Thanks in advance Regards, T.alsaid
Eric Blake
2014-Mar-24 17:17 UTC
Re: [libvirt-users] Starting processes inside VMs using Libvirt?
On 03/24/2014 10:36 AM, Taimur Al Said wrote:> Hi there, > > I am a beginner with Libvirt. I was practicing using Python bindings with > libvirt to do some basic stuff like starting a VM, rebooting a VM, > displaying the number of domain,etc. I was wondering since the hypervisor > has control over the VMs, it is possible to use Libvirt to inject code into > the VM? Is it possible to start processes inside a particular VM using the > Libvirt API. If not, what would you recommend instead? Thanks in advanceWhat hypervisor are you using? With lxc:// URI, this is already possible (see virsh lxc-enter-namespace). With qemu:// URI, this isn't really libvirt's thing to do directly; but you might be able to enhance the qemu-guest-agent to run an arbitrary command, then install that agent in your guest, then use libvirt's 'virsh qemu-agent-command' to drive that new agent command. If the changes you want in your guest can be done while the guest is offline, then libguestfs is a great suite of tools for making all sorts of guest disk image modifications (which is as programmatic as you can get for injecting behavior changes into your guest). But actually injecting live processes into a running qemu guest is not possible without setting up some sort of higher-level protocol, such as qemu-guest-agent. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Taimur Al Said
2014-Mar-24 19:31 UTC
Re: [libvirt-users] Starting processes inside VMs using Libvirt?
Thank you Eric, I am using KVM: qemu.. I'll try to see how I can use qemu-guest-agent.. If you have links to examples on how to start with it let me know please. Consider the following simple scenario.. I am using KVM to run several VMs; one of OSs in the guests is Windows XP. I want to send to it something from the Hypervisor level, e,g text,parameters,etc so that it will be displayed in the VM screen or stored in a file so I can read from the VM later.. It's best to be done on a live VM. How can such a simple scenario be performed. Does it have to be through the method of qemu-guest-agent?? Thanks alot, T.alsaid On Mon, Mar 24, 2014 at 5:17 PM, Eric Blake <eblake@redhat.com> wrote:> On 03/24/2014 10:36 AM, Taimur Al Said wrote: > > Hi there, > > > > I am a beginner with Libvirt. I was practicing using Python bindings with > > libvirt to do some basic stuff like starting a VM, rebooting a VM, > > displaying the number of domain,etc. I was wondering since the hypervisor > > has control over the VMs, it is possible to use Libvirt to inject code > into > > the VM? Is it possible to start processes inside a particular VM using > the > > Libvirt API. If not, what would you recommend instead? Thanks in advance > > What hypervisor are you using? With lxc:// URI, this is already > possible (see virsh lxc-enter-namespace). With qemu:// URI, this isn't > really libvirt's thing to do directly; but you might be able to enhance > the qemu-guest-agent to run an arbitrary command, then install that > agent in your guest, then use libvirt's 'virsh qemu-agent-command' to > drive that new agent command. > > If the changes you want in your guest can be done while the guest is > offline, then libguestfs is a great suite of tools for making all sorts > of guest disk image modifications (which is as programmatic as you can > get for injecting behavior changes into your guest). But actually > injecting live processes into a running qemu guest is not possible > without setting up some sort of higher-level protocol, such as > qemu-guest-agent. > > -- > Eric Blake eblake redhat com +1-919-301-3266 > Libvirt virtualization library http://libvirt.org > >