From patchwork Wed Jun 28 18:49:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 106562 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp247145qge; Wed, 28 Jun 2017 11:50:05 -0700 (PDT) X-Received: by 10.237.48.130 with SMTP id 2mr14679738qtf.17.1498675805558; Wed, 28 Jun 2017 11:50:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498675805; cv=none; d=google.com; s=arc-20160816; b=HIUDsXzqxVV23WGJRVKJiVNEIXw+c1fIRw9aSzYu3pj167Aa2zzX7gKDfC1dA0LnSi AP4ICsxZamkVC1lCMo+Y07QvV6/Pk9aKOtQctP2fCr9QMj8PeCobb4bGKEiwteTgbyT1 Ekewhmww6VT3XkU4nS2YOkzQEpCFANL6I1SZ6hQTqvTE9UcH+adnjmFo2tHa8JBM7j+o UTUXWOoiIjVtWFrP2kYpKmrGVOx4sMpFv5HdDXOphONmPXZ53QeqA93tYRa6oNGaCKm9 wH10KgYCoCapDqUwp3LE5LWTVfiZE5JH/PaOL8EO9eGBrPc1Krt60mGpwM9gN4xSddg8 fRMA== 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=HtIWkxBJqJcfxLAhxl/Sc/VGFT0EnfENLZdKyyIsvU8=; b=MlrzwM/8x9Aji5djaBBHpF/Fl+lcl+S3WS+b1ypaDSYtmVnHxZBayKSaYyn7XEUzEq 36CAMEmSBboi+VZLRUdqZiSN3AiR8i2K3rbNED57ErMCSSnN5o9I5BjzPQTrfueySU+H tPV0PpeERrTZvt4pSzCouvYcfnhZeXGK+DsZ7ovuw6E3+BzhW6fWxeEUHjVDy2YETfyg TAXkTbjNM4bnrHfqfMkf+qyz5dGB8pSEsbow6Kxf2XTKfnxCt3TbiCs1FpGbxDxUrgWU h4BiSk4OOj4GjfCwaEcOP+Lg3gttiZmQIcqIjvcUg2QpdF7Xe+0MoKwnAcdi55Dl4za+ Jvgg== 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 z78si2807368qkg.396.2017.06.28.11.50.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Jun 2017 11:50:05 -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-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 329A4C04B329; Wed, 28 Jun 2017 18:50:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 329A4C04B329 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.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 329A4C04B329 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 EE4EF81F37; Wed, 28 Jun 2017 18:50:03 +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 99DE41853E34; Wed, 28 Jun 2017 18:50:02 +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 v5SInhLO031259 for ; Wed, 28 Jun 2017 14:49:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id A737C62930; Wed, 28 Jun 2017 18:49:43 +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 510E75D6A6; Wed, 28 Jun 2017 18:49:43 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Wed, 28 Jun 2017 14:49:30 -0400 Message-Id: <661a663f7482b57c85f3c590bbe2d714bb992b8d.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 4/8] conf: add virDomainVideoDefNew 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 28 Jun 2017 18:50:04 +0000 (UTC) To handle setting a default heads value. Convert callers that were doing it by hand Signed-off-by: Cole Robinson --- src/conf/domain_conf.c | 21 ++++++++++++++++----- src/conf/domain_conf.h | 1 + src/libvirt_private.syms | 1 + src/qemu/qemu_parse_command.c | 3 +-- src/vz/vz_sdk.c | 3 +-- 5 files changed, 20 insertions(+), 9 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 c3149f976..47b668dc1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2351,6 +2351,20 @@ void virDomainShmemDefFree(virDomainShmemDefPtr def) VIR_FREE(def); } + +virDomainVideoDefPtr +virDomainVideoDefNew(void) +{ + virDomainVideoDefPtr def; + + if (VIR_ALLOC(def) < 0) + return NULL; + + def->heads = 1; + return def; +} + + void virDomainVideoDefFree(virDomainVideoDefPtr def) { if (!def) @@ -13660,7 +13674,7 @@ virDomainVideoDefParseXML(xmlNodePtr node, ctxt->node = node; - if (VIR_ALLOC(def) < 0) + if (!(def = virDomainVideoDefNew())) return NULL; cur = node->children; @@ -13754,8 +13768,6 @@ virDomainVideoDefParseXML(xmlNodePtr node, _("cannot parse video heads '%s'"), heads); goto error; } - } else { - def->heads = 1; } if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) @@ -20944,7 +20956,7 @@ virDomainDefAddImplicitVideo(virDomainDefPtr def) if (def->ngraphics == 0 || def->nvideos > 0) return 0; - if (VIR_ALLOC(video) < 0) + if (!(video = virDomainVideoDefNew())) goto cleanup; video->type = virDomainVideoDefaultType(def); if (video->type < 0) { @@ -20952,7 +20964,6 @@ virDomainDefAddImplicitVideo(virDomainDefPtr def) _("cannot determine default video type")); goto cleanup; } - video->heads = 1; if (VIR_APPEND_ELEMENT(def->videos, def->nvideos, video) < 0) goto cleanup; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 964bc02f9..db89ffa97 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2683,6 +2683,7 @@ void virDomainSoundDefFree(virDomainSoundDefPtr def); void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def); void virDomainNVRAMDefFree(virDomainNVRAMDefPtr def); void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def); +virDomainVideoDefPtr virDomainVideoDefNew(void); void virDomainVideoDefFree(virDomainVideoDefPtr def); virDomainHostdevDefPtr virDomainHostdevDefAlloc(virDomainXMLOptionPtr xmlopt); void virDomainHostdevDefClear(virDomainHostdevDefPtr def); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 888412ac7..248237c4a 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -528,6 +528,7 @@ virDomainUSBDeviceDefForeach; virDomainVideoDefaultRAM; virDomainVideoDefaultType; virDomainVideoDefFree; +virDomainVideoDefNew; virDomainVideoTypeFromString; virDomainVideoTypeToString; virDomainVideoVGAConfTypeFromString; diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c index 60c81f0ca..6751868a6 100644 --- a/src/qemu/qemu_parse_command.c +++ b/src/qemu/qemu_parse_command.c @@ -2606,10 +2606,9 @@ qemuParseCommandLine(virCapsPtr caps, if (def->ngraphics) { virDomainVideoDefPtr vid; - if (VIR_ALLOC(vid) < 0) + if (!(vid = virDomainVideoDefNew())) goto error; vid->type = video; - vid->heads = 1; if (VIR_APPEND_ELEMENT(def->videos, def->nvideos, vid) < 0) { virDomainVideoDefFree(vid); diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index a62b31079..950eeaa34 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -552,12 +552,11 @@ prlsdkAddDomainVideoInfoCt(virDomainDefPtr def) if (def->ngraphics == 0) return 0; - if (VIR_ALLOC(video) < 0) + if (!(video = virDomainVideoDefNew())) goto cleanup; video->type = VIR_DOMAIN_VIDEO_TYPE_PARALLELS; video->vram = 0; - video->heads = 1; if (VIR_APPEND_ELEMENT(def->videos, def->nvideos, video) < 0) goto cleanup;