[PATCH v1 2/3] qemu: Fill virtio-mem/virtio-pmem .memaddr at runtime

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

 



After a QEMU domain is started, among other thing we query memory
device information. And while memory address is returned by QEMU
for all models, we store it only for DIMMs and NVDIMMs. Do store
it for VIRTIO_MEM and VIRTIO_PMEM too.

This effectively reports the address the virtio-mem/virtio-pmem
is mapped to in live XML.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/qemu/qemu_domain.c       |  7 +++++--
 src/qemu/qemu_monitor_json.c | 12 ++++++++++--
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 6c29c8f09f..c10e939e0c 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -8538,7 +8538,11 @@ qemuDomainUpdateMemoryDeviceInfo(virDomainObj *vm,
 
         switch (mem->model) {
         case VIR_DOMAIN_MEMORY_MODEL_VIRTIO_MEM:
-            mem->currentsize = VIR_DIV_UP(dimm->size, 1024);
+        case VIR_DOMAIN_MEMORY_MODEL_VIRTIO_PMEM:
+            if (mem->model == VIR_DOMAIN_MEMORY_MODEL_VIRTIO_MEM) {
+                mem->currentsize = VIR_DIV_UP(dimm->size, 1024);
+            }
+            mem->address = dimm->address;
             break;
 
         case VIR_DOMAIN_MEMORY_MODEL_DIMM:
@@ -8548,7 +8552,6 @@ qemuDomainUpdateMemoryDeviceInfo(virDomainObj *vm,
             mem->info.addr.dimm.base = dimm->address;
             break;
 
-        case VIR_DOMAIN_MEMORY_MODEL_VIRTIO_PMEM:
         case VIR_DOMAIN_MEMORY_MODEL_SGX_EPC:
         case VIR_DOMAIN_MEMORY_MODEL_NONE:
         case VIR_DOMAIN_MEMORY_MODEL_LAST:
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index f4416c929f..3b2caf05e2 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -7265,6 +7265,7 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitor *mon,
         case VIR_DOMAIN_MEMORY_MODEL_DIMM:
         case VIR_DOMAIN_MEMORY_MODEL_NVDIMM:
         case VIR_DOMAIN_MEMORY_MODEL_VIRTIO_MEM:
+        case VIR_DOMAIN_MEMORY_MODEL_VIRTIO_PMEM:
             /* While 'id' attribute is marked as optional in QEMU's QAPI
              * specification, Libvirt always sets it. Thus we can fail if not
              * present. */
@@ -7305,13 +7306,21 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitor *mon,
                     return -1;
 
                 }
-            } else if (model == VIR_DOMAIN_MEMORY_MODEL_VIRTIO_MEM) {
+            } else if (model == VIR_DOMAIN_MEMORY_MODEL_VIRTIO_MEM ||
+                       model == VIR_DOMAIN_MEMORY_MODEL_VIRTIO_PMEM) {
                 if (virJSONValueObjectGetNumberUlong(dimminfo, "size",
                                                      &meminfo->size) < 0) {
                     virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                                    _("malformed/missing size in virtio memory info"));
                     return -1;
                 }
+
+                if (virJSONValueObjectGetNumberUlong(dimminfo, "memaddr",
+                                                     &meminfo->address) < 0) {
+                    virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                                   _("malformed/missing memaddr in virtio memory info"));
+                    return -1;
+                }
             }
             break;
 
@@ -7336,7 +7345,6 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitor *mon,
             }
             break;
 
-        case VIR_DOMAIN_MEMORY_MODEL_VIRTIO_PMEM:
         case VIR_DOMAIN_MEMORY_MODEL_NONE:
         case VIR_DOMAIN_MEMORY_MODEL_LAST:
             /* type not handled yet */
-- 
2.39.2




[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