|
|
7548c0 |
From 362d106d8897a3982f5eaed0c4bc0194d6f9ef28 Mon Sep 17 00:00:00 2001
|
|
|
7548c0 |
Message-Id: <362d106d8897a3982f5eaed0c4bc0194d6f9ef28@dist-git>
|
|
|
7548c0 |
From: Boris Fiuczynski <fiuczy@linux.ibm.com>
|
|
|
7548c0 |
Date: Fri, 26 Feb 2021 06:43:35 -0500
|
|
|
7548c0 |
Subject: [PATCH] qemu: Add virtio related options to vsock
|
|
|
7548c0 |
|
|
|
7548c0 |
Add virtio related options iommu, ats and packed as driver element attributes
|
|
|
7548c0 |
to vsock devices. Ex:
|
|
|
7548c0 |
|
|
|
7548c0 |
<vsock model='virtio'>
|
|
|
7548c0 |
<cid auto='no' address='3'/>
|
|
|
7548c0 |
<driver iommu='on'/>
|
|
|
7548c0 |
</vsock>
|
|
|
7548c0 |
|
|
|
7548c0 |
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
|
|
|
7548c0 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
7548c0 |
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
7548c0 |
(cherry picked from commit bd112c9e0f7523b90bf1362cf60deea7db05a32b)
|
|
|
7548c0 |
|
|
|
7548c0 |
Resolves: https://bugzilla.redhat.com/1931548
|
|
|
7548c0 |
|
|
|
7548c0 |
Note: since the virtio option packed is not yet available in the code
|
|
|
7548c0 |
version it will also not be available with this backported patch.
|
|
|
7548c0 |
|
|
|
7548c0 |
Conflicts: docs/formatdomain.rst:
|
|
|
7548c0 |
converted changes into docs/formatdomain.html.in
|
|
|
7548c0 |
src/conf/domain_conf.c:
|
|
|
7548c0 |
resolved conflicts by moving the code into the correct methods
|
|
|
7548c0 |
src/conf/domain_validate.c:
|
|
|
7548c0 |
does not exist downstream. moved code to src/conf/domain_conf.c
|
|
|
7548c0 |
src/qemu/qemu_validate.c:
|
|
|
7548c0 |
does not exist downstream. can be neglected
|
|
|
7548c0 |
|
|
|
7548c0 |
Message-Id: <20210226114335.100390-2-bfiuczyn@redhat.com>
|
|
|
7548c0 |
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
7548c0 |
---
|
|
|
7548c0 |
docs/formatdomain.html.in | 5 ++-
|
|
|
7548c0 |
docs/schemas/domaincommon.rng | 5 +++
|
|
|
7548c0 |
src/conf/domain_conf.c | 27 ++++++++++++++
|
|
|
7548c0 |
src/conf/domain_conf.h | 1 +
|
|
|
7548c0 |
src/qemu/qemu_command.c | 4 ++
|
|
|
7548c0 |
.../vhost-vsock-ccw-iommu.s390x-latest.args | 37 +++++++++++++++++++
|
|
|
7548c0 |
.../vhost-vsock-ccw-iommu.xml | 37 +++++++++++++++++++
|
|
|
7548c0 |
tests/qemuxml2argvtest.c | 1 +
|
|
|
7548c0 |
.../vhost-vsock-ccw-iommu.s390x-latest.xml | 1 +
|
|
|
7548c0 |
tests/qemuxml2xmltest.c | 2 +
|
|
|
7548c0 |
10 files changed, 119 insertions(+), 1 deletion(-)
|
|
|
7548c0 |
create mode 100644 tests/qemuxml2argvdata/vhost-vsock-ccw-iommu.s390x-latest.args
|
|
|
7548c0 |
create mode 100644 tests/qemuxml2argvdata/vhost-vsock-ccw-iommu.xml
|
|
|
7548c0 |
create mode 120000 tests/qemuxml2xmloutdata/vhost-vsock-ccw-iommu.s390x-latest.xml
|
|
|
7548c0 |
|
|
|
7548c0 |
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
|
|
|
7548c0 |
index bec753e37f..127dd13cc0 100644
|
|
|
7548c0 |
--- a/docs/formatdomain.html.in
|
|
|
7548c0 |
+++ b/docs/formatdomain.html.in
|
|
|
7548c0 |
@@ -9240,7 +9240,10 @@ qemu-kvm -net nic,model=? /dev/null
|
|
|
7548c0 |
element specifies the CID assigned to the guest. If the attribute
|
|
|
7548c0 |
auto is set to yes , libvirt
|
|
|
7548c0 |
will assign a free CID automatically on domain startup.
|
|
|
7548c0 |
- Since 4.4.0
|
|
|
7548c0 |
+ Since 4.4.0
|
|
|
7548c0 |
+ The optional driver element allows to specify virtio options, see
|
|
|
7548c0 |
+ Virtio-specific options for more details.
|
|
|
7548c0 |
+ Since 7.1.0
|
|
|
7548c0 |
|
|
|
7548c0 |
|
|
|
7548c0 |
...
|
|
|
7548c0 |
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
|
|
|
7548c0 |
index 9fda5f17e0..4a42cb9b40 100644
|
|
|
7548c0 |
--- a/docs/schemas/domaincommon.rng
|
|
|
7548c0 |
+++ b/docs/schemas/domaincommon.rng
|
|
|
7548c0 |
@@ -4685,6 +4685,11 @@
|
|
|
7548c0 |
<optional>
|
|
|
7548c0 |
<ref name="alias"/>
|
|
|
7548c0 |
</optional>
|
|
|
7548c0 |
+ <optional>
|
|
|
7548c0 |
+ <element name="driver">
|
|
|
7548c0 |
+ <ref name="virtioOptions"/>
|
|
|
7548c0 |
+ </element>
|
|
|
7548c0 |
+ </optional>
|
|
|
7548c0 |
</interleave>
|
|
|
7548c0 |
</element>
|
|
|
7548c0 |
</define>
|
|
|
7548c0 |
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
|
|
7548c0 |
index c5a0442c6f..166c3e48d2 100644
|
|
|
7548c0 |
--- a/src/conf/domain_conf.c
|
|
|
7548c0 |
+++ b/src/conf/domain_conf.c
|
|
|
7548c0 |
@@ -2392,6 +2392,7 @@ virDomainVsockDefFree(virDomainVsockDefPtr vsock)
|
|
|
7548c0 |
|
|
|
7548c0 |
virObjectUnref(vsock->privateData);
|
|
|
7548c0 |
virDomainDeviceInfoClear(&vsock->info);
|
|
|
7548c0 |
+ VIR_FREE(vsock->virtio);
|
|
|
7548c0 |
VIR_FREE(vsock);
|
|
|
7548c0 |
}
|
|
|
7548c0 |
|
|
|
7548c0 |
@@ -6504,6 +6505,15 @@ virDomainMemoryDefValidate(const virDomainMemoryDef *mem)
|
|
|
7548c0 |
}
|
|
|
7548c0 |
|
|
|
7548c0 |
|
|
|
7548c0 |
+static bool
|
|
|
7548c0 |
+virDomainVsockIsVirtioModel(const virDomainVsockDef *vsock)
|
|
|
7548c0 |
+{
|
|
|
7548c0 |
+ return (vsock->model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO ||
|
|
|
7548c0 |
+ vsock->model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL ||
|
|
|
7548c0 |
+ vsock->model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL);
|
|
|
7548c0 |
+}
|
|
|
7548c0 |
+
|
|
|
7548c0 |
+
|
|
|
7548c0 |
static int
|
|
|
7548c0 |
virDomainVsockDefValidate(const virDomainVsockDef *vsock)
|
|
|
7548c0 |
{
|
|
|
7548c0 |
@@ -6513,6 +6523,10 @@ virDomainVsockDefValidate(const virDomainVsockDef *vsock)
|
|
|
7548c0 |
return -1;
|
|
|
7548c0 |
}
|
|
|
7548c0 |
|
|
|
7548c0 |
+ if (!virDomainVsockIsVirtioModel(vsock) &&
|
|
|
7548c0 |
+ virDomainCheckVirtioOptions(vsock->virtio) < 0)
|
|
|
7548c0 |
+ return -1;
|
|
|
7548c0 |
+
|
|
|
7548c0 |
return 0;
|
|
|
7548c0 |
}
|
|
|
7548c0 |
|
|
|
7548c0 |
@@ -16649,6 +16663,11 @@ virDomainVsockDefParseXML(virDomainXMLOptionPtr xmlopt,
|
|
|
7548c0 |
if (virDomainDeviceInfoParseXML(xmlopt, node, &vsock->info, flags) < 0)
|
|
|
7548c0 |
return NULL;
|
|
|
7548c0 |
|
|
|
7548c0 |
+ if (virDomainVirtioOptionsParseXML(virXPathNode("./driver", ctxt),
|
|
|
7548c0 |
+ &vsock->virtio) < 0)
|
|
|
7548c0 |
+ return NULL;
|
|
|
7548c0 |
+
|
|
|
7548c0 |
+
|
|
|
7548c0 |
return g_steal_pointer(&vsock);
|
|
|
7548c0 |
}
|
|
|
7548c0 |
|
|
|
7548c0 |
@@ -23350,6 +23369,10 @@ virDomainVsockDefCheckABIStability(virDomainVsockDefPtr src,
|
|
|
7548c0 |
return false;
|
|
|
7548c0 |
}
|
|
|
7548c0 |
|
|
|
7548c0 |
+ if (src->virtio && dst->virtio &&
|
|
|
7548c0 |
+ !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio))
|
|
|
7548c0 |
+ return false;
|
|
|
7548c0 |
+
|
|
|
7548c0 |
if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info))
|
|
|
7548c0 |
return false;
|
|
|
7548c0 |
|
|
|
7548c0 |
@@ -28364,6 +28387,7 @@ virDomainVsockDefFormat(virBufferPtr buf,
|
|
|
7548c0 |
g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf);
|
|
|
7548c0 |
g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
|
|
|
7548c0 |
g_auto(virBuffer) cidAttrBuf = VIR_BUFFER_INITIALIZER;
|
|
|
7548c0 |
+ g_auto(virBuffer) drvAttrBuf = VIR_BUFFER_INITIALIZER;
|
|
|
7548c0 |
|
|
|
7548c0 |
if (vsock->model) {
|
|
|
7548c0 |
virBufferAsprintf(&attrBuf, " model='%s'",
|
|
|
7548c0 |
@@ -28381,6 +28405,9 @@ virDomainVsockDefFormat(virBufferPtr buf,
|
|
|
7548c0 |
if (virDomainDeviceInfoFormat(&childBuf, &vsock->info, 0) < 0)
|
|
|
7548c0 |
return -1;
|
|
|
7548c0 |
|
|
|
7548c0 |
+ virDomainVirtioOptionsFormat(&drvAttrBuf, vsock->virtio);
|
|
|
7548c0 |
+
|
|
|
7548c0 |
+ virXMLFormatElement(&childBuf, "driver", &drvAttrBuf, NULL);
|
|
|
7548c0 |
virXMLFormatElement(buf, "vsock", &attrBuf, &childBuf);
|
|
|
7548c0 |
|
|
|
7548c0 |
return 0;
|
|
|
7548c0 |
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
|
|
|
7548c0 |
index 118077edaa..3aed1fb22a 100644
|
|
|
7548c0 |
--- a/src/conf/domain_conf.h
|
|
|
7548c0 |
+++ b/src/conf/domain_conf.h
|
|
|
7548c0 |
@@ -2389,6 +2389,7 @@ struct _virDomainVsockDef {
|
|
|
7548c0 |
virTristateBool auto_cid;
|
|
|
7548c0 |
|
|
|
7548c0 |
virDomainDeviceInfo info;
|
|
|
7548c0 |
+ virDomainVirtioOptionsPtr virtio;
|
|
|
7548c0 |
};
|
|
|
7548c0 |
|
|
|
7548c0 |
struct _virDomainVirtioOptions {
|
|
|
7548c0 |
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
|
|
|
7548c0 |
index 67d7334b0f..998c3c90f8 100644
|
|
|
7548c0 |
--- a/src/qemu/qemu_command.c
|
|
|
7548c0 |
+++ b/src/qemu/qemu_command.c
|
|
|
7548c0 |
@@ -9965,6 +9965,10 @@ qemuBuildVsockDevStr(virDomainDefPtr def,
|
|
|
7548c0 |
virBufferAsprintf(&buf, ",id=%s", vsock->info.alias);
|
|
|
7548c0 |
virBufferAsprintf(&buf, ",guest-cid=%u", vsock->guest_cid);
|
|
|
7548c0 |
virBufferAsprintf(&buf, ",vhostfd=%s%u", fdprefix, priv->vhostfd);
|
|
|
7548c0 |
+
|
|
|
7548c0 |
+ if (qemuBuildVirtioOptionsStr(&buf, vsock->virtio, qemuCaps) < 0)
|
|
|
7548c0 |
+ return NULL;
|
|
|
7548c0 |
+
|
|
|
7548c0 |
if (qemuBuildDeviceAddressStr(&buf, def, &vsock->info, qemuCaps) < 0)
|
|
|
7548c0 |
return NULL;
|
|
|
7548c0 |
|
|
|
7548c0 |
diff --git a/tests/qemuxml2argvdata/vhost-vsock-ccw-iommu.s390x-latest.args b/tests/qemuxml2argvdata/vhost-vsock-ccw-iommu.s390x-latest.args
|
|
|
7548c0 |
new file mode 100644
|
|
|
7548c0 |
index 0000000000..78eede78d3
|
|
|
7548c0 |
--- /dev/null
|
|
|
7548c0 |
+++ b/tests/qemuxml2argvdata/vhost-vsock-ccw-iommu.s390x-latest.args
|
|
|
7548c0 |
@@ -0,0 +1,37 @@
|
|
|
7548c0 |
+LC_ALL=C \
|
|
|
7548c0 |
+PATH=/bin \
|
|
|
7548c0 |
+HOME=/tmp/lib/domain--1-QEMUGuest1 \
|
|
|
7548c0 |
+USER=test \
|
|
|
7548c0 |
+LOGNAME=test \
|
|
|
7548c0 |
+XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
|
|
|
7548c0 |
+XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
|
|
|
7548c0 |
+XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
|
|
|
7548c0 |
+QEMU_AUDIO_DRV=none \
|
|
|
7548c0 |
+/usr/bin/qemu-system-s390x \
|
|
|
7548c0 |
+-name guest=QEMUGuest1,debug-threads=on \
|
|
|
7548c0 |
+-S \
|
|
|
7548c0 |
+-object secret,id=masterKey0,format=raw,\
|
|
|
7548c0 |
+file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
|
|
|
7548c0 |
+-machine s390-ccw-virtio,accel=tcg,usb=off,dump-guest-core=off \
|
|
|
7548c0 |
+-cpu qemu \
|
|
|
7548c0 |
+-m 214 \
|
|
|
7548c0 |
+-overcommit mem-lock=off \
|
|
|
7548c0 |
+-smp 1,sockets=1,cores=1,threads=1 \
|
|
|
7548c0 |
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
|
|
|
7548c0 |
+-display none \
|
|
|
7548c0 |
+-no-user-config \
|
|
|
7548c0 |
+-nodefaults \
|
|
|
7548c0 |
+-chardev socket,id=charmonitor,fd=1729,server,nowait \
|
|
|
7548c0 |
+-mon chardev=charmonitor,id=monitor,mode=control \
|
|
|
7548c0 |
+-rtc base=utc \
|
|
|
7548c0 |
+-no-shutdown \
|
|
|
7548c0 |
+-boot strict=on \
|
|
|
7548c0 |
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
|
|
|
7548c0 |
+-device virtio-blk-ccw,scsi=off,devno=fe.0.0000,drive=drive-virtio-disk0,\
|
|
|
7548c0 |
+id=virtio-disk0,bootindex=1 \
|
|
|
7548c0 |
+-device virtio-balloon-ccw,id=balloon0,devno=fe.0.0001 \
|
|
|
7548c0 |
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
|
|
|
7548c0 |
+resourcecontrol=deny \
|
|
|
7548c0 |
+-device vhost-vsock-ccw,id=vsock0,guest-cid=4,vhostfd=6789,iommu_platform=on,\
|
|
|
7548c0 |
+devno=fe.0.0002 \
|
|
|
7548c0 |
+-msg timestamp=on
|
|
|
7548c0 |
diff --git a/tests/qemuxml2argvdata/vhost-vsock-ccw-iommu.xml b/tests/qemuxml2argvdata/vhost-vsock-ccw-iommu.xml
|
|
|
7548c0 |
new file mode 100644
|
|
|
7548c0 |
index 0000000000..dbfe082a6f
|
|
|
7548c0 |
--- /dev/null
|
|
|
7548c0 |
+++ b/tests/qemuxml2argvdata/vhost-vsock-ccw-iommu.xml
|
|
|
7548c0 |
@@ -0,0 +1,37 @@
|
|
|
7548c0 |
+<domain type='qemu'>
|
|
|
7548c0 |
+ <name>QEMUGuest1</name>
|
|
|
7548c0 |
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
|
|
7548c0 |
+ <memory unit='KiB'>219136</memory>
|
|
|
7548c0 |
+ <currentMemory unit='KiB'>219136</currentMemory>
|
|
|
7548c0 |
+ <vcpu placement='static'>1</vcpu>
|
|
|
7548c0 |
+ <os>
|
|
|
7548c0 |
+ <type arch='s390x' machine='s390-ccw-virtio'>hvm</type>
|
|
|
7548c0 |
+ <boot dev='hd'/>
|
|
|
7548c0 |
+ </os>
|
|
|
7548c0 |
+ <cpu mode='custom' match='exact' check='none'>
|
|
|
7548c0 |
+ <model fallback='forbid'>qemu</model>
|
|
|
7548c0 |
+ </cpu>
|
|
|
7548c0 |
+ <clock offset='utc'/>
|
|
|
7548c0 |
+ <on_poweroff>destroy</on_poweroff>
|
|
|
7548c0 |
+ <on_reboot>restart</on_reboot>
|
|
|
7548c0 |
+ <on_crash>destroy</on_crash>
|
|
|
7548c0 |
+ <devices>
|
|
|
7548c0 |
+ <emulator>/usr/bin/qemu-system-s390x</emulator>
|
|
|
7548c0 |
+ <disk type='block' device='disk'>
|
|
|
7548c0 |
+ <driver name='qemu' type='raw'/>
|
|
|
7548c0 |
+ <source dev='/dev/HostVG/QEMUGuest1'/>
|
|
|
7548c0 |
+ <target dev='hda' bus='virtio'/>
|
|
|
7548c0 |
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/>
|
|
|
7548c0 |
+ </disk>
|
|
|
7548c0 |
+ <controller type='pci' index='0' model='pci-root'/>
|
|
|
7548c0 |
+ <memballoon model='virtio'>
|
|
|
7548c0 |
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0001'/>
|
|
|
7548c0 |
+ </memballoon>
|
|
|
7548c0 |
+ <panic model='s390'/>
|
|
|
7548c0 |
+ <vsock model='virtio'>
|
|
|
7548c0 |
+ <cid auto='no' address='4'/>
|
|
|
7548c0 |
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0002'/>
|
|
|
7548c0 |
+ <driver iommu='on'/>
|
|
|
7548c0 |
+ </vsock>
|
|
|
7548c0 |
+ </devices>
|
|
|
7548c0 |
+</domain>
|
|
|
7548c0 |
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
|
|
|
7548c0 |
index 629f5ac100..a22e3ba157 100644
|
|
|
7548c0 |
--- a/tests/qemuxml2argvtest.c
|
|
|
7548c0 |
+++ b/tests/qemuxml2argvtest.c
|
|
|
7548c0 |
@@ -3056,6 +3056,7 @@ mymain(void)
|
|
|
7548c0 |
DO_TEST_CAPS_LATEST("vhost-vsock-auto");
|
|
|
7548c0 |
DO_TEST_CAPS_ARCH_LATEST("vhost-vsock-ccw", "s390x");
|
|
|
7548c0 |
DO_TEST_CAPS_ARCH_LATEST("vhost-vsock-ccw-auto", "s390x");
|
|
|
7548c0 |
+ DO_TEST_CAPS_ARCH_LATEST("vhost-vsock-ccw-iommu", "s390x");
|
|
|
7548c0 |
|
|
|
7548c0 |
DO_TEST_CAPS_VER("launch-security-sev", "2.12.0");
|
|
|
7548c0 |
|
|
|
7548c0 |
diff --git a/tests/qemuxml2xmloutdata/vhost-vsock-ccw-iommu.s390x-latest.xml b/tests/qemuxml2xmloutdata/vhost-vsock-ccw-iommu.s390x-latest.xml
|
|
|
7548c0 |
new file mode 120000
|
|
|
7548c0 |
index 0000000000..78971a8ef9
|
|
|
7548c0 |
--- /dev/null
|
|
|
7548c0 |
+++ b/tests/qemuxml2xmloutdata/vhost-vsock-ccw-iommu.s390x-latest.xml
|
|
|
7548c0 |
@@ -0,0 +1 @@
|
|
|
7548c0 |
+../qemuxml2argvdata/vhost-vsock-ccw-iommu.xml
|
|
|
7548c0 |
\ No newline at end of file
|
|
|
7548c0 |
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
|
|
|
7548c0 |
index 60efcac6c8..461b5bc68f 100644
|
|
|
7548c0 |
--- a/tests/qemuxml2xmltest.c
|
|
|
7548c0 |
+++ b/tests/qemuxml2xmltest.c
|
|
|
7548c0 |
@@ -1433,6 +1433,8 @@ mymain(void)
|
|
|
7548c0 |
QEMU_CAPS_CCW);
|
|
|
7548c0 |
DO_TEST("vhost-vsock-ccw-auto", QEMU_CAPS_DEVICE_VHOST_VSOCK,
|
|
|
7548c0 |
QEMU_CAPS_CCW);
|
|
|
7548c0 |
+ DO_TEST_CAPS_ARCH_LATEST("vhost-vsock-ccw-iommu", "s390x");
|
|
|
7548c0 |
+
|
|
|
7548c0 |
|
|
|
7548c0 |
DO_TEST_CAPS_LATEST("vhost-user-fs-fd-memory");
|
|
|
7548c0 |
DO_TEST_CAPS_LATEST("vhost-user-fs-hugepages");
|
|
|
7548c0 |
--
|
|
|
7548c0 |
2.30.0
|
|
|
7548c0 |
|