From nobody Fri May 3 20:00:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1611773315; cv=none; d=zohomail.com; s=zohoarc; b=CbEIjY+nNO6OrDTOdC5HKZfNFLNEz7+BYDRFnE88zVENOTQjOPIWenzk+orNNRP90wuVUfejPrxjxim2UrjC64AdMi4I2zouYx3lU0uDvmifnPCoT8ha87x5SgksY6HDR9OyPjdGADS8Zz1tjZl8JkBOVT2NkyxEnuAB/lqIXnA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611773315; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=ODXlDRa1NpW+DMaiptKwxCLhFufR4aEGZYs2wkIRf8M=; b=FTugQwqoT9wLjrKViFtmOvHsdr5jXyiAWOH1uTf42tsr//8p3kif8p66YHoVLXoiIxs0X5NHlTxrObQkorlmojuIhia+KAMekAlQHMnPFpmtQuCygx9y3jnOYRKur3CVQhehnKCTyJmjXF2yke/KKy0DOJM5mQC172W52f5i0ME= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1611773315345742.9673024122785; Wed, 27 Jan 2021 10:48:35 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-454-j0ZfNLWrNSK6hPCvbBDOWQ-1; Wed, 27 Jan 2021 13:48:31 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 30BE610054FF; Wed, 27 Jan 2021 18:48:24 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 757CE60864; Wed, 27 Jan 2021 18:48:23 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D472E1809CA1; Wed, 27 Jan 2021 18:48:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 10RIlO4p029999 for ; Wed, 27 Jan 2021 13:47:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id 524D810F8E27; Wed, 27 Jan 2021 18:47:24 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4BF3610F8E22 for ; Wed, 27 Jan 2021 18:47:21 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 999A1803C9F for ; Wed, 27 Jan 2021 18:47:21 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-259-Y3-TgECtO-eX-k_ee6cw6g-1; Wed, 27 Jan 2021 13:47:17 -0500 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 10RIWbLw035046; Wed, 27 Jan 2021 13:47:16 -0500 Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0b-001b2d01.pphosted.com with ESMTP id 36b411bmwf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Jan 2021 13:47:16 -0500 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 10RIbBwS004560; Wed, 27 Jan 2021 18:47:14 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma06ams.nl.ibm.com with ESMTP id 368b2h43p6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Jan 2021 18:47:14 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 10RIlBAo18874842 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Jan 2021 18:47:12 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DA9B34C046; Wed, 27 Jan 2021 18:47:11 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9B2DE4C044; Wed, 27 Jan 2021 18:47:11 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.49.182]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 27 Jan 2021 18:47:11 +0000 (GMT) X-MC-Unique: j0ZfNLWrNSK6hPCvbBDOWQ-1 X-MC-Unique: Y3-TgECtO-eX-k_ee6cw6g-1 From: Boris Fiuczynski To: libvir-list@redhat.com Subject: [PATCH] qemu: Add virtio related options to vsock Date: Wed, 27 Jan 2021 19:46:59 +0100 Message-Id: <20210127184659.30126-1-fiuczy@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343, 18.0.737 definitions=2021-01-27_06:2021-01-27, 2021-01-27 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1011 mlxlogscore=999 adultscore=0 priorityscore=1501 impostorscore=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 phishscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101270090 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: bwalk@linux.ibm.com, mhartmay@linux.ibm.com, abologna@redhat.com, shalini@linux.ibm.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add virtio related options iommu, ats and packed as driver element attribut= es to vsock devices. Ex: Signed-off-by: Boris Fiuczynski Reviewed-by: Michal Privoznik --- docs/formatdomain.rst | 2 + docs/schemas/domaincommon.rng | 5 +++ src/conf/domain_conf.c | 34 +++++++++++++-- src/conf/domain_conf.h | 1 + src/qemu/qemu_command.c | 3 ++ src/qemu/qemu_validate.c | 3 ++ .../vhost-vsock-ccw-iommu.s390x-latest.args | 42 +++++++++++++++++++ .../vhost-vsock-ccw-iommu.xml | 33 +++++++++++++++ tests/qemuxml2argvtest.c | 1 + .../vhost-vsock-ccw-iommu.s390x-latest.xml | 37 ++++++++++++++++ tests/qemuxml2xmltest.c | 2 + 11 files changed, 160 insertions(+), 3 deletions(-) create mode 100644 tests/qemuxml2argvdata/vhost-vsock-ccw-iommu.s390x-late= st.args create mode 100644 tests/qemuxml2argvdata/vhost-vsock-ccw-iommu.xml create mode 100644 tests/qemuxml2xmloutdata/vhost-vsock-ccw-iommu.s390x-la= test.xml diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index c738078b90..a09868bed5 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -7433,6 +7433,8 @@ devices <#elementsVirtioTransitional>`__ for more det= ails. The optional attribute ``address`` of the ``cid`` element specifies the CID assigned to= the guest. If the attribute ``auto`` is set to ``yes``, libvirt will assign a = free CID automatically on domain startup. :since:`Since 4.4.0` +The optional ``driver`` element allows to specify virtio options, see +`Virtio-specific options <#elementsVirtio>`__ for more details. :since:`S= ince 7.1.0` =20 :: =20 diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index a4bddcf132..232587e690 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4883,6 +4883,11 @@ + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index dab4f10326..b94204cb4f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2457,6 +2457,7 @@ virDomainVsockDefFree(virDomainVsockDefPtr vsock) =20 virObjectUnref(vsock->privateData); virDomainDeviceInfoClear(&vsock->info); + VIR_FREE(vsock->virtio); VIR_FREE(vsock); } =20 @@ -5321,7 +5322,16 @@ virDomainNetDefPostParse(virDomainNetDefPtr net) } =20 =20 -static void +static bool +virDomainVsockIsVirtioModel(const virDomainVsockDef *vsock) +{ + return (vsock->model =3D=3D VIR_DOMAIN_VSOCK_MODEL_VIRTIO || + vsock->model =3D=3D VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL= || + vsock->model =3D=3D VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITI= ONAL); +} + + +static int virDomainVsockDefPostParse(virDomainVsockDefPtr vsock) { if (vsock->auto_cid =3D=3D VIR_TRISTATE_BOOL_ABSENT) { @@ -5330,6 +5340,12 @@ virDomainVsockDefPostParse(virDomainVsockDefPtr vsoc= k) else vsock->auto_cid =3D VIR_TRISTATE_BOOL_YES; } + + if (!virDomainVsockIsVirtioModel(vsock) && + virDomainCheckVirtioOptions(vsock->virtio) < 0) + return -1; + + return 0; } =20 =20 @@ -5410,8 +5426,7 @@ virDomainDeviceDefPostParseCommon(virDomainDeviceDefP= tr dev, break; =20 case VIR_DOMAIN_DEVICE_VSOCK: - virDomainVsockDefPostParse(dev->data.vsock); - ret =3D 0; + ret =3D virDomainVsockDefPostParse(dev->data.vsock); break; =20 case VIR_DOMAIN_DEVICE_MEMORY: @@ -15711,6 +15726,11 @@ virDomainVsockDefParseXML(virDomainXMLOptionPtr xm= lopt, if (virDomainDeviceInfoParseXML(xmlopt, node, &vsock->info, flags) < 0) return NULL; =20 + if (virDomainVirtioOptionsParseXML(virXPathNode("./driver", ctxt), + &vsock->virtio) < 0) + return NULL; + + return g_steal_pointer(&vsock); } =20 @@ -22897,6 +22917,10 @@ virDomainVsockDefCheckABIStability(virDomainVsockD= efPtr src, return false; } =20 + if (src->virtio && dst->virtio && + !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) + return false; + if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info)) return false; =20 @@ -28087,6 +28111,7 @@ virDomainVsockDefFormat(virBufferPtr buf, g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; g_auto(virBuffer) cidAttrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) drvAttrBuf =3D VIR_BUFFER_INITIALIZER; =20 if (vsock->model) { virBufferAsprintf(&attrBuf, " model=3D'%s'", @@ -28103,6 +28128,9 @@ virDomainVsockDefFormat(virBufferPtr buf, =20 virDomainDeviceInfoFormat(&childBuf, &vsock->info, 0); =20 + virDomainVirtioOptionsFormat(&drvAttrBuf, vsock->virtio); + + virXMLFormatElement(&childBuf, "driver", &drvAttrBuf, NULL); virXMLFormatElement(buf, "vsock", &attrBuf, &childBuf); } =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 95ad052891..0a5d151150 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2543,6 +2543,7 @@ struct _virDomainVsockDef { virTristateBool auto_cid; =20 virDomainDeviceInfo info; + virDomainVirtioOptionsPtr virtio; }; =20 struct _virDomainVirtioOptions { diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 1ec302d4ac..4986ca8b08 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9733,6 +9733,9 @@ qemuBuildVsockDevStr(virDomainDefPtr def, virBufferAsprintf(&buf, ",id=3D%s", vsock->info.alias); virBufferAsprintf(&buf, ",guest-cid=3D%u", vsock->guest_cid); virBufferAsprintf(&buf, ",vhostfd=3D%s%u", fdprefix, priv->vhostfd); + + qemuBuildVirtioOptionsStr(&buf, vsock->virtio); + if (qemuBuildDeviceAddressStr(&buf, def, &vsock->info, qemuCaps) < 0) return NULL; =20 diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index a060bd98ba..cb9311cb9c 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -4200,6 +4200,9 @@ qemuValidateDomainDeviceDefVsock(const virDomainVsock= Def *vsock, "vsock")) return -1; =20 + if (qemuValidateDomainVirtioOptions(vsock->virtio, qemuCaps) < 0) + return -1; + return 0; } =20 diff --git a/tests/qemuxml2argvdata/vhost-vsock-ccw-iommu.s390x-latest.args= b/tests/qemuxml2argvdata/vhost-vsock-ccw-iommu.s390x-latest.args new file mode 100644 index 0000000000..aed32eef25 --- /dev/null +++ b/tests/qemuxml2argvdata/vhost-vsock-ccw-iommu.s390x-latest.args @@ -0,0 +1,42 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-QEMUGuest1 \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-s390x \ +-name guest=3DQEMUGuest1,debug-threads=3Don \ +-S \ +-object secret,id=3DmasterKey0,format=3Draw,\ +file=3D/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine s390-ccw-virtio,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff,\ +memory-backend=3Ds390.ram \ +-cpu qemu \ +-m 214 \ +-object memory-backend-ram,id=3Ds390.ram,size=3D224395264 \ +-overcommit mem-lock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-boot strict=3Don \ +-blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1",\ +"node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw= ",\ +"file":"libvirt-1-storage"}' \ +-device virtio-blk-ccw,devno=3Dfe.0.0000,drive=3Dlibvirt-1-format,id=3Dvir= tio-disk0,\ +bootindex=3D1 \ +-device virtio-balloon-ccw,id=3Dballoon0,devno=3Dfe.0.0001 \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,\ +resourcecontrol=3Ddeny \ +-device vhost-vsock-ccw,id=3Dvsock0,guest-cid=3D4,vhostfd=3D6789,iommu_pla= tform=3Don,\ +devno=3Dfe.0.0002 \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/vhost-vsock-ccw-iommu.xml b/tests/qemux= ml2argvdata/vhost-vsock-ccw-iommu.xml new file mode 100644 index 0000000000..ba9cdc82bf --- /dev/null +++ b/tests/qemuxml2argvdata/vhost-vsock-ccw-iommu.xml @@ -0,0 +1,33 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-s390x + + + + +
+ + +
+ + + + +
+ + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index cf77224fc3..c5d82ac72e 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -3400,6 +3400,7 @@ mymain(void) DO_TEST_CAPS_LATEST("vhost-vsock-auto"); DO_TEST_CAPS_ARCH_LATEST("vhost-vsock-ccw", "s390x"); DO_TEST_CAPS_ARCH_LATEST("vhost-vsock-ccw-auto", "s390x"); + DO_TEST_CAPS_ARCH_LATEST("vhost-vsock-ccw-iommu", "s390x"); =20 DO_TEST_CAPS_VER("launch-security-sev", "2.12.0"); DO_TEST_CAPS_VER("launch-security-sev-missing-platform-info", "2.12.0"= ); diff --git a/tests/qemuxml2xmloutdata/vhost-vsock-ccw-iommu.s390x-latest.xm= l b/tests/qemuxml2xmloutdata/vhost-vsock-ccw-iommu.s390x-latest.xml new file mode 100644 index 0000000000..dbfe082a6f --- /dev/null +++ b/tests/qemuxml2xmloutdata/vhost-vsock-ccw-iommu.s390x-latest.xml @@ -0,0 +1,37 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + qemu + + + destroy + restart + destroy + + /usr/bin/qemu-system-s390x + + + + +
+ + + +
+ + + + +
+ + + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 9553a8a4f8..50dd970789 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1403,6 +1403,8 @@ mymain(void) QEMU_CAPS_CCW); DO_TEST("vhost-vsock-ccw-auto", QEMU_CAPS_DEVICE_VHOST_VSOCK, QEMU_CAPS_CCW); + DO_TEST_CAPS_ARCH_LATEST("vhost-vsock-ccw-iommu", "s390x"); + =20 DO_TEST_CAPS_LATEST("vhost-user-fs-fd-memory"); DO_TEST_CAPS_LATEST("vhost-user-fs-hugepages"); --=20 2.26.2