[libvirt] ANNOUNCE: virt-xml: Edit libvirt XML with command line options

I've just pushed a new tool to virt-manager.git called virt-xml. virt-xml uses virt-install's command line options to allow building and editing domain XML. Best way to describe what it can do is with a bunch of examples: See a list of all suboptions that --disk and --network take # virt-xml --disk=? --network=? Change the <description> of domain 'example': # virt-xml example --edit --metadata description="my new description" # Enable the boot device menu for domain 'example': # virt-xml example --edit --boot bootmenu=on Clear the previous <cpu> definition of domain 'winxp', change it to 'host-model', but interactively confirm the diff before saving: # virt-xml winxp --edit --cpu host-model,clearxml=yes --confirm Change the sound cards with model=ac97 to model=ich6 on 'fedora19', but only output the diff: # virt-xml fedora19 --edit model=ac97 --soundhw model=ich6 --print-diff Update the first graphics password to 'foo' of the running VM 'rhel6': # virt-xml rhel6 --edit --graphics password=foo --update Remove the disk path from disk device hdc: # virt-xml rhel6 --edit target=hdc --disk path= Change all disk devices of type 'disk' to use cache=none, using XML from stdin, printing the new XML to stdout. # cat <xmlfile> | virt-xml --edit device=disk --disk cache=none Change all host devices to use driver_name=vfio for VM 'fedora20' on the remote connection # virt-xml --connect qemu+ssh://remotehost/system \ fedora20 --edit all --host-device driver_name=vfio Hotplug host USB device 001.003 to running domain 'fedora19': # virt-xml f19 --add-device --host-device 001.003 --update Add a spicevmc channel to the domain 'winxp', that will be available after the next VM shutdown. # virt-xml winxp --add-device --channel spicevmc Create a 10G qcow2 disk image and attach it to 'fedora18' for the next VM startup: # virt-xml fedora18 --add-device \ --disk /var/lib/libvirt/images/newimage.qcow2,format=qcow2,size=10 Remove the disk vdb from the running domain 'rhel7': # virt-xml rhel7 --remove-device --disk target=vdb Remove all graphics devices from the VM 'rhel7' after the next shutdown: # virt-xml rhel7 --remove-device --graphics all Generate XML for a virtio console device and print it to stdout: # virt-xml --build-xml --console pty,target_type=virtio The man page and --help output have more info, man page at: https://git.fedorahosted.org/cgit/virt-manager.git/tree/man/virt-xml.pod If you are interested in trying it out before it hits any distro, it's really simple: git clone git://git.fedorahosted.org/virt-manager.git cd virt-manager ./virt-xml --help Nothing is set in stone yet, so if anyone has suggestions about the command line syntax or any of the above, please speak up: I plan on cutting a new virt-manager release with virt-xml within the next few weeks. Thanks, Cole

On Sun, Jan 26, 2014 at 01:24:59PM -0500, Cole Robinson wrote:
I've just pushed a new tool to virt-manager.git called virt-xml. virt-xml uses virt-install's command line options to allow building and editing domain XML. Best way to describe what it can do is with a bunch of examples:
Hi, good job, no more adding of useless options to virsh :) I am just wondering about one thing: [...]
Update the first graphics password to 'foo' of the running VM 'rhel6':
# virt-xml rhel6 --edit --graphics password=foo --update
This changes the password for the first graphics only, but how to change it for particular one or all of them together? [...]
Remove all graphics devices from the VM 'rhel7' after the next shutdown:
# virt-xml rhel7 --remove-device --graphics all
I tried combining it with this ^^ example and I ended up with this weird diff: python2 virt-xml ipa --edit --graphics all,password=foo --print-diff --- Original XML +++ Altered XML @@ -87,7 +87,7 @@ </channel> <input type="tablet" bus="usb"/> <input type="mouse" bus="ps2"/> - <graphics type="vnc" port="-1" autoport="yes" websocket="12345"/> + <graphics type="all" port="-1" autoport="yes" websocket="12345" passwd="foo"/> <graphics type="spice" port="-1" autoport="no" listen="0.0.0.0"> <listen type="address" address="0.0.0.0"/> </graphics> -- What's the proper way to do that or is this supposed to work? If the latter is the case, I'll be happy to find the place and fix it, but I rather ask at first ;) [...]
git clone git://git.fedorahosted.org/virt-manager.git cd virt-manager ./virt-xml --help
And one off-topic question; since we have libvirt bindings for both current major python versions, is anyone working on the transition (or is it even worth it) to change to python3 or even to some compatible mid-point between these two? What would you say to a suggestion of changing our shebang in headers from '/usr/bin/python' to '/usr/bin/env python2'? Because if I have python3 set as default, none of the commands work and it looks like that's the last compatible thing to do for me to be able to stick with python3 as default. Have a nice day, Martin

On 01/27/2014 05:24 AM, Martin Kletzander wrote:
On Sun, Jan 26, 2014 at 01:24:59PM -0500, Cole Robinson wrote:
I've just pushed a new tool to virt-manager.git called virt-xml. virt-xml uses virt-install's command line options to allow building and editing domain XML. Best way to describe what it can do is with a bunch of examples:
Hi, good job, no more adding of useless options to virsh :)
I am just wondering about one thing:
[...]
Update the first graphics password to 'foo' of the running VM 'rhel6':
# virt-xml rhel6 --edit --graphics password=foo --update
This changes the password for the first graphics only, but how to change it for particular one or all of them together?
[...]
Remove all graphics devices from the VM 'rhel7' after the next shutdown:
# virt-xml rhel7 --remove-device --graphics all
I tried combining it with this ^^ example and I ended up with this weird diff:
python2 virt-xml ipa --edit --graphics all,password=foo --print-diff --- Original XML +++ Altered XML @@ -87,7 +87,7 @@ </channel> <input type="tablet" bus="usb"/> <input type="mouse" bus="ps2"/> - <graphics type="vnc" port="-1" autoport="yes" websocket="12345"/> + <graphics type="all" port="-1" autoport="yes" websocket="12345" passwd="foo"/> <graphics type="spice" port="-1" autoport="no" listen="0.0.0.0"> <listen type="address" address="0.0.0.0"/> </graphics> --
What's the proper way to do that or is this supposed to work? If the latter is the case, I'll be happy to find the place and fix it, but I rather ask at first ;)
I'm missing a few examples :) The idea is that --edit takes arguments that allow selecting which device you want to operate on. But when using --remove-device, you pass --edit style arguments to --disk/--network/--host-device etc. So to do what you are trying to do, it would be: virt-xml $domain --edit all --graphics password=foo Or virt-xml $domain --edit 2 --graphics password=foo etc. The weirdness there was my tradeoff for inventing some extra --remove-device syntax like: --remove-device host-device=driver_type=vfio,foo=bar ... The implemented way also keeps the pattern of having 1 action (--edit, --add-device, --remove-device, --build-xml) and one XML option (--disk, --network, --graphics, etc.) But suggestions welcome.
[...]
git clone git://git.fedorahosted.org/virt-manager.git cd virt-manager ./virt-xml --help
And one off-topic question; since we have libvirt bindings for both current major python versions, is anyone working on the transition (or is it even worth it) to change to python3 or even to some compatible mid-point between these two?
What would you say to a suggestion of changing our shebang in headers from '/usr/bin/python' to '/usr/bin/env python2'? Because if I have python3 set as default, none of the commands work and it looks like that's the last compatible thing to do for me to be able to stick with python3 as default.
No plans on my end and I haven't really heard many complaints. I looked at things like a year ago, but our minimal deps at the time weren't available for python3 for the cli tools at least (urlgrabber and libvirt). I wouldn't be surprised if we could get the cli tools working with python2.7 __future__ stuff pretty painlessly but no idea how difficult virt-manager work be. - Cole

On 01/26/2014 11:24 AM, Cole Robinson wrote:
I've just pushed a new tool to virt-manager.git called virt-xml. virt-xml uses virt-install's command line options to allow building and editing domain XML. Best way to describe what it can do is with a bunch of examples:
See a list of all suboptions that --disk and --network take
# virt-xml --disk=? --network=?
Nothing is set in stone yet, so if anyone has suggestions about the command line syntax or any of the above, please speak up: I plan on cutting a new virt-manager release with virt-xml within the next few weeks.
Qemu recently changed to use --foo=help rather than --foo=?, so as to avoid the need for shell quoting to avoid globbing if you have (unusual) files named ./--foo=a and such in the current directory. I'd suggest you do the same. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 01/27/2014 09:16 AM, Eric Blake wrote:
On 01/26/2014 11:24 AM, Cole Robinson wrote:
I've just pushed a new tool to virt-manager.git called virt-xml. virt-xml uses virt-install's command line options to allow building and editing domain XML. Best way to describe what it can do is with a bunch of examples:
See a list of all suboptions that --disk and --network take
# virt-xml --disk=? --network=?
Nothing is set in stone yet, so if anyone has suggestions about the command line syntax or any of the above, please speak up: I plan on cutting a new virt-manager release with virt-xml within the next few weeks.
Qemu recently changed to use --foo=help rather than --foo=?, so as to avoid the need for shell quoting to avoid globbing if you have (unusual) files named ./--foo=a and such in the current directory. I'd suggest you do the same.
Thanks for the suggestion, I added that as an option as well. - Cole

On 26.01.2014 19:24, Cole Robinson wrote:
I've just pushed a new tool to virt-manager.git called virt-xml. virt-xml uses virt-install's command line options to allow building and editing domain XML. Best way to describe what it can do is with a bunch of examples:
See a list of all suboptions that --disk and --network take
# virt-xml --disk=? --network=?
What a coincidence, libvirt-designer creates binary called virtxml :) Hopefully, it won't confuse users. Michal

On 01/28/2014 11:49 AM, Michal Privoznik wrote:
On 26.01.2014 19:24, Cole Robinson wrote:
I've just pushed a new tool to virt-manager.git called virt-xml. virt-xml uses virt-install's command line options to allow building and editing domain XML. Best way to describe what it can do is with a bunch of examples:
See a list of all suboptions that --disk and --network take
# virt-xml --disk=? --network=?
What a coincidence, libvirt-designer creates binary called virtxml :)
Hopefully, it won't confuse users.
Hmm, that's unfortunate, I didn't know about that. I wish that tool was more aptly named 'virt-designer'... - Cole
participants (4)
-
Cole Robinson
-
Eric Blake
-
Martin Kletzander
-
Michal Privoznik