From nobody Mon Apr 29 05:10:25 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 1503302857628441.3349745207678; Mon, 21 Aug 2017 01:07:37 -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 6E09C81DF6; Mon, 21 Aug 2017 08:07:35 +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 4E61B66835; Mon, 21 Aug 2017 08:07:35 +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 0A42D1806104; Mon, 21 Aug 2017 08:07:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7L87NV2002373 for ; Mon, 21 Aug 2017 04:07:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id A20036F926; Mon, 21 Aug 2017 08:07:23 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 26E746F924 for ; Mon, 21 Aug 2017 08:07:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6E09C81DF6 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=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 21 Aug 2017 10:07:01 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 01/17] tests: introduce genericxml test for TCP chardev 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.25]); Mon, 21 Aug 2017 08:07:36 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- .../generic-chardev-tcp-missing-host.xml | 25 ++++++++++++++++ .../generic-chardev-tcp-missing-service.xml | 25 ++++++++++++++++ tests/genericxml2xmlindata/generic-chardev-tcp.xml | 32 ++++++++++++++++++= ++ .../genericxml2xmloutdata/generic-chardev-tcp.xml | 35 ++++++++++++++++++= ++++ tests/genericxml2xmltest.c | 6 ++++ 5 files changed, 123 insertions(+) create mode 100644 tests/genericxml2xmlindata/generic-chardev-tcp-missing-= host.xml create mode 100644 tests/genericxml2xmlindata/generic-chardev-tcp-missing-= service.xml create mode 100644 tests/genericxml2xmlindata/generic-chardev-tcp.xml create mode 100644 tests/genericxml2xmloutdata/generic-chardev-tcp.xml diff --git a/tests/genericxml2xmlindata/generic-chardev-tcp-missing-host.xm= l b/tests/genericxml2xmlindata/generic-chardev-tcp-missing-host.xml new file mode 100644 index 0000000000..523c34f29b --- /dev/null +++ b/tests/genericxml2xmlindata/generic-chardev-tcp-missing-host.xml @@ -0,0 +1,25 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + + + + + diff --git a/tests/genericxml2xmlindata/generic-chardev-tcp-missing-service= .xml b/tests/genericxml2xmlindata/generic-chardev-tcp-missing-service.xml new file mode 100644 index 0000000000..880f07436a --- /dev/null +++ b/tests/genericxml2xmlindata/generic-chardev-tcp-missing-service.xml @@ -0,0 +1,25 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + + + + + diff --git a/tests/genericxml2xmlindata/generic-chardev-tcp.xml b/tests/gen= ericxml2xmlindata/generic-chardev-tcp.xml new file mode 100644 index 0000000000..e59c572a12 --- /dev/null +++ b/tests/genericxml2xmlindata/generic-chardev-tcp.xml @@ -0,0 +1,32 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + + + + + + + + + + + + diff --git a/tests/genericxml2xmloutdata/generic-chardev-tcp.xml b/tests/ge= nericxml2xmloutdata/generic-chardev-tcp.xml new file mode 100644 index 0000000000..ef217c0abb --- /dev/null +++ b/tests/genericxml2xmloutdata/generic-chardev-tcp.xml @@ -0,0 +1,35 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + + + + + + + + + + + + + + + diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c index 5626eedf43..f5ad001968 100644 --- a/tests/genericxml2xmltest.c +++ b/tests/genericxml2xmltest.c @@ -105,6 +105,12 @@ mymain(void) DO_TEST("cpu-cache-passthrough"); DO_TEST("cpu-cache-disable"); =20 + DO_TEST_DIFFERENT("chardev-tcp"); + DO_TEST_FULL("chardev-tcp-missing-host", 0, false, + TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); + DO_TEST_FULL("chardev-tcp-missing-service", 0, false, + TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); + virObjectUnref(caps); virObjectUnref(xmlopt); =20 --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 05:10:25 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 1503302848046145.0236214748619; Mon, 21 Aug 2017 01:07:28 -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 0927D83F3D; Mon, 21 Aug 2017 08:07:26 +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 B1C866C519; Mon, 21 Aug 2017 08:07:25 +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 3B6133FAD0; Mon, 21 Aug 2017 08:07:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7L87OlP002383 for ; Mon, 21 Aug 2017 04:07:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 956636F926; Mon, 21 Aug 2017 08:07:24 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C2FB6F932 for ; Mon, 21 Aug 2017 08:07:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0927D83F3D Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 21 Aug 2017 10:07:02 +0200 Message-Id: <36a8db9b2d5806e977cdafae5c721dd2518f916a.1503302799.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 02/17] tests: introduce genericxml test for UDP chardev 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.27]); Mon, 21 Aug 2017 08:07:26 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- ...generic-chardev-udp-missing-connect-service.xml | 24 +++++++++++ tests/genericxml2xmlindata/generic-chardev-udp.xml | 47 ++++++++++++++++++= ++++ .../genericxml2xmloutdata/generic-chardev-udp.xml | 47 ++++++++++++++++++= ++++ tests/genericxml2xmltest.c | 3 ++ 4 files changed, 121 insertions(+) create mode 100644 tests/genericxml2xmlindata/generic-chardev-udp-missing-= connect-service.xml create mode 100644 tests/genericxml2xmlindata/generic-chardev-udp.xml create mode 100644 tests/genericxml2xmloutdata/generic-chardev-udp.xml diff --git a/tests/genericxml2xmlindata/generic-chardev-udp-missing-connect= -service.xml b/tests/genericxml2xmlindata/generic-chardev-udp-missing-conne= ct-service.xml new file mode 100644 index 0000000000..c7ed52b457 --- /dev/null +++ b/tests/genericxml2xmlindata/generic-chardev-udp-missing-connect-servic= e.xml @@ -0,0 +1,24 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + + + + diff --git a/tests/genericxml2xmlindata/generic-chardev-udp.xml b/tests/gen= ericxml2xmlindata/generic-chardev-udp.xml new file mode 100644 index 0000000000..34441ae68e --- /dev/null +++ b/tests/genericxml2xmlindata/generic-chardev-udp.xml @@ -0,0 +1,47 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/genericxml2xmloutdata/generic-chardev-udp.xml b/tests/ge= nericxml2xmloutdata/generic-chardev-udp.xml new file mode 100644 index 0000000000..c4a719f2f6 --- /dev/null +++ b/tests/genericxml2xmloutdata/generic-chardev-udp.xml @@ -0,0 +1,47 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c index f5ad001968..c10c3f5c04 100644 --- a/tests/genericxml2xmltest.c +++ b/tests/genericxml2xmltest.c @@ -110,6 +110,9 @@ mymain(void) TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); DO_TEST_FULL("chardev-tcp-missing-service", 0, false, TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); + DO_TEST_DIFFERENT("chardev-udp"); + DO_TEST_FULL("chardev-udp-missing-connect-service", 0, false, + TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); =20 virObjectUnref(caps); virObjectUnref(xmlopt); --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 05:10:25 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 1503302858603660.5562829023257; Mon, 21 Aug 2017 01:07:38 -0700 (PDT) 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 46BFF13A98; Mon, 21 Aug 2017 08:07:36 +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 2021A6F932; Mon, 21 Aug 2017 08:07:36 +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 D37FC1803B21; Mon, 21 Aug 2017 08:07:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7L87PrS002388 for ; Mon, 21 Aug 2017 04:07:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 66CE76F924; Mon, 21 Aug 2017 08:07:25 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id E260C6F92F for ; Mon, 21 Aug 2017 08:07:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 46BFF13A98 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 21 Aug 2017 10:07:03 +0200 Message-Id: <0e90f28450a05f61aea374a2584d8838fdc11f42.1503302799.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 03/17] tests: introduce genericxml test for UNIX chardev 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 21 Aug 2017 08:07:36 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- .../generic-chardev-unix-redirdev-missing-path.xml | 24 ++++++++++++ .../generic-chardev-unix-rng-missing-path.xml | 25 ++++++++++++ ...generic-chardev-unix-smartcard-missing-path.xml | 23 +++++++++++ .../genericxml2xmlindata/generic-chardev-unix.xml | 43 ++++++++++++++++++= +++ .../genericxml2xmloutdata/generic-chardev-unix.xml | 44 ++++++++++++++++++= ++++ tests/genericxml2xmltest.c | 7 ++++ 6 files changed, 166 insertions(+) create mode 100644 tests/genericxml2xmlindata/generic-chardev-unix-redirde= v-missing-path.xml create mode 100644 tests/genericxml2xmlindata/generic-chardev-unix-rng-mis= sing-path.xml create mode 100644 tests/genericxml2xmlindata/generic-chardev-unix-smartca= rd-missing-path.xml create mode 100644 tests/genericxml2xmlindata/generic-chardev-unix.xml create mode 100644 tests/genericxml2xmloutdata/generic-chardev-unix.xml diff --git a/tests/genericxml2xmlindata/generic-chardev-unix-redirdev-missi= ng-path.xml b/tests/genericxml2xmlindata/generic-chardev-unix-redirdev-miss= ing-path.xml new file mode 100644 index 0000000000..f0d6f3d60a --- /dev/null +++ b/tests/genericxml2xmlindata/generic-chardev-unix-redirdev-missing-path= .xml @@ -0,0 +1,24 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + + + + diff --git a/tests/genericxml2xmlindata/generic-chardev-unix-rng-missing-pa= th.xml b/tests/genericxml2xmlindata/generic-chardev-unix-rng-missing-path.x= ml new file mode 100644 index 0000000000..fb45c044f8 --- /dev/null +++ b/tests/genericxml2xmlindata/generic-chardev-unix-rng-missing-path.xml @@ -0,0 +1,25 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + + + + + diff --git a/tests/genericxml2xmlindata/generic-chardev-unix-smartcard-miss= ing-path.xml b/tests/genericxml2xmlindata/generic-chardev-unix-smartcard-mi= ssing-path.xml new file mode 100644 index 0000000000..451c8aa660 --- /dev/null +++ b/tests/genericxml2xmlindata/generic-chardev-unix-smartcard-missing-pat= h.xml @@ -0,0 +1,23 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + + + diff --git a/tests/genericxml2xmlindata/generic-chardev-unix.xml b/tests/ge= nericxml2xmlindata/generic-chardev-unix.xml new file mode 100644 index 0000000000..bc715a3ae8 --- /dev/null +++ b/tests/genericxml2xmlindata/generic-chardev-unix.xml @@ -0,0 +1,43 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/genericxml2xmloutdata/generic-chardev-unix.xml b/tests/g= enericxml2xmloutdata/generic-chardev-unix.xml new file mode 100644 index 0000000000..c797cbff8a --- /dev/null +++ b/tests/genericxml2xmloutdata/generic-chardev-unix.xml @@ -0,0 +1,44 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c index c10c3f5c04..7dc137ed16 100644 --- a/tests/genericxml2xmltest.c +++ b/tests/genericxml2xmltest.c @@ -113,6 +113,13 @@ mymain(void) DO_TEST_DIFFERENT("chardev-udp"); DO_TEST_FULL("chardev-udp-missing-connect-service", 0, false, TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); + DO_TEST_DIFFERENT("chardev-unix"); + DO_TEST_FULL("chardev-unix-smartcard-missing-path", 0, false, + TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); + DO_TEST_FULL("chardev-unix-redirdev-missing-path", 0, false, + TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); + DO_TEST_FULL("chardev-unix-rng-missing-path", 0, false, + TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); =20 virObjectUnref(caps); virObjectUnref(xmlopt); --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 05:10:25 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 1503302861140865.595873373143; Mon, 21 Aug 2017 01:07:41 -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 686047E42C; Mon, 21 Aug 2017 08:07:39 +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 45CD66C520; Mon, 21 Aug 2017 08:07:39 +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 100033FAD2; Mon, 21 Aug 2017 08:07:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7L87QBc002405 for ; Mon, 21 Aug 2017 04:07:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id C38FC6F927; Mon, 21 Aug 2017 08:07:26 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4805D6F926 for ; Mon, 21 Aug 2017 08:07:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 686047E42C Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 21 Aug 2017 10:07:04 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 04/17] conf: switch from while to for loop for chardev parsing 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.27]); Mon, 21 Aug 2017 08:07:39 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This removes one level of indentation. Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 168 ++++++++++++++++++++++++---------------------= ---- 1 file changed, 84 insertions(+), 84 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3bef5bed3b..ba0241cb21 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10918,100 +10918,100 @@ virDomainChrSourceDefParseXML(virDomainChrSourc= eDefPtr def, char *haveTLS =3D NULL; char *tlsFromConfig =3D NULL; =20 - while (cur !=3D NULL) { - if (cur->type =3D=3D XML_ELEMENT_NODE) { - if (virXMLNodeNameEqual(cur, "source")) { - if (!mode) - mode =3D virXMLPropString(cur, "mode"); - if (!haveTLS) - haveTLS =3D virXMLPropString(cur, "tls"); - if (!tlsFromConfig) - tlsFromConfig =3D virXMLPropString(cur, "tlsFromConfig= "); + for (; cur; cur =3D cur->next) { + if (cur->type !=3D XML_ELEMENT_NODE) + continue; =20 - switch ((virDomainChrType) def->type) { - case VIR_DOMAIN_CHR_TYPE_FILE: - case VIR_DOMAIN_CHR_TYPE_PTY: - case VIR_DOMAIN_CHR_TYPE_DEV: - case VIR_DOMAIN_CHR_TYPE_PIPE: - case VIR_DOMAIN_CHR_TYPE_UNIX: - if (!append && def->type =3D=3D VIR_DOMAIN_CHR_TYPE_FI= LE) - append =3D virXMLPropString(cur, "append"); - /* PTY path is only parsed from live xml. */ - if (!path && - (def->type !=3D VIR_DOMAIN_CHR_TYPE_PTY || - !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE))) - path =3D virXMLPropString(cur, "path"); + if (virXMLNodeNameEqual(cur, "source")) { + if (!mode) + mode =3D virXMLPropString(cur, "mode"); + if (!haveTLS) + haveTLS =3D virXMLPropString(cur, "tls"); + if (!tlsFromConfig) + tlsFromConfig =3D virXMLPropString(cur, "tlsFromConfig"); =20 - break; + switch ((virDomainChrType) def->type) { + case VIR_DOMAIN_CHR_TYPE_FILE: + case VIR_DOMAIN_CHR_TYPE_PTY: + case VIR_DOMAIN_CHR_TYPE_DEV: + case VIR_DOMAIN_CHR_TYPE_PIPE: + case VIR_DOMAIN_CHR_TYPE_UNIX: + if (!append && def->type =3D=3D VIR_DOMAIN_CHR_TYPE_FILE) + append =3D virXMLPropString(cur, "append"); + /* PTY path is only parsed from live xml. */ + if (!path && + (def->type !=3D VIR_DOMAIN_CHR_TYPE_PTY || + !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE))) + path =3D virXMLPropString(cur, "path"); =20 - case VIR_DOMAIN_CHR_TYPE_UDP: - case VIR_DOMAIN_CHR_TYPE_TCP: - if (!mode || STREQ(mode, "connect")) { - if (!connectHost) - connectHost =3D virXMLPropString(cur, "host"); - if (!connectService) - connectService =3D virXMLPropString(cur, "serv= ice"); - } else if (STREQ(mode, "bind")) { - if (!bindHost) - bindHost =3D virXMLPropString(cur, "host"); - if (!bindService) - bindService =3D virXMLPropString(cur, "service= "); - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown source mode '%s'"), mode= ); - goto error; - } + break; =20 - if (def->type =3D=3D VIR_DOMAIN_CHR_TYPE_UDP) - VIR_FREE(mode); - break; - - case VIR_DOMAIN_CHR_TYPE_SPICEPORT: - if (!channel) - channel =3D virXMLPropString(cur, "channel"); - break; - - case VIR_DOMAIN_CHR_TYPE_NMDM: - if (!master) - master =3D virXMLPropString(cur, "master"); - if (!slave) - slave =3D virXMLPropString(cur, "slave"); - break; - - case VIR_DOMAIN_CHR_TYPE_LAST: - case VIR_DOMAIN_CHR_TYPE_NULL: - case VIR_DOMAIN_CHR_TYPE_VC: - case VIR_DOMAIN_CHR_TYPE_STDIO: - case VIR_DOMAIN_CHR_TYPE_SPICEVMC: - break; + case VIR_DOMAIN_CHR_TYPE_UDP: + case VIR_DOMAIN_CHR_TYPE_TCP: + if (!mode || STREQ(mode, "connect")) { + if (!connectHost) + connectHost =3D virXMLPropString(cur, "host"); + if (!connectService) + connectService =3D virXMLPropString(cur, "service"= ); + } else if (STREQ(mode, "bind")) { + if (!bindHost) + bindHost =3D virXMLPropString(cur, "host"); + if (!bindService) + bindService =3D virXMLPropString(cur, "service"); + } else { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown source mode '%s'"), mode); + goto error; } =20 - /* Check for an optional seclabel override in . */ - if (chr_def) { - xmlNodePtr saved_node =3D ctxt->node; - ctxt->node =3D cur; - if (virSecurityDeviceLabelDefParseXML(&def->seclabels, - &def->nseclabels, - vmSeclabels, - nvmSeclabels, - ctxt, - flags) < 0) { - ctxt->node =3D saved_node; - goto error; - } + if (def->type =3D=3D VIR_DOMAIN_CHR_TYPE_UDP) + VIR_FREE(mode); + break; + + case VIR_DOMAIN_CHR_TYPE_SPICEPORT: + if (!channel) + channel =3D virXMLPropString(cur, "channel"); + break; + + case VIR_DOMAIN_CHR_TYPE_NMDM: + if (!master) + master =3D virXMLPropString(cur, "master"); + if (!slave) + slave =3D virXMLPropString(cur, "slave"); + break; + + case VIR_DOMAIN_CHR_TYPE_LAST: + case VIR_DOMAIN_CHR_TYPE_NULL: + case VIR_DOMAIN_CHR_TYPE_VC: + case VIR_DOMAIN_CHR_TYPE_STDIO: + case VIR_DOMAIN_CHR_TYPE_SPICEVMC: + break; + } + + /* Check for an optional seclabel override in . */ + if (chr_def) { + xmlNodePtr saved_node =3D ctxt->node; + ctxt->node =3D cur; + if (virSecurityDeviceLabelDefParseXML(&def->seclabels, + &def->nseclabels, + vmSeclabels, + nvmSeclabels, + ctxt, + flags) < 0) { ctxt->node =3D saved_node; + goto error; } - } else if (virXMLNodeNameEqual(cur, "log")) { - if (!logfile) - logfile =3D virXMLPropString(cur, "file"); - if (!logappend) - logappend =3D virXMLPropString(cur, "append"); - } else if (virXMLNodeNameEqual(cur, "protocol")) { - if (!protocol) - protocol =3D virXMLPropString(cur, "type"); + ctxt->node =3D saved_node; } + } else if (virXMLNodeNameEqual(cur, "log")) { + if (!logfile) + logfile =3D virXMLPropString(cur, "file"); + if (!logappend) + logappend =3D virXMLPropString(cur, "append"); + } else if (virXMLNodeNameEqual(cur, "protocol")) { + if (!protocol) + protocol =3D virXMLPropString(cur, "type"); } - cur =3D cur->next; } =20 switch ((virDomainChrType) def->type) { --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 05:10:25 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 1503302865460450.46711362890096; Mon, 21 Aug 2017 01:07:45 -0700 (PDT) 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 6678D552FE; Mon, 21 Aug 2017 08:07:43 +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 4328617AB7; Mon, 21 Aug 2017 08:07:43 +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 A461E3FAEE; Mon, 21 Aug 2017 08:07:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7L87Riq002419 for ; Mon, 21 Aug 2017 04:07:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 92FD36F926; Mon, 21 Aug 2017 08:07:27 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1AB566F924 for ; Mon, 21 Aug 2017 08:07:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6678D552FE Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 21 Aug 2017 10:07:05 +0200 Message-Id: <066a50686045fac4a4c4858dd87ae7fe59b2c79d.1503302799.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 05/17] conf: error out for multiple source elements while parsing chardev 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 21 Aug 2017 08:07:43 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Currently we accept and correctly parse this chardev XML: ... ... The parsed formatted XML is: ... ... That behavior is super wrong and should not be allowed. If you notice the current parse takes the first found attribute and uses that value, so for example from the "" only the "host" attribute is used. It works the same way for all possible attributes that we are able to parse for source element. This patch enforces providing only one source element for all character devices, only for UDP type we allow to provide two source elements since you can specify both modes. Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 17 ++++++++++++++ .../generic-chardev-tcp-multiple-source.xml | 26 ++++++++++++++++++= ++++ .../generic-chardev-udp-multiple-source.xml | 26 ++++++++++++++++++= ++++ tests/genericxml2xmltest.c | 4 ++++ 4 files changed, 73 insertions(+) create mode 100644 tests/genericxml2xmlindata/generic-chardev-tcp-multiple= -source.xml create mode 100644 tests/genericxml2xmlindata/generic-chardev-udp-multiple= -source.xml diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ba0241cb21..651a049cf1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10917,12 +10917,29 @@ virDomainChrSourceDefParseXML(virDomainChrSourceD= efPtr def, char *append =3D NULL; char *haveTLS =3D NULL; char *tlsFromConfig =3D NULL; + int sourceParsed =3D 0; =20 for (; cur; cur =3D cur->next) { if (cur->type !=3D XML_ELEMENT_NODE) continue; =20 if (virXMLNodeNameEqual(cur, "source")) { + /* Parse only the first source element since only one is used + * for chardev devices, the only exception is UDP type, where + * user can specify two source elements. */ + if (sourceParsed >=3D 1 && def->type !=3D VIR_DOMAIN_CHR_TYPE_= UDP) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("only one source element is allowed for " + "character device")); + goto error; + } else if (sourceParsed >=3D 2) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("only two source elements are allowed for= " + "character device")); + goto error; + } + sourceParsed++; + if (!mode) mode =3D virXMLPropString(cur, "mode"); if (!haveTLS) diff --git a/tests/genericxml2xmlindata/generic-chardev-tcp-multiple-source= .xml b/tests/genericxml2xmlindata/generic-chardev-tcp-multiple-source.xml new file mode 100644 index 0000000000..bb8592aa4f --- /dev/null +++ b/tests/genericxml2xmlindata/generic-chardev-tcp-multiple-source.xml @@ -0,0 +1,26 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + + + + + + diff --git a/tests/genericxml2xmlindata/generic-chardev-udp-multiple-source= .xml b/tests/genericxml2xmlindata/generic-chardev-udp-multiple-source.xml new file mode 100644 index 0000000000..2b87a1bfaa --- /dev/null +++ b/tests/genericxml2xmlindata/generic-chardev-udp-multiple-source.xml @@ -0,0 +1,26 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + + + + + + diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c index 7dc137ed16..03913a68c9 100644 --- a/tests/genericxml2xmltest.c +++ b/tests/genericxml2xmltest.c @@ -110,9 +110,13 @@ mymain(void) TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); DO_TEST_FULL("chardev-tcp-missing-service", 0, false, TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); + DO_TEST_FULL("chardev-tcp-multiple-source", 0, false, + TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); DO_TEST_DIFFERENT("chardev-udp"); DO_TEST_FULL("chardev-udp-missing-connect-service", 0, false, TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); + DO_TEST_FULL("chardev-udp-multiple-source", 0, false, + TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); DO_TEST_DIFFERENT("chardev-unix"); DO_TEST_FULL("chardev-unix-smartcard-missing-path", 0, false, TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 05:10:25 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 1503302854022842.1987824004425; Mon, 21 Aug 2017 01:07:34 -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 20C3E80F9F; Mon, 21 Aug 2017 08:07:32 +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 ED2BC6C520; Mon, 21 Aug 2017 08:07:31 +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 B55F63FAD4; Mon, 21 Aug 2017 08:07:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7L87S1q002432 for ; Mon, 21 Aug 2017 04:07:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6597E6F924; Mon, 21 Aug 2017 08:07:28 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id E0E266F927 for ; Mon, 21 Aug 2017 08:07:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 20C3E80F9F Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 21 Aug 2017 10:07:06 +0200 Message-Id: <5d6ec9c11456cd5b435604ec079487b7868a3a78.1503302799.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 06/17] conf: error out for multiple log elements while parsing chardev 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.27]); Mon, 21 Aug 2017 08:07:32 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Remove check whether a variable was already set because the element is parsed only once now. Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 651a049cf1..639aa430ae 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10917,6 +10917,7 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef= Ptr def, char *append =3D NULL; char *haveTLS =3D NULL; char *tlsFromConfig =3D NULL; + bool logParsed =3D false; int sourceParsed =3D 0; =20 for (; cur; cur =3D cur->next) { @@ -11021,10 +11022,15 @@ virDomainChrSourceDefParseXML(virDomainChrSourceD= efPtr def, ctxt->node =3D saved_node; } } else if (virXMLNodeNameEqual(cur, "log")) { - if (!logfile) - logfile =3D virXMLPropString(cur, "file"); - if (!logappend) - logappend =3D virXMLPropString(cur, "append"); + if (logParsed) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("only one protocol element is allowed for= " + "character device")); + goto error; + } + logParsed =3D true; + logfile =3D virXMLPropString(cur, "file"); + logappend =3D virXMLPropString(cur, "append"); } else if (virXMLNodeNameEqual(cur, "protocol")) { if (!protocol) protocol =3D virXMLPropString(cur, "type"); --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 05:10:25 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 1503302862733461.9672942696783; Mon, 21 Aug 2017 01:07:42 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D57D7C047B89; Mon, 21 Aug 2017 08:07:40 +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 7C0F566A04; Mon, 21 Aug 2017 08:07:40 +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 410BF3FAD5; Mon, 21 Aug 2017 08:07:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7L87TJJ002438 for ; Mon, 21 Aug 2017 04:07:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 369796F92D; Mon, 21 Aug 2017 08:07:29 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id B2B8E6F924 for ; Mon, 21 Aug 2017 08:07:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D57D7C047B89 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=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 21 Aug 2017 10:07:07 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 07/17] conf: error out for multiple protocol elements while parsing chardev 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 21 Aug 2017 08:07:41 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Remove check whether a variable was already set because the element is parsed only once now. Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 639aa430ae..bb4be5d1cd 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10918,6 +10918,7 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef= Ptr def, char *haveTLS =3D NULL; char *tlsFromConfig =3D NULL; bool logParsed =3D false; + bool protocolParsed =3D false; int sourceParsed =3D 0; =20 for (; cur; cur =3D cur->next) { @@ -11032,8 +11033,14 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDe= fPtr def, logfile =3D virXMLPropString(cur, "file"); logappend =3D virXMLPropString(cur, "append"); } else if (virXMLNodeNameEqual(cur, "protocol")) { - if (!protocol) - protocol =3D virXMLPropString(cur, "type"); + if (protocolParsed) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("only one log element is allowed for " + "character device")); + goto error; + } + protocolParsed =3D true; + protocol =3D virXMLPropString(cur, "type"); } } =20 --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 05:10:25 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 1503302866009593.8905024054912; Mon, 21 Aug 2017 01:07:46 -0700 (PDT) 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 2A17280C06; Mon, 21 Aug 2017 08:07:44 +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 0518117AB7; Mon, 21 Aug 2017 08:07:44 +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 BB166180610A; Mon, 21 Aug 2017 08:07:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7L87UCC002448 for ; Mon, 21 Aug 2017 04:07:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 41E6D6F930; Mon, 21 Aug 2017 08:07:30 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC8AF6F92F for ; Mon, 21 Aug 2017 08:07:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2A17280C06 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 21 Aug 2017 10:07:08 +0200 Message-Id: <69f53b5ae8f771df2e7db797af3755e1f180bf08.1503302799.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 08/17] conf: move chardev protocol parsing to separate function 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 21 Aug 2017 08:07:44 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index bb4be5d1cd..8fe79f70bf 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10885,6 +10885,30 @@ virDomainChrDefParseTargetXML(virDomainChrDefPtr d= ef, return ret; } =20 + +static int +virDomainChrSourceDefParseProtocol(virDomainChrSourceDefPtr def, + xmlNodePtr protocol) +{ + char *prot =3D NULL; + + if (def->type !=3D VIR_DOMAIN_CHR_TYPE_TCP) + return 0; + + if ((prot =3D virXMLPropString(protocol, "type")) && + (def->data.tcp.protocol =3D + virDomainChrTcpProtocolTypeFromString(prot)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Unknown protocol '%s'"), prot); + VIR_FREE(prot); + return -1; + } + + VIR_FREE(prot); + return 0; +} + + #define SERIAL_CHANNEL_NAME_CHARS \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-." =20 @@ -10910,7 +10934,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef= Ptr def, char *logfile =3D NULL; char *logappend =3D NULL; char *mode =3D NULL; - char *protocol =3D NULL; char *channel =3D NULL; char *master =3D NULL; char *slave =3D NULL; @@ -11040,7 +11063,8 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef= Ptr def, goto error; } protocolParsed =3D true; - protocol =3D virXMLPropString(cur, "type"); + if (virDomainChrSourceDefParseProtocol(def, cur) < 0) + goto error; } } =20 @@ -11151,16 +11175,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDe= fPtr def, } def->data.tcp.tlsFromConfig =3D !!tmp; } - - if (!protocol) - def->data.tcp.protocol =3D VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW; - else if ((def->data.tcp.protocol =3D - virDomainChrTcpProtocolTypeFromString(protocol)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Unknown protocol '%s'"), protocol); - goto error; - } - break; =20 case VIR_DOMAIN_CHR_TYPE_UDP: @@ -11227,7 +11241,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef= Ptr def, ret =3D 0; cleanup: VIR_FREE(mode); - VIR_FREE(protocol); VIR_FREE(bindHost); VIR_FREE(bindService); VIR_FREE(connectHost); --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 05:10:25 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 1503302867704580.1652304618034; Mon, 21 Aug 2017 01:07:47 -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 06AFA3B721; Mon, 21 Aug 2017 08:07:46 +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 D5B127E2FA; Mon, 21 Aug 2017 08:07:45 +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 9DB40180610B; Mon, 21 Aug 2017 08:07:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7L87Vnu002453 for ; Mon, 21 Aug 2017 04:07:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1343F6F930; Mon, 21 Aug 2017 08:07:31 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F0D86F92F for ; Mon, 21 Aug 2017 08:07:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 06AFA3B721 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 21 Aug 2017 10:07:09 +0200 Message-Id: <3d1164d7d0e34a25f41e2223b35d98080496b716.1503302799.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 09/17] conf: move chardev log parsing to separate function 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.30]); Mon, 21 Aug 2017 08:07:46 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8fe79f70bf..eb576b90ae 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10909,6 +10909,28 @@ virDomainChrSourceDefParseProtocol(virDomainChrSou= rceDefPtr def, } =20 =20 +static int +virDomainChrSourceDefParseLog(virDomainChrSourceDefPtr def, + xmlNodePtr log) +{ + char *append =3D NULL; + + def->logfile =3D virXMLPropString(log, "file"); + + if ((append =3D virXMLPropString(log, "append")) && + (def->logappend =3D virTristateSwitchTypeFromString(append)) <=3D = 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid append attribute value '%s'"), + append); + VIR_FREE(append); + return -1; + } + + VIR_FREE(append); + return 0; +} + + #define SERIAL_CHANNEL_NAME_CHARS \ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-." =20 @@ -10931,8 +10953,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef= Ptr def, char *connectHost =3D NULL; char *connectService =3D NULL; char *path =3D NULL; - char *logfile =3D NULL; - char *logappend =3D NULL; char *mode =3D NULL; char *channel =3D NULL; char *master =3D NULL; @@ -11053,8 +11073,8 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef= Ptr def, goto error; } logParsed =3D true; - logfile =3D virXMLPropString(cur, "file"); - logappend =3D virXMLPropString(cur, "append"); + if (virDomainChrSourceDefParseLog(def, cur) < 0) + goto error; } else if (virXMLNodeNameEqual(cur, "protocol")) { if (protocolParsed) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -11228,16 +11248,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDe= fPtr def, break; } =20 - def->logfile =3D logfile; - logfile =3D NULL; - - if (logappend !=3D NULL && - (def->logappend =3D virTristateSwitchTypeFromString(logappend)) <= =3D 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid append attribute value '%s'"), logappend= ); - goto error; - } - ret =3D 0; cleanup: VIR_FREE(mode); @@ -11248,8 +11258,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef= Ptr def, VIR_FREE(path); VIR_FREE(channel); VIR_FREE(append); - VIR_FREE(logappend); - VIR_FREE(logfile); VIR_FREE(haveTLS); VIR_FREE(tlsFromConfig); =20 --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 05:10:25 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 1503302868547815.5521706971285; Mon, 21 Aug 2017 01:07:48 -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 D7A2B7E43D; Mon, 21 Aug 2017 08:07:46 +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 B374E7E2FA; Mon, 21 Aug 2017 08:07:46 +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 6F765185735D; Mon, 21 Aug 2017 08:07:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7L87WlP002462 for ; Mon, 21 Aug 2017 04:07:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2389A6F924; Mon, 21 Aug 2017 08:07:32 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 95B536F926 for ; Mon, 21 Aug 2017 08:07:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D7A2B7E43D Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 21 Aug 2017 10:07:10 +0200 Message-Id: <91c30bbad83abaaed608b365cd90f3b7d2c6640e.1503302799.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 10/17] conf: move mode parsing of chardev source to separate function 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.27]); Mon, 21 Aug 2017 08:07:47 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 60 +++++++++++++++++++++++++++++++++++++---------= ---- 1 file changed, 45 insertions(+), 15 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index eb576b90ae..e0045eba19 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10886,6 +10886,39 @@ virDomainChrDefParseTargetXML(virDomainChrDefPtr d= ef, } =20 =20 +typedef enum { + VIR_DOMAIN_CHR_SOURCE_MODE_CONNECT, + VIR_DOMAIN_CHR_SOURCE_MODE_BIND, +} virDomainChrSourceModeType; + + +/** + * virDomainChrSourceDefParseMode: + * @source: XML dom node + * + * Returns: -1 in case of error, + * virDomainChrSourceModeType in case of success + */ +static int +virDomainChrSourceDefParseMode(xmlNodePtr source) +{ + char *mode =3D virXMLPropString(source, "mode"); + int ret =3D -1; + + if (!mode || STREQ(mode, "connect")) { + ret =3D VIR_DOMAIN_CHR_SOURCE_MODE_CONNECT; + } else if (STREQ(mode, "bind")) { + ret =3D VIR_DOMAIN_CHR_SOURCE_MODE_BIND; + } else { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown source mode '%s'"), mode); + } + + VIR_FREE(mode); + return ret; +} + + static int virDomainChrSourceDefParseProtocol(virDomainChrSourceDefPtr def, xmlNodePtr protocol) @@ -10948,12 +10981,12 @@ virDomainChrSourceDefParseXML(virDomainChrSourceD= efPtr def, int nvmSeclabels) { int ret =3D -1; + int mode =3D VIR_DOMAIN_CHR_SOURCE_MODE_CONNECT; char *bindHost =3D NULL; char *bindService =3D NULL; char *connectHost =3D NULL; char *connectService =3D NULL; char *path =3D NULL; - char *mode =3D NULL; char *channel =3D NULL; char *master =3D NULL; char *slave =3D NULL; @@ -10985,8 +11018,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef= Ptr def, } sourceParsed++; =20 - if (!mode) - mode =3D virXMLPropString(cur, "mode"); if (!haveTLS) haveTLS =3D virXMLPropString(cur, "tls"); if (!tlsFromConfig) @@ -11005,29 +11036,29 @@ virDomainChrSourceDefParseXML(virDomainChrSourceD= efPtr def, (def->type !=3D VIR_DOMAIN_CHR_TYPE_PTY || !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE))) path =3D virXMLPropString(cur, "path"); + if (def->type =3D=3D VIR_DOMAIN_CHR_TYPE_UNIX) { + if ((mode =3D virDomainChrSourceDefParseMode(cur)) < 0) + goto error; + } =20 break; =20 case VIR_DOMAIN_CHR_TYPE_UDP: case VIR_DOMAIN_CHR_TYPE_TCP: - if (!mode || STREQ(mode, "connect")) { + if ((mode =3D virDomainChrSourceDefParseMode(cur)) < 0) + goto error; + if (mode =3D=3D VIR_DOMAIN_CHR_SOURCE_MODE_CONNECT) { if (!connectHost) connectHost =3D virXMLPropString(cur, "host"); if (!connectService) connectService =3D virXMLPropString(cur, "service"= ); - } else if (STREQ(mode, "bind")) { + } else if (mode =3D=3D VIR_DOMAIN_CHR_SOURCE_MODE_BIND) { if (!bindHost) bindHost =3D virXMLPropString(cur, "host"); if (!bindService) bindService =3D virXMLPropString(cur, "service"); - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown source mode '%s'"), mode); - goto error; } =20 - if (def->type =3D=3D VIR_DOMAIN_CHR_TYPE_UDP) - VIR_FREE(mode); break; =20 case VIR_DOMAIN_CHR_TYPE_SPICEPORT: @@ -11137,7 +11168,7 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef= Ptr def, break; =20 case VIR_DOMAIN_CHR_TYPE_TCP: - if (!mode || STREQ(mode, "connect")) { + if (mode =3D=3D VIR_DOMAIN_CHR_SOURCE_MODE_CONNECT) { if (!connectHost) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing source host attribute for char d= evice")); @@ -11155,7 +11186,7 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef= Ptr def, def->data.tcp.service =3D connectService; connectService =3D NULL; def->data.tcp.listen =3D false; - } else { + } else if (mode =3D=3D VIR_DOMAIN_CHR_SOURCE_MODE_BIND) { if (!bindHost) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing source host attribute for char d= evice")); @@ -11226,7 +11257,7 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef= Ptr def, goto error; } =20 - def->data.nix.listen =3D mode !=3D NULL && STRNEQ(mode, "connect"); + def->data.nix.listen =3D mode =3D=3D VIR_DOMAIN_CHR_SOURCE_MODE_BI= ND; =20 def->data.nix.path =3D path; path =3D NULL; @@ -11250,7 +11281,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef= Ptr def, =20 ret =3D 0; cleanup: - VIR_FREE(mode); VIR_FREE(bindHost); VIR_FREE(bindService); VIR_FREE(connectHost); --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 05:10:25 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 1503302858855410.2510377047; Mon, 21 Aug 2017 01:07:38 -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 94037883DC; Mon, 21 Aug 2017 08:07:36 +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 6799966835; Mon, 21 Aug 2017 08:07:36 +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 2171D1800C96; Mon, 21 Aug 2017 08:07:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7L87WOn002480 for ; Mon, 21 Aug 2017 04:07:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id E08756F926; Mon, 21 Aug 2017 08:07:32 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 679F06F924 for ; Mon, 21 Aug 2017 08:07:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 94037883DC Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 21 Aug 2017 10:07:11 +0200 Message-Id: <3cc946bdb022e39b55d7aac4f437440fd63694da.1503302799.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 11/17] conf: move TCP chardev source parsing to separate function 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.26]); Mon, 21 Aug 2017 08:07:37 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 121 +++++++++++++++++++++++----------------------= ---- 1 file changed, 57 insertions(+), 64 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e0045eba19..023d86cec5 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10920,6 +10920,52 @@ virDomainChrSourceDefParseMode(xmlNodePtr source) =20 =20 static int +virDomainChrSourceDefParseTCP(virDomainChrSourceDefPtr def, + xmlNodePtr source, + unsigned int flags) +{ + int mode; + char *tmp =3D NULL; + int tmpVal; + + if ((mode =3D virDomainChrSourceDefParseMode(source)) < 0) + goto error; + + def->data.tcp.listen =3D mode =3D=3D VIR_DOMAIN_CHR_SOURCE_MODE_BIND; + def->data.tcp.host =3D virXMLPropString(source, "host"); + def->data.tcp.service =3D virXMLPropString(source, "service"); + + if ((tmp =3D virXMLPropString(source, "tls"))) { + if ((def->data.tcp.haveTLS =3D virTristateBoolTypeFromString(tmp))= <=3D 0) { + virReportError(VIR_ERR_XML_ERROR, + _("unknown chardev 'tls' setting '%s'"), + tmp); + goto error; + } + VIR_FREE(tmp); + } + + if ((flags & VIR_DOMAIN_DEF_PARSE_STATUS) && + (tmp =3D virXMLPropString(source, "tlsFromConfig"))) { + if (virStrToLong_i(tmp, NULL, 10, &tmpVal) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("Invalid tlsFromConfig value: %s"), + tmp); + goto error; + } + def->data.tcp.tlsFromConfig =3D !!tmpVal; + VIR_FREE(tmp); + } + + return 0; + + error: + VIR_FREE(tmp); + return -1; +} + + +static int virDomainChrSourceDefParseProtocol(virDomainChrSourceDefPtr def, xmlNodePtr protocol) { @@ -10991,8 +11037,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef= Ptr def, char *master =3D NULL; char *slave =3D NULL; char *append =3D NULL; - char *haveTLS =3D NULL; - char *tlsFromConfig =3D NULL; bool logParsed =3D false; bool protocolParsed =3D false; int sourceParsed =3D 0; @@ -11018,11 +11062,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDe= fPtr def, } sourceParsed++; =20 - if (!haveTLS) - haveTLS =3D virXMLPropString(cur, "tls"); - if (!tlsFromConfig) - tlsFromConfig =3D virXMLPropString(cur, "tlsFromConfig"); - switch ((virDomainChrType) def->type) { case VIR_DOMAIN_CHR_TYPE_FILE: case VIR_DOMAIN_CHR_TYPE_PTY: @@ -11044,7 +11083,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef= Ptr def, break; =20 case VIR_DOMAIN_CHR_TYPE_UDP: - case VIR_DOMAIN_CHR_TYPE_TCP: if ((mode =3D virDomainChrSourceDefParseMode(cur)) < 0) goto error; if (mode =3D=3D VIR_DOMAIN_CHR_SOURCE_MODE_CONNECT) { @@ -11058,7 +11096,11 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDe= fPtr def, if (!bindService) bindService =3D virXMLPropString(cur, "service"); } + break; =20 + case VIR_DOMAIN_CHR_TYPE_TCP: + if (virDomainChrSourceDefParseTCP(def, cur, flags) < 0) + goto error; break; =20 case VIR_DOMAIN_CHR_TYPE_SPICEPORT: @@ -11168,63 +11210,16 @@ virDomainChrSourceDefParseXML(virDomainChrSourceD= efPtr def, break; =20 case VIR_DOMAIN_CHR_TYPE_TCP: - if (mode =3D=3D VIR_DOMAIN_CHR_SOURCE_MODE_CONNECT) { - if (!connectHost) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing source host attribute for char d= evice")); - goto error; - } - - if (!connectService) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing source service attribute for cha= r device")); - goto error; - } - - def->data.tcp.host =3D connectHost; - connectHost =3D NULL; - def->data.tcp.service =3D connectService; - connectService =3D NULL; - def->data.tcp.listen =3D false; - } else if (mode =3D=3D VIR_DOMAIN_CHR_SOURCE_MODE_BIND) { - if (!bindHost) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing source host attribute for char d= evice")); - goto error; - } - - if (!bindService) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing source service attribute for cha= r device")); - goto error; - } - - def->data.tcp.host =3D bindHost; - bindHost =3D NULL; - def->data.tcp.service =3D bindService; - bindService =3D NULL; - def->data.tcp.listen =3D true; - } - - if (haveTLS && - (def->data.tcp.haveTLS =3D - virTristateBoolTypeFromString(haveTLS)) <=3D 0) { - virReportError(VIR_ERR_XML_ERROR, - _("unknown chardev 'tls' setting '%s'"), - haveTLS); + if (!def->data.tcp.host) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Missing source host attribute for char devic= e")); goto error; } =20 - if (tlsFromConfig && - flags & VIR_DOMAIN_DEF_PARSE_STATUS) { - int tmp; - if (virStrToLong_i(tlsFromConfig, NULL, 10, &tmp) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("Invalid tlsFromConfig value: %s"), - tlsFromConfig); - goto error; - } - def->data.tcp.tlsFromConfig =3D !!tmp; + if (!def->data.tcp.service) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Missing source service attribute for char de= vice")); + goto error; } break; =20 @@ -11288,8 +11283,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef= Ptr def, VIR_FREE(path); VIR_FREE(channel); VIR_FREE(append); - VIR_FREE(haveTLS); - VIR_FREE(tlsFromConfig); =20 return ret; =20 --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 05:10:25 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 1503302862326258.2285725412745; Mon, 21 Aug 2017 01:07:42 -0700 (PDT) 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 9DB3681E0D; Mon, 21 Aug 2017 08:07:40 +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 699D36F94A; Mon, 21 Aug 2017 08:07:40 +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 2E0EF3FAD9; Mon, 21 Aug 2017 08:07:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7L87XAL002492 for ; Mon, 21 Aug 2017 04:07:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id B30986F924; Mon, 21 Aug 2017 08:07:33 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B3BB6F92B for ; Mon, 21 Aug 2017 08:07:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9DB3681E0D 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=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 21 Aug 2017 10:07:12 +0200 Message-Id: <2b8018cd291bb50c7b27781d8c2a8a0fb632aa3e.1503302799.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 12/17] conf: move UDP chardev source parsing to separate function 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 21 Aug 2017 08:07:41 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The extra check whether (connect|bind)(Host|Service) was set is required because for UDP chardev there can be two source elements. Without the check there could be a memory leak. Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 56 ++++++++++++++++++++++------------------------= ---- 1 file changed, 25 insertions(+), 31 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 023d86cec5..d8a195a141 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10966,6 +10966,29 @@ virDomainChrSourceDefParseTCP(virDomainChrSourceDe= fPtr def, =20 =20 static int +virDomainChrSourceDefParseUDP(virDomainChrSourceDefPtr def, + xmlNodePtr source) +{ + int mode; + + if ((mode =3D virDomainChrSourceDefParseMode(source)) < 0) + return -1; + + if (mode =3D=3D VIR_DOMAIN_CHR_SOURCE_MODE_CONNECT && + !def->data.udp.connectHost && !def->data.udp.connectService) { + def->data.udp.connectHost =3D virXMLPropString(source, "host"); + def->data.udp.connectService =3D virXMLPropString(source, "service= "); + } else if (mode =3D=3D VIR_DOMAIN_CHR_SOURCE_MODE_BIND && + !def->data.udp.bindHost && !def->data.udp.bindService) { + def->data.udp.bindHost =3D virXMLPropString(source, "host"); + def->data.udp.bindService =3D virXMLPropString(source, "service"); + } + + return 0; +} + + +static int virDomainChrSourceDefParseProtocol(virDomainChrSourceDefPtr def, xmlNodePtr protocol) { @@ -11028,10 +11051,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDe= fPtr def, { int ret =3D -1; int mode =3D VIR_DOMAIN_CHR_SOURCE_MODE_CONNECT; - char *bindHost =3D NULL; - char *bindService =3D NULL; - char *connectHost =3D NULL; - char *connectService =3D NULL; char *path =3D NULL; char *channel =3D NULL; char *master =3D NULL; @@ -11083,19 +11102,8 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDe= fPtr def, break; =20 case VIR_DOMAIN_CHR_TYPE_UDP: - if ((mode =3D virDomainChrSourceDefParseMode(cur)) < 0) + if (virDomainChrSourceDefParseUDP(def, cur) < 0) goto error; - if (mode =3D=3D VIR_DOMAIN_CHR_SOURCE_MODE_CONNECT) { - if (!connectHost) - connectHost =3D virXMLPropString(cur, "host"); - if (!connectService) - connectService =3D virXMLPropString(cur, "service"= ); - } else if (mode =3D=3D VIR_DOMAIN_CHR_SOURCE_MODE_BIND) { - if (!bindHost) - bindHost =3D virXMLPropString(cur, "host"); - if (!bindService) - bindService =3D virXMLPropString(cur, "service"); - } break; =20 case VIR_DOMAIN_CHR_TYPE_TCP: @@ -11224,21 +11232,11 @@ virDomainChrSourceDefParseXML(virDomainChrSourceD= efPtr def, break; =20 case VIR_DOMAIN_CHR_TYPE_UDP: - if (!connectService) { + if (!def->data.udp.connectService) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing source service attribute for char de= vice")); goto error; } - - def->data.udp.connectHost =3D connectHost; - connectHost =3D NULL; - def->data.udp.connectService =3D connectService; - connectService =3D NULL; - - def->data.udp.bindHost =3D bindHost; - bindHost =3D NULL; - def->data.udp.bindService =3D bindService; - bindService =3D NULL; break; =20 case VIR_DOMAIN_CHR_TYPE_UNIX: @@ -11276,10 +11274,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDe= fPtr def, =20 ret =3D 0; cleanup: - VIR_FREE(bindHost); - VIR_FREE(bindService); - VIR_FREE(connectHost); - VIR_FREE(connectService); VIR_FREE(path); VIR_FREE(channel); VIR_FREE(append); --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 05:10:25 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 1503302906158130.24057078751582; Mon, 21 Aug 2017 01:08:26 -0700 (PDT) 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 7ABEB83F3D; Mon, 21 Aug 2017 08:08:24 +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 5385B6F926; Mon, 21 Aug 2017 08:08:22 +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 929C936FB; Mon, 21 Aug 2017 08:07:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7L87Y9m002501 for ; Mon, 21 Aug 2017 04:07:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 97F526F927; Mon, 21 Aug 2017 08:07:34 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D9F46F924 for ; Mon, 21 Aug 2017 08:07:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7ABEB83F3D Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 21 Aug 2017 10:07:13 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 13/17] conf: move UNIX chardev source parsing to separate function 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 21 Aug 2017 08:08:24 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d8a195a141..d69590e29d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10989,6 +10989,23 @@ virDomainChrSourceDefParseUDP(virDomainChrSourceDe= fPtr def, =20 =20 static int +virDomainChrSourceDefParseUnix(virDomainChrSourceDefPtr def, + xmlNodePtr source) +{ + + int mode; + + if ((mode =3D virDomainChrSourceDefParseMode(source)) < 0) + return -1; + + def->data.nix.listen =3D mode =3D=3D VIR_DOMAIN_CHR_SOURCE_MODE_BIND; + def->data.nix.path =3D virXMLPropString(source, "path"); + + return 0; +} + + +static int virDomainChrSourceDefParseProtocol(virDomainChrSourceDefPtr def, xmlNodePtr protocol) { @@ -11050,7 +11067,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef= Ptr def, int nvmSeclabels) { int ret =3D -1; - int mode =3D VIR_DOMAIN_CHR_SOURCE_MODE_CONNECT; char *path =3D NULL; char *channel =3D NULL; char *master =3D NULL; @@ -11086,7 +11102,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef= Ptr def, case VIR_DOMAIN_CHR_TYPE_PTY: case VIR_DOMAIN_CHR_TYPE_DEV: case VIR_DOMAIN_CHR_TYPE_PIPE: - case VIR_DOMAIN_CHR_TYPE_UNIX: if (!append && def->type =3D=3D VIR_DOMAIN_CHR_TYPE_FILE) append =3D virXMLPropString(cur, "append"); /* PTY path is only parsed from live xml. */ @@ -11094,11 +11109,11 @@ virDomainChrSourceDefParseXML(virDomainChrSourceD= efPtr def, (def->type !=3D VIR_DOMAIN_CHR_TYPE_PTY || !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE))) path =3D virXMLPropString(cur, "path"); - if (def->type =3D=3D VIR_DOMAIN_CHR_TYPE_UNIX) { - if ((mode =3D virDomainChrSourceDefParseMode(cur)) < 0) - goto error; - } + break; =20 + case VIR_DOMAIN_CHR_TYPE_UNIX: + if (virDomainChrSourceDefParseUnix(def, cur) < 0) + goto error; break; =20 case VIR_DOMAIN_CHR_TYPE_UDP: @@ -11241,7 +11256,7 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef= Ptr def, =20 case VIR_DOMAIN_CHR_TYPE_UNIX: /* path can be auto generated */ - if (!path && + if (!def->data.nix.path && (!chr_def || (chr_def->targetType !=3D VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_= XEN && chr_def->targetType !=3D VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_= VIRTIO))) { @@ -11249,11 +11264,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDe= fPtr def, _("Missing source path attribute for char devic= e")); goto error; } - - def->data.nix.listen =3D mode =3D=3D VIR_DOMAIN_CHR_SOURCE_MODE_BI= ND; - - def->data.nix.path =3D path; - path =3D NULL; break; =20 case VIR_DOMAIN_CHR_TYPE_SPICEPORT: --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 05:10:25 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 1503302931542865.1744541042218; Mon, 21 Aug 2017 01:08:51 -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 CFD297E44B; Mon, 21 Aug 2017 08:08:49 +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 AA1D06C523; Mon, 21 Aug 2017 08:08:49 +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 1E7C13FAD5; Mon, 21 Aug 2017 08:07:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7L87ZsX002513 for ; Mon, 21 Aug 2017 04:07:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 798736F924; Mon, 21 Aug 2017 08:07:35 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id F1C416F92D for ; Mon, 21 Aug 2017 08:07:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CFD297E44B Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 21 Aug 2017 10:07:14 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 14/17] conf: assign parsed strings directly into chardev source definition 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.27]); Mon, 21 Aug 2017 08:08:50 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Since the source element is parsed only once for these type of character devices we don't have to use temporary variable and check whether the variable was already set. Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 43 ++++++++++++------------------------------- 1 file changed, 12 insertions(+), 31 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d69590e29d..84184a265e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11067,10 +11067,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDe= fPtr def, int nvmSeclabels) { int ret =3D -1; - char *path =3D NULL; - char *channel =3D NULL; - char *master =3D NULL; - char *slave =3D NULL; char *append =3D NULL; bool logParsed =3D false; bool protocolParsed =3D false; @@ -11105,10 +11101,9 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDe= fPtr def, if (!append && def->type =3D=3D VIR_DOMAIN_CHR_TYPE_FILE) append =3D virXMLPropString(cur, "append"); /* PTY path is only parsed from live xml. */ - if (!path && - (def->type !=3D VIR_DOMAIN_CHR_TYPE_PTY || - !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE))) - path =3D virXMLPropString(cur, "path"); + if (def->type !=3D VIR_DOMAIN_CHR_TYPE_PTY || + !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) + def->data.file.path =3D virXMLPropString(cur, "path"); break; =20 case VIR_DOMAIN_CHR_TYPE_UNIX: @@ -11127,15 +11122,12 @@ virDomainChrSourceDefParseXML(virDomainChrSourceD= efPtr def, break; =20 case VIR_DOMAIN_CHR_TYPE_SPICEPORT: - if (!channel) - channel =3D virXMLPropString(cur, "channel"); + def->data.spiceport.channel =3D virXMLPropString(cur, "cha= nnel"); break; =20 case VIR_DOMAIN_CHR_TYPE_NMDM: - if (!master) - master =3D virXMLPropString(cur, "master"); - if (!slave) - slave =3D virXMLPropString(cur, "slave"); + def->data.nmdm.master =3D virXMLPropString(cur, "master"); + def->data.nmdm.slave =3D virXMLPropString(cur, "slave"); break; =20 case VIR_DOMAIN_CHR_TYPE_LAST: @@ -11202,34 +11194,26 @@ virDomainChrSourceDefParseXML(virDomainChrSourceD= efPtr def, _("Invalid append attribute value '%s'"), appen= d); goto error; } - if (!path && + if (!def->data.file.path && def->type !=3D VIR_DOMAIN_CHR_TYPE_PTY) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing source path attribute for char devic= e")); goto error; } - - def->data.file.path =3D path; - path =3D NULL; break; =20 case VIR_DOMAIN_CHR_TYPE_NMDM: - if (!master) { + if (!def->data.nmdm.master) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing master path attribute for nmdm devic= e")); goto error; } =20 - if (!slave) { + if (!def->data.nmdm.slave) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing slave path attribute for nmdm device= ")); goto error; } - - def->data.nmdm.master =3D master; - def->data.nmdm.slave =3D slave; - master =3D NULL; - slave =3D NULL; break; =20 case VIR_DOMAIN_CHR_TYPE_TCP: @@ -11267,25 +11251,22 @@ virDomainChrSourceDefParseXML(virDomainChrSourceD= efPtr def, break; =20 case VIR_DOMAIN_CHR_TYPE_SPICEPORT: - if (!channel) { + if (!def->data.spiceport.channel) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Missing source channel attribute for char de= vice")); goto error; } - if (strspn(channel, SERIAL_CHANNEL_NAME_CHARS) < strlen(channel)) { + if (strspn(def->data.spiceport.channel, + SERIAL_CHANNEL_NAME_CHARS) < strlen(def->data.spiceport= .channel)) { virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid character in source channel for char= device")); goto error; } - def->data.spiceport.channel =3D channel; - channel =3D NULL; break; } =20 ret =3D 0; cleanup: - VIR_FREE(path); - VIR_FREE(channel); VIR_FREE(append); =20 return ret; --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 05:10:25 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 1503302934315642.4045816187485; Mon, 21 Aug 2017 01:08:54 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6A743806C4; Mon, 21 Aug 2017 08:08:52 +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 40E3066A0F; Mon, 21 Aug 2017 08:08:52 +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 7D24D3FC73; Mon, 21 Aug 2017 08:07:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7L87aQm002522 for ; Mon, 21 Aug 2017 04:07:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id C8CA36F92D; Mon, 21 Aug 2017 08:07:36 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4DDF16F924 for ; Mon, 21 Aug 2017 08:07:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6A743806C4 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 21 Aug 2017 10:07:15 +0200 Message-Id: <54ccad1ebbc3e7772be9918ba646e72b41efaaea.1503302799.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 15/17] conf: move FILE chardev source parsing to separate function 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 21 Aug 2017 08:08:53 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 84184a265e..1baf6b9174 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11006,6 +11006,28 @@ virDomainChrSourceDefParseUnix(virDomainChrSourceD= efPtr def, =20 =20 static int +virDomainChrSourceDefParseFile(virDomainChrSourceDefPtr def, + xmlNodePtr source) +{ + char *append =3D NULL; + + def->data.file.path =3D virXMLPropString(source, "path"); + + if ((append =3D virXMLPropString(source, "append")) && + (def->data.file.append =3D virTristateSwitchTypeFromString(append)= ) <=3D 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid append attribute value '%s'"), + append); + VIR_FREE(append); + return -1; + } + + VIR_FREE(append); + return 0; +} + + +static int virDomainChrSourceDefParseProtocol(virDomainChrSourceDefPtr def, xmlNodePtr protocol) { @@ -11067,7 +11089,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef= Ptr def, int nvmSeclabels) { int ret =3D -1; - char *append =3D NULL; bool logParsed =3D false; bool protocolParsed =3D false; int sourceParsed =3D 0; @@ -11095,11 +11116,13 @@ virDomainChrSourceDefParseXML(virDomainChrSourceD= efPtr def, =20 switch ((virDomainChrType) def->type) { case VIR_DOMAIN_CHR_TYPE_FILE: + if (virDomainChrSourceDefParseFile(def, cur) < 0) + goto error; + break; + case VIR_DOMAIN_CHR_TYPE_PTY: case VIR_DOMAIN_CHR_TYPE_DEV: case VIR_DOMAIN_CHR_TYPE_PIPE: - if (!append && def->type =3D=3D VIR_DOMAIN_CHR_TYPE_FILE) - append =3D virXMLPropString(cur, "append"); /* PTY path is only parsed from live xml. */ if (def->type !=3D VIR_DOMAIN_CHR_TYPE_PTY || !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) @@ -11188,12 +11211,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDe= fPtr def, case VIR_DOMAIN_CHR_TYPE_PTY: case VIR_DOMAIN_CHR_TYPE_DEV: case VIR_DOMAIN_CHR_TYPE_PIPE: - if (append && def->type =3D=3D VIR_DOMAIN_CHR_TYPE_FILE && - (def->data.file.append =3D virTristateSwitchTypeFromString(app= end)) <=3D 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid append attribute value '%s'"), appen= d); - goto error; - } if (!def->data.file.path && def->type !=3D VIR_DOMAIN_CHR_TYPE_PTY) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -11267,8 +11284,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef= Ptr def, =20 ret =3D 0; cleanup: - VIR_FREE(append); - return ret; =20 error: --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 05:10:25 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 1503302905145830.4655531048496; Mon, 21 Aug 2017 01:08:25 -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 06D71806AF; Mon, 21 Aug 2017 08:08:23 +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 D94566C520; Mon, 21 Aug 2017 08:08:20 +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 669DF3FA5C; Mon, 21 Aug 2017 08:07:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7L87eC4002552 for ; Mon, 21 Aug 2017 04:07:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id D9C1F6F939; Mon, 21 Aug 2017 08:07:40 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5CE186F92B for ; Mon, 21 Aug 2017 08:07:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 06D71806AF Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 21 Aug 2017 10:07:16 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 16/17] conf: separate PTY chardev source parsing 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.26]); Mon, 21 Aug 2017 08:08:23 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" There is no reason why to share the same code for PTY and other file based chardev source types. Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1baf6b9174..3e20b22799 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11121,14 +11121,16 @@ virDomainChrSourceDefParseXML(virDomainChrSourceD= efPtr def, break; =20 case VIR_DOMAIN_CHR_TYPE_PTY: - case VIR_DOMAIN_CHR_TYPE_DEV: - case VIR_DOMAIN_CHR_TYPE_PIPE: /* PTY path is only parsed from live xml. */ - if (def->type !=3D VIR_DOMAIN_CHR_TYPE_PTY || - !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) + if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) def->data.file.path =3D virXMLPropString(cur, "path"); break; =20 + case VIR_DOMAIN_CHR_TYPE_DEV: + case VIR_DOMAIN_CHR_TYPE_PIPE: + def->data.file.path =3D virXMLPropString(cur, "path"); + break; + case VIR_DOMAIN_CHR_TYPE_UNIX: if (virDomainChrSourceDefParseUnix(def, cur) < 0) goto error; @@ -11201,6 +11203,7 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef= Ptr def, =20 switch ((virDomainChrType) def->type) { case VIR_DOMAIN_CHR_TYPE_NULL: + case VIR_DOMAIN_CHR_TYPE_PTY: case VIR_DOMAIN_CHR_TYPE_VC: case VIR_DOMAIN_CHR_TYPE_STDIO: case VIR_DOMAIN_CHR_TYPE_SPICEVMC: @@ -11208,11 +11211,9 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDe= fPtr def, break; =20 case VIR_DOMAIN_CHR_TYPE_FILE: - case VIR_DOMAIN_CHR_TYPE_PTY: case VIR_DOMAIN_CHR_TYPE_DEV: case VIR_DOMAIN_CHR_TYPE_PIPE: - if (!def->data.file.path && - def->type !=3D VIR_DOMAIN_CHR_TYPE_PTY) { + if (!def->data.file.path) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing source path attribute for char devic= e")); goto error; --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 05:10:25 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 1503302904721908.5799368274635; Mon, 21 Aug 2017 01:08:24 -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 DBA297EA8A; Mon, 21 Aug 2017 08:08:22 +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 B952A7E5C2; Mon, 21 Aug 2017 08:08:21 +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 8370A1864DC2; Mon, 21 Aug 2017 08:07:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7L87jbe002569 for ; Mon, 21 Aug 2017 04:07:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id 397C46F926; Mon, 21 Aug 2017 08:07:45 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id B58316F924 for ; Mon, 21 Aug 2017 08:07:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DBA297EA8A Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 21 Aug 2017 10:07:17 +0200 Message-Id: <642733061f2f0684200275fd6a1f01d6aeb1ce0b.1503302799.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 17/17] conf: move chardev validation into virDomainDeviceDefValidateInternal 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.28]); Mon, 21 Aug 2017 08:08:23 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 221 +++++++++++++++++++++++++++++----------------= ---- 1 file changed, 132 insertions(+), 89 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3e20b22799..b698569f82 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5034,6 +5034,101 @@ virDomainDefHasUSB(const virDomainDef *def) return false; } =20 + +#define SERIAL_CHANNEL_NAME_CHARS \ + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-." + + +static int +virDomainChrSourceDefValidate(const virDomainChrSourceDef *def, + const virDomainChrDef *chr_def) +{ + switch ((virDomainChrType) def->type) { + case VIR_DOMAIN_CHR_TYPE_NULL: + case VIR_DOMAIN_CHR_TYPE_PTY: + case VIR_DOMAIN_CHR_TYPE_VC: + case VIR_DOMAIN_CHR_TYPE_STDIO: + case VIR_DOMAIN_CHR_TYPE_SPICEVMC: + case VIR_DOMAIN_CHR_TYPE_LAST: + break; + + case VIR_DOMAIN_CHR_TYPE_FILE: + case VIR_DOMAIN_CHR_TYPE_DEV: + case VIR_DOMAIN_CHR_TYPE_PIPE: + if (!def->data.file.path) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Missing source path attribute for char devic= e")); + return -1; + } + break; + + case VIR_DOMAIN_CHR_TYPE_NMDM: + if (!def->data.nmdm.master) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Missing master path attribute for nmdm devic= e")); + return -1; + } + + if (!def->data.nmdm.slave) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Missing slave path attribute for nmdm device= ")); + return -1; + } + break; + + case VIR_DOMAIN_CHR_TYPE_TCP: + if (!def->data.tcp.host) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Missing source host attribute for char devic= e")); + return -1; + } + + if (!def->data.tcp.service) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Missing source service attribute for char de= vice")); + return -1; + } + break; + + case VIR_DOMAIN_CHR_TYPE_UDP: + if (!def->data.udp.connectService) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Missing source service attribute for char de= vice")); + return -1; + } + break; + + case VIR_DOMAIN_CHR_TYPE_UNIX: + /* path can be auto generated */ + if (!def->data.nix.path && + (!chr_def || + (chr_def->targetType !=3D VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_= XEN && + chr_def->targetType !=3D VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_= VIRTIO))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Missing source path attribute for char devic= e")); + return -1; + } + break; + + case VIR_DOMAIN_CHR_TYPE_SPICEPORT: + if (!def->data.spiceport.channel) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Missing source channel attribute for char de= vice")); + return -1; + } + if (strspn(def->data.spiceport.channel, + SERIAL_CHANNEL_NAME_CHARS) < strlen(def->data.spiceport= .channel)) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("Invalid character in source channel for char= device")); + return -1; + } + break; + } + + return 0; +} + + static int virDomainRedirdevDefValidate(const virDomainDef *def, const virDomainRedirdevDef *redirdev) @@ -5046,7 +5141,7 @@ virDomainRedirdevDefValidate(const virDomainDef *def, return -1; } =20 - return 0; + return virDomainChrSourceDefValidate(redirdev->source, NULL); } =20 =20 @@ -5083,6 +5178,33 @@ virDomainControllerDefValidate(const virDomainContro= llerDef *controller) =20 =20 static int +virDomainChrDefValidate(const virDomainChrDef *chr) +{ + return virDomainChrSourceDefValidate(chr->source, chr); +} + + +static int +virDomainSmartcardDefValidate(const virDomainSmartcardDef *smartcard) +{ + if (smartcard->type =3D=3D VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH) + return virDomainChrSourceDefValidate(smartcard->data.passthru, NUL= L); + + return 0; +} + + +static int +virDomainRNGDefValidate(const virDomainRNGDef *rng) +{ + if (rng->backend =3D=3D VIR_DOMAIN_RNG_BACKEND_EGD) + return virDomainChrSourceDefValidate(rng->source.chardev, NULL); + + return 0; +} + + +static int virDomainDeviceDefValidateInternal(const virDomainDeviceDef *dev, const virDomainDef *def) { @@ -5099,6 +5221,15 @@ virDomainDeviceDefValidateInternal(const virDomainDe= viceDef *dev, case VIR_DOMAIN_DEVICE_CONTROLLER: return virDomainControllerDefValidate(dev->data.controller); =20 + case VIR_DOMAIN_DEVICE_CHR: + return virDomainChrDefValidate(dev->data.chr); + + case VIR_DOMAIN_DEVICE_SMARTCARD: + return virDomainSmartcardDefValidate(dev->data.smartcard); + + case VIR_DOMAIN_DEVICE_RNG: + return virDomainRNGDefValidate(dev->data.rng); + case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_INPUT: @@ -5108,11 +5239,8 @@ virDomainDeviceDefValidateInternal(const virDomainDe= viceDef *dev, case VIR_DOMAIN_DEVICE_WATCHDOG: case VIR_DOMAIN_DEVICE_GRAPHICS: case VIR_DOMAIN_DEVICE_HUB: - case VIR_DOMAIN_DEVICE_SMARTCARD: - case VIR_DOMAIN_DEVICE_CHR: case VIR_DOMAIN_DEVICE_MEMBALLOON: case VIR_DOMAIN_DEVICE_NVRAM: - case VIR_DOMAIN_DEVICE_RNG: case VIR_DOMAIN_DEVICE_SHMEM: case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_PANIC: @@ -11072,9 +11200,6 @@ virDomainChrSourceDefParseLog(virDomainChrSourceDef= Ptr def, } =20 =20 -#define SERIAL_CHANNEL_NAME_CHARS \ - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-." - /* Parse the source half of the XML definition for a character device, * where node is the first element of node->children of the parent * element. def->type must already be valid. @@ -11201,88 +11326,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDe= fPtr def, } } =20 - switch ((virDomainChrType) def->type) { - case VIR_DOMAIN_CHR_TYPE_NULL: - case VIR_DOMAIN_CHR_TYPE_PTY: - case VIR_DOMAIN_CHR_TYPE_VC: - case VIR_DOMAIN_CHR_TYPE_STDIO: - case VIR_DOMAIN_CHR_TYPE_SPICEVMC: - case VIR_DOMAIN_CHR_TYPE_LAST: - break; - - case VIR_DOMAIN_CHR_TYPE_FILE: - case VIR_DOMAIN_CHR_TYPE_DEV: - case VIR_DOMAIN_CHR_TYPE_PIPE: - if (!def->data.file.path) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing source path attribute for char devic= e")); - goto error; - } - break; - - case VIR_DOMAIN_CHR_TYPE_NMDM: - if (!def->data.nmdm.master) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing master path attribute for nmdm devic= e")); - goto error; - } - - if (!def->data.nmdm.slave) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing slave path attribute for nmdm device= ")); - goto error; - } - break; - - case VIR_DOMAIN_CHR_TYPE_TCP: - if (!def->data.tcp.host) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing source host attribute for char devic= e")); - goto error; - } - - if (!def->data.tcp.service) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing source service attribute for char de= vice")); - goto error; - } - break; - - case VIR_DOMAIN_CHR_TYPE_UDP: - if (!def->data.udp.connectService) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing source service attribute for char de= vice")); - goto error; - } - break; - - case VIR_DOMAIN_CHR_TYPE_UNIX: - /* path can be auto generated */ - if (!def->data.nix.path && - (!chr_def || - (chr_def->targetType !=3D VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_= XEN && - chr_def->targetType !=3D VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_= VIRTIO))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Missing source path attribute for char devic= e")); - goto error; - } - break; - - case VIR_DOMAIN_CHR_TYPE_SPICEPORT: - if (!def->data.spiceport.channel) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Missing source channel attribute for char de= vice")); - goto error; - } - if (strspn(def->data.spiceport.channel, - SERIAL_CHANNEL_NAME_CHARS) < strlen(def->data.spiceport= .channel)) { - virReportError(VIR_ERR_INVALID_ARG, "%s", - _("Invalid character in source channel for char= device")); - goto error; - } - break; - } - ret =3D 0; cleanup: return ret; --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list