From nobody Wed May 8 04:11:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1551874689335187.40066363274764; Wed, 6 Mar 2019 04:18:09 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1BF1B307EAA2; Wed, 6 Mar 2019 12:18:07 +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 8C837600C5; Wed, 6 Mar 2019 12:18:06 +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 C591A1819AFB; Wed, 6 Mar 2019 12:18:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x26CI3Nv009390 for ; Wed, 6 Mar 2019 07:18:03 -0500 Received: by smtp.corp.redhat.com (Postfix) id E37BA5C28C; Wed, 6 Mar 2019 12:18:03 +0000 (UTC) Received: from kinshicho.brq.redhat.com (unknown [10.43.2.212]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 40A071802C for ; Wed, 6 Mar 2019 12:18:03 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Wed, 6 Mar 2019 13:17:57 +0100 Message-Id: <20190306121758.16039-2-abologna@redhat.com> In-Reply-To: <20190306121758.16039-1-abologna@redhat.com> References: <20190306121758.16039-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/2] qemu: Improve validation for virtio input devices 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 06 Mar 2019 12:18:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" While the parser and schema have to accept all possible models, virtio-(non-)transitional models are only applicable to type=3Dpassthrough and should be otherwise rejected. Signed-off-by: Andrea Bolognani Reviewed-by: Cole Robinson --- src/libvirt_private.syms | 1 + src/qemu/qemu_domain.c | 32 +++++++++++++++++++ .../virtio-transitional-not-supported.xml | 11 +++++++ tests/qemuxml2argvtest.c | 4 +++ 4 files changed, 48 insertions(+) create mode 100644 tests/qemuxml2argvdata/virtio-transitional-not-supporte= d.xml diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 69643732e0..2645e55988 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -419,6 +419,7 @@ virDomainInputBusTypeToString; virDomainInputDefFind; virDomainInputDefFree; virDomainInputDefGetPath; +virDomainInputTypeToString; virDomainIOMMUModelTypeFromString; virDomainIOMMUModelTypeToString; virDomainIOThreadIDAdd; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 1487268a89..f37e6cf81a 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5971,6 +5971,38 @@ qemuDomainDeviceDefValidateInput(const virDomainInpu= tDef *input, if (input->bus !=3D VIR_DOMAIN_INPUT_BUS_VIRTIO) return 0; =20 + /* Only type=3Dpassthrough supports model=3Dvirtio-(non-)transitional = */ + switch ((virDomainInputModel)input->model) { + case VIR_DOMAIN_INPUT_MODEL_VIRTIO_TRANSITIONAL: + case VIR_DOMAIN_INPUT_MODEL_VIRTIO_NON_TRANSITIONAL: + switch ((virDomainInputType)input->type) { + case VIR_DOMAIN_INPUT_TYPE_MOUSE: + case VIR_DOMAIN_INPUT_TYPE_TABLET: + case VIR_DOMAIN_INPUT_TYPE_KBD: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("virtio (non-)transitional models are not " + "supported for input type=3D%s"), + virDomainInputTypeToString(input->type)); + return -1; + case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH: + break; + case VIR_DOMAIN_INPUT_TYPE_LAST: + default: + virReportEnumRangeError(virDomainInputType, + input->type); + return -1; + } + break; + case VIR_DOMAIN_INPUT_MODEL_VIRTIO: + case VIR_DOMAIN_INPUT_MODEL_DEFAULT: + break; + case VIR_DOMAIN_INPUT_MODEL_LAST: + default: + virReportEnumRangeError(virDomainInputModel, + input->model); + return -1; + } + switch ((virDomainInputType)input->type) { case VIR_DOMAIN_INPUT_TYPE_MOUSE: baseName =3D "virtio-mouse"; diff --git a/tests/qemuxml2argvdata/virtio-transitional-not-supported.xml b= /tests/qemuxml2argvdata/virtio-transitional-not-supported.xml new file mode 100644 index 0000000000..881d91d5a6 --- /dev/null +++ b/tests/qemuxml2argvdata/virtio-transitional-not-supported.xml @@ -0,0 +1,11 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + + hvm + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index de9eb6abdb..113ad54b9c 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -3001,6 +3001,10 @@ mymain(void) DO_TEST_CAPS_VER("virtio-non-transitional", "3.1.0"); DO_TEST_CAPS_LATEST("virtio-transitional"); DO_TEST_CAPS_LATEST("virtio-non-transitional"); + DO_TEST_PARSE_ERROR("virtio-transitional-not-supported", + QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, + QEMU_CAPS_DEVICE_PCI_BRIDGE, + QEMU_CAPS_DEVICE_IOH3420); =20 /* Simple headless guests for various architectures */ DO_TEST_CAPS_ARCH_LATEST("aarch64-virt-headless", "aarch64"); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 04:11:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1551874700309466.18200530471097; Wed, 6 Mar 2019 04:18:20 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9D1C63082AED; Wed, 6 Mar 2019 12:18:18 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7C9A318E3A; Wed, 6 Mar 2019 12:18:18 +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 41E43131F7; Wed, 6 Mar 2019 12:18:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x26CI4vo009397 for ; Wed, 6 Mar 2019 07:18:04 -0500 Received: by smtp.corp.redhat.com (Postfix) id BD51B1802C; Wed, 6 Mar 2019 12:18:04 +0000 (UTC) Received: from kinshicho.brq.redhat.com (unknown [10.43.2.212]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 407525C28C for ; Wed, 6 Mar 2019 12:18:04 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Wed, 6 Mar 2019 13:17:58 +0100 Message-Id: <20190306121758.16039-3-abologna@redhat.com> In-Reply-To: <20190306121758.16039-1-abologna@redhat.com> References: <20190306121758.16039-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] docs: Document configuration quirks for virtio devices 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Wed, 06 Mar 2019 12:18:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Some devices (namely virtio-scsi, virtio-gpu, virtio-keyboard, virtio-tablet and virtio-mouse, plus virtio-crypto which is not supported by libvirt) don't follow the same rules as all other virtio devices, which is something that ought to be documented. Signed-off-by: Andrea Bolognani Reviewed-by: Cole Robinson --- docs/formatdomain.html.in | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index eb00c01d96..a9a8cfcd46 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -4132,6 +4132,24 @@ =20 +

+ While the information outlined above apply to most virtio devices, + there are a few exceptions: +

+ +
    +
  • + for SCSI controllers, virtio-scsi must be used instead + of virtio for backwards compatibility reasons; +
  • +
  • + some devices, such as GPUs and input devices (keyboard, tablet and + mouse), are only defined in the virtio 1.0 spec and as such don't + have a transitional variant: the only accepted model is + virtio, which will result in a non-transitional devic= e. +
  • +
+

For more details see the qemu patch posting and the --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list