From nobody Sun May 5 00:10:39 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.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1491994157446668.323956299534; Wed, 12 Apr 2017 03:49:17 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 8A8F880F7D; Wed, 12 Apr 2017 10:49:09 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A809460BE2; Wed, 12 Apr 2017 10:49:08 +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 5E1655EC65; Wed, 12 Apr 2017 10:49:06 +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 v3CAn50n007223 for ; Wed, 12 Apr 2017 06:49:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 319B59ECD0; Wed, 12 Apr 2017 10:49:05 +0000 (UTC) Received: from dnr.brq.redhat.com (dhcp129-199.brq.redhat.com [10.34.129.199]) by smtp.corp.redhat.com (Postfix) with ESMTP id B05349ECCF for ; Wed, 12 Apr 2017 10:49:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8A8F880F7D Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8A8F880F7D From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Wed, 12 Apr 2017 12:48:58 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] qemu: do not crash on USB address with no port and invalid bus 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-Type: text/plain; charset="utf-8" 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 12 Apr 2017 10:49:16 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Properly error out when the user requests a port from a bus that does not have a controller present in the domain XML. https://bugzilla.redhat.com/show_bug.cgi?id=3D1441589 --- src/conf/domain_addr.c | 3 ++- .../qemuxml2argv-usb-bus-missing.xml | 22 ++++++++++++++++++= ++++ tests/qemuxml2argvtest.c | 3 +++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-usb-bus-missing.xml diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index 35bdc34..8b61091 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -2009,7 +2009,8 @@ virDomainUSBAddressAssign(virDomainUSBAddressSetPtr a= ddrs, =20 if (info->type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) { VIR_DEBUG("A USB=C2=A0port on bus %u was requested", info->addr.us= b.bus); - if (!addrs->buses[info->addr.usb.bus]) { + if (info->addr.usb.bus >=3D addrs->nbuses || + !addrs->buses[info->addr.usb.bus]) { virReportError(VIR_ERR_XML_ERROR, _("USB bus %u requested but no controller " "with that index is present"), info->addr.usb= .bus); diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-bus-missing.xml b/test= s/qemuxml2argvdata/qemuxml2argv-usb-bus-missing.xml new file mode 100644 index 0000000..831a4c0 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-bus-missing.xml @@ -0,0 +1,22 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + /usr/bin/qemu-system-i686 + + + +
+ + +
+ + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index ed99c21..c1b014b 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1341,6 +1341,9 @@ mymain(void) DO_TEST("usb-port-missing", QEMU_CAPS_CHARDEV, QEMU_CAPS_USB_HUB, QEMU_CAPS_NODEFCONFIG); + DO_TEST_PARSE_ERROR("usb-bus-missing", + QEMU_CAPS_CHARDEV, QEMU_CAPS_USB_HUB, + QEMU_CAPS_NODEFCONFIG); DO_TEST("usb-ports", QEMU_CAPS_CHARDEV, QEMU_CAPS_USB_HUB, QEMU_CAPS_NODEFCONFIG); --=20 2.10.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list