]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: formatting XML from domain def choosing the root name
authorMaxiwell S. Garcia <maxiwell@linux.ibm.com>
Thu, 29 Aug 2019 20:55:42 +0000 (17:55 -0300)
committerJiri Denemark <jdenemar@redhat.com>
Wed, 11 Sep 2019 11:09:45 +0000 (13:09 +0200)
The function virDomainDefFormatInternal() has the predefined root name
"domain" to format the XML. But to save both active and inactive domain
in the snapshot XML, the new root name "inactiveDomain" was created.
So, the new function virDomainDefFormatInternalSetRootName() allows to
choose the root name of XML. The former function became a tiny wrapper
to call the new function setting the correct parameters.

Signed-off-by: Maxiwell S. Garcia <maxiwell@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
src/conf/domain_conf.c
src/conf/domain_conf.h

index b3b8c543d5c7d30927f22c36f888f4db8488249f..3dc638f0de3890f3cd80c326ea0777fb916233ac 100644 (file)
@@ -28336,17 +28336,29 @@ virDomainDefFormatFeatures(virBufferPtr buf,
     return virXMLFormatElement(buf, "features", NULL, &childBuf);
 }
 
-
-/* This internal version appends to an existing buffer
- * (possibly with auto-indent), rather than flattening
- * to string.
- * Return -1 on failure.  */
 int
 virDomainDefFormatInternal(virDomainDefPtr def,
                            virCapsPtr caps,
                            unsigned int flags,
                            virBufferPtr buf,
                            virDomainXMLOptionPtr xmlopt)
+{
+    return virDomainDefFormatInternalSetRootName(def, caps, flags, buf,
+                                                 xmlopt, "domain");
+}
+
+
+/* This internal version appends to an existing buffer
+ * (possibly with auto-indent), rather than flattening
+ * to string.
+ * Return -1 on failure.  */
+int
+virDomainDefFormatInternalSetRootName(virDomainDefPtr def,
+                                      virCapsPtr caps,
+                                      unsigned int flags,
+                                      virBufferPtr buf,
+                                      virDomainXMLOptionPtr xmlopt,
+                                      const char *rootname)
 {
     unsigned char *uuid;
     char uuidstr[VIR_UUID_STRING_BUFLEN];
@@ -28371,7 +28383,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
     if (def->id == -1)
         flags |= VIR_DOMAIN_DEF_FORMAT_INACTIVE;
 
-    virBufferAsprintf(buf, "<domain type='%s'", type);
+    virBufferAsprintf(buf, "<%s type='%s'", rootname, type);
     if (!(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE))
         virBufferAsprintf(buf, " id='%d'", def->id);
     if (def->namespaceData && def->ns.format)
@@ -28853,7 +28865,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
     virDomainSEVDefFormat(buf, def->sev);
 
     virBufferAdjustIndent(buf, -2);
-    virBufferAddLit(buf, "</domain>\n");
+    virBufferAsprintf(buf, "</%s>\n", rootname);
 
     if (virBufferCheckError(buf) < 0)
         goto error;
index af80c2b7abe7fec6e1e145e4abf6a1b1c03d0843..82631ecb076476c7605ede0c788897f963d0ec4b 100644 (file)
@@ -3080,6 +3080,12 @@ int virDomainDefFormatInternal(virDomainDefPtr def,
                                unsigned int flags,
                                virBufferPtr buf,
                                virDomainXMLOptionPtr xmlopt);
+int virDomainDefFormatInternalSetRootName(virDomainDefPtr def,
+                                          virCapsPtr caps,
+                                          unsigned int flags,
+                                          virBufferPtr buf,
+                                          virDomainXMLOptionPtr xmlopt,
+                                          const char *rootname);
 
 int virDomainDiskSourceFormat(virBufferPtr buf,
                               virStorageSourcePtr src,