domain_conf: Allow to look up virtio-block devices by their CCW address

On s390x, devices are accessed via the channel subsystem by default,
so we need to look up the devices via their CCW address there instead
of using PCI.

This fixes "virsh domfsinfo" on s390x for virtio-block devices (the first
attempt from commit f8333b3b0a did it in the wrong way, reporting the
device name on the guest side instead of the target name on the host side).

Fixes: f8333b3b0a ("qemu: Fix domfsinfo for non-PCI device information ...")
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1858771
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@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:47 +01:00 committed by Michal Privoznik
parent f5c8cf9e0e
commit 5db43b5a76
3 changed files with 18 additions and 4 deletions

View File

@ -16089,6 +16089,7 @@ virDomainDiskControllerMatch(int controller_type, int disk_bus)
int
virDomainDiskIndexByAddress(virDomainDefPtr def,
virPCIDeviceAddressPtr pci_address,
virDomainDeviceCCWAddressPtr ccw_addr,
unsigned int bus, unsigned int target,
unsigned int unit)
{
@ -16105,6 +16106,11 @@ virDomainDiskIndexByAddress(virDomainDefPtr def,
if (vdisk->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI &&
virPCIDeviceAddressEqual(&vdisk->info.addr.pci, pci_address))
return i;
if (vdisk->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW &&
ccw_addr &&
virDomainDeviceCCWAddressEqual(&vdisk->info.addr.ccw, ccw_addr)) {
return i;
}
if (vdisk->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) {
virDomainDeviceDriveAddressPtr drive = &vdisk->info.addr.drive;
if (controller &&
@ -16121,11 +16127,13 @@ virDomainDiskIndexByAddress(virDomainDefPtr def,
virDomainDiskDefPtr
virDomainDiskByAddress(virDomainDefPtr def,
virPCIDeviceAddressPtr pci_address,
virDomainDeviceCCWAddressPtr ccw_addr,
unsigned int bus,
unsigned int target,
unsigned int unit)
{
int idx = virDomainDiskIndexByAddress(def, pci_address, bus, target, unit);
int idx = virDomainDiskIndexByAddress(def, pci_address, ccw_addr,
bus, target, unit);
return idx < 0 ? NULL : def->disks[idx];
}

View File

@ -3378,10 +3378,12 @@ void virDomainRNGDefFree(virDomainRNGDefPtr def);
int virDomainDiskIndexByAddress(virDomainDefPtr def,
virPCIDeviceAddressPtr pci_controller,
virDomainDeviceCCWAddressPtr ccw_addr,
unsigned int bus, unsigned int target,
unsigned int unit);
virDomainDiskDefPtr virDomainDiskByAddress(virDomainDefPtr def,
virPCIDeviceAddressPtr pci_controller,
virDomainDeviceCCWAddressPtr ccw_addr,
unsigned int bus,
unsigned int target,
unsigned int unit);

View File

@ -18887,15 +18887,15 @@ qemuAgentFSInfoToPublic(qemuAgentFSInfoPtr agent,
diskDef = virDomainDiskByAddress(vmdef,
&agentdisk->pci_controller,
agentdisk->has_ccw_address ?
&agentdisk->ccw_addr : NULL,
agentdisk->bus,
agentdisk->target,
agentdisk->unit);
if (diskDef != NULL)
ret->devAlias[i] = g_strdup(diskDef->dst);
else if (agentdisk->devnode != NULL)
ret->devAlias[i] = g_strdup(agentdisk->devnode);
else
VIR_DEBUG("Missing devnode name for '%s'.", ret->mountpoint);
VIR_DEBUG("Missing target name for '%s'.", ret->mountpoint);
}
return ret;
@ -19931,6 +19931,8 @@ 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->bus,
info[i]->address->target,
info[i]->address->unit);
@ -20015,6 +20017,8 @@ 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->bus,
d->target,
d->unit);