From nobody Mon May 6 05:28:35 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1505918439996843.3190732458334; Wed, 20 Sep 2017 07:40:39 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 67E4113AAD; Wed, 20 Sep 2017 14:40:38 +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 387325D75F; Wed, 20 Sep 2017 14:40:38 +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 82066185594B; Wed, 20 Sep 2017 14:40:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8KEInIl021501 for ; Wed, 20 Sep 2017 10:18:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8473360481; Wed, 20 Sep 2017 14:18:49 +0000 (UTC) Received: from dnr.brq.redhat.com (unknown [10.43.2.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C7C26046B for ; Wed, 20 Sep 2017 14:18:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 67E4113AAD Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Wed, 20 Sep 2017 16:18:45 +0200 Message-Id: <7e43f51ada6c1ea13a1a9de8db9670250e4eaf9c.1505917117.git.jtomko@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] qemu: report a nicer error when USB is disabled 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: , MIME-Version: 1.0 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 20 Sep 2017 14:40:39 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" If the user tries to define a domain that has and also some USB devices, we report an error: error: internal error: No free USB ports Which is technically still correct for a domain with no USB ports. Change it to: USB is disabled for this domain, but USB devices are present in the domain = XML https://bugzilla.redhat.com/show_bug.cgi?id=3D1347550 Reviewed-by: Andrea Bolognani --- src/conf/domain_conf.c | 2 +- src/conf/domain_conf.h | 2 ++ src/libvirt_private.syms | 1 + src/qemu/qemu_domain_address.c | 7 +++++++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f3b4dd33d..028fcb5be 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5116,7 +5116,7 @@ virDomainDiskDefValidate(const virDomainDiskDef *disk) return 0; } =20 -static bool +bool virDomainDefHasUSB(const virDomainDef *def) { size_t i; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index bb3b6f0c3..32e191e0a 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2656,6 +2656,8 @@ int virDomainDefPostParse(virDomainDefPtr def, unsigned int parseFlags, virDomainXMLOptionPtr xmlopt, void *parseOpaque); +bool +virDomainDefHasUSB(const virDomainDef *def); =20 int virDomainDefValidate(virDomainDefPtr def, virCapsPtr caps, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 5b1bc5e4f..21f226258 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -267,6 +267,7 @@ virDomainDefGetVcpusTopology; virDomainDefHasDeviceAddress; virDomainDefHasMemballoon; virDomainDefHasMemoryHotplug; +virDomainDefHasUSB; virDomainDefHasVcpusOffline; virDomainDefMaybeAddController; virDomainDefMaybeAddInput; diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 69c0c8bf2..0d565b3ea 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -2644,6 +2644,13 @@ qemuDomainUSBAddressAddHubs(virDomainDefPtr def) &data, false)); =20 + if (data.count && !virDomainDefHasUSB(def)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("USB is disabled for this domain, but USB devices= " + "are present in the domain XML")); + return -1; + } + if (data.count > available_ports) hubs_needed =3D VIR_DIV_UP(data.count - available_ports + 1, VIR_DOMAIN_USB_HUB_PORTS - 1); --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list