mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 01:45:17 +00:00
qemu: store complete agent filesystem information
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 <jjongsma@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
e888c0f667
commit
bdb8a800b4
@ -1853,6 +1853,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;
|
||||
};
|
||||
|
||||
@ -1876,6 +1881,7 @@ qemuAgentDiskInfoFree(qemuAgentDiskInfoPtr info)
|
||||
|
||||
VIR_FREE(info->serial);
|
||||
VIR_FREE(info->alias);
|
||||
VIR_FREE(info->bus_type);
|
||||
VIR_FREE(info->devnode);
|
||||
VIR_FREE(info);
|
||||
}
|
||||
@ -1956,10 +1962,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,
|
||||
@ -1973,6 +1975,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);
|
||||
|
||||
@ -1989,9 +1994,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",
|
||||
@ -2000,18 +2005,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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user