diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index b155896e78..af0397e6e2 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -1824,6 +1824,7 @@ qemuAgentDiskAddressFree(qemuAgentDiskAddressPtr info) g_free(info->serial); g_free(info->bus_type); g_free(info->devnode); + g_free(info->ccw_addr); g_free(info); } @@ -1899,12 +1900,17 @@ qemuAgentGetDiskAddress(virJSONValuePtr json) GET_DISK_ADDR(pci, &addr->pci_controller.function, "function"); if ((ccw = virJSONValueObjectGet(json, "ccw-address"))) { - addr->has_ccw_address = true; - GET_DISK_ADDR(ccw, &addr->ccw_addr.cssid, "cssid"); - if (addr->ccw_addr.cssid == 0) /* Guest CSSID 0 is 0xfe on host */ - addr->ccw_addr.cssid = 0xfe; - GET_DISK_ADDR(ccw, &addr->ccw_addr.ssid, "ssid"); - GET_DISK_ADDR(ccw, &addr->ccw_addr.devno, "devno"); + g_autofree virDomainDeviceCCWAddressPtr ccw_addr = NULL; + + ccw_addr = g_new0(virDomainDeviceCCWAddress, 1); + + GET_DISK_ADDR(ccw, &ccw_addr->cssid, "cssid"); + if (ccw_addr->cssid == 0) /* Guest CSSID 0 is 0xfe on host */ + ccw_addr->cssid = 0xfe; + GET_DISK_ADDR(ccw, &ccw_addr->ssid, "ssid"); + GET_DISK_ADDR(ccw, &ccw_addr->devno, "devno"); + + addr->ccw_addr = g_steal_pointer(&ccw_addr); } #undef GET_DISK_ADDR diff --git a/src/qemu/qemu_agent.h b/src/qemu/qemu_agent.h index 4ea9b9dc1e..0d47230161 100644 --- a/src/qemu/qemu_agent.h +++ b/src/qemu/qemu_agent.h @@ -77,8 +77,7 @@ struct _qemuAgentDiskAddress { unsigned int target; unsigned int unit; char *devnode; - bool has_ccw_address; - virDomainDeviceCCWAddress ccw_addr; + virDomainDeviceCCWAddressPtr ccw_addr; }; void qemuAgentDiskAddressFree(qemuAgentDiskAddressPtr addr); G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuAgentDiskAddress, qemuAgentDiskAddressFree); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 62b0852c33..a376824854 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18887,8 +18887,7 @@ qemuAgentFSInfoToPublic(qemuAgentFSInfoPtr agent, diskDef = virDomainDiskByAddress(vmdef, &agentdisk->pci_controller, - agentdisk->has_ccw_address ? - &agentdisk->ccw_addr : NULL, + agentdisk->ccw_addr, agentdisk->bus, agentdisk->target, agentdisk->unit); @@ -19931,8 +19930,7 @@ qemuAgentDiskInfoFormatParams(qemuAgentDiskInfoPtr *info, /* match the disk to the target in the vm definition */ diskdef = virDomainDiskByAddress(vmdef, &info[i]->address->pci_controller, - info[i]->address->has_ccw_address ? - &info[i]->address->ccw_addr : NULL, + info[i]->address->ccw_addr, info[i]->address->bus, info[i]->address->target, info[i]->address->unit); @@ -20017,8 +20015,7 @@ qemuAgentFSInfoFormatParams(qemuAgentFSInfoPtr *fsinfo, /* match the disk to the target in the vm definition */ diskdef = virDomainDiskByAddress(vmdef, &d->pci_controller, - d->has_ccw_address ? - &d->ccw_addr : NULL, + d->ccw_addr, d->bus, d->target, d->unit);