[PATCH 1/3] qemu: agent: Store CCW address in qemuAgentDiskInfo if provided by the guest

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


Newer versions of the QEMU guest agent will provide the CCW address
of devices on s390x. Store this information in the qemuAgentDiskInfo
so that we can use this later.

We also map the CSSID 0 from the guest to the value 0xfe on the host,
see https://www.qemu.org/docs/master/system/s390x/css.html for details.

Signed-off-by: Thomas Huth <thuth at redhat.com>
---
 src/qemu/qemu_agent.c | 11 +++++++++++
 src/qemu/qemu_agent.h |  2 ++
 2 files changed, 13 insertions(+)

diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 230253d404..d7ad20376c 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -1868,6 +1868,7 @@ qemuAgentGetFSInfoFillDisks(virJSONValuePtr jsondisks,
     for (i = 0; i < fsinfo->ndisks; i++) {
         virJSONValuePtr jsondisk = virJSONValueArrayGet(jsondisks, i);
         virJSONValuePtr pci;
+        virJSONValuePtr ccw;
         qemuAgentDiskInfoPtr disk;
         const char *val;
 
@@ -1916,6 +1917,16 @@ qemuAgentGetFSInfoFillDisks(virJSONValuePtr jsondisks,
         GET_DISK_ADDR(pci, &disk->pci_controller.bus, "bus");
         GET_DISK_ADDR(pci, &disk->pci_controller.slot, "slot");
         GET_DISK_ADDR(pci, &disk->pci_controller.function, "function");
+
+        if ((ccw = virJSONValueObjectGet(jsondisk, "ccw-address"))) {
+            disk->has_ccw_address = true;
+            GET_DISK_ADDR(ccw, &disk->ccw_addr.cssid, "cssid");
+            if (disk->ccw_addr.cssid == 0)  /* Guest CSSID 0 is 0xfe on host */
+                disk->ccw_addr.cssid = 0xfe;
+            GET_DISK_ADDR(ccw, &disk->ccw_addr.ssid, "ssid");
+            GET_DISK_ADDR(ccw, &disk->ccw_addr.devno, "devno");
+        }
+
 #undef GET_DISK_ADDR
     }
 
diff --git a/src/qemu/qemu_agent.h b/src/qemu/qemu_agent.h
index 7cbab489ec..37b482f3b2 100644
--- a/src/qemu/qemu_agent.h
+++ b/src/qemu/qemu_agent.h
@@ -77,6 +77,8 @@ struct _qemuAgentDiskInfo {
     unsigned int target;
     unsigned int unit;
     char *devnode;
+    bool has_ccw_address;
+    virDomainDeviceCCWAddress ccw_addr;
 };
 
 typedef struct _qemuAgentFSInfo qemuAgentFSInfo;
-- 
2.18.4




More information about the libvir-list mailing list