commit 6688393c6b222b5d7cba238f21d55134611ede9c
Author: Erik Skultety <eskultet@redhat.com>
Date:   Thu Jun 14 14:18:30 2018 +0200

    conf: Fix formatting of <sev> element in domain capabilities XML
    
    We only formatted the <sev> element when QEMU supported the feature when
    in fact we should always format the element to make clear that libvirt
    knows about the feature and the fact whether it is or isn't supported
    depends on QEMU version, in other words if QEMU doesn't support the
    feature we're going to format the following into the domain capabilities
    XML:
    
    <sev supported='no'/>
    
    This patch also adjusts the RNG schema accordingly in order to reflect
    the proposed change.
    
    Signed-off-by: Erik Skultety <eskultet@redhat.com>
    Reviewed-by: Ján Tomko <jtomko@redhat.com>

Index: libvirt-4.0.0/docs/schemas/domaincaps.rng
===================================================================
--- libvirt-4.0.0.orig/docs/schemas/domaincaps.rng
+++ libvirt-4.0.0/docs/schemas/domaincaps.rng
@@ -173,9 +173,7 @@
     <element name='features'>
       <interleave>
         <ref name='gic'/>
-        <optional>
-          <ref name='sev'/>
-        </optional>
+        <ref name='sev'/>
       </interleave>
     </element>
   </define>
@@ -189,12 +187,15 @@
 
   <define name='sev'>
     <element name='sev'>
-      <element name='cbitpos'>
-        <data type='unsignedInt'/>
-      </element>
-      <element name='reducedPhysBits'>
-        <data type='unsignedInt'/>
-      </element>
+      <ref name='supported'/>
+      <optional>
+        <element name='cbitpos'>
+          <data type='unsignedInt'/>
+        </element>
+        <element name='reducedPhysBits'>
+          <data type='unsignedInt'/>
+        </element>
+      </optional>
     </element>
   </define>
 
