qemu: Drop has_ccw_address from _qemuAgentDiskAddress

In recent patches new mambers to _qemuAgentDiskAddress struct
were introduced to keep optional CCW address sent by the guest
agent. These two members are a struct to store CCW address into
and a boolean to keep track whether the CCW address is valid.
Well, we can hold the same information with a pointer - instead
of storing the CCW address structure let's keep just a pointer to
it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
Michal Privoznik 2020-12-10 12:37:26 +01:00
parent 3fef204d59
commit 1165467940
3 changed files with 16 additions and 14 deletions

View File

@ -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

View File

@ -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);

View File

@ -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);