[libvirt] virsh capabilities vs. domcapabilities

We have some inconsistencies in the node capabilities (which shows guest capabilities for some default binaries) and domcapabilities (which shows guest capabilities for a specified binary). It might be nicer for client applications if the two XML components share a common schema and output layout, so that the same client code can be used to parse either (sub-tree of) XML, modulo the name of the top-most element containing the tree. Furthermore, I'm trying to figure out how to advertise whether a given domain will support active commit (and similarly, Peter's patches for relative backing name preservation). Advertising the feature just through 'virsh capabilities' is insufficient, because that only covers the default binary; so it seems like the sort of thing that should also be in 'virsh domcapabilities'. Since virConnectGetDomainCapabilities is brand new to 1.2.7, we still have time to change its XML. But I want consensus on whether we need things to match, or whether we intentionally want people to rely only on the newer XML format of the new API call (that is, don't bloat 'virsh capabilities'/virConnectGetCapabilities any further, and learning whether active commit is supported will have to be done via 'virsh domcapabilities'/virConnectGetDomainCapabilities). That is, I'm wondering if <domainCapabilities> should use <capabilities>/<guest> as its starting point, rather than completely inventing new XML. I'm also finding 'virsh domcapabilities' a bit hard to use - even though it allows all its arguments to be optional at the RPC level, the qemu implementation isn't so happy: # tools/virsh domcapabilities error: failed to get emulator capabilities error: virttype_str in qemuConnectGetDomainCapabilities must not be NULL but how am I supposed to know what --virttype strings are valid? # tools/virsh domcapabilities --virttype kvm error: failed to get emulator capabilities error: invalid argument: at least one of emulatorbin or architecture fields must be present Would it be nicer to behave the same as 'virsh capabilities' and give the details of the default binary in this case? Now, for a comparison between the two XML per binary: 'virsh capabilities' gives me this segment: <guest> <os_type>hvm</os_type> <arch name='alpha'> <wordsize>64</wordsize> <emulator>/usr/bin/qemu-system-alpha</emulator> <machine maxCpus='4'>clipper</machine> <domain type='qemu'> </domain> </arch> <features> <deviceboot/> <disksnapshot default='on' toggle='no'/> </features> </guest> while 'virsh domcapabilities --emulatorbin /usr/bin/qemu-system-alpha --virttype kvm' gives this: <domainCapabilities> <path>/usr/bin/qemu-system-alpha</path> <domain>kvm</domain> <machine>clipper</machine> <arch>alpha</arch> <vcpu max='4'/> <devices> <disk supported='yes'> <enum name='diskDevice'> <value>disk</value> <value>cdrom</value> <value>floppy</value> <value>lun</value> </enum> <enum name='bus'> <value>ide</value> <value>fdc</value> <value>scsi</value> <value>virtio</value> <value>usb</value> </enum> </disk> <hostdev supported='yes'> <enum name='mode'> <value>subsystem</value> </enum> <enum name='startupPolicy'> <value>default</value> <value>mandatory</value> <value>requisite</value> <value>optional</value> </enum> <enum name='subsysType'> <value>usb</value> <value>pci</value> <value>scsi</value> </enum> <enum name='capsType'/> <enum name='pciBackend'/> </hostdev> </devices> </domainCapabilities> I'm okay that the domcapabilites output is longer, and don't think we need to backport any of the new stuff to the older API. But any information present in the old API should be easily retrieved using the new API, so that the information isn't lost, and so that a client can learn the same amount of detail about a non-default binary as they can about the defaults. Look at the difference in XPath to get to some of the same information: /guest/os_type vs. ? - where is os_type in domcapabilities? /guest/arch@name vs. /domainCapabilities/arch - why is one an attribute and the other an element? /guest/arch/wordsize vs. nothing - where is wordsize in domcapabilities? /guest/arch/emulator vs. /domainCapabilities/path - why 3 levels vs. 2, and different naming? /guest/arch/machine@maxCpus vs. /domainCapabilities/vcpu@max - why 3 levels vs. 2, with different naming? /guest/arch/machine vs. /domainCapabilities/machine - why 3 levels vs. 2? /guest/arch/domain@type vs. /domainCapabilities/domain - why attribute of 3 levels vs. element at 2 levels? And did I expose an error when I passed --virrtype kvm, even though qemu-system-alpha is only a qemu emulator on my machine (since kvm emulators is only for hardware-assit emulation, which is not possible when I'm doing cross architecture)? /guest/features vs. ? - where are the features in domcapabilities? -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Wed, Jul 16, 2014 at 01:00:30PM -0600, Eric Blake wrote:
Furthermore, I'm trying to figure out how to advertise whether a given domain will support active commit (and similarly, Peter's patches for relative backing name preservation). Advertising the feature just through 'virsh capabilities' is insufficient, because that only covers the default binary; so it seems like the sort of thing that should also be in 'virsh domcapabilities'.
My view is that now we have dom capabilities, we shouldn't add anything more to the old capabilities that is related to guest emulators. The main motivation is that the old capabilities is not scalable given the sheer volume of data we need to report per QEMU.
Since virConnectGetDomainCapabilities is brand new to 1.2.7, we still have time to change its XML. But I want consensus on whether we need things to match, or whether we intentionally want people to rely only on the newer XML format of the new API call (that is, don't bloat 'virsh capabilities'/virConnectGetCapabilities any further, and learning whether active commit is supported will have to be done via 'virsh domcapabilities'/virConnectGetDomainCapabilities). That is, I'm wondering if <domainCapabilities> should use <capabilities>/<guest> as its starting point, rather than completely inventing new XML.
I don't think there's really anything of value in the old capabilities XML schema that needs preserving as-is.
I'm also finding 'virsh domcapabilities' a bit hard to use - even though it allows all its arguments to be optional at the RPC level, the qemu implementation isn't so happy:
# tools/virsh domcapabilities error: failed to get emulator capabilities error: virttype_str in qemuConnectGetDomainCapabilities must not be NULL
but how am I supposed to know what --virttype strings are valid?
Hmm, I'm pretty sure we agreed virt type was going to be optional and would jsut get a sensible default. So we should fix that.
# tools/virsh domcapabilities --virttype kvm error: failed to get emulator capabilities error: invalid argument: at least one of emulatorbin or architecture fields must be present
Would it be nicer to behave the same as 'virsh capabilities' and give the details of the default binary in this case?
My original idea was that either emulator or arch would be required. If we wanted to allow just virtype on its own, I guess we could just default to the current host arch.
Now, for a comparison between the two XML per binary:
'virsh capabilities' gives me this segment:
<guest> <os_type>hvm</os_type> <arch name='alpha'> <wordsize>64</wordsize> <emulator>/usr/bin/qemu-system-alpha</emulator> <machine maxCpus='4'>clipper</machine> <domain type='qemu'> </domain> </arch> <features> <deviceboot/> <disksnapshot default='on' toggle='no'/> </features> </guest>
while 'virsh domcapabilities --emulatorbin /usr/bin/qemu-system-alpha --virttype kvm' gives this:
<domainCapabilities> <path>/usr/bin/qemu-system-alpha</path> <domain>kvm</domain> <machine>clipper</machine> <arch>alpha</arch> <vcpu max='4'/> <devices> <disk supported='yes'> <enum name='diskDevice'> <value>disk</value> <value>cdrom</value> <value>floppy</value> <value>lun</value> </enum> <enum name='bus'> <value>ide</value> <value>fdc</value> <value>scsi</value> <value>virtio</value> <value>usb</value> </enum> </disk> <hostdev supported='yes'> <enum name='mode'> <value>subsystem</value> </enum> <enum name='startupPolicy'> <value>default</value> <value>mandatory</value> <value>requisite</value> <value>optional</value> </enum> <enum name='subsysType'> <value>usb</value> <value>pci</value> <value>scsi</value> </enum> <enum name='capsType'/> <enum name='pciBackend'/> </hostdev> </devices> </domainCapabilities>
I'm okay that the domcapabilites output is longer, and don't think we need to backport any of the new stuff to the older API. But any information present in the old API should be easily retrieved using the new API, so that the information isn't lost, and so that a client can learn the same amount of detail about a non-default binary as they can about the defaults.
Look at the difference in XPath to get to some of the same information:
/guest/os_type vs. ? - where is os_type in domcapabilities?
Yep, that's an oversight really.
/guest/arch@name vs. /domainCapabilities/arch - why is one an attribute and the other an element?
/guest/arch/wordsize vs. nothing - where is wordsize in domcapabilities?
/guest/arch/emulator vs. /domainCapabilities/path - why 3 levels vs. 2, and different naming?
/guest/arch/machine@maxCpus vs. /domainCapabilities/vcpu@max - why 3 levels vs. 2, with different naming?
/guest/arch/machine vs. /domainCapabilities/machine - why 3 levels vs. 2?
This is just a reflection of the fact that we're doing a different XML schema. We had the extra '/guest' level in the original XML because we were reporting on multiple guest types. I see no reason to make the new XML have this uneccessary extra level of nesting.
/guest/arch/domain@type vs. /domainCapabilities/domain - why attribute of 3 levels vs. element at 2 levels? And did I expose an error when I passed --virrtype kvm, even though qemu-system-alpha is only a qemu emulator on my machine (since kvm emulators is only for hardware-assit emulation, which is not possible when I'm doing cross architecture)?
/guest/features vs. ? - where are the features in domcapabilities?
Explicitly gone. The features element in the current capabilies is just a dumping ground for random stuff. Initially at least the new capabilities XML is structured around the idea of reporting valid enum strings for elements in the domain XML schema, and is structured to follow the domain XML schema nested. I guess you're wondering about where to fit in the data that isn't related to the domain XML schema, but rather API capabilities. I'd suggest we try to come up with something formal for API information. eg <operations> <nameoftheapiwithvirprefixremoved> ...info... </nameoftheapiwithvirprefixremoved> </operations> If the info is related to an 'unsigned int flags' parameter value then we should perhaps using <flag name="NNNN"/> where 'NNNN' is the trailing suffix of the flag constant name (ie the common shared prefix removed). eg for virDomainBlockRebase, we might add <operations> <blockrebase> <flag name="relative" supported='yes|no'/> </blockrebase> </operations> NB, absence of a <flag name='xxx'> entirely does not mean it is unsupported. It just means we've declined to provide info on it. We'd always have an explicit supported='no' attribute for stuff that is not supported. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 16.07.2014 21:00, Eric Blake wrote:
We have some inconsistencies in the node capabilities (which shows guest capabilities for some default binaries) and domcapabilities (which shows guest capabilities for a specified binary). It might be nicer for client applications if the two XML components share a common schema and output layout, so that the same client code can be used to parse either (sub-tree of) XML, modulo the name of the top-most element containing the tree.
Furthermore, I'm trying to figure out how to advertise whether a given domain will support active commit (and similarly, Peter's patches for relative backing name preservation). Advertising the feature just through 'virsh capabilities' is insufficient, because that only covers the default binary; so it seems like the sort of thing that should also be in 'virsh domcapabilities'.
That depends on how's active commit accepted by libvirt. IIUC it's a flag to an API. (Okay, you got me there, I'm not paying much attention to snapshot work). The best solution would be to introduce another section, where supported flags to APIs would be enumerated (same way that attribute values are). But this is sooo much more work than in attribute part (esp. without introspection) that the resulting code would be unmaintainable. So my suggestion is to come up with yet another section and put arbitrary strings there to represent features like active commit. For instance: <domainCapabilities> <path/> <domain/> ... <features> <enum name='commit'> <value>active-commit</value> <value>{some ordinary commit}</value> </enum> </features> <devices/> </domainCapabilities>
Since virConnectGetDomainCapabilities is brand new to 1.2.7, we still have time to change its XML. But I want consensus on whether we need things to match, or whether we intentionally want people to rely only on the newer XML format of the new API call (that is, don't bloat 'virsh capabilities'/virConnectGetCapabilities any further, and learning whether active commit is supported will have to be done via 'virsh domcapabilities'/virConnectGetDomainCapabilities). That is, I'm wondering if <domainCapabilities> should use <capabilities>/<guest> as its starting point, rather than completely inventing new XML.
I'm also finding 'virsh domcapabilities' a bit hard to use - even though it allows all its arguments to be optional at the RPC level, the qemu implementation isn't so happy:
# tools/virsh domcapabilities error: failed to get emulator capabilities error: virttype_str in qemuConnectGetDomainCapabilities must not be NULL
but how am I supposed to know what --virttype strings are valid?
By reading the documentation :P From the virsh manpage: The virttype option specifies the virtualization type used. The value to be used is either from the 'type' attribute of the <domain/> top level element from the domain XML or the 'type' attribute found within each <guest/> element from the virsh capabilities output. I know virsh user is user unfriendly, but I think this could be solved by wise auto completion (if I find another student to complete it). Or if you have any idea meanwhile ...
# tools/virsh domcapabilities --virttype kvm error: failed to get emulator capabilities error: invalid argument: at least one of emulatorbin or architecture fields must be present
Would it be nicer to behave the same as 'virsh capabilities' and give the details of the default binary in this case?
Sure, but in order to get default binary we must know architecture (consider the case where you have both /usr/bin/qemu-system-x86_64 and /usr/bin/qemu-system-i686). Although, having only one qemu binary on the system makes it easy to find the default, doesn't it? Patch on the way.
Now, for a comparison between the two XML per binary:
'virsh capabilities' gives me this segment:
<guest> <os_type>hvm</os_type> <arch name='alpha'> <wordsize>64</wordsize> <emulator>/usr/bin/qemu-system-alpha</emulator> <machine maxCpus='4'>clipper</machine> <domain type='qemu'> </domain> </arch> <features> <deviceboot/> <disksnapshot default='on' toggle='no'/> </features> </guest>
while 'virsh domcapabilities --emulatorbin /usr/bin/qemu-system-alpha --virttype kvm' gives this:
<domainCapabilities> <path>/usr/bin/qemu-system-alpha</path> <domain>kvm</domain> <machine>clipper</machine> <arch>alpha</arch> <vcpu max='4'/> <devices> <disk supported='yes'> <enum name='diskDevice'> <value>disk</value> <value>cdrom</value> <value>floppy</value> <value>lun</value> </enum> <enum name='bus'> <value>ide</value> <value>fdc</value> <value>scsi</value> <value>virtio</value> <value>usb</value> </enum> </disk> <hostdev supported='yes'> <enum name='mode'> <value>subsystem</value> </enum> <enum name='startupPolicy'> <value>default</value> <value>mandatory</value> <value>requisite</value> <value>optional</value> </enum> <enum name='subsysType'> <value>usb</value> <value>pci</value> <value>scsi</value> </enum> <enum name='capsType'/> <enum name='pciBackend'/> </hostdev> </devices> </domainCapabilities>
I'm okay that the domcapabilites output is longer, and don't think we need to backport any of the new stuff to the older API. But any information present in the old API should be easily retrieved using the new API, so that the information isn't lost, and so that a client can learn the same amount of detail about a non-default binary as they can about the defaults.
Look at the difference in XPath to get to some of the same information:
/guest/os_type vs. ? - where is os_type in domcapabilities?
nowhere yet.
/guest/arch@name vs. /domainCapabilities/arch - why is one an attribute and the other an element?
/guest/arch/wordsize vs. nothing - where is wordsize in domcapabilities?
Well, nowhere yet. But it's trivial to add.
/guest/arch/emulator vs. /domainCapabilities/path - why 3 levels vs. 2, and different naming?
This is something provided by callee, so in fact it has no additional value.
/guest/arch/machine@maxCpus vs. /domainCapabilities/vcpu@max - why 3 levels vs. 2, with different naming?
Because we may want to extend <vcpu/> fom domaincaps in the future.
/guest/arch/machine vs. /domainCapabilities/machine - why 3 levels vs. 2?
/guest/arch/domain@type vs. /domainCapabilities/domain - why attribute of 3 levels vs. element at 2 levels? And did I expose an error when I passed --virrtype kvm, even though qemu-system-alpha is only a qemu emulator on my machine (since kvm emulators is only for hardware-assit emulation, which is not possible when I'm doing cross architecture)?
/guest/features vs. ? - where are the features in domcapabilities?
To sum up - I'm not hesitant to make things easier for users, but allowing them to use same XPath over different types of XML documents put much pressure on us. On the other hand, patches are welcome - as usual :) Michal

On Thu, Jul 17, 2014 at 11:05:08AM +0200, Michal Privoznik wrote:
# tools/virsh domcapabilities --virttype kvm error: failed to get emulator capabilities error: invalid argument: at least one of emulatorbin or architecture fields must be present
Would it be nicer to behave the same as 'virsh capabilities' and give the details of the default binary in this case?
Sure, but in order to get default binary we must know architecture (consider the case where you have both /usr/bin/qemu-system-x86_64 and /usr/bin/qemu-system-i686). Although, having only one qemu binary on the system makes it easy to find the default, doesn't it? Patch on the way.
IMHO it would be preferrable to always default to virArchFromHost() if arch is none, since that gives a predictable default value, as opposed to probing emulators which is unpredictable Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 17.07.2014 11:11, Daniel P. Berrange wrote:
On Thu, Jul 17, 2014 at 11:05:08AM +0200, Michal Privoznik wrote:
# tools/virsh domcapabilities --virttype kvm error: failed to get emulator capabilities error: invalid argument: at least one of emulatorbin or architecture fields must be present
Would it be nicer to behave the same as 'virsh capabilities' and give the details of the default binary in this case?
Sure, but in order to get default binary we must know architecture (consider the case where you have both /usr/bin/qemu-system-x86_64 and /usr/bin/qemu-system-i686). Although, having only one qemu binary on the system makes it easy to find the default, doesn't it? Patch on the way.
IMHO it would be preferrable to always default to virArchFromHost() if arch is none, since that gives a predictable default value, as opposed to probing emulators which is unpredictable
Yep, that's exactly what I've done in my patch: https://www.redhat.com/archives/libvir-list/2014-July/msg00884.html Michal

On 07/17/2014 03:05 AM, Michal Privoznik wrote:
Furthermore, I'm trying to figure out how to advertise whether a given domain will support active commit (and similarly, Peter's patches for relative backing name preservation). Advertising the feature just through 'virsh capabilities' is insufficient, because that only covers the default binary; so it seems like the sort of thing that should also be in 'virsh domcapabilities'.
That depends on how's active commit accepted by libvirt. IIUC it's a flag to an API. (Okay, you got me there, I'm not paying much attention to snapshot work).
You use a flag to trigger it for now (although there is a proposal to eventually allow active commit without a flag); but the main point is that people want to know up front if the flag even stands a chance of working, which depends on the abilities of the qemu binary.
The best solution would be to introduce another section, where supported flags to APIs would be enumerated (same way that attribute values are). But this is sooo much more work than in attribute part (esp. without introspection) that the resulting code would be unmaintainable.
A list of supported flags may be too hard, compared to just a list of feature names.
I'm also finding 'virsh domcapabilities' a bit hard to use - even though it allows all its arguments to be optional at the RPC level, the qemu implementation isn't so happy:
# tools/virsh domcapabilities error: failed to get emulator capabilities error: virttype_str in qemuConnectGetDomainCapabilities must not be NULL
but how am I supposed to know what --virttype strings are valid?
By reading the documentation :P From the virsh manpage:
The virttype option specifies the virtualization type used. The value to be used is either from the 'type' attribute of the <domain/> top level element from the domain XML or the 'type' attribute found within each <guest/> element from the virsh capabilities output.
You know, I can think of a couple of UI additions that would make this command really cool: - virsh domcapabilities --domain $dom uses the same name, uuid, or id as all other domain lookups, then calls dumpxml on that domain, scrapes the <domain> XML, and uses the parameters it found to pass to the virConnectGetDomainCapabilities call - virsh domcapabilities --xml $file takes $file which contains either <domain> or <guest> XML (no ambiguity, because the top level element says which style), scrapes it for the right parameters, and passes those parameters (or NULL for missing parameters) to virConnectGetDomainCapabilities Remember, it is possible to define a <domain> with the user input XML not listing an <emulator>, where a later dumpxml will show the default emulator that got chosen. So the same idea applies to the virsh command - if the user supplies a <domain> XML file without an explicit <emulator>, then we use NULL for that parameter to virConnectGetDomainCapabilities, and we should get results for the default emulator that will be used to run that domain. Also, by allowing <guest> XML (as a subset of overall 'virsh capabilities') as the input, it is possible to easily transition from the old API (tell me what emulator(s) will be used) to the new (tell me what features/drivers I can use with that emulator).
I know virsh user is user unfriendly, but I think this could be solved by wise auto completion (if I find another student to complete it). Or if you have any idea meanwhile ...
There's a pending patch series (now several months old) that improves some auto completion; I need to find time to review and revive it.
/guest/arch/emulator vs. /domainCapabilities/path - why 3 levels vs. 2, and different naming?
This is something provided by callee, so in fact it has no additional value.
Not true. If you take my argument above about allowing NULL emulator to mean "tell me the default emulator and its capabilities", then this output parameter is essential in that case.
/guest/arch/machine@maxCpus vs. /domainCapabilities/vcpu@max - why 3 levels vs. 2, with different naming?
Because we may want to extend <vcpu/> fom domaincaps in the future.
Okay, so we are intentionally breaking design from the old XML, and clients cannot share XPath code between the old style and new style. I can live with that; although it might be worth some documentation on the old API how to find the same information in the new. Maybe as simple as just documenting all the mappings that I already identified in this mail. I know - patches welcome :) -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (3)
-
Daniel P. Berrange
-
Eric Blake
-
Michal Privoznik