[PATCH v4 06/14] Introduce <actual/> property to virtio-mem

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

 



The virtio-mem has another property that isn't exposed yet:
actual size exposed to the guest. Please note, that this is
different to <requested/> because esp. on sizing the memory
down guest may refuse to release some blocks. Therefore, let's
have another size to report in the XML. But because of its
nature, the <actual/> won't be parsed and is report only (for
live XMLs).

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 docs/formatdomain.rst         | 7 +++++++
 docs/schemas/domaincommon.rng | 5 +++++
 src/conf/domain_conf.c        | 9 +++++++--
 src/conf/domain_conf.h        | 3 +++
 4 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
index 967d5bbb91..01e5a3fe03 100644
--- a/docs/formatdomain.rst
+++ b/docs/formatdomain.rst
@@ -7773,6 +7773,7 @@ Example: usage of the memory devices
          <node>0</node>
          <block unit='KiB'>2048</block>
          <requested unit='KiB'>1048576</requested>
+         <actual unit='KiB'>524288</requested>
        </target>
      </memory>
    </devices>
@@ -7888,6 +7889,12 @@ Example: usage of the memory devices
      The total size exposed to the guest. Must respect ``block`` granularity
      and be smaller than or equal to ``size``.
 
+   ``actual``
+     Active XML for ``virtio-mem`` model may contain ``actual`` element that
+     reflects the actual size of the corresponding virtio memory device. The
+     element is formatted into live XML and never parsed, i.e. it is
+     output-only element.
+
 :anchor:`<a id="elementsIommu"/>`
 
 IOMMU devices
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 439dd893ff..b832dce19b 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -6649,6 +6649,11 @@
             <ref name="scaledInteger"/>
           </element>
         </optional>
+        <optional>
+          <element name="actual">
+            <ref name="scaledInteger"/>
+          </element>
+        </optional>
         <optional>
           <element name="label">
             <element name="size">
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 76344b592d..1ef70e8a80 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -25870,7 +25870,8 @@ virDomainMemorySourceDefFormat(virBuffer *buf,
 
 static void
 virDomainMemoryTargetDefFormat(virBuffer *buf,
-                               virDomainMemoryDef *def)
+                               virDomainMemoryDef *def,
+                               unsigned int flags)
 {
     g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf);
 
@@ -25892,6 +25893,10 @@ virDomainMemoryTargetDefFormat(virBuffer *buf,
 
         virBufferAsprintf(&childBuf, "<requested unit='KiB'>%llu</requested>\n",
                           def->requestedsize);
+        if (!(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE)) {
+            virBufferAsprintf(&childBuf, "<actual unit='KiB'>%llu</actual>\n",
+                              def->actualsize);
+        }
     }
 
     virXMLFormatElement(buf, "target", NULL, &childBuf);
@@ -25924,7 +25929,7 @@ virDomainMemoryDefFormat(virBuffer *buf,
     if (virDomainMemorySourceDefFormat(buf, def) < 0)
         return -1;
 
-    virDomainMemoryTargetDefFormat(buf, def);
+    virDomainMemoryTargetDefFormat(buf, def, flags);
 
     virDomainDeviceInfoFormat(buf, &def->info, flags);
 
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 0c43a6ae64..b57eba655d 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2482,6 +2482,9 @@ struct _virDomainMemoryDef {
     unsigned long long labelsize; /* kibibytes; valid only for NVDIMM */
     unsigned long long blocksize; /* kibibytes; valid only for VIRTIO_MEM */
     unsigned long long requestedsize; /* kibibytes; valid only for VIRTIO_MEM */
+    unsigned long long actualsize; /* kibibytes, valid for VIRTIO_MEM and
+                                      active domain only, only to report never
+                                      parse */
     bool readonly; /* valid only for NVDIMM */
 
     /* required for QEMU NVDIMM ppc64 support */
-- 
2.31.1




[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