Blame SOURCES/kvm-qga-commands-posix-Support-fsinfo-for-non-PCI-virtio.patch

f66865
From 250227a53c1d43d2bd8346922edb3452f3534be6 Mon Sep 17 00:00:00 2001
f66865
From: Thomas Huth <thuth@redhat.com>
f66865
Date: Fri, 2 Oct 2020 10:17:42 -0400
f66865
Subject: [PATCH 03/14] qga/commands-posix: Support fsinfo for non-PCI virtio
f66865
 devices, too
f66865
MIME-Version: 1.0
f66865
Content-Type: text/plain; charset=UTF-8
f66865
Content-Transfer-Encoding: 8bit
f66865
f66865
RH-Author: Thomas Huth <thuth@redhat.com>
f66865
Message-id: <20201002101742.249169-4-thuth@redhat.com>
f66865
Patchwork-id: 98528
f66865
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH 3/3] qga/commands-posix: Support fsinfo for non-PCI virtio devices, too
f66865
Bugzilla: 1755075
f66865
RH-Acked-by: Danilo de Paula <ddepaula@redhat.com>
f66865
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
f66865
RH-Acked-by: David Hildenbrand <david@redhat.com>
f66865
f66865
QEMU on s390x uses virtio via channel I/O instead of PCI by default.
f66865
Add a function to detect and provide information for virtio-scsi and
f66865
virtio-block devices here, too.
f66865
f66865
Signed-off-by: Thomas Huth <thuth@redhat.com>
f66865
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
f66865
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
f66865
(cherry picked from commit 23843c129d5e1ca360605e511a43a34faebb47c4)
f66865
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
f66865
---
f66865
 qga/commands-posix.c | 42 +++++++++++++++++++++++++++++++++++++++++-
f66865
 1 file changed, 41 insertions(+), 1 deletion(-)
f66865
f66865
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
f66865
index 6db76aadd1..c86c87ed52 100644
f66865
--- a/qga/commands-posix.c
f66865
+++ b/qga/commands-posix.c
f66865
@@ -1000,6 +1000,39 @@ cleanup:
f66865
     return ret;
f66865
 }
f66865
 
f66865
+/*
f66865
+ * Store disk device info for non-PCI virtio devices (for example s390x
f66865
+ * channel I/O devices). Returns true if information has been stored, or
f66865
+ * false for failure.
f66865
+ */
f66865
+static bool build_guest_fsinfo_for_nonpci_virtio(char const *syspath,
f66865
+                                                 GuestDiskAddress *disk,
f66865
+                                                 Error **errp)
f66865
+{
f66865
+    unsigned int tgt[3];
f66865
+    char *p;
f66865
+
f66865
+    if (!strstr(syspath, "/virtio") || !strstr(syspath, "/block")) {
f66865
+        g_debug("Unsupported virtio device '%s'", syspath);
f66865
+        return false;
f66865
+    }
f66865
+
f66865
+    p = strstr(syspath, "/target");
f66865
+    if (p && sscanf(p + 7, "%*u:%*u:%*u/%*u:%u:%u:%u",
f66865
+                    &tgt[0], &tgt[1], &tgt[2]) == 3) {
f66865
+        /* virtio-scsi: target*:0:<target>:<unit> */
f66865
+        disk->bus_type = GUEST_DISK_BUS_TYPE_SCSI;
f66865
+        disk->bus = tgt[0];
f66865
+        disk->target = tgt[1];
f66865
+        disk->unit = tgt[2];
f66865
+    } else {
f66865
+        /* virtio-blk: 1 disk per 1 device */
f66865
+        disk->bus_type = GUEST_DISK_BUS_TYPE_VIRTIO;
f66865
+    }
f66865
+
f66865
+    return true;
f66865
+}
f66865
+
f66865
 /* Store disk device info specified by @sysfs into @fs */
f66865
 static void build_guest_fsinfo_for_real_device(char const *syspath,
f66865
                                                GuestFilesystemInfo *fs,
f66865
@@ -1050,7 +1083,14 @@ static void build_guest_fsinfo_for_real_device(char const *syspath,
f66865
     udev_device_unref(udevice);
f66865
 #endif
f66865
 
f66865
-    has_hwinf = build_guest_fsinfo_for_pci_dev(syspath, disk, errp);
f66865
+    if (strstr(syspath, "/devices/pci")) {
f66865
+        has_hwinf = build_guest_fsinfo_for_pci_dev(syspath, disk, errp);
f66865
+    } else if (strstr(syspath, "/virtio")) {
f66865
+        has_hwinf = build_guest_fsinfo_for_nonpci_virtio(syspath, disk, errp);
f66865
+    } else {
f66865
+        g_debug("Unsupported device type for '%s'", syspath);
f66865
+        has_hwinf = false;
f66865
+    }
f66865
 
f66865
     if (has_hwinf || disk->has_dev || disk->has_serial) {
f66865
         list->next = fs->disk;
f66865
-- 
f66865
2.27.0
f66865