render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
a41c76
From 668555bc90e36fd571ff3ac5aa798e951a84ee19 Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <668555bc90e36fd571ff3ac5aa798e951a84ee19@dist-git>
a41c76
From: Jonathon Jongsma <jjongsma@redhat.com>
a41c76
Date: Thu, 20 Feb 2020 10:52:24 -0600
a41c76
Subject: [PATCH] qemu: store complete agent filesystem information
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
In an effort to avoid holding both an agent and normal job at the same
a41c76
time, we shouldn't access the vm definition from within qemu_agent.c
a41c76
(i.e. while the agent job is being held). In preparation, we need to
a41c76
store the full filesystem disk information in qemuAgentDiskInfo.  In a
a41c76
following commit, we can pass this information back to the caller and
a41c76
the caller can search the vm definition to match the filsystem disk to
a41c76
an alias.
a41c76
a41c76
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
a41c76
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
a41c76
(cherry picked from commit bdb8a800b4920cf9184fd2fd117b17c67ba74dfb)
a41c76
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1759566
a41c76
Message-Id: <20200220165227.11491-3-jjongsma@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 src/qemu/qemu_agent.c | 36 ++++++++++++++++++++----------------
a41c76
 1 file changed, 20 insertions(+), 16 deletions(-)
a41c76
a41c76
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
a41c76
index 0f099f3b2a..077b5538de 100644
a41c76
--- a/src/qemu/qemu_agent.c
a41c76
+++ b/src/qemu/qemu_agent.c
a41c76
@@ -1849,6 +1849,11 @@ typedef qemuAgentDiskInfo *qemuAgentDiskInfoPtr;
a41c76
 struct _qemuAgentDiskInfo {
a41c76
     char *alias;
a41c76
     char *serial;
a41c76
+    virPCIDeviceAddress pci_controller;
a41c76
+    char *bus_type;
a41c76
+    unsigned int bus;
a41c76
+    unsigned int target;
a41c76
+    unsigned int unit;
a41c76
     char *devnode;
a41c76
 };
a41c76
 
a41c76
@@ -1872,6 +1877,7 @@ qemuAgentDiskInfoFree(qemuAgentDiskInfoPtr info)
a41c76
 
a41c76
     VIR_FREE(info->serial);
a41c76
     VIR_FREE(info->alias);
a41c76
+    VIR_FREE(info->bus_type);
a41c76
     VIR_FREE(info->devnode);
a41c76
     VIR_FREE(info);
a41c76
 }
a41c76
@@ -1952,10 +1958,6 @@ qemuAgentGetFSInfoFillDisks(virJSONValuePtr jsondisks,
a41c76
         qemuAgentDiskInfoPtr disk;
a41c76
         virDomainDiskDefPtr diskDef;
a41c76
         const char *val;
a41c76
-        unsigned int bus;
a41c76
-        unsigned int target;
a41c76
-        unsigned int unit;
a41c76
-        virPCIDeviceAddress pci_address;
a41c76
 
a41c76
         if (!jsondisk) {
a41c76
             virReportError(VIR_ERR_INTERNAL_ERROR,
a41c76
@@ -1969,6 +1971,9 @@ qemuAgentGetFSInfoFillDisks(virJSONValuePtr jsondisks,
a41c76
             return -1;
a41c76
         disk = fsinfo->disks[i];
a41c76
 
a41c76
+        if ((val = virJSONValueObjectGetString(jsondisk, "bus-type")))
a41c76
+            disk->bus_type = g_strdup(val);
a41c76
+
a41c76
         if ((val = virJSONValueObjectGetString(jsondisk, "serial")))
a41c76
             disk->serial = g_strdup(val);
a41c76
 
a41c76
@@ -1985,9 +1990,9 @@ qemuAgentGetFSInfoFillDisks(virJSONValuePtr jsondisks,
a41c76
             } \
a41c76
         } while (0)
a41c76
 
a41c76
-        GET_DISK_ADDR(jsondisk, &bus, "bus");
a41c76
-        GET_DISK_ADDR(jsondisk, &target, "target");
a41c76
-        GET_DISK_ADDR(jsondisk, &unit, "unit");
a41c76
+        GET_DISK_ADDR(jsondisk, &disk->bus, "bus");
a41c76
+        GET_DISK_ADDR(jsondisk, &disk->target, "target");
a41c76
+        GET_DISK_ADDR(jsondisk, &disk->unit, "unit");
a41c76
 
a41c76
         if (!(pci = virJSONValueObjectGet(jsondisk, "pci-controller"))) {
a41c76
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
a41c76
@@ -1996,18 +2001,17 @@ qemuAgentGetFSInfoFillDisks(virJSONValuePtr jsondisks,
a41c76
             return -1;
a41c76
         }
a41c76
 
a41c76
-        GET_DISK_ADDR(pci, &pci_address.domain, "domain");
a41c76
-        GET_DISK_ADDR(pci, &pci_address.bus, "bus");
a41c76
-        GET_DISK_ADDR(pci, &pci_address.slot, "slot");
a41c76
-        GET_DISK_ADDR(pci, &pci_address.function, "function");
a41c76
+        GET_DISK_ADDR(pci, &disk->pci_controller.domain, "domain");
a41c76
+        GET_DISK_ADDR(pci, &disk->pci_controller.bus, "bus");
a41c76
+        GET_DISK_ADDR(pci, &disk->pci_controller.slot, "slot");
a41c76
+        GET_DISK_ADDR(pci, &disk->pci_controller.function, "function");
a41c76
 
a41c76
 #undef GET_DISK_ADDR
a41c76
-
a41c76
         if (!(diskDef = virDomainDiskByAddress(vmdef,
a41c76
-                                               &pci_address,
a41c76
-                                               bus,
a41c76
-                                               target,
a41c76
-                                               unit)))
a41c76
+                                               &disk->pci_controller,
a41c76
+                                               disk->bus,
a41c76
+                                               disk->target,
a41c76
+                                               disk->unit)))
a41c76
             continue;
a41c76
 
a41c76
         disk->alias = g_strdup(diskDef->dst);
a41c76
-- 
a41c76
2.25.0
a41c76