[PATCH 2/3] domain_conf: Allow to look up virtio-block devices by their CCW address

Thomas Huth thuth at redhat.com
Wed Nov 25 11:06:47 UTC 2020


On s390x, devices are attached to the channel IO subsytem 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 f8333b3b0a7 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 ...")
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1858771
Signed-off-by: Thomas Huth <thuth at redhat.com>
---
 src/conf/domain_conf.c | 10 +++++++++-
 src/conf/domain_conf.h |  2 ++
 src/qemu/qemu_driver.c |  8 +++++---
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 2393bf6a37..00c115d453 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -17598,6 +17598,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)
 {
@@ -17614,6 +17615,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 &&
@@ -17630,11 +17636,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];
 }
 
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 96e6c34553..b062b962bb 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3342,10 +3342,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);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b69be1bedc..7324412708 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -18852,15 +18852,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;
@@ -19903,6 +19903,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);
-- 
2.18.4




More information about the libvir-list mailing list