From patchwork Wed Jun 28 18:49:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 106566 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp251297qge; Wed, 28 Jun 2017 11:55:29 -0700 (PDT) X-Received: by 10.200.51.23 with SMTP id t23mr14193493qta.38.1498676129127; Wed, 28 Jun 2017 11:55:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498676129; cv=none; d=google.com; s=arc-20160816; b=f5y/Y4U15sbjqJ/9WmzlrtC4VEbQalJ2nZGJSs7LnYVfsWHn3nxzQSUwnWviqGZM+R T1RtYTZqOjjslz99WYvHmsHoaEPdKAmjkFoQQmXYJ+awf8nj0MdqgKfndOBvbRFVzm/O YGMXyY96cIavD7DV8pWAtJK2n9bzpwrFGJRjQjGJoveorcsIGXkBeWHxpECS2uqo48BG B10FCOeDmS+YiGpzUbwaFcxKRBvsalJhK1epK6L99T1fAtsffrJEA3YdpCusd/PNvGPg 2/FKAuOGCyM4TjZwUV+OHE+76njM7vx7UYOgGOe68S3qWSNPpVAv1JEU3pkZZ5vxOPTW MAEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:references :in-reply-to:message-id:date:to:from:delivered-to:dkim-filter :dmarc-filter:arc-authentication-results; bh=Eu0m2b5dAyV61qtgxS/Ej1Jh11JCIZseCh/ZHTCu3Ds=; b=NU+7dhagWrJPAXKcOosPuICRUyl7dw/Rp88oBh5nHWdlZJJwNpL6aX5BzKCk8JBtxy Z28whqxn1L1x39N1KeTvTVyZfsFBnBR0YwLtq7mmNYqaY072LZkECBBcZ1+pKrsa0xnC emaY0iAV1NiIc2HBp0efMjy7zcJbxhzOld+/V9paCNI6dN7t7Hh6DCMolfyOWFa76gAb I0L5FAAFxWtkFCkJbekzb8CS5oNN3VhIB7UOFZvYJ1pQK4CcMU5oxzwa0ixH2KAXGMsv 7vNpBKItO2cv+YzmAzIaDp6/MxoQyALQl+UWsMJMVtrcduuyrM+4CngcpKu3u3Ud+Slf KFVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id 89si2726290qtg.388.2017.06.28.11.55.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Jun 2017 11:55:29 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 31F3F7F6A2; Wed, 28 Jun 2017 18:55:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 31F3F7F6A2 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.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 31F3F7F6A2 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 C83DF60465; Wed, 28 Jun 2017 18:55:26 +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 A625E184383E; Wed, 28 Jun 2017 18:55:25 +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 v5SIniFu031269 for ; Wed, 28 Jun 2017 14:49:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id B326162930; Wed, 28 Jun 2017 18:49:44 +0000 (UTC) Delivered-To: libvir-list@redhat.com Received: from worklaptop.redhat.com (ovpn-116-174.phx2.redhat.com [10.3.116.174]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5AF895D6A6; Wed, 28 Jun 2017 18:49:44 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Wed, 28 Jun 2017 14:49:32 -0400 Message-Id: <35beb39dfc59110828e865d5bf639ffc2119daf0.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 6/8] conf: domain: move video type validation to DeviceDefValidate 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 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.25]); Wed, 28 Jun 2017 18:55:28 +0000 (UTC) This allows drivers to set their own default. But if a driver neglects to fill one in, we still error like we previously would at parse time. Signed-off-by: Cole Robinson --- src/conf/domain_conf.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) -- 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: John Ferlan diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 984d15abf..bb61f4091 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5075,6 +5075,18 @@ virDomainControllerDefValidate(const virDomainControllerDef *controller) static int +virDomainVideoDefValidate(const virDomainVideoDef *video) +{ + if (video->type == VIR_DOMAIN_VIDEO_TYPE_DEFAULT) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing video model and cannot determine default")); + return -1; + } + return 0; +} + + +static int virDomainDeviceDefValidateInternal(const virDomainDeviceDef *dev, const virDomainDef *def) { @@ -5091,11 +5103,13 @@ virDomainDeviceDefValidateInternal(const virDomainDeviceDef *dev, case VIR_DOMAIN_DEVICE_CONTROLLER: return virDomainControllerDefValidate(dev->data.controller); + case VIR_DOMAIN_DEVICE_VIDEO: + return virDomainVideoDefValidate(dev->data.video); + case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_INPUT: case VIR_DOMAIN_DEVICE_SOUND: - case VIR_DOMAIN_DEVICE_VIDEO: case VIR_DOMAIN_DEVICE_HOSTDEV: case VIR_DOMAIN_DEVICE_WATCHDOG: case VIR_DOMAIN_DEVICE_GRAPHICS: @@ -13564,7 +13578,7 @@ virDomainVideoDefaultType(const virDomainDef *def) case VIR_DOMAIN_VIRT_BHYVE: return VIR_DOMAIN_VIDEO_TYPE_GOP; default: - return -1; + return VIR_DOMAIN_VIDEO_TYPE_DEFAULT; } } @@ -13709,11 +13723,7 @@ virDomainVideoDefParseXML(xmlNodePtr node, goto error; } } else { - if ((def->type = virDomainVideoDefaultType(dom)) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("missing video model and cannot determine default")); - goto error; - } + def->type = virDomainVideoDefaultType(dom); } if (ram) { @@ -20960,11 +20970,6 @@ virDomainDefAddImplicitVideo(virDomainDefPtr def) if (!(video = virDomainVideoDefNew())) goto cleanup; video->type = virDomainVideoDefaultType(def); - if (video->type < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot determine default video type")); - goto cleanup; - } if (VIR_APPEND_ELEMENT(def->videos, def->nvideos, video) < 0) goto cleanup;