render / rpms / libvirt

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