Skip to contentSkip to conversation

qga/commands-posix: Send CCW address on s390x with the fsinfo data

PATCH Superseded Thomas Huth 3 participants 6 messages Nov 25, 2020 – Dec 16, 2020

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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

We need the CCW address on the libvirt side to correctly identify the disk, so add this information to the GuestDiskAddress on s390x.

---
 qga/commands-posix.c | 34 ++++++++++++++++++++++++++++++++++
 qga/qapi-schema.json | 19 ++++++++++++++++++-
 2 files changed, 52 insertions(+), 1 deletion(-)
qga/commands-posix.c +34 -0
index c089e38120..5aa5eff84f 100644
@@ -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 {
qga/qapi-schema.json +18 -1
index 3b3d1d0bd9..8be84b56e9 100644
@@ -846,6 +846,21 @@
   'data': {'domain': 'int', 'bus': 'int',
            'slot': 'int', 'function': 'int'} }
 
+##
+# @GuestCCWAddress:
+#
+# @cssid: channel subsystem image id
+# @ssid: subchannel set id
+# @devno:  device number
+#
+# Since: 6.0
+##
+{ 'struct': 'GuestCCWAddress',
+  'data': {'cssid': 'int',
+           'ssid': 'int',
+           'subchno': 'int',
+           'devno': 'int'} }
+
 ##
 # @GuestDiskAddress:
 #
@@ -856,6 +871,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 +879,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:
Signature · 1 line
2.18.4
#1 lore raw
Quoted 10 lines · On Wed, 25 Nov 2020 11:54:17 +0100 Thomas Huth <[email protected]> wrote:

We need the CCW address on the libvirt side to correctly identify the disk, so add this information to the GuestDiskAddress on s390x.

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

(...)

qga/qapi-schema.json line 853

Quoted 13 lines
qga/qapi-schema.json +5 -0
index 3b3d1d0bd9..8be84b56e9 100644
@@ -846,6 +846,21 @@
   'data': {'domain': 'int', 'bus': 'int',
            'slot': 'int', 'function': 'int'} }
 
+##
+# @GuestCCWAddress:
+#
+# @cssid: channel subsystem image id
+# @ssid: subchannel set id

You're missing subchno here.

qga/qapi-schema.json line 866

Quoted 13 lines
qga/qapi-schema.json +10 -0
+# @devno:  device number
+#
+# Since: 6.0
+##
+{ 'struct': 'GuestCCWAddress',
+  'data': {'cssid': 'int',
+           'ssid': 'int',
+           'subchno': 'int',
+           'devno': 'int'} }
+
 ##
 # @GuestDiskAddress:
 #

(...)

Otherwise LGTM.

#2 lore raw
In reply to Thomas Huth
Quoted 98 lines · Thomas Huth

We need the CCW address on the libvirt side to correctly identify the disk, so add this information to the GuestDiskAddress on s390x.

---
 qga/commands-posix.c | 34 ++++++++++++++++++++++++++++++++++
 qga/qapi-schema.json | 19 ++++++++++++++++++-
 2 files changed, 52 insertions(+), 1 deletion(-)
qga/commands-posix.c +34 -0
index c089e38120..5aa5eff84f 100644
@@ -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 {
qga/qapi-schema.json +16 -0
index 3b3d1d0bd9..8be84b56e9 100644
@@ -846,6 +846,21 @@
   'data': {'domain': 'int', 'bus': 'int',
            'slot': 'int', 'function': 'int'} }
 
+##
+# @GuestCCWAddress:
+#
+# @cssid: channel subsystem image id
+# @ssid: subchannel set id
+# @devno:  device number
+#
+# Since: 6.0
+##
+{ 'struct': 'GuestCCWAddress',
+  'data': {'cssid': 'int',
+           'ssid': 'int',
+           'subchno': 'int',
+           'devno': 'int'} }
+
 ##
 # @GuestDiskAddress:
 #
@@ -856,6 +871,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
 ##

qga/qapi-schema.json line 886

Quoted 9 lines
qga/qapi-schema.json +2 -1
@@ -863,7 +879,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:

Ping!

Michael, any comments on this, or do you think that it ready to go?

Thanks,
Thomas

#3 lore raw
Quoted 11 lines · On Mon, 14 Dec 2020 09:53:21 +0100 Thomas Huth <[email protected]> wrote:
Quoted 9 lines · Thomas Huth

We need the CCW address on the libvirt side to correctly identify the disk, so add this information to the GuestDiskAddress on s390x.

---
 qga/commands-posix.c | 34 ++++++++++++++++++++++++++++++++++
 qga/qapi-schema.json | 19 ++++++++++++++++++-
 2 files changed, 52 insertions(+), 1 deletion(-)
Quoted 3 lines

Ping!

Michael, any comments on this, or do you think that it ready to go?

If nobody objects, I can also merge this (or rather the v2 of this patch) through the s390x tree.

#4 lore raw
Quoted 14 lines · Cornelia Huck
Quoted 10 lines · On Mon, 14 Dec 2020 09:53:21 +0100 Thomas Huth <[email protected]> wrote:
Quoted 9 lines · Thomas Huth

We need the CCW address on the libvirt side to correctly identify the disk, so add this information to the GuestDiskAddress on s390x.

---
 qga/commands-posix.c | 34 ++++++++++++++++++++++++++++++++++
 qga/qapi-schema.json | 19 ++++++++++++++++++-
 2 files changed, 52 insertions(+), 1 deletion(-)
Quoted 6 lines
Quoted 3 lines

Ping!

Michael, any comments on this, or do you think that it ready to go?

If nobody objects, I can also merge this (or rather the v2 of this patch) through the s390x tree.

Oh, right, I pinged on the wrong version, sorry! So, Cornelia, if you could pick up v2, that would be great! I think the patch should not have any effects on non-s390x architectures, so it should be ok if it goes via the s390x tree.

Thanks,
Thomas

#5 lore raw
In reply to Cornelia Huck

Quoting Cornelia Huck (2020-12-16 06:40:39)

Quoted 14 lines
Quoted 10 lines · On Mon, 14 Dec 2020 09:53:21 +0100 Thomas Huth <[email protected]> wrote:
Quoted 9 lines · Thomas Huth

We need the CCW address on the libvirt side to correctly identify the disk, so add this information to the GuestDiskAddress on s390x.

---
 qga/commands-posix.c | 34 ++++++++++++++++++++++++++++++++++
 qga/qapi-schema.json | 19 ++++++++++++++++++-
 2 files changed, 52 insertions(+), 1 deletion(-)
Quoted 7 lines
Quoted 3 lines

Ping!

Michael, any comments on this, or do you think that it ready to go?

If nobody objects, I can also merge this (or rather the v2 of this patch) through the s390x tree.

No objections here. v2 looks good. Thanks!