[libvirt] Redefining the XML of VM

Hi, I'm a newbie to Libvirt, i want to know if i can change the vm definition xml dynamically. like change cpu, network value. I found the hook in Libvirt, and i can get the xml from standard input. but i change it and out put to standard output, it no effect. I was try to execute “virsh define” shell command in python script on hook, but it was blocked and unabled to execute another Libvirt command. Is there create vm hook in Libvirt? Any help is appreciated. Regards,

On 01/08/2014 01:56 PM, kangta123 wrote:
Hi,
I'm a newbie to Libvirt, i want to know if i can change the vm definition xml dynamically. like change cpu, network value.
You can't do that with hooks. You'll need to edit the domain definition before you ask libvirt to start it.
I found the hook in Libvirt, and i can get the xml from standard input. but i change it and out put to standard output, it no effect.
Libvirt only reads the standard output of the migrate hook script.
I was try to execute “virsh define” shell command in python script on hook, but it was blocked and unabled to execute another Libvirt command.
You shouldn't call libvirt functions from your hook script, see http://libvirt.org/hooks.html#recursive or [1].
Is there create vm hook in Libvirt?
No (and it wouldn't let you change the definition anyway). Jan [1] https://www.redhat.com/archives/libvirt-users/2013-November/msg00020.html

On 01/08/2014 06:36 AM, Ján Tomko wrote:
On 01/08/2014 01:56 PM, kangta123 wrote:
Hi,
I'm a newbie to Libvirt, i want to know if i can change the vm definition xml dynamically. like change cpu, network value.
You can't do that with hooks. You'll need to edit the domain definition before you ask libvirt to start it.
There are _some_ things you can change on a running domain, such as network devices, by means of hotplug operations. But you can't do a wholesale change of the XML outside of hotplug except for an offline domain. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (3)
-
Eric Blake
-
Ján Tomko
-
kangta123