[libvirt] [PATCH 1/2] qemu: Add ccw support for vhost-vsock

Boris Fiuczynski fiuczy at linux.ibm.com
Wed Jul 4 11:21:44 UTC 2018


Add support and tests for vhost-vsock-ccw.

Signed-off-by: Boris Fiuczynski <fiuczy at linux.ibm.com>
---
 src/qemu/qemu_command.c                       | 15 +++++++--
 src/qemu/qemu_domain_address.c                |  7 +++-
 .../vhost-vsock-ccw-auto.args                 | 27 ++++++++++++++++
 .../qemuxml2argvdata/vhost-vsock-ccw-auto.xml | 25 +++++++++++++++
 tests/qemuxml2argvdata/vhost-vsock-ccw.args   | 27 ++++++++++++++++
 tests/qemuxml2argvdata/vhost-vsock-ccw.xml    | 32 +++++++++++++++++++
 tests/qemuxml2argvtest.c                      |  4 +++
 .../vhost-vsock-ccw-auto.xml                  | 32 +++++++++++++++++++
 tests/qemuxml2xmloutdata/vhost-vsock-ccw.xml  |  1 +
 tests/qemuxml2xmltest.c                       |  5 +++
 10 files changed, 172 insertions(+), 3 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/vhost-vsock-ccw-auto.args
 create mode 100644 tests/qemuxml2argvdata/vhost-vsock-ccw-auto.xml
 create mode 100644 tests/qemuxml2argvdata/vhost-vsock-ccw.args
 create mode 100644 tests/qemuxml2argvdata/vhost-vsock-ccw.xml
 create mode 100644 tests/qemuxml2xmloutdata/vhost-vsock-ccw-auto.xml
 create mode 120000 tests/qemuxml2xmloutdata/vhost-vsock-ccw.xml

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 04c5c28438..ab6944f68e 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -10089,10 +10089,21 @@ qemuBuildVsockDevStr(virDomainDefPtr def,
 {
     qemuDomainVsockPrivatePtr priv = (qemuDomainVsockPrivatePtr)vsock->privateData;
     virBuffer buf = VIR_BUFFER_INITIALIZER;
-    const char *device = "vhost-vsock-pci";
     char *ret = NULL;
+    const char *devsuffix;
 
-    virBufferAsprintf(&buf, "%s", device);
+    if (vsock->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
+        devsuffix = "pci";
+    } else if (vsock->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
+        devsuffix = "ccw";
+    } else {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("unsupported address type %s for vsock device"),
+                       virDomainDeviceAddressTypeToString(vsock->info.type));
+        goto cleanup;
+    }
+
+    virBufferAsprintf(&buf, "vhost-vsock-%s", devsuffix);
     virBufferAsprintf(&buf, ",id=%s", vsock->info.alias);
     virBufferAsprintf(&buf, ",guest-cid=%u", vsock->guest_cid);
     virBufferAsprintf(&buf, ",vhostfd=%s%u", fdprefix, priv->vhostfd);
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index eb11a660d7..9639595175 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -306,7 +306,8 @@ qemuDomainPrimeVirtioDeviceAddresses(virDomainDefPtr def,
        declare address-less virtio devices to be of address type 'type'
        disks, networks, videos, consoles, controllers, memballoon and rng
        in this order
-       if type is ccw filesystem devices are declared to be of address type ccw
+       if type is ccw filesystem and vsock devices are declared to be of
+       address type ccw
     */
     size_t i;
 
@@ -373,6 +374,10 @@ qemuDomainPrimeVirtioDeviceAddresses(virDomainDefPtr def,
             if (def->fss[i]->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
                 def->fss[i]->info.type = type;
         }
+        if (def->vsock &&
+            def->vsock->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
+            def->vsock->info.type = type;
+        }
     }
 }
 
diff --git a/tests/qemuxml2argvdata/vhost-vsock-ccw-auto.args b/tests/qemuxml2argvdata/vhost-vsock-ccw-auto.args
new file mode 100644
index 0000000000..23a9b5ab46
--- /dev/null
+++ b/tests/qemuxml2argvdata/vhost-vsock-ccw-auto.args
@@ -0,0 +1,27 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-s390x \
+-name QEMUGuest1 \
+-S \
+-machine s390-ccw-virtio,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-boot c \
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
+-device virtio-blk-ccw,devno=fe.0.0000,drive=drive-virtio-disk0,\
+id=virtio-disk0 \
+-device virtio-balloon-ccw,id=balloon0,devno=fe.0.0001 \
+-device vhost-vsock-ccw,id=vsock0,guest-cid=42,vhostfd=6789,devno=fe.0.0002
diff --git a/tests/qemuxml2argvdata/vhost-vsock-ccw-auto.xml b/tests/qemuxml2argvdata/vhost-vsock-ccw-auto.xml
new file mode 100644
index 0000000000..e5b60765ab
--- /dev/null
+++ b/tests/qemuxml2argvdata/vhost-vsock-ccw-auto.xml
@@ -0,0 +1,25 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219136</memory>
+  <currentMemory unit='KiB'>219136</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='s390x' machine='s390-ccw-virtio'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-s390x</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='virtio'/>
+    </disk>
+    <vsock>
+      <cid auto='yes'/>
+    </vsock>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/vhost-vsock-ccw.args b/tests/qemuxml2argvdata/vhost-vsock-ccw.args
new file mode 100644
index 0000000000..3dd690aa1a
--- /dev/null
+++ b/tests/qemuxml2argvdata/vhost-vsock-ccw.args
@@ -0,0 +1,27 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-s390x \
+-name QEMUGuest1 \
+-S \
+-machine s390-ccw-virtio,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-boot c \
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
+-device virtio-blk-ccw,devno=fe.0.0000,drive=drive-virtio-disk0,\
+id=virtio-disk0 \
+-device virtio-balloon-ccw,id=balloon0,devno=fe.0.0001 \
+-device vhost-vsock-ccw,id=vsock0,guest-cid=4,vhostfd=6789,devno=fe.0.0003
diff --git a/tests/qemuxml2argvdata/vhost-vsock-ccw.xml b/tests/qemuxml2argvdata/vhost-vsock-ccw.xml
new file mode 100644
index 0000000000..083061c6cc
--- /dev/null
+++ b/tests/qemuxml2argvdata/vhost-vsock-ccw.xml
@@ -0,0 +1,32 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219136</memory>
+  <currentMemory unit='KiB'>219136</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='s390x' machine='s390-ccw-virtio'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-s390x</emulator>
+    <disk type='block' device='disk'>
+      <driver name='qemu' type='raw'/>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='virtio'/>
+      <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/>
+    </disk>
+    <memballoon model='virtio'>
+      <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0001'/>
+    </memballoon>
+    <panic model='s390'/>
+    <vsock model='virtio'>
+      <cid auto='no' address='4'/>
+      <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0003'/>
+    </vsock>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index d6911f9344..60bd9585e5 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -2914,6 +2914,10 @@ mymain(void)
 
     DO_TEST_CAPS_LATEST("vhost-vsock");
     DO_TEST_CAPS_LATEST("vhost-vsock-auto");
+    DO_TEST("vhost-vsock-ccw", QEMU_CAPS_DEVICE_VHOST_VSOCK,
+            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
+    DO_TEST("vhost-vsock-ccw-auto", QEMU_CAPS_DEVICE_VHOST_VSOCK,
+            QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
 
     DO_TEST("launch-security-sev",
             QEMU_CAPS_KVM,
diff --git a/tests/qemuxml2xmloutdata/vhost-vsock-ccw-auto.xml b/tests/qemuxml2xmloutdata/vhost-vsock-ccw-auto.xml
new file mode 100644
index 0000000000..38a0fb3808
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/vhost-vsock-ccw-auto.xml
@@ -0,0 +1,32 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219136</memory>
+  <currentMemory unit='KiB'>219136</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='s390x' machine='s390-ccw-virtio'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-s390x</emulator>
+    <disk type='block' device='disk'>
+      <driver name='qemu' type='raw'/>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='virtio'/>
+      <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/>
+    </disk>
+    <memballoon model='virtio'>
+      <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0001'/>
+    </memballoon>
+    <panic model='s390'/>
+    <vsock model='virtio'>
+      <cid auto='yes'/>
+      <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0002'/>
+    </vsock>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/vhost-vsock-ccw.xml b/tests/qemuxml2xmloutdata/vhost-vsock-ccw.xml
new file mode 120000
index 0000000000..e0fa69dba9
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/vhost-vsock-ccw.xml
@@ -0,0 +1 @@
+../qemuxml2argvdata/vhost-vsock-ccw.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index bbb995656e..9e369ff592 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -1222,6 +1222,11 @@ mymain(void)
 
     DO_TEST("vhost-vsock", QEMU_CAPS_DEVICE_VHOST_VSOCK);
     DO_TEST("vhost-vsock-auto", QEMU_CAPS_DEVICE_VHOST_VSOCK);
+    DO_TEST("vhost-vsock-ccw", QEMU_CAPS_DEVICE_VHOST_VSOCK,
+            QEMU_CAPS_CCW);
+    DO_TEST("vhost-vsock-ccw-auto", QEMU_CAPS_DEVICE_VHOST_VSOCK,
+            QEMU_CAPS_CCW);
+
 
     if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
         virFileDeleteTree(fakerootdir);
-- 
2.17.0




More information about the libvir-list mailing list