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