[PATCH v2 7/7] dumpxml: add output of block info

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

 



This patch adds the common code for outputting drive sizing
information, when a user has requested the new API flag.  The
output covers the data stashed into virStorageSource of each
disk of the domain.

* docs/schemas/domaincommon.rng (storageSourceExtra): New define.
* src/conf/domain_conf.c (virDomainDiskDefFormat): Output sizing
when flag is set.
(DUMPXML_FLAGS): Add new flag.

Signed-off-by: Eric Blake <eblake@xxxxxxxxxx>
---
 docs/schemas/domaincommon.rng | 22 ++++++++++++++++++++++
 src/conf/domain_conf.c        | 16 +++++++++++++++-
 2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 6863ec6..2d551a9 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1280,6 +1280,28 @@
     </element>
   </define>

+  <define name='storageSourceExtra' combine='choice'>
+    <!-- Override of storagecommon.rng to allow domain disks to list
+         extras without impacting snapshot disks -->
+    <interleave>
+      <optional>
+        <element name="capacity">
+          <ref name="scaledInteger"/>
+        </element>
+      </optional>
+      <optional>
+        <element name="allocation">
+          <ref name="scaledInteger"/>
+        </element>
+      </optional>
+      <optional>
+        <element name="physical">
+          <ref name="scaledInteger"/>
+        </element>
+      </optional>
+    </interleave>
+  </define>
+
   <define name="diskBackingChain">
     <choice>
       <ref name="diskBackingStore"/>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5f4b9f6..41ad8cf 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -108,7 +108,8 @@ typedef enum {
     (VIR_DOMAIN_XML_SECURE |                    \
      VIR_DOMAIN_XML_INACTIVE |                  \
      VIR_DOMAIN_XML_UPDATE_CPU |                \
-     VIR_DOMAIN_XML_MIGRATABLE)
+     VIR_DOMAIN_XML_MIGRATABLE |		\
+     VIR_DOMAIN_XML_BLOCK_INFO)

 verify(((VIR_DOMAIN_XML_INTERNAL_STATUS |
          VIR_DOMAIN_XML_INTERNAL_ACTUAL_NET |
@@ -16344,6 +16345,19 @@ virDomainDiskDefFormat(virBufferPtr buf,
                                   flags) < 0)
         return -1;

+    if (flags & VIR_DOMAIN_XML_BLOCK_INFO) {
+        if (def->src->capacity)
+            virBufferAsprintf(buf, "<capacity unit='bytes'>%llu</capacity>\n",
+                              def->src->capacity);
+        if (def->src->allocation)
+            virBufferAsprintf(buf,
+                              "<allocation unit='bytes'>%llu</allocation>\n",
+                              def->src->allocation);
+        if (def->src->physical)
+            virBufferAsprintf(buf, "<physical unit='bytes'>%llu</physical>\n",
+                              def->src->physical);
+    }
+
     /* Don't format backingStore to inactive XMLs until the code for
      * persistent storage of backing chains is ready. */
     if (!(flags & VIR_DOMAIN_XML_INACTIVE) &&
-- 
1.9.3

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