From nobody Sun May 5 07:37:26 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 1501765024132162.70444092707442; Thu, 3 Aug 2017 05:57:04 -0700 (PDT) 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 958E061473; Thu, 3 Aug 2017 12:57:00 +0000 (UTC) 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 CCB0778907; Thu, 3 Aug 2017 12:56:59 +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 36EFA4A467; Thu, 3 Aug 2017 12:56:58 +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 v73CuvtV010855 for ; Thu, 3 Aug 2017 08:56:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 35DCD7F7E7; Thu, 3 Aug 2017 12:56:57 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8491480F66 for ; Thu, 3 Aug 2017 12:56:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 958E061473 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 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Thu, 3 Aug 2017 14:55:30 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/2] tests: add smartcard test cases to qemuxml2xmltest 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 03 Aug 2017 12:57:02 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Generated from the tests files used by qemuxml2argvtest with the formatting function from before my commit 0c1d8632 broke smartcard XML formatting. Reviewed-by: John Ferlan --- .../qemuxml2xmlout-smartcard-controller.xml | 31 ++++++++++++++++++= ++ .../qemuxml2xmlout-smartcard-host-certificates.xml | 34 ++++++++++++++++++= ++++ .../qemuxml2xmlout-smartcard-host.xml | 31 ++++++++++++++++++= ++ ...muxml2xmlout-smartcard-passthrough-spicevmc.xml | 31 ++++++++++++++++++= ++ .../qemuxml2xmlout-smartcard-passthrough-tcp.xml | 33 ++++++++++++++++++= +++ tests/qemuxml2xmltest.c | 6 ++++ 6 files changed, 166 insertions(+) create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-smartcard-contr= oller.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-smartcard-host-= certificates.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-smartcard-host.= xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-smartcard-passt= hrough-spicevmc.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-smartcard-passt= hrough-tcp.xml diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-smartcard-controller.x= ml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-smartcard-controller.xml new file mode 100644 index 000000000..dc7365b0b --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-smartcard-controller.xml @@ -0,0 +1,31 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + +
+ + + +
+ + + + +
+ + + diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-smartcard-host-certifi= cates.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-smartcard-host-certific= ates.xml new file mode 100644 index 000000000..e0835f6c0 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-smartcard-host-certificates.x= ml @@ -0,0 +1,34 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + +
+ + + + + cert1 + cert2 + cert3 +
+ + + + +
+ + + diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-smartcard-host.xml b/t= ests/qemuxml2xmloutdata/qemuxml2xmlout-smartcard-host.xml new file mode 100644 index 000000000..abb2c4b6e --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-smartcard-host.xml @@ -0,0 +1,31 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + +
+ + + + +
+ + + + +
+ + + diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-smartcard-passthrough-= spicevmc.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-smartcard-passthroug= h-spicevmc.xml new file mode 100644 index 000000000..38755e2d7 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-smartcard-passthrough-spicevm= c.xml @@ -0,0 +1,31 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + +
+ + + + +
+ + + + +
+ + + diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-smartcard-passthrough-= tcp.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-smartcard-passthrough-tcp= .xml new file mode 100644 index 000000000..2232daa35 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-smartcard-passthrough-tcp.xml @@ -0,0 +1,33 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + +
+ + + + + + +
+ + + + +
+ + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index bf4d507f6..0d549adec 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1199,6 +1199,12 @@ mymain(void) DO_TEST("cpu-check-default-partial", NONE); DO_TEST("cpu-check-default-partial2", NONE); =20 + DO_TEST("smartcard-host", NONE); + DO_TEST("smartcard-host-certificates", NONE); + DO_TEST("smartcard-passthrough-tcp", NONE); + DO_TEST("smartcard-passthrough-spicevmc", NONE); + DO_TEST("smartcard-controller", NONE); + if (getenv("LIBVIRT_SKIP_CLEANUP") =3D=3D NULL) virFileDeleteTree(fakerootdir); =20 --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 07:37:26 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 1501765913869505.789191014022; Thu, 3 Aug 2017 06:11:53 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6CA2561479; Thu, 3 Aug 2017 13:11:51 +0000 (UTC) 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 30D4B7E0B7; Thu, 3 Aug 2017 13:11:51 +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 A490514B20; Thu, 3 Aug 2017 13:11:50 +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 v73CuwVO010867 for ; Thu, 3 Aug 2017 08:56:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8A9377F7E7; Thu, 3 Aug 2017 12:56:58 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0D80E80F66 for ; Thu, 3 Aug 2017 12:56:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6CA2561479 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 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Thu, 3 Aug 2017 14:55:31 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] conf: fix formatting of smartcard 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 03 Aug 2017 13:11:52 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" My commit 0c1d863 broke formatting of passthrough smartcard devices: resulted in invalid XML: type=3D'spicevmc'>
Split out chardev source formatting function into two - one formatting the attributes and other formatting the subelements. Reported-by: Cole Robinson Reviewed-by: John Ferlan --- src/conf/domain_conf.c | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index eb7052303..640f29d3e 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) +virDomainChrAttrsDefFormat(virBufferPtr buf, + virDomainChrSourceDefPtr def, + bool tty_compat) { const char *type =3D virDomainChrTypeToString(def->type); =20 @@ -22823,7 +22822,14 @@ virDomainChrSourceDefFormat(virBufferPtr buf, virBufferEscapeString(buf, " tty=3D'%s'", def->data.file.path); } - virBufferAddLit(buf, ">\n"); + return 0; +} + +static void +virDomainChrSourceDefFormat(virBufferPtr buf, + virDomainChrSourceDefPtr def, + unsigned int flags) +{ =20 switch ((virDomainChrType)def->type) { case VIR_DOMAIN_CHR_TYPE_NULL: @@ -22924,7 +22930,7 @@ virDomainChrSourceDefFormat(virBufferPtr buf, virBufferAddLit(buf, "/>\n"); } =20 - return 0; + return; } =20 static int @@ -22953,8 +22959,10 @@ 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 (virDomainChrAttrsDefFormat(buf, def->source, tty_compat) < 0) return -1; + virBufferAddLit(buf, ">\n"); + virDomainChrSourceDefFormat(buf, def->source, flags); =20 /* Format block */ switch (def->deviceType) { @@ -23067,9 +23075,7 @@ virDomainSmartcardDefFormat(virBufferPtr buf, break; =20 case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH: - if (virDomainChrSourceDefFormat(&childBuf, def->data.passthru, fal= se, - flags) < 0) - return -1; + virDomainChrSourceDefFormat(&childBuf, def->data.passthru, flags); break; =20 default: @@ -23083,6 +23089,10 @@ virDomainSmartcardDefFormat(virBufferPtr buf, return -1; =20 virBufferAsprintf(buf, "type =3D=3D VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH && + virDomainChrAttrsDefFormat(buf, def->data.passthru, false) < 0) + return -1; + if (virBufferUse(&childBuf)) { virBufferAddLit(buf, ">\n"); virBufferAddBuffer(buf, &childBuf); @@ -23390,10 +23400,11 @@ virDomainRNGDefFormat(virBufferPtr buf, break; =20 case VIR_DOMAIN_RNG_BACKEND_EGD: - virBufferAdjustIndent(buf, 2); - if (virDomainChrSourceDefFormat(buf, def->source.chardev, - false, flags) < 0) + if (virDomainChrAttrsDefFormat(buf, def->source.chardev, false) < = 0) return -1; + virBufferAddLit(buf, ">\n"); + virBufferAdjustIndent(buf, 2); + virDomainChrSourceDefFormat(buf, def->source.chardev, flags); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); =20 @@ -24234,9 +24245,11 @@ virDomainRedirdevDefFormat(virBufferPtr buf, bus =3D virDomainRedirdevBusTypeToString(def->bus); =20 virBufferAsprintf(buf, "source, false, flags) < 0) + if (virDomainChrAttrsDefFormat(buf, def->source, false) < 0) return -1; + virBufferAddLit(buf, ">\n"); + virBufferAdjustIndent(buf, 2); + virDomainChrSourceDefFormat(buf, def->source, flags); virDomainDeviceInfoFormat(buf, &def->info, flags | VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT); virBufferAdjustIndent(buf, -2); --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list