qemu: agent: Store CCW address in qemuAgentDiskInfo if provided by the guest

Newer versions of the QEMU guest agent will provide the CCW address
of devices on s390x. Store this information in the qemuAgentDiskInfo
so that we can use this later.

We also map the CSSID 0 from the guest to the value 0xfe on the host,
see https://www.qemu.org/docs/master/system/s390x/css.html for details.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Thomas Huth 2020-11-25 12:06:46 +01:00 committed by Michal Privoznik
parent bed50bcbbb
commit f5c8cf9e0e
2 changed files with 12 additions and 0 deletions

View File

@ -1866,6 +1866,7 @@ static qemuAgentDiskAddressPtr
qemuAgentGetDiskAddress(virJSONValuePtr json)
{
virJSONValuePtr pci;
virJSONValuePtr ccw;
g_autoptr(qemuAgentDiskAddress) addr = NULL;
addr = g_new0(qemuAgentDiskAddress, 1);
@ -1896,6 +1897,15 @@ qemuAgentGetDiskAddress(virJSONValuePtr json)
GET_DISK_ADDR(pci, &addr->pci_controller.bus, "bus");
GET_DISK_ADDR(pci, &addr->pci_controller.slot, "slot");
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");
}
#undef GET_DISK_ADDR
return g_steal_pointer(&addr);

View File

@ -77,6 +77,8 @@ struct _qemuAgentDiskAddress {
unsigned int target;
unsigned int unit;
char *devnode;
bool has_ccw_address;
virDomainDeviceCCWAddress ccw_addr;
};
void qemuAgentDiskAddressFree(qemuAgentDiskAddressPtr addr);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuAgentDiskAddress, qemuAgentDiskAddressFree);