[libvirt] Redefining the XML of VM

Ján Tomko jtomko at redhat.com
Wed Jan 8 13:36:22 UTC 2014

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).


[1] https://www.redhat.com/archives/libvirt-users/2013-November/msg00020.html

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

More information about the libvir-list mailing list