[PATCH 03/14] snapshot: indent domain xml when nesting, round 3

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

 



Pretty mechanical.  Also includes some long line breaks, as well
as relying on the fact that virBufferIndentEscapeString(buf, indent,
format, NULL) is a no-op.  I've marked all the sub-elements that
need indentation fixups in later patches.

* src/conf/domain_conf.c (virDomainDefFormatInternal): Indent all
parts of <domain> body generated here.
---
 src/conf/domain_conf.c |  259 ++++++++++++++++++++++++------------------------
 1 files changed, 130 insertions(+), 129 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3e3be3c..64bc82d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10485,65 +10485,65 @@ virDomainDefFormatInternal(virDomainDefPtr def,
     virBufferAddLit(buf, ">\n");

     indent += 2;
-    /* XXX Fix indentation of the body */

-    virBufferEscapeString(buf, "  <name>%s</name>\n", def->name);
+    virBufferIndentEscapeString(buf, indent, "<name>%s</name>\n", def->name);

     uuid = def->uuid;
     virUUIDFormat(uuid, uuidstr);
-    virBufferAsprintf(buf, "  <uuid>%s</uuid>\n", uuidstr);
+    virBufferAsprintf(buf, "%*s<uuid>%s</uuid>\n", indent, "", uuidstr);

-    if (def->description)
-        virBufferEscapeString(buf, "  <description>%s</description>\n",
-                              def->description);
+    virBufferIndentEscapeString(buf, indent,
+                                "<description>%s</description>\n",
+                                def->description);

-    virBufferAsprintf(buf, "  <memory>%lu</memory>\n", def->mem.max_balloon);
-    virBufferAsprintf(buf, "  <currentMemory>%lu</currentMemory>\n",
-                      def->mem.cur_balloon);
+    virBufferAsprintf(buf, "%*s<memory>%lu</memory>\n",
+                      indent, "", def->mem.max_balloon);
+    virBufferAsprintf(buf, "%*s<currentMemory>%lu</currentMemory>\n",
+                      indent, "", def->mem.cur_balloon);

     /* add blkiotune only if there are any */
     if (def->blkio.weight) {
-        virBufferAsprintf(buf, "  <blkiotune>\n");
-        virBufferAsprintf(buf, "    <weight>%u</weight>\n",
-                          def->blkio.weight);
-        virBufferAsprintf(buf, "  </blkiotune>\n");
+        virBufferIndentAddLit(buf, indent, "<blkiotune>\n");
+        virBufferAsprintf(buf, "%*s<weight>%u</weight>\n",
+                          indent + 2, "", def->blkio.weight);
+        virBufferIndentAddLit(buf, indent, "</blkiotune>\n");
     }

     /* add memtune only if there are any */
     if (def->mem.hard_limit || def->mem.soft_limit || def->mem.min_guarantee ||
         def->mem.swap_hard_limit)
-        virBufferAsprintf(buf, "  <memtune>\n");
+        virBufferIndentAddLit(buf, indent, "<memtune>\n");
     if (def->mem.hard_limit) {
-        virBufferAsprintf(buf, "    <hard_limit>%lu</hard_limit>\n",
-                          def->mem.hard_limit);
+        virBufferAsprintf(buf, "%*s<hard_limit>%lu</hard_limit>\n",
+                          indent + 2, "", def->mem.hard_limit);
     }
     if (def->mem.soft_limit) {
-        virBufferAsprintf(buf, "    <soft_limit>%lu</soft_limit>\n",
-                          def->mem.soft_limit);
+        virBufferAsprintf(buf, "%*s<soft_limit>%lu</soft_limit>\n",
+                          indent + 2, "", def->mem.soft_limit);
     }
     if (def->mem.min_guarantee) {
-        virBufferAsprintf(buf, "    <min_guarantee>%lu</min_guarantee>\n",
-                          def->mem.min_guarantee);
+        virBufferAsprintf(buf, "%*s<min_guarantee>%lu</min_guarantee>\n",
+                          indent + 2, "", def->mem.min_guarantee);
     }
     if (def->mem.swap_hard_limit) {
-        virBufferAsprintf(buf, "    <swap_hard_limit>%lu</swap_hard_limit>\n",
-                          def->mem.swap_hard_limit);
+        virBufferAsprintf(buf, "%*s<swap_hard_limit>%lu</swap_hard_limit>\n",
+                          indent + 2, "", def->mem.swap_hard_limit);
     }
     if (def->mem.hard_limit || def->mem.soft_limit || def->mem.min_guarantee ||
         def->mem.swap_hard_limit)
-        virBufferAsprintf(buf, "  </memtune>\n");
+        virBufferIndentAddLit(buf, indent, "</memtune>\n");

     if (def->mem.hugepage_backed) {
-        virBufferAddLit(buf, "  <memoryBacking>\n");
-        virBufferAddLit(buf, "    <hugepages/>\n");
-        virBufferAddLit(buf, "  </memoryBacking>\n");
+        virBufferIndentAddLit(buf, indent, "<memoryBacking>\n");
+        virBufferIndentAddLit(buf, indent, "  <hugepages/>\n");
+        virBufferIndentAddLit(buf, indent, "</memoryBacking>\n");
     }

     for (n = 0 ; n < def->cpumasklen ; n++)
         if (def->cpumask[n] != 1)
             allones = 0;

-    virBufferAddLit(buf, "  <vcpu");
+    virBufferIndentAddLit(buf, indent, "<vcpu");
     if (!allones) {
         char *cpumask = NULL;
         if ((cpumask =
@@ -10558,22 +10558,22 @@ virDomainDefFormatInternal(virDomainDefPtr def,

     if (def->cputune.shares || def->cputune.vcpupin ||
         def->cputune.period || def->cputune.quota)
-        virBufferAddLit(buf, "  <cputune>\n");
+        virBufferIndentAddLit(buf, indent, "<cputune>\n");

     if (def->cputune.shares)
-        virBufferAsprintf(buf, "    <shares>%lu</shares>\n",
-                          def->cputune.shares);
+        virBufferAsprintf(buf, "%*s<shares>%lu</shares>\n",
+                          indent + 2, "", def->cputune.shares);
     if (def->cputune.period)
-        virBufferAsprintf(buf, "    <period>%llu</period>\n",
-                          def->cputune.period);
+        virBufferAsprintf(buf, "%*s<period>%llu</period>\n",
+                          indent + 2, "", def->cputune.period);
     if (def->cputune.quota)
-        virBufferAsprintf(buf, "    <quota>%lld</quota>\n",
-                          def->cputune.quota);
+        virBufferAsprintf(buf, "%*s<quota>%lld</quota>\n",
+                          indent + 2, "", def->cputune.quota);
     if (def->cputune.vcpupin) {
         int i;
         for (i = 0; i < def->cputune.nvcpupin; i++) {
-            virBufferAsprintf(buf, "    <vcpupin vcpu='%u' ",
-                              def->cputune.vcpupin[i]->vcpuid);
+            virBufferAsprintf(buf, "%*s<vcpupin vcpu='%u' ",
+                              indent + 2, "", def->cputune.vcpupin[i]->vcpuid);

             char *cpumask = NULL;
             cpumask = virDomainCpuSetFormat(def->cputune.vcpupin[i]->cpumask,
@@ -10592,43 +10592,43 @@ virDomainDefFormatInternal(virDomainDefPtr def,

     if (def->cputune.shares || def->cputune.vcpupin ||
         def->cputune.period || def->cputune.quota)
-        virBufferAddLit(buf, "  </cputune>\n");
-
-    if (def->numatune.memory.nodemask)
-        virBufferAddLit(buf, "  <numatune>\n");
+        virBufferIndentAddLit(buf, indent, "</cputune>\n");

     if (def->numatune.memory.nodemask) {
         char *nodemask = NULL;
+
+        virBufferIndentAddLit(buf, indent, "<numatune>\n");
         nodemask = virDomainCpuSetFormat(def->numatune.memory.nodemask,
                                          VIR_DOMAIN_CPUMASK_LEN);
         if (nodemask == NULL) {
-            virDomainReportError(VIR_ERR_INTERNAL_ERROR,
-                                 "%s", _("failed to format nodeset for NUMA memory tuning"));
+            virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                          _("failed to format nodeset for NUMA memory tuning"));
             goto cleanup;
         }

-        virBufferAsprintf(buf, "    <memory mode='%s' nodeset='%s'/>\n",
-                          virDomainNumatuneMemModeTypeToString(def->numatune.memory.mode),
+        virBufferAsprintf(buf, "%*s<memory mode='%s' nodeset='%s'/>\n",
+                          indent + 2, "",
+                          virDomainNumatuneMemModeTypeToString(def->numatune.
+                                                               memory.mode),
                           nodemask);
         VIR_FREE(nodemask);
+        virBufferIndentAddLit(buf, indent, "</numatune>\n");
     }

-    if (def->numatune.memory.nodemask)
-        virBufferAddLit(buf, "  </numatune>\n");
-
     if (def->sysinfo)
-        virDomainSysinfoDefFormat(buf, def->sysinfo);
+        virDomainSysinfoDefFormat(buf, def->sysinfo); /* XXX indent */

     if (def->os.bootloader) {
-        virBufferEscapeString(buf, "  <bootloader>%s</bootloader>\n",
-                              def->os.bootloader);
-        if (def->os.bootloaderArgs)
-            virBufferEscapeString(buf, "  <bootloader_args>%s</bootloader_args>\n",
-                                  def->os.bootloaderArgs);
+        virBufferIndentEscapeString(buf, indent,
+                                    "<bootloader>%s</bootloader>\n",
+                                    def->os.bootloader);
+        virBufferIndentEscapeString(buf, indent,
+                                    "<bootloader_args>%s</bootloader_args>\n",
+                                    def->os.bootloaderArgs);
     }
-    virBufferAddLit(buf, "  <os>\n");

-    virBufferAddLit(buf, "    <type");
+    virBufferIndentAddLit(buf, indent, "<os>\n");
+    virBufferIndentAddLit(buf, indent + 2, "<type");
     if (def->os.arch)
         virBufferAsprintf(buf, " arch='%s'", def->os.arch);
     if (def->os.machine)
@@ -10644,24 +10644,18 @@ virDomainDefFormatInternal(virDomainDefPtr def,
     else
         virBufferAsprintf(buf, ">%s</type>\n", def->os.type);

-    if (def->os.init)
-        virBufferEscapeString(buf, "    <init>%s</init>\n",
-                              def->os.init);
-    if (def->os.loader)
-        virBufferEscapeString(buf, "    <loader>%s</loader>\n",
-                              def->os.loader);
-    if (def->os.kernel)
-        virBufferEscapeString(buf, "    <kernel>%s</kernel>\n",
-                              def->os.kernel);
-    if (def->os.initrd)
-        virBufferEscapeString(buf, "    <initrd>%s</initrd>\n",
-                              def->os.initrd);
-    if (def->os.cmdline)
-        virBufferEscapeString(buf, "    <cmdline>%s</cmdline>\n",
-                              def->os.cmdline);
-    if (def->os.root)
-        virBufferEscapeString(buf, "    <root>%s</root>\n",
-                              def->os.root);
+    virBufferIndentEscapeString(buf, indent + 2, "<init>%s</init>\n",
+                                def->os.init);
+    virBufferIndentEscapeString(buf, indent + 2, "<loader>%s</loader>\n",
+                                def->os.loader);
+    virBufferIndentEscapeString(buf, indent + 2, "<kernel>%s</kernel>\n",
+                                def->os.kernel);
+    virBufferIndentEscapeString(buf, indent + 2, "<initrd>%s</initrd>\n",
+                                def->os.initrd);
+    virBufferIndentEscapeString(buf, indent + 2, "<cmdline>%s</cmdline>\n",
+                                def->os.cmdline);
+    virBufferIndentEscapeString(buf, indent + 2, "<root>%s</root>\n",
+                                def->os.root);

     if (!def->os.bootloader) {
         for (n = 0 ; n < def->os.nBootDevs ; n++) {
@@ -10673,21 +10667,24 @@ virDomainDefFormatInternal(virDomainDefPtr def,
                                      def->os.bootDevs[n]);
                 goto cleanup;
             }
-            virBufferAsprintf(buf, "    <boot dev='%s'/>\n", boottype);
+            virBufferAsprintf(buf, "%*s<boot dev='%s'/>\n",
+                              indent + 2, "", boottype);
         }

         if (def->os.bootmenu != VIR_DOMAIN_BOOT_MENU_DEFAULT) {
             const char *enabled = (def->os.bootmenu ==
                                    VIR_DOMAIN_BOOT_MENU_ENABLED ? "yes"
                                                                 : "no");
-            virBufferAsprintf(buf, "    <bootmenu enable='%s'/>\n", enabled);
+            virBufferAsprintf(buf, "%*s<bootmenu enable='%s'/>\n",
+                              indent + 2, "", enabled);
         }

         if (def->os.bios.useserial) {
             const char *useserial = (def->os.bios.useserial ==
                                      VIR_DOMAIN_BIOS_USESERIAL_YES ? "yes"
                                                                    : "no");
-            virBufferAsprintf(buf, "    <bios useserial='%s'/>\n", useserial);
+            virBufferAsprintf(buf, "%*s<bios useserial='%s'/>\n",
+                              indent + 2, "", useserial);
         }
     }

@@ -10700,14 +10697,15 @@ virDomainDefFormatInternal(virDomainDefPtr def,
                          _("unexpected smbios mode %d"), def->os.smbios_mode);
             goto cleanup;
         }
-        virBufferAsprintf(buf, "    <smbios mode='%s'/>\n", mode);
+        virBufferAsprintf(buf, "%*s<smbios mode='%s'/>\n",
+                          indent + 2, "", mode);
     }

-    virBufferAddLit(buf, "  </os>\n");
+    virBufferIndentAddLit(buf, indent, "</os>\n");

     if (def->features) {
         int i;
-        virBufferAddLit(buf, "  <features>\n");
+        virBufferIndentAddLit(buf, indent, "<features>\n");
         for (i = 0 ; i < VIR_DOMAIN_FEATURE_LAST ; i++) {
             if (def->features & (1 << i)) {
                 const char *name = virDomainFeatureTypeToString(i);
@@ -10716,20 +10714,21 @@ virDomainDefFormatInternal(virDomainDefPtr def,
                                          _("unexpected feature %d"), i);
                     goto cleanup;
                 }
-                virBufferAsprintf(buf, "    <%s/>\n", name);
+                virBufferAsprintf(buf, "%*s<%s/>\n", indent + 2, "", name);
             }
         }
-        virBufferAddLit(buf, "  </features>\n");
+        virBufferIndentAddLit(buf, indent, "</features>\n");
     }

-    if (virCPUDefFormatBuf(buf, def->cpu, "  ", 0) < 0)
+    if (virCPUDefFormatBuf(buf, def->cpu, "  ", 0) < 0) /* XXX indent */
         goto cleanup;

-    virBufferAsprintf(buf, "  <clock offset='%s'",
+    virBufferAsprintf(buf, "%*s<clock offset='%s'", indent, "",
                       virDomainClockOffsetTypeToString(def->clock.offset));
     switch (def->clock.offset) {
     case VIR_DOMAIN_CLOCK_OFFSET_VARIABLE:
-        virBufferAsprintf(buf, " adjustment='%lld'", def->clock.data.adjustment);
+        virBufferAsprintf(buf, " adjustment='%lld'",
+                          def->clock.data.adjustment);
         break;
     case VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE:
         virBufferEscapeString(buf, " timezone='%s'", def->clock.data.timezone);
@@ -10740,67 +10739,67 @@ virDomainDefFormatInternal(virDomainDefPtr def,
     } else {
         virBufferAddLit(buf, ">\n");
         for (n = 0; n < def->clock.ntimers; n++) {
-            if (virDomainTimerDefFormat(buf, def->clock.timers[n]) < 0)
+            if (virDomainTimerDefFormat(buf, def->clock.timers[n]) < 0) /* XXX indent */
                 goto cleanup;
         }
-        virBufferAddLit(buf, "  </clock>\n");
+        virBufferIndentAddLit(buf, indent, "</clock>\n");
     }

     if (virDomainLifecycleDefFormat(buf, def->onPoweroff,
                                     "on_poweroff",
-                                    virDomainLifecycleTypeToString) < 0)
+                                    virDomainLifecycleTypeToString) < 0) /* XXX indent */
         goto cleanup;
     if (virDomainLifecycleDefFormat(buf, def->onReboot,
                                     "on_reboot",
-                                    virDomainLifecycleTypeToString) < 0)
+                                    virDomainLifecycleTypeToString) < 0) /* XXX indent */
         goto cleanup;
     if (virDomainLifecycleDefFormat(buf, def->onCrash,
                                     "on_crash",
-                                    virDomainLifecycleCrashTypeToString) < 0)
+                                    virDomainLifecycleCrashTypeToString) < 0) /* XXX indent */
         goto cleanup;

-    virBufferAddLit(buf, "  <devices>\n");
+    virBufferIndentAddLit(buf, indent, "<devices>\n");
+    indent += 2;

-    if (def->emulator)
-        virBufferEscapeString(buf, "    <emulator>%s</emulator>\n",
-                              def->emulator);
+    virBufferIndentEscapeString(buf, indent, "<emulator>%s</emulator>\n",
+                                def->emulator);

     for (n = 0 ; n < def->ndisks ; n++)
-        if (virDomainDiskDefFormat(buf, def->disks[n], flags) < 0)
+        if (virDomainDiskDefFormat(buf, def->disks[n], flags) < 0)  /* XXX indent */
             goto cleanup;

     for (n = 0 ; n < def->ncontrollers ; n++)
-        if (virDomainControllerDefFormat(buf, def->controllers[n], flags) < 0)
+        if (virDomainControllerDefFormat(buf, def->controllers[n], flags) < 0) /* XXX indent */
             goto cleanup;

     for (n = 0 ; n < def->nleases ; n++)
-        if (virDomainLeaseDefFormat(buf, def->leases[n]) < 0)
+        if (virDomainLeaseDefFormat(buf, def->leases[n]) < 0) /* XXX indent */
             goto cleanup;

     for (n = 0 ; n < def->nfss ; n++)
-        if (virDomainFSDefFormat(buf, def->fss[n], flags) < 0)
+        if (virDomainFSDefFormat(buf, def->fss[n], flags) < 0) /* XXX indent */
             goto cleanup;


     for (n = 0 ; n < def->nnets ; n++)
-        if (virDomainNetDefFormat(buf, def->nets[n], flags) < 0)
+        if (virDomainNetDefFormat(buf, def->nets[n], flags) < 0) /* XXX indent */
             goto cleanup;

     for (n = 0 ; n < def->nsmartcards ; n++)
-        if (virDomainSmartcardDefFormat(buf, def->smartcards[n], flags) < 0)
+        if (virDomainSmartcardDefFormat(buf, def->smartcards[n], flags) < 0) /* XXX indent */
             goto cleanup;

     for (n = 0 ; n < def->nserials ; n++)
-        if (virDomainChrDefFormat(buf, def->serials[n], flags) < 0)
+        if (virDomainChrDefFormat(buf, def->serials[n], flags) < 0) /* XXX indent */
             goto cleanup;

     for (n = 0 ; n < def->nparallels ; n++)
-        if (virDomainChrDefFormat(buf, def->parallels[n], flags) < 0)
+        if (virDomainChrDefFormat(buf, def->parallels[n], flags) < 0) /* XXX indent */
             goto cleanup;

     /* If there's a PV console that's preferred.. */
     if (def->console) {
-        if (virDomainChrDefFormat(buf, def->console, flags) < 0)
+        if (virDomainChrDefFormat(buf, def->console, flags) < 0) /* XXX indent */
             goto cleanup;
     } else if (def->nserials != 0) {
         /* ..else for legacy compat duplicate the first serial device as a
@@ -10808,17 +10807,17 @@ virDomainDefFormatInternal(virDomainDefPtr def,
         virDomainChrDef console;
         memcpy(&console, def->serials[0], sizeof(console));
         console.deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
-        if (virDomainChrDefFormat(buf, &console, flags) < 0)
+        if (virDomainChrDefFormat(buf, &console, flags) < 0) /* XXX indent */
             goto cleanup;
     }

     for (n = 0 ; n < def->nchannels ; n++)
-        if (virDomainChrDefFormat(buf, def->channels[n], flags) < 0)
+        if (virDomainChrDefFormat(buf, def->channels[n], flags) < 0) /* XXX indent */
             goto cleanup;

     for (n = 0 ; n < def->ninputs ; n++)
         if (def->inputs[n]->bus == VIR_DOMAIN_INPUT_BUS_USB &&
-            virDomainInputDefFormat(buf, def->inputs[n], flags) < 0)
+            virDomainInputDefFormat(buf, def->inputs[n], flags) < 0) /* XXX indent */
             goto cleanup;

     if (def->ngraphics > 0) {
@@ -10830,41 +10829,42 @@ virDomainDefFormatInternal(virDomainDefPtr def,
             { .alias = NULL },
         };

-        if (virDomainInputDefFormat(buf, &autoInput, flags) < 0)
+        if (virDomainInputDefFormat(buf, &autoInput, flags) < 0) /* XXX indent */
             goto cleanup;

         for (n = 0 ; n < def->ngraphics ; n++)
-            if (virDomainGraphicsDefFormat(buf, def->graphics[n], flags) < 0)
+            if (virDomainGraphicsDefFormat(buf, def->graphics[n], flags) < 0) /* XXX indent */
                 goto cleanup;
     }

     for (n = 0 ; n < def->nsounds ; n++)
-        if (virDomainSoundDefFormat(buf, def->sounds[n], flags) < 0)
+        if (virDomainSoundDefFormat(buf, def->sounds[n], flags) < 0) /* XXX indent */
             goto cleanup;

     for (n = 0 ; n < def->nvideos ; n++)
-        if (virDomainVideoDefFormat(buf, def->videos[n], flags) < 0)
+        if (virDomainVideoDefFormat(buf, def->videos[n], flags) < 0) /* XXX indent */
             goto cleanup;

     for (n = 0 ; n < def->nhostdevs ; n++)
-        if (virDomainHostdevDefFormat(buf, def->hostdevs[n], flags) < 0)
+        if (virDomainHostdevDefFormat(buf, def->hostdevs[n], flags) < 0) /* XXX indent */
             goto cleanup;

     for (n = 0 ; n < def->nredirdevs ; n++)
-        if (virDomainRedirdevDefFormat(buf, def->redirdevs[n], flags) < 0)
+        if (virDomainRedirdevDefFormat(buf, def->redirdevs[n], flags) < 0) /* XXX indent */
             goto cleanup;

     for (n = 0 ; n < def->nhubs ; n++)
-        if (virDomainHubDefFormat(buf, def->hubs[n], flags) < 0)
+        if (virDomainHubDefFormat(buf, def->hubs[n], flags) < 0) /* XXX indent */
             goto cleanup;

     if (def->watchdog)
-        virDomainWatchdogDefFormat (buf, def->watchdog, flags);
+        virDomainWatchdogDefFormat (buf, def->watchdog, flags); /* XXX indent */

     if (def->memballoon)
-        virDomainMemballoonDefFormat (buf, def->memballoon, flags);
+        virDomainMemballoonDefFormat (buf, def->memballoon, flags); /* XXX indent */

-    virBufferAddLit(buf, "  </devices>\n");
+    indent -= 2;
+    virBufferIndentAddLit(buf, indent, "</devices>\n");

     if (def->seclabel.model) {
         const char *sectype = virDomainSeclabelTypeToString(def->seclabel.type);
@@ -10876,29 +10876,30 @@ virDomainDefFormatInternal(virDomainDefPtr def,
             (flags & VIR_DOMAIN_XML_INACTIVE)) {
             /* This is the default for inactive xml, so nothing to output.  */
         } else {
-            virBufferAsprintf(buf, "  <seclabel type='%s' model='%s' relabel='%s'>\n",
+            virBufferAsprintf(buf, "%*s<seclabel type='%s' model='%s' "
+                              "relabel='%s'>\n", indent, "",
                               sectype, def->seclabel.model,
                               def->seclabel.norelabel ? "no" : "yes");
-            if (def->seclabel.label)
-                virBufferEscapeString(buf, "    <label>%s</label>\n",
-                                      def->seclabel.label);
-            if (!def->seclabel.norelabel && def->seclabel.imagelabel)
-                virBufferEscapeString(buf, "    <imagelabel>%s</imagelabel>\n",
-                                      def->seclabel.imagelabel);
-            if (def->seclabel.baselabel &&
-                (def->seclabel.type == VIR_DOMAIN_SECLABEL_DYNAMIC))
-                virBufferEscapeString(buf, "    <baselabel>%s</baselabel>\n",
-                                      def->seclabel.baselabel);
-            virBufferAddLit(buf, "  </seclabel>\n");
+            virBufferIndentEscapeString(buf, indent + 2,
+                                        "<label>%s</label>\n",
+                                        def->seclabel.label);
+            if (!def->seclabel.norelabel)
+                virBufferIndentEscapeString(buf, indent + 2,
+                                            "<imagelabel>%s</imagelabel>\n",
+                                            def->seclabel.imagelabel);
+            if (def->seclabel.type == VIR_DOMAIN_SECLABEL_DYNAMIC)
+                virBufferIndentEscapeString(buf, indent + 2,
+                                            "<baselabel>%s</baselabel>\n",
+                                            def->seclabel.baselabel);
+            virBufferIndentAddLit(buf, indent, "</seclabel>\n");
         }
     }

     if (def->namespaceData && def->ns.format) {
-        if ((def->ns.format)(buf, def->namespaceData) < 0)
+        if ((def->ns.format)(buf, def->namespaceData) < 0) /* XXX indent */
             goto cleanup;
     }

-    /* XXX Fix indentation of body prior to here */
     indent -= 2;

     virBufferIndentAddLit(buf, indent, "</domain>\n");
-- 
1.7.4.4

--
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]