From patchwork Sun Aug 27 15:04:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 111084 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp3665511qge; Sun, 27 Aug 2017 08:05:02 -0700 (PDT) X-Received: by 10.55.93.197 with SMTP id r188mr6139369qkb.308.1503846301992; Sun, 27 Aug 2017 08:05:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503846301; cv=none; d=google.com; s=arc-20160816; b=FgQiEmgZnP+iwPQa78oyI8OEfFTWOLviq+zx6CZk1S8gBLkNzJfsTMCp6146STW2os KRBdzaMBFAwAuNIycB3QLV6AXKRcMqOE9C7bsPMDQx1t94W35Vt2vVShJq9YK+yp6dhz M7BVDCs275ozZPqj3VZXTu/3vc+63homaXKXS2oBQZRlPm0Fi50F1gytoSi0S8k8Tma9 VI7RvUnUCN+W1fE6Op+yT/IxNEg6S2QwPCVE/Dz1MaiQQ5W19ksI3WhbUCIIOlVM2nMZ qmjFeN0cLSXiOQ8bHdjabSzRkuNCp4XBe8iEld0Wj9tFnY7FieZAJDz8/GRBTzrVD+Uj bIXw== 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:dmarc-filter :arc-authentication-results; bh=Y8kcJyRsW4HSQFIiFeh5O372bTGz207kFpuLMQIVkqs=; b=W4e5J14CJAQJ0fSrAw7CSasTLAiiGq4TYjmlZ5ulVTE1APEm3HrFWr9Jm8b0OIfZFT poi+fmiqXWVQBbAipSZU43LCoEgRC7mrJeMg8vKyYrEX0Nuy+hCdKhyU6/39dvG1vjqw 4B52BYRg+Wc7w8hStHj8gEGExSXwbUefG694g/u6lw6GCM+sT+GuQDIvRvDbHQAx4pfw vocb/WTR3TR0MhhhlYMtIVORaKtaF2v+8KOgfdPtBDoG6X17b3/oVjSFuSBuLPHIIwuk OOIZwToR8GyRxN6LPBNdac1wSvqmPh/m+yrEFlYL1SjexU6V0o3Pg98QH9Y0VsHop8/V dL0A== 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 b27si2100498qkb.113.2017.08.27.08.05.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 27 Aug 2017 08:05:01 -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-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 7819D5F7AF; Sun, 27 Aug 2017 15:05:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7819D5F7AF Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com 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 579EF60619; Sun, 27 Aug 2017 15:05:00 +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 21C833FACD; Sun, 27 Aug 2017 15:05:00 +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 v7RF4nBC015473 for ; Sun, 27 Aug 2017 11:04:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2F1E26E8F5; Sun, 27 Aug 2017 15:04:49 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from colepc.redhat.com (ovpn-116-34.phx2.redhat.com [10.3.116.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA2086E8E7; Sun, 27 Aug 2017 15:04:48 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Sun, 27 Aug 2017 11:04:40 -0400 Message-Id: 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 v2 3/5] 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Sun, 27 Aug 2017 15:05:01 +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 | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) -- 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Pavel Hrdina diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a6b793075..e902ea9a8 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5314,7 +5314,18 @@ virDomainHostdevDefValidate(const virDomainHostdevDef *hostdev) break; } } + return 0; +} + +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; } @@ -5348,11 +5359,13 @@ virDomainDeviceDefValidateInternal(const virDomainDeviceDef *dev, case VIR_DOMAIN_DEVICE_HOSTDEV: return virDomainHostdevDefValidate(dev->data.hostdev); + 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_WATCHDOG: case VIR_DOMAIN_DEVICE_GRAPHICS: case VIR_DOMAIN_DEVICE_HUB: @@ -13866,7 +13879,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; } } @@ -14015,11 +14028,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) { @@ -21223,11 +21232,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;