g_free(info->serial);
g_free(info->bus_type);
g_free(info->devnode);
+ g_free(info->ccw_addr);
g_free(info);
}
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
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);
diskDef = virDomainDiskByAddress(vmdef,
&agentdisk->pci_controller,
- agentdisk->has_ccw_address ?
- &agentdisk->ccw_addr : NULL,
+ agentdisk->ccw_addr,
agentdisk->bus,
agentdisk->target,
agentdisk->unit);
/* 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);
/* 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);