From nobody Sun May 5 11:17:55 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 1501703506140371.6651436879117; Wed, 2 Aug 2017 12:51:46 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3455CC057FA8; Wed, 2 Aug 2017 19:51:43 +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 ABBD54146; Wed, 2 Aug 2017 19:51:42 +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 754381803B21; Wed, 2 Aug 2017 19:51:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v72JpdBx014455 for ; Wed, 2 Aug 2017 15:51:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2CD9917BA3; Wed, 2 Aug 2017 19:51:39 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-186.phx2.redhat.com [10.3.116.186]) by smtp.corp.redhat.com (Postfix) with ESMTP id E50A5424F for ; Wed, 2 Aug 2017 19:51:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3455CC057FA8 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Wed, 2 Aug 2017 15:51:34 -0400 Message-Id: <20170802195134.28814-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] conf: Fix printing of 'type' and 'tty_compat' for Chr devices 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 02 Aug 2017 19:51:44 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Commit id '0c1d8632' caused a regression in the virt-manager test suite when formatting the . Adust the code to print the type in it's own new helper called virDomainChrTypeFormat and have the virDomainChrSourceDefFormat manage just formatting the source and change to a void type since only 0 could be returned. Adjust the callers to handle properly. Signed-off-by: John Ferlan --- Although technically a CI build breaker since virt-manager test is failing, I figured I'd let this one go through the formal review just in case someone has agita over new function name or would like to see things done in a different manner.=20 src/conf/domain_conf.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index eb70523..878c15d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -22804,10 +22804,9 @@ virDomainNetDefFormat(virBufferPtr buf, /* Assumes that "". */ static int -virDomainChrSourceDefFormat(virBufferPtr buf, - virDomainChrSourceDefPtr def, - bool tty_compat, - unsigned int flags) +virDomainChrTypeFormat(virBufferPtr buf, + virDomainChrSourceDefPtr def, + bool tty_compat) { const char *type =3D virDomainChrTypeToString(def->type); =20 @@ -22825,6 +22824,15 @@ virDomainChrSourceDefFormat(virBufferPtr buf, } virBufferAddLit(buf, ">\n"); =20 + return 0; +} + + +static void +virDomainChrSourceDefFormat(virBufferPtr buf, + virDomainChrSourceDefPtr def, + unsigned int flags) +{ switch ((virDomainChrType)def->type) { case VIR_DOMAIN_CHR_TYPE_NULL: case VIR_DOMAIN_CHR_TYPE_VC: @@ -22923,8 +22931,6 @@ virDomainChrSourceDefFormat(virBufferPtr buf, } virBufferAddLit(buf, "/>\n"); } - - return 0; } =20 static int @@ -22953,8 +22959,9 @@ virDomainChrDefFormat(virBufferPtr buf, def->source->type =3D=3D VIR_DOMAIN_CHR_TYPE_PTY && !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE) && def->source->data.file.path); - if (virDomainChrSourceDefFormat(buf, def->source, tty_compat, flags) <= 0) + if (virDomainChrTypeFormat(buf, def->source, tty_compat) < 0) return -1; + virDomainChrSourceDefFormat(buf, def->source, flags); =20 /* Format block */ switch (def->deviceType) { @@ -23053,6 +23060,8 @@ virDomainSmartcardDefFormat(virBufferPtr buf, return -1; } =20 + virBufferAsprintf(buf, "type) { case VIR_DOMAIN_SMARTCARD_TYPE_HOST: break; @@ -23067,9 +23076,9 @@ virDomainSmartcardDefFormat(virBufferPtr buf, break; =20 case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH: - if (virDomainChrSourceDefFormat(&childBuf, def->data.passthru, fal= se, - flags) < 0) + if (virDomainChrTypeFormat(buf, def->data.passthru, false) < 0) return -1; + virDomainChrSourceDefFormat(&childBuf, def->data.passthru, flags); break; =20 default: @@ -23082,7 +23091,6 @@ virDomainSmartcardDefFormat(virBufferPtr buf, if (virBufferCheckError(&childBuf) < 0) return -1; =20 - virBufferAsprintf(buf, "\n"); virBufferAddBuffer(buf, &childBuf); @@ -23390,10 +23398,10 @@ virDomainRNGDefFormat(virBufferPtr buf, break; =20 case VIR_DOMAIN_RNG_BACKEND_EGD: - virBufferAdjustIndent(buf, 2); - if (virDomainChrSourceDefFormat(buf, def->source.chardev, - false, flags) < 0) + if (virDomainChrTypeFormat(buf, def->source.chardev, false) < 0) return -1; + virBufferAdjustIndent(buf, 2); + virDomainChrSourceDefFormat(buf, def->source.chardev, flags); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); =20 @@ -24234,9 +24242,10 @@ virDomainRedirdevDefFormat(virBufferPtr buf, bus =3D virDomainRedirdevBusTypeToString(def->bus); =20 virBufferAsprintf(buf, "source, false, flags) < 0) + if (virDomainChrTypeFormat(buf, def->source, false) < 0) return -1; + virBufferAdjustIndent(buf, 2); + virDomainChrSourceDefFormat(buf, def->source, flags); virDomainDeviceInfoFormat(buf, &def->info, flags | VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT); virBufferAdjustIndent(buf, -2); --=20 2.9.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list