diff mbox series

[v2,10/16] conf: domcaps: Don't output XML on tristate ABSENT

Message ID 967f4c7ce08001ad3d2ea3675c23cadffe864cab.1551914794.git.crobinso@redhat.com
State Accepted
Commit e3119a3323f5370296125b2dc48b92d12e39f099
Headers show
Series domcaps: use virTristateBool | expand

Commit Message

Cole Robinson March 6, 2019, 11:36 p.m. UTC
Change domcaps to skip formatting XML if the default
TRISTATE_BOOL_ABSENT is found. Now when domcaps is extended, driver
XML output won't change until an explicit TRISTATE_BOOL value is set
in driver code.

Signed-off-by: Cole Robinson <crobinso@redhat.com>

---
 src/conf/domain_capabilities.c       | 10 +++++++---
 tests/domaincapsschemadata/empty.xml |  9 ---------
 2 files changed, 7 insertions(+), 12 deletions(-)

-- 
2.20.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
diff mbox series

Patch

diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c
index 081549eefb..f45a3bcc3d 100644
--- a/src/conf/domain_capabilities.c
+++ b/src/conf/domain_capabilities.c
@@ -370,10 +370,12 @@  virDomainCapsStringValuesFormat(virBufferPtr buf,
 
 #define FORMAT_PROLOGUE(item) \
     do { \
+        if (item->supported == VIR_TRISTATE_BOOL_ABSENT) \
+            return; \
         virBufferAsprintf(buf, "<" #item " supported='%s'%s\n", \
                 (item->supported == VIR_TRISTATE_BOOL_YES) ? "yes" : "no", \
                 (item->supported == VIR_TRISTATE_BOOL_YES) ? ">" : "/>"); \
-        if (item->supported != VIR_TRISTATE_BOOL_YES) \
+        if (item->supported == VIR_TRISTATE_BOOL_NO) \
             return; \
         virBufferAdjustIndent(buf, 2); \
     } while (0)
@@ -386,8 +388,10 @@  virDomainCapsStringValuesFormat(virBufferPtr buf,
 
 #define FORMAT_SINGLE(name, supported) \
     do { \
-        virBufferAsprintf(&buf, "<%s supported='%s'/>\n", name, \
-                (supported == VIR_TRISTATE_BOOL_YES) ? "yes" : "no"); \
+        if (supported != VIR_TRISTATE_BOOL_ABSENT) { \
+            virBufferAsprintf(&buf, "<%s supported='%s'/>\n", name, \
+                    (supported == VIR_TRISTATE_BOOL_YES) ? "yes" : "no"); \
+        } \
     } while (0)
 
 #define ENUM_PROCESS(master, capsEnum, valToStr) \
diff --git a/tests/domaincapsschemadata/empty.xml b/tests/domaincapsschemadata/empty.xml
index 2b2e97d3b3..6c3f5f54fd 100644
--- a/tests/domaincapsschemadata/empty.xml
+++ b/tests/domaincapsschemadata/empty.xml
@@ -3,23 +3,14 @@ 
   <domain>kvm</domain>
   <machine>my-machine-type</machine>
   <arch>x86_64</arch>
-  <iothreads supported='no'/>
-  <os supported='no'/>
   <cpu>
     <mode name='host-passthrough' supported='no'/>
     <mode name='host-model' supported='no'/>
     <mode name='custom' supported='no'/>
   </cpu>
   <devices>
-    <disk supported='no'/>
-    <graphics supported='no'/>
-    <video supported='no'/>
-    <hostdev supported='no'/>
   </devices>
   <features>
-    <gic supported='no'/>
-    <vmcoreinfo supported='no'/>
-    <genid supported='no'/>
     <sev supported='no'/>
   </features>
 </domainCapabilities>