Re: [PATCH v3 1/2] qemu: formatting XML from domain def choosing the root name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 8/14/19 11:47 AM, Maxiwell S. Garcia wrote:
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, this function was modified to be driven by the new flag
VIR_DOMAIN_DEF_FORMAT_INACTIVE_NODE to choose the correct root name.

Signed-off-by: Maxiwell S. Garcia <maxiwell@xxxxxxxxxxxxx>
---

Reviewed-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx>
Tested-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx>

 src/conf/domain_conf.c | 13 ++++++++++---
 src/conf/domain_conf.h |  1 +
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 03312afaaf..7d6393b9ac 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -28230,6 +28230,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
     unsigned char *uuid;
     char uuidstr[VIR_UUID_STRING_BUFLEN];
     const char *type = NULL;
+    const char *rootname = NULL;
     int n;
     size_t i;
     char *netprefix = NULL;
@@ -28238,7 +28239,8 @@ virDomainDefFormatInternal(virDomainDefPtr def,
                   VIR_DOMAIN_DEF_FORMAT_STATUS |
                   VIR_DOMAIN_DEF_FORMAT_ACTUAL_NET |
                   VIR_DOMAIN_DEF_FORMAT_PCI_ORIG_STATES |
-                  VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST,
+                  VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST |
+                  VIR_DOMAIN_DEF_FORMAT_INACTIVE_NODE,
                   -1);
 
     if (!(type = virDomainVirtTypeToString(def->virtType))) {
@@ -28250,7 +28252,12 @@ virDomainDefFormatInternal(virDomainDefPtr def,
     if (def->id == -1)
         flags |= VIR_DOMAIN_DEF_FORMAT_INACTIVE;
 
-    virBufferAsprintf(buf, "<domain type='%s'", type);
+    if (flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE_NODE)
+        rootname = "inactiveDomain";
+    else
+        rootname = "domain";
+
+    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.href)
@@ -28732,7 +28739,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;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index bce47443c8..63791a8002 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2984,6 +2984,7 @@ typedef enum {
     VIR_DOMAIN_DEF_FORMAT_ALLOW_ROM       = 1 << 6,
     VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT      = 1 << 7,
     VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST    = 1 << 8,
+    VIR_DOMAIN_DEF_FORMAT_INACTIVE_NODE   = 1 << 9,
 } virDomainDefFormatFlags;
 
 /* Use these flags to skip specific domain ABI consistency checks done

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux