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

Cole Robinson crobinso at redhat.com
Mon Jan 27 15:19:34 UTC 2014

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="">
>        <listen type="address" address=""/>
>      </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


  virt-xml $domain --edit 2 --graphics password=foo


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

More information about the libvir-list mailing list