From nobody Fri May 16 04:51:12 2025 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 149867578876477.08923939391445; Wed, 28 Jun 2017 11:49:48 -0700 (PDT) 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 E751A4E4CB; Wed, 28 Jun 2017 18:49:45 +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 A303A60462; Wed, 28 Jun 2017 18:49:45 +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 69DA21853E30; Wed, 28 Jun 2017 18:49:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5SIngJv031247 for ; Wed, 28 Jun 2017 14:49:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9BA3F62930; Wed, 28 Jun 2017 18:49:42 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-116-174.phx2.redhat.com [10.3.116.174]) by smtp.corp.redhat.com (Postfix) with ESMTP id 406B75D6A6; Wed, 28 Jun 2017 18:49:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E751A4E4CB Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.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 E751A4E4CB From: Cole Robinson To: libvir-list@redhat.com Date: Wed, 28 Jun 2017 14:49:28 -0400 Message-Id: <139fc7181b50d7909d7ac7f4296f4edaf1f22275.1498675591.git.crobinso@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/8] qemu: domain: Move some validation out of DeviceDefPostParse 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 28 Jun 2017 18:49:46 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" And into DeviceDefValidate which is the expected place Signed-off-by: Cole Robinson Reviewed-by: John Ferlan --- src/qemu/qemu_domain.c | 55 +++++++++++++++++++++++++++-------------------= ---- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 8e7404da6..90f489840 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3191,6 +3191,33 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef= *dev, } } =20 + /* forbid capabilities mode hostdev in this kind of hypervisor */ + if (dev->type =3D=3D VIR_DOMAIN_DEVICE_HOSTDEV && + dev->data.hostdev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIE= S) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("hostdev mode 'capabilities' is not " + "supported in %s"), + virDomainVirtTypeToString(def->virtType)); + goto cleanup; + } + + if (dev->type =3D=3D VIR_DOMAIN_DEVICE_VIDEO) { + if (dev->data.video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_QXL && + dev->data.video->vgamem) { + if (dev->data.video->vgamem < 1024) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("value for 'vgamem' must be at least 1 Mi= B " + "(1024 KiB)")); + goto cleanup; + } + if (dev->data.video->vgamem !=3D VIR_ROUND_UP_POWER_OF_TWO(dev= ->data.video->vgamem)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("value for 'vgamem' must be power of two"= )); + goto cleanup; + } + } + } + ret =3D 0; cleanup: virObjectUnref(cfg); @@ -3551,31 +3578,9 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr d= ev, goto cleanup; } =20 - /* forbid capabilities mode hostdev in this kind of hypervisor */ - if (dev->type =3D=3D VIR_DOMAIN_DEVICE_HOSTDEV && - dev->data.hostdev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIE= S) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("hostdev mode 'capabilities' is not " - "supported in %s"), - virDomainVirtTypeToString(def->virtType)); - goto cleanup; - } - - if (dev->type =3D=3D VIR_DOMAIN_DEVICE_VIDEO && - dev->data.video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_QXL) { - if (dev->data.video->vgamem) { - if (dev->data.video->vgamem < 1024) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("value for 'vgamem' must be at least 1 Mi= B " - "(1024 KiB)")); - goto cleanup; - } - if (dev->data.video->vgamem !=3D VIR_ROUND_UP_POWER_OF_TWO(dev= ->data.video->vgamem)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("value for 'vgamem' must be power of two"= )); - goto cleanup; - } - } else { + if (dev->type =3D=3D VIR_DOMAIN_DEVICE_VIDEO) { + if (dev->data.video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_QXL && + !dev->data.video->vgamem) { dev->data.video->vgamem =3D QEMU_QXL_VGAMEM_DEFAULT; } } --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list