]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: agent: Store CCW address in qemuAgentDiskInfo if provided by the guest
authorThomas Huth <thuth@redhat.com>
Wed, 25 Nov 2020 11:06:46 +0000 (12:06 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 22 Dec 2020 13:16:31 +0000 (14:16 +0100)
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@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_agent.c
src/qemu/qemu_agent.h

index d4530dcd7a8d9f7677e7d5f348b8b44efdfbaf8a..b155896e78a657d739aafc09559c288a01932eba 100644 (file)
@@ -1866,6 +1866,7 @@ static qemuAgentDiskAddressPtr
 qemuAgentGetDiskAddress(virJSONValuePtr json)
 {
     virJSONValuePtr pci;
+    virJSONValuePtr ccw;
     g_autoptr(qemuAgentDiskAddress) addr = NULL;
 
     addr = g_new0(qemuAgentDiskAddress, 1);
@@ -1896,6 +1897,15 @@ qemuAgentGetDiskAddress(virJSONValuePtr json)
     GET_DISK_ADDR(pci, &addr->pci_controller.bus, "bus");
     GET_DISK_ADDR(pci, &addr->pci_controller.slot, "slot");
     GET_DISK_ADDR(pci, &addr->pci_controller.function, "function");
+
+    if ((ccw = virJSONValueObjectGet(json, "ccw-address"))) {
+        addr->has_ccw_address = true;
+        GET_DISK_ADDR(ccw, &addr->ccw_addr.cssid, "cssid");
+        if (addr->ccw_addr.cssid == 0)  /* Guest CSSID 0 is 0xfe on host */
+            addr->ccw_addr.cssid = 0xfe;
+        GET_DISK_ADDR(ccw, &addr->ccw_addr.ssid, "ssid");
+        GET_DISK_ADDR(ccw, &addr->ccw_addr.devno, "devno");
+    }
 #undef GET_DISK_ADDR
 
     return g_steal_pointer(&addr);
index 74f1410760f99bf3dcaf5ca3c48c78e348ea8db9..4ea9b9dc1ee758685cceed4ac734ab74deca8b1b 100644 (file)
@@ -77,6 +77,8 @@ struct _qemuAgentDiskAddress {
     unsigned int target;
     unsigned int unit;
     char *devnode;
+    bool has_ccw_address;
+    virDomainDeviceCCWAddress ccw_addr;
 };
 void qemuAgentDiskAddressFree(qemuAgentDiskAddressPtr addr);
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuAgentDiskAddress, qemuAgentDiskAddressFree);