[libvirt] [PATCH 00/10] domcaps: use virTristateBool

Cole Robinson crobinso at redhat.com
Tue Feb 19 20:09:29 UTC 2019


Extending domaincapabilities with new XML schema is currently a bit of
a maintenance pain. Consider the case of adding a new enum for listing
<sound> models. I want to output this info for the qemu driver.

Internally in the domaincapabilities plumbing, whether a <device> is
supported= is tracked with boolean true/false. If I extend that
pattern for <sound> devices and fill in data for the qemu driver, the
other domcaps implementations will now automatically output a new XML
element:

  <sound supported='no'>

Now, for bhyve I can 'git grep' confirm that it doesn't have any
<sound> support, but for xen/libxl it _is_ supported. So if I don't
fill in accurate support in the xen driver, I've just made their
domcaps report blatantly incorrect info.

Ideally I would make these <sound> changes and the other drivers output
would _not_ change. xen output would now be incomplete, but not
obviously wrong, which is easier on me the developer, and safer for the
API consumer.

This moves domcaps plumbing in that direction. It switches most
internal 'supported' fields to virTristateBool so we can track an
ABSENT state and map that to outputting no XML. Explicit supported='no'
values are filled in where needed to ensure existing driver XML doesn't
change. cpu and sev supported= values are left unconverted, but they
require semi-special handling anyways so aren't really affected by the
problem I laid out above.

Cole Robinson (10):
  tests: domcaps: Add a default 'empty' test
  tests: domcaps: Remove unused typedef
  tests: domcaps: Remove 'full' test
  conf: domcaps: Add single line formatting macro
  conf: domcaps: use virTristateBool for 'supported'
  qemu: domcaps: fill in explicit supported BOOL_NO
  libxl: domcaps: fill in explicit supported BOOL_NO
  bhyve: domcaps: fill in explicit supported BOOL_NO
  schemas: domcaps: Make more elements optional
  conf: domcaps: Don't output XML on tristate ABSENT

 docs/schemas/domaincaps.rng          | 20 +++++--
 src/bhyve/bhyve_capabilities.c       | 20 +++++--
 src/conf/domain_capabilities.c       | 26 ++++++----
 src/conf/domain_capabilities.h       | 20 +++----
 src/libxl/libxl_capabilities.c       | 18 ++++---
 src/qemu/qemu_capabilities.c         | 26 ++++++----
 tests/domaincapsschemadata/empty.xml | 16 ++++++
 tests/domaincapstest.c               | 78 ++--------------------------
 8 files changed, 103 insertions(+), 121 deletions(-)
 create mode 100644 tests/domaincapsschemadata/empty.xml

-- 
2.20.1




More information about the libvir-list mailing list