[PATCH v2] qga/commands-posix: Send CCW address on s390x with the fsinfo data

Thomas Huth posted 1 patch 3 years, 4 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20201127082353.448251-1-thuth@redhat.com
Maintainers: Cornelia Huck <cohuck@redhat.com>, Michael Roth <michael.roth@amd.com>, Thomas Huth <thuth@redhat.com>
qga/commands-posix.c | 34 ++++++++++++++++++++++++++++++++++
qga/qapi-schema.json | 20 +++++++++++++++++++-
2 files changed, 53 insertions(+), 1 deletion(-)
[PATCH v2] qga/commands-posix: Send CCW address on s390x with the fsinfo data
Posted by Thomas Huth 3 years, 4 months ago
We need the CCW address on the libvirt side to correctly identify
the disk, so add this information to the GuestDiskAddress on s390x.

Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1755075
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 v2: Add missing comment about "subchno" (thanks to Cornelia for spotting this)

 The libirt part of this fix can be found here:
 https://www.redhat.com/archives/libvir-list/2020-November/msg01455.html

 qga/commands-posix.c | 34 ++++++++++++++++++++++++++++++++++
 qga/qapi-schema.json | 20 +++++++++++++++++++-
 2 files changed, 53 insertions(+), 1 deletion(-)

diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index c089e38120..5aa5eff84f 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -1029,6 +1029,38 @@ static bool build_guest_fsinfo_for_nonpci_virtio(char const *syspath,
     return true;
 }
 
+/*
+ * Store disk device info for CCW devices (s390x channel I/O devices).
+ * Returns true if information has been stored, or false for failure.
+ */
+static bool build_guest_fsinfo_for_ccw_dev(char const *syspath,
+                                           GuestDiskAddress *disk,
+                                           Error **errp)
+{
+    unsigned int cssid, ssid, subchno, devno;
+    char *p;
+
+    p = strstr(syspath, "/devices/css");
+    if (!p || sscanf(p + 12, "%*x/%x.%x.%x/%*x.%*x.%x/",
+                     &cssid, &ssid, &subchno, &devno) < 4) {
+        g_debug("could not parse ccw device sysfs path: %s", syspath);
+        return false;
+    }
+
+    disk->has_ccw_address = true;
+    disk->ccw_address = g_new0(GuestCCWAddress, 1);
+    disk->ccw_address->cssid = cssid;
+    disk->ccw_address->ssid = ssid;
+    disk->ccw_address->subchno = subchno;
+    disk->ccw_address->devno = devno;
+
+    if (strstr(p, "/virtio")) {
+        build_guest_fsinfo_for_nonpci_virtio(syspath, disk, errp);
+    }
+
+    return true;
+}
+
 /* Store disk device info specified by @sysfs into @fs */
 static void build_guest_fsinfo_for_real_device(char const *syspath,
                                                GuestFilesystemInfo *fs,
@@ -1081,6 +1113,8 @@ static void build_guest_fsinfo_for_real_device(char const *syspath,
 
     if (strstr(syspath, "/devices/pci")) {
         has_hwinf = build_guest_fsinfo_for_pci_dev(syspath, disk, errp);
+    } else if (strstr(syspath, "/devices/css")) {
+        has_hwinf = build_guest_fsinfo_for_ccw_dev(syspath, disk, errp);
     } else if (strstr(syspath, "/virtio")) {
         has_hwinf = build_guest_fsinfo_for_nonpci_virtio(syspath, disk, errp);
     } else {
diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json
index 3b3d1d0bd9..9a82b7e952 100644
--- a/qga/qapi-schema.json
+++ b/qga/qapi-schema.json
@@ -846,6 +846,22 @@
   'data': {'domain': 'int', 'bus': 'int',
            'slot': 'int', 'function': 'int'} }
 
+##
+# @GuestCCWAddress:
+#
+# @cssid: channel subsystem image id
+# @ssid: subchannel set id
+# @subchno: subchannel number
+# @devno: device number
+#
+# Since: 6.0
+##
+{ 'struct': 'GuestCCWAddress',
+  'data': {'cssid': 'int',
+           'ssid': 'int',
+           'subchno': 'int',
+           'devno': 'int'} }
+
 ##
 # @GuestDiskAddress:
 #
@@ -856,6 +872,7 @@
 # @unit: unit id
 # @serial: serial number (since: 3.1)
 # @dev: device node (POSIX) or device UNC (Windows) (since: 3.1)
+# @ccw-address: CCW address on s390x (since: 6.0)
 #
 # Since: 2.2
 ##
@@ -863,7 +880,8 @@
   'data': {'pci-controller': 'GuestPCIAddress',
            'bus-type': 'GuestDiskBusType',
            'bus': 'int', 'target': 'int', 'unit': 'int',
-           '*serial': 'str', '*dev': 'str'} }
+           '*serial': 'str', '*dev': 'str',
+           '*ccw-address': 'GuestCCWAddress'} }
 
 ##
 # @GuestDiskInfo:
-- 
2.18.4


Re: [PATCH v2] qga/commands-posix: Send CCW address on s390x with the fsinfo data
Posted by Cornelia Huck 3 years, 4 months ago
On Fri, 27 Nov 2020 09:23:53 +0100
Thomas Huth <thuth@redhat.com> wrote:

> We need the CCW address on the libvirt side to correctly identify
> the disk, so add this information to the GuestDiskAddress on s390x.
> 
> Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1755075
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  v2: Add missing comment about "subchno" (thanks to Cornelia for spotting this)
> 
>  The libirt part of this fix can be found here:
>  https://www.redhat.com/archives/libvir-list/2020-November/msg01455.html
> 
>  qga/commands-posix.c | 34 ++++++++++++++++++++++++++++++++++
>  qga/qapi-schema.json | 20 +++++++++++++++++++-
>  2 files changed, 53 insertions(+), 1 deletion(-)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>


Re: [PATCH v2] qga/commands-posix: Send CCW address on s390x with the fsinfo data
Posted by Michael Roth 3 years, 3 months ago
Quoting Thomas Huth (2020-11-27 02:23:53)
> We need the CCW address on the libvirt side to correctly identify
> the disk, so add this information to the GuestDiskAddress on s390x.
> 
> Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1755075
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  v2: Add missing comment about "subchno" (thanks to Cornelia for spotting this)
> 

Reviewed-by: Michael Roth <michael.roth@amd.com>

Re: [PATCH v2] qga/commands-posix: Send CCW address on s390x with the fsinfo data
Posted by Cornelia Huck 3 years, 3 months ago
On Fri, 27 Nov 2020 09:23:53 +0100
Thomas Huth <thuth@redhat.com> wrote:

> We need the CCW address on the libvirt side to correctly identify
> the disk, so add this information to the GuestDiskAddress on s390x.
> 
> Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1755075
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  v2: Add missing comment about "subchno" (thanks to Cornelia for spotting this)
> 
>  The libirt part of this fix can be found here:
>  https://www.redhat.com/archives/libvir-list/2020-November/msg01455.html
> 
>  qga/commands-posix.c | 34 ++++++++++++++++++++++++++++++++++
>  qga/qapi-schema.json | 20 +++++++++++++++++++-
>  2 files changed, 53 insertions(+), 1 deletion(-)

Thanks, applied.