[RFC PATCH 12/12] qemu: WIP: lookup nodenames

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

 



---
 src/qemu/qemu_domain.h       |  1 +
 src/qemu/qemu_monitor.c      | 11 ++++++++++-
 src/qemu/qemu_monitor_json.c |  8 +++++++-
 src/qemu/qemu_process.c      |  1 +
 4 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 705a3ad59..db6e9a75f 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -356,6 +356,7 @@ struct qemuDomainDiskInfo {
     bool tray_open;
     bool empty;
     int io_status;
+    char *nodename;
 };

 typedef struct _qemuDomainHostdevPrivate qemuDomainHostdevPrivate;
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 7caced7fe..42c32bc64 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -2147,6 +2147,15 @@ qemuMonitorBlockIOStatusToError(const char *status)
     return -1;
 }

+static void
+qemuDomainDiskInfoFree(void *value, const void *name ATTRIBUTE_UNUSED)
+{
+    struct qemuDomainDiskInfo *info = value;
+
+    VIR_FREE(info->nodename);
+    VIR_FREE(info);
+}
+

 virHashTablePtr
 qemuMonitorGetBlockInfo(qemuMonitorPtr mon)
@@ -2156,7 +2165,7 @@ qemuMonitorGetBlockInfo(qemuMonitorPtr mon)

     QEMU_CHECK_MONITOR_NULL(mon);

-    if (!(table = virHashCreate(32, virHashValueFree)))
+    if (!(table = virHashCreate(32, qemuDomainDiskInfoFree)))
         return NULL;

     if (mon->json)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 4b8103195..6e65b26d3 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -1868,9 +1868,11 @@ int qemuMonitorJSONGetBlockInfo(qemuMonitorPtr mon,

     for (i = 0; i < virJSONValueArraySize(devices); i++) {
         virJSONValuePtr dev;
+        virJSONValuePtr image;
         struct qemuDomainDiskInfo *info;
         const char *thisdev;
         const char *status;
+        const char *nodename;

         if (!(dev = qemuMonitorJSONGetBlockDev(devices, i)))
             goto cleanup;
@@ -1907,8 +1909,12 @@ int qemuMonitorJSONGetBlockInfo(qemuMonitorPtr mon,
             info->tray = true;

         /* presence of 'inserted' notifies that a medium is in the device */
-        if (!virJSONValueObjectGetObject(dev, "inserted"))
+        if ((image = virJSONValueObjectGetObject(dev, "inserted"))) {
+            if ((nodename = virJSONValueObjectGetString(image, "node-name")))
+                ignore_value(VIR_STRDUP(info->nodename, nodename));
+        } else {
             info->empty = true;
+        }

         /* Missing io-status indicates no error */
         if ((status = virJSONValueObjectGetString(dev, "io-status"))) {
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index cfe4073de..74409f88a 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -6735,6 +6735,7 @@ qemuProcessRefreshDisks(virQEMUDriverPtr driver,
         /* fill in additional data */
         diskpriv->removable = info->removable;
         diskpriv->tray = info->tray;
+        VIR_STEAL_PTR(disk->src->nodeName, info->nodename);
     }

     ret = 0;
-- 
2.11.1

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