Index: libvirt-4.0.0/src/conf/domain_capabilities.c
===================================================================
--- libvirt-4.0.0.orig/src/conf/domain_capabilities.c
+++ libvirt-4.0.0/src/conf/domain_capabilities.c
@@ -566,16 +566,20 @@ static void
 virDomainCapsFeatureSEVFormat(virBufferPtr buf,
                               virSEVCapabilityPtr const sev)
 {
-    if (!sev)
-        return;
 
-    virBufferAddLit(buf, "<sev supported='yes'>\n");
-    virBufferAdjustIndent(buf, 2);
-    virBufferAsprintf(buf, "<cbitpos>%d</cbitpos>\n", sev->cbitpos);
-    virBufferAsprintf(buf, "<reducedPhysBits>%d</reducedPhysBits>\n",
+    if (!sev) {
+        virBufferAddLit(buf, "<sev supported='no'/>\n");
+    } else {
+        virBufferAddLit(buf, "<sev supported='yes'>\n");
+        virBufferAdjustIndent(buf, 2);
+        virBufferAsprintf(buf, "<cbitpos>%d</cbitpos>\n", sev->cbitpos);
+        virBufferAsprintf(buf, "<reducedPhysBits>%d</reducedPhysBits>\n",
                           sev->reduced_phys_bits);
-    virBufferAdjustIndent(buf, -2);
-    virBufferAddLit(buf, "</sev>\n");
+        virBufferAdjustIndent(buf, -2);
+        virBufferAddLit(buf, "</sev>\n");
+    }
+
+    return;
 }
 
 
Index: libvirt-4.0.0/tests/domaincapsschemadata/basic.xml
===================================================================
--- libvirt-4.0.0.orig/tests/domaincapsschemadata/basic.xml
+++ libvirt-4.0.0/tests/domaincapsschemadata/basic.xml
@@ -17,5 +17,6 @@
   </devices>
   <features>
     <gic supported='no'/>
+    <sev supported='no'/>
   </features>
 </domainCapabilities>
Index: libvirt-4.0.0/tests/domaincapsschemadata/bhyve_basic.x86_64.xml
===================================================================
--- libvirt-4.0.0.orig/tests/domaincapsschemadata/bhyve_basic.x86_64.xml
+++ libvirt-4.0.0/tests/domaincapsschemadata/bhyve_basic.x86_64.xml
@@ -27,5 +27,6 @@
   </devices>
   <features>
     <gic supported='no'/>
+    <sev supported='no'/>
   </features>
 </domainCapabilities>
Index: libvirt-4.0.0/tests/domaincapsschemadata/bhyve_fbuf.x86_64.xml
===================================================================
--- libvirt-4.0.0.orig/tests/domaincapsschemadata/bhyve_fbuf.x86_64.xml
+++ libvirt-4.0.0/tests/domaincapsschemadata/bhyve_fbuf.x86_64.xml
@@ -44,5 +44,6 @@
   </devices>
   <features>
     <gic supported='no'/>
+    <sev supported='no'/>
   </features>
 </domainCapabilities>
Index: libvirt-4.0.0/tests/domaincapsschemadata/bhyve_uefi.x86_64.xml
===================================================================
--- libvirt-4.0.0.orig/tests/domaincapsschemadata/bhyve_uefi.x86_64.xml
+++ libvirt-4.0.0/tests/domaincapsschemadata/bhyve_uefi.x86_64.xml
@@ -36,5 +36,6 @@
   </devices>
   <features>
     <gic supported='no'/>
+    <sev supported='no'/>
   </features>
 </domainCapabilities>
Index: libvirt-4.0.0/tests/domaincapsschemadata/full.xml
===================================================================
--- libvirt-4.0.0.orig/tests/domaincapsschemadata/full.xml
+++ libvirt-4.0.0/tests/domaincapsschemadata/full.xml
@@ -107,5 +107,6 @@
   </devices>
   <features>
     <gic supported='no'/>
+    <sev supported='no'/>
   </features>
 </domainCapabilities>
Index: libvirt-4.0.0/tests/domaincapsschemadata/libxl-xenfv-usb.xml
===================================================================
--- libvirt-4.0.0.orig/tests/domaincapsschemadata/libxl-xenfv-usb.xml
+++ libvirt-4.0.0/tests/domaincapsschemadata/libxl-xenfv-usb.xml
@@ -70,5 +70,6 @@
   </devices>
   <features>
     <gic supported='no'/>
+    <sev supported='no'/>
   </features>
 </domainCapabilities>
Index: libvirt-4.0.0/tests/domaincapsschemadata/libxl-xenfv.xml
===================================================================
--- libvirt-4.0.0.orig/tests/domaincapsschemadata/libxl-xenfv.xml
+++ libvirt-4.0.0/tests/domaincapsschemadata/libxl-xenfv.xml
@@ -69,5 +69,6 @@
   </devices>
   <features>
     <gic supported='no'/>
+    <sev supported='no'/>
   </features>
 </domainCapabilities>
Index: libvirt-4.0.0/tests/domaincapsschemadata/libxl-xenpv-usb.xml
===================================================================
--- libvirt-4.0.0.orig/tests/domaincapsschemadata/libxl-xenpv-usb.xml
+++ libvirt-4.0.0/tests/domaincapsschemadata/libxl-xenpv-usb.xml
@@ -60,5 +60,6 @@
   </devices>
   <features>
     <gic supported='no'/>
+    <sev supported='no'/>
   </features>
 </domainCapabilities>
Index: libvirt-4.0.0/tests/domaincapsschemadata/libxl-xenpv.xml
===================================================================
--- libvirt-4.0.0.orig/tests/domaincapsschemadata/libxl-xenpv.xml
+++ libvirt-4.0.0/tests/domaincapsschemadata/libxl-xenpv.xml
@@ -59,5 +59,6 @@
   </devices>
   <features>
     <gic supported='no'/>
+    <sev supported='no'/>
   </features>
 </domainCapabilities>
Index: libvirt-4.0.0/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml
===================================================================
--- libvirt-4.0.0.orig/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml
+++ libvirt-4.0.0/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml
@@ -108,5 +108,6 @@
   </devices>
   <features>
     <gic supported='no'/>
+    <sev supported='no'/>
   </features>
 </domainCapabilities>
Index: libvirt-4.0.0/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml
===================================================================
--- libvirt-4.0.0.orig/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml
+++ libvirt-4.0.0/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml
@@ -108,5 +108,6 @@
   </devices>
   <features>
     <gic supported='no'/>
+    <sev supported='no'/>
   </features>
 </domainCapabilities>
Index: libvirt-4.0.0/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml
===================================================================
--- libvirt-4.0.0.orig/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml
+++ libvirt-4.0.0/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml
@@ -81,5 +81,6 @@
   </devices>
   <features>
     <gic supported='no'/>
+    <sev supported='no'/>
   </features>
 </domainCapabilities>
Index: libvirt-4.0.0/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml
===================================================================
--- libvirt-4.0.0.orig/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml
+++ libvirt-4.0.0/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml
@@ -113,5 +113,6 @@
   </devices>
   <features>
     <gic supported='no'/>
+    <sev supported='no'/>
   </features>
 </domainCapabilities>
Index: libvirt-4.0.0/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml
===================================================================
--- libvirt-4.0.0.orig/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml
+++ libvirt-4.0.0/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml
@@ -74,5 +74,6 @@
   </devices>
   <features>
     <gic supported='no'/>
+    <sev supported='no'/>
   </features>
 </domainCapabilities>
Index: libvirt-4.0.0/tests/domaincapsschemadata/qemu_2.8.0-tcg.x86_64.xml
===================================================================
--- libvirt-4.0.0.orig/tests/domaincapsschemadata/qemu_2.8.0-tcg.x86_64.xml
+++ libvirt-4.0.0/tests/domaincapsschemadata/qemu_2.8.0-tcg.x86_64.xml
@@ -114,5 +114,6 @@
   </devices>
   <features>
     <gic supported='no'/>
+    <sev supported='no'/>
   </features>
 </domainCapabilities>
Index: libvirt-4.0.0/tests/domaincapsschemadata/qemu_2.8.0.s390x.xml
===================================================================
--- libvirt-4.0.0.orig/tests/domaincapsschemadata/qemu_2.8.0.s390x.xml
+++ libvirt-4.0.0/tests/domaincapsschemadata/qemu_2.8.0.s390x.xml
@@ -155,5 +155,6 @@
   </devices>
   <features>
     <gic supported='no'/>
+    <sev supported='no'/>
   </features>
 </domainCapabilities>
Index: libvirt-4.0.0/tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml
===================================================================
--- libvirt-4.0.0.orig/tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml
+++ libvirt-4.0.0/tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml
@@ -114,5 +114,6 @@
   </devices>
   <features>
     <gic supported='no'/>
+    <sev supported='no'/>
   </features>
 </domainCapabilities>
Index: libvirt-4.0.0/tests/domaincapsschemadata/qemu_2.9.0-q35.x86_64.xml
===================================================================
--- libvirt-4.0.0.orig/tests/domaincapsschemadata/qemu_2.9.0-q35.x86_64.xml
+++ libvirt-4.0.0/tests/domaincapsschemadata/qemu_2.9.0-q35.x86_64.xml
@@ -122,5 +122,6 @@
   </devices>
   <features>
     <gic supported='no'/>
+    <sev supported='no'/>
   </features>
 </domainCapabilities>
Index: libvirt-4.0.0/tests/domaincapsschemadata/qemu_2.9.0-tcg.x86_64.xml
===================================================================
--- libvirt-4.0.0.orig/tests/domaincapsschemadata/qemu_2.9.0-tcg.x86_64.xml
+++ libvirt-4.0.0/tests/domaincapsschemadata/qemu_2.9.0-tcg.x86_64.xml
@@ -145,5 +145,6 @@
   </devices>
   <features>
     <gic supported='no'/>
+    <sev supported='no'/>
   </features>
 </domainCapabilities>
Index: libvirt-4.0.0/tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml
===================================================================
--- libvirt-4.0.0.orig/tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml
+++ libvirt-4.0.0/tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml
@@ -123,5 +123,6 @@
   </devices>
   <features>
     <gic supported='no'/>
+    <sev supported='no'/>
   </features>
 </domainCapabilities>
Index: libvirt-4.0.0/tests/domaincapsschemadata/qemu_2.6.0-gicv2-virt.aarch64.xml
===================================================================
--- libvirt-4.0.0.orig/tests/domaincapsschemadata/qemu_2.6.0-gicv2-virt.aarch64.xml
+++ libvirt-4.0.0/tests/domaincapsschemadata/qemu_2.6.0-gicv2-virt.aarch64.xml
@@ -112,5 +112,6 @@
         <value>2</value>
       </enum>
     </gic>
+    <sev supported='no'/>
   </features>
 </domainCapabilities>
Index: libvirt-4.0.0/tests/domaincapsschemadata/qemu_2.6.0-gicv3-virt.aarch64.xml
===================================================================
--- libvirt-4.0.0.orig/tests/domaincapsschemadata/qemu_2.6.0-gicv3-virt.aarch64.xml
+++ libvirt-4.0.0/tests/domaincapsschemadata/qemu_2.6.0-gicv3-virt.aarch64.xml
@@ -112,5 +112,6 @@
         <value>3</value>
       </enum>
     </gic>
+    <sev supported='no'/>
   </features>
 </domainCapabilities>
