From nobody Wed May 1 17:39:33 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 1505413345879487.2970077160446; Thu, 14 Sep 2017 11:22:25 -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 EF01067725; Thu, 14 Sep 2017 18:22: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 B446236F9; Thu, 14 Sep 2017 18:22: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 1EF9BEFC1; Thu, 14 Sep 2017 18:22:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8EI3FIM018314 for ; Thu, 14 Sep 2017 14:03:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 093B46682E; Thu, 14 Sep 2017 18:03:15 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-172.phx2.redhat.com [10.3.116.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id C6FDF17103 for ; Thu, 14 Sep 2017 18:03:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EF01067725 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: John Ferlan To: libvir-list@redhat.com Date: Thu, 14 Sep 2017 14:03:05 -0400 Message-Id: <20170914180310.1426-2-jferlan@redhat.com> In-Reply-To: <20170914180310.1426-1-jferlan@redhat.com> References: <20170914180310.1426-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/6] docs: Remove unnecessary example for iscsi disk type='volume' 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]); Thu, 14 Sep 2017 18:22:25 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Alter the example to remove the from: and The reality is, it's not even used. For a the authdef from the storage source pool will supercede whatever is in the definition during virStorageTranslateDiskSourcePool processing. In fact, if the pool doesn't have/need authentication, then the authdef would be removed anyway as the storage pool would be handling things. The "proof" for this is in the adjustment to the test to add an for a disk. The resulting .args file won't add what normally would be added "myname:encodedpassword@" prior to the hostname in the IQN (e.g. iscsi://myname:encodedpassword@iscsi.example.org:3260/... Signed-off-by: John Ferlan --- docs/formatdomain.html.in | 6 ------ .../qemuxml2argv-disk-source-pool-mode.args | 3 +++ .../qemuxml2argvdata/qemuxml2argv-disk-source-pool-mode.xml | 13 +++++++++= ++++ .../qemuxml2xmlout-disk-source-pool-mode.xml | 13 +++++++++= ++++ 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 8ca7637a4..3b78bbeb8 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2385,17 +2385,11 @@ <disk type=3D'volume' device=3D'disk'> <driver name=3D'qemu' type=3D'raw'/> <source pool=3D'iscsi-pool' volume=3D'unit:0:0:1' mode=3D'host'/> - <auth username=3D'myuser'> - <secret type=3D'iscsi' usage=3D'libvirtiscsi'/> - </auth> <target dev=3D'vdb' bus=3D'virtio'/> </disk> <disk type=3D'volume' device=3D'disk'> <driver name=3D'qemu' type=3D'raw'/> <source pool=3D'iscsi-pool' volume=3D'unit:0:0:2' mode=3D'direct'/&= gt; - <auth username=3D'myuser'> - <secret type=3D'iscsi' usage=3D'libvirtiscsi'/> - </auth> <target dev=3D'vdc' bus=3D'virtio'/> </disk> <disk type=3D'file' device=3D'disk'> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool-mode.args= b/tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool-mode.args index 7cda627f2..5b4e65e10 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool-mode.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool-mode.args @@ -28,4 +28,7 @@ id=3Ddrive-ide0-0-2,readonly=3Don \ -device ide-drive,bus=3Dide.0,unit=3D2,drive=3Ddrive-ide0-0-2,id=3Dide0-0-= 2 \ -drive file=3D/tmp/idedisk.img,format=3Draw,if=3Dnone,id=3Ddrive-ide0-0-3 \ -device ide-drive,bus=3Dide.0,unit=3D3,drive=3Ddrive-ide0-0-3,id=3Dide0-0-= 3 \ +-drive file=3Discsi://iscsi.example.com:3260/demo-target/3,if=3Dnone,media= =3Dcdrom,\ +id=3Ddrive-ide0-0-4,readonly=3Don \ +-device ide-drive,bus=3Dide.0,unit=3D4,drive=3Ddrive-ide0-0-4,id=3Dide0-0-= 4 \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool-mode.xml = b/tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool-mode.xml index eaf411c8b..3f5a2d524 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool-mode.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool-mode.xml @@ -39,6 +39,19 @@
+ + + + + + + + + + + +
+ diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-source-pool-mode.= xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-source-pool-mode.xml index 1ca56fbb9..a14ed7b97 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-source-pool-mode.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-source-pool-mode.xml @@ -39,6 +39,19 @@
+ + + + + + + + + + + +
+
--=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 17:39:33 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 1505415524585323.02120804094034; Thu, 14 Sep 2017 11:58:44 -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 37E8EC04DBE5; Thu, 14 Sep 2017 18:58:43 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 05D1A5C545; Thu, 14 Sep 2017 18:58: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 BAFE21843762; Thu, 14 Sep 2017 18:58:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8EI3Fp6018320 for ; Thu, 14 Sep 2017 14:03:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 646016682E; Thu, 14 Sep 2017 18:03:15 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-172.phx2.redhat.com [10.3.116.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B62B17103 for ; Thu, 14 Sep 2017 18:03:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 37E8EC04DBE5 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Thu, 14 Sep 2017 14:03:06 -0400 Message-Id: <20170914180310.1426-3-jferlan@redhat.com> In-Reply-To: <20170914180310.1426-1-jferlan@redhat.com> References: <20170914180310.1426-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/6] conf: Add invalid secrettype checks 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.32]); Thu, 14 Sep 2017 18:58:43 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add a couple of tests to "validate" checks in domain_conf that either a missing secrettype (CONFIG_UNSUPPORTED) or an mismatched secrettype of ceph for an iSCSI disk (INTERNAL_ERROR) will cause a parsing error. Signed-off-by: John Ferlan --- ...drive-network-iscsi-auth-secrettype-invalid.xml | 33 ++++++++++++++++++= ++++ ...k-drive-network-iscsi-auth-wrong-secrettype.xml | 33 ++++++++++++++++++= ++++ tests/qemuxml2argvtest.c | 2 ++ 3 files changed, 68 insertions(+) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-= iscsi-auth-secrettype-invalid.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-= iscsi-auth-wrong-secrettype.xml diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi-a= uth-secrettype-invalid.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive= -network-iscsi-auth-secrettype-invalid.xml new file mode 100644 index 000000000..7e6b623c3 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi-auth-sec= rettype-invalid.xml @@ -0,0 +1,33 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + + + + + + + + + + + + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi-a= uth-wrong-secrettype.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-n= etwork-iscsi-auth-wrong-secrettype.xml new file mode 100644 index 000000000..4854abd6c --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-iscsi-auth-wro= ng-secrettype.xml @@ -0,0 +1,33 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + + + + + + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 2c040e4c0..fd05155ef 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -917,6 +917,8 @@ mymain(void) DO_TEST("disk-drive-network-nbd-unix", NONE); DO_TEST("disk-drive-network-iscsi", NONE); DO_TEST("disk-drive-network-iscsi-auth", NONE); + DO_TEST_PARSE_ERROR("disk-drive-network-iscsi-auth-secrettype-invalid"= , NONE); + DO_TEST_PARSE_ERROR("disk-drive-network-iscsi-auth-wrong-secrettype", = NONE); DO_TEST("disk-drive-network-iscsi-lun", QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_BLOCK); --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 17:39:33 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 1505413376950747.8925029506966; Thu, 14 Sep 2017 11:22:56 -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 E0DDF4ACBD; Thu, 14 Sep 2017 18:22:55 +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 BA7736F94A; Thu, 14 Sep 2017 18:22:55 +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 56F474EE4F; Thu, 14 Sep 2017 18:22:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8EI3GSh018326 for ; Thu, 14 Sep 2017 14:03:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 097576682E; Thu, 14 Sep 2017 18:03:16 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-172.phx2.redhat.com [10.3.116.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id C616517103 for ; Thu, 14 Sep 2017 18:03:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E0DDF4ACBD Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Thu, 14 Sep 2017 14:03:07 -0400 Message-Id: <20170914180310.1426-4-jferlan@redhat.com> In-Reply-To: <20170914180310.1426-1-jferlan@redhat.com> References: <20170914180310.1426-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/6] conf: Move authdef validation 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.38]); Thu, 14 Sep 2017 18:22:56 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rather than checking during XML processing, move the checks for correct and valid auth into virDomainDiskDefParseValidate. This will introduce virDomainDiskSourceDefParseAuthValidate to validate that the authdef stored for the virStorageSource is valid. This can then be expanded to service backingStore sources as well. Alter the message text slightly as well to distinguish between an unknown name and an incorrectly used name. Since type is not a mandatory field, add the NULLSTR() around the output of the unknown error. NB, a config using unknown formatting would fail virschematest since it only accepts 'iscsi' and 'ceph' as "valid" types. Signed-off-by: John Ferlan --- src/conf/domain_conf.c | 67 +++++++++++++++++++++++++---------------------= ---- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a43b25c31..07bda1a36 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8500,6 +8500,39 @@ virDomainDiskDefGeometryParse(virDomainDiskDefPtr de= f, =20 =20 static int +virDomainDiskSourceDefParseAuthValidate(const virStorageSource *src) +{ + virStorageAuthDefPtr authdef =3D src->auth; + int actUsage; + + /* Disk volume types won't have the secrettype filled in until + * after virStorageTranslateDiskSourcePool is run + */ + if (src->type =3D=3D VIR_STORAGE_TYPE_VOLUME || !authdef) + return 0; + + if ((actUsage =3D virSecretUsageTypeFromString(authdef->secrettype)) <= 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown secret type '%s'"), + NULLSTR(authdef->secrettype)); + return -1; + } + + if ((src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_ISCSI && + actUsage !=3D VIR_SECRET_USAGE_TYPE_ISCSI) || + (src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_RBD && + actUsage !=3D VIR_SECRET_USAGE_TYPE_CEPH)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("invalid secret type '%s'"), + virSecretUsageTypeToString(actUsage)); + return -1; + } + + return 0; +} + + +static int virDomainDiskDefParseValidate(const virDomainDiskDef *def) { if (def->bus !=3D VIR_DOMAIN_DISK_BUS_VIRTIO) { @@ -8572,7 +8605,7 @@ virDomainDiskDefParseValidate(const virDomainDiskDef = *def) } } =20 - return 0; + return virDomainDiskSourceDefParseAuthValidate(def->src); } =20 =20 @@ -8731,8 +8764,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, char *vendor =3D NULL; char *product =3D NULL; char *domain_name =3D NULL; - int expected_secret_usage =3D -1; - int auth_secret_usage =3D -1; =20 if (!(def =3D virDomainDiskDefNew(xmlopt))) return NULL; @@ -8776,13 +8807,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlop= t, =20 source =3D true; =20 - if (def->src->type =3D=3D VIR_STORAGE_TYPE_NETWORK) { - if (def->src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_ISC= SI) - expected_secret_usage =3D VIR_SECRET_USAGE_TYPE_ISCSI; - else if (def->src->protocol =3D=3D VIR_STORAGE_NET_PROTOCO= L_RBD) - expected_secret_usage =3D VIR_SECRET_USAGE_TYPE_CEPH; - } - startupPolicy =3D virXMLPropString(cur, "startupPolicy"); =20 } else if (!target && @@ -8840,17 +8864,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlop= t, virXMLNodeNameEqual(cur, "auth")) { if (!(authdef =3D virStorageAuthDefParse(node->doc, cur))) goto error; - /* Disk volume types won't have the secrettype filled in until - * after virStorageTranslateDiskSourcePool is run - */ - if (def->src->type !=3D VIR_STORAGE_TYPE_VOLUME && - (auth_secret_usage =3D - virSecretUsageTypeFromString(authdef->secrettype)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("invalid secret type %s"), - authdef->secrettype); - goto error; - } } else if (virXMLNodeNameEqual(cur, "iotune")) { if (virDomainDiskDefIotuneParse(def, ctxt) < 0) goto error; @@ -8914,18 +8927,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlop= t, } } =20 - /* Disk volume types will have authentication information handled in - * virStorageTranslateDiskSourcePool - */ - if (def->src->type !=3D VIR_STORAGE_TYPE_VOLUME && - auth_secret_usage !=3D -1 && auth_secret_usage !=3D expected_secre= t_usage) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("invalid secret type '%s'"), - virSecretUsageTypeToString(auth_secret_usage)); - goto error; - } - - /* Only CDROM and Floppy devices are allowed missing source path * to indicate no media present. LUN is for raw access CD-ROMs * that are not attached to a physical device presently */ --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 17:39:33 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 1505413397663733.3295791280701; Thu, 14 Sep 2017 11:23:17 -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 F1B0E356F5; Thu, 14 Sep 2017 18:23:15 +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 B99456682E; Thu, 14 Sep 2017 18:23:15 +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 806A33CB0; Thu, 14 Sep 2017 18:23:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8EI3G6H018332 for ; Thu, 14 Sep 2017 14:03:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6092217103; Thu, 14 Sep 2017 18:03:16 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-172.phx2.redhat.com [10.3.116.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2AE976685F for ; Thu, 14 Sep 2017 18:03:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com F1B0E356F5 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: John Ferlan To: libvir-list@redhat.com Date: Thu, 14 Sep 2017 14:03:08 -0400 Message-Id: <20170914180310.1426-5-jferlan@redhat.com> In-Reply-To: <20170914180310.1426-1-jferlan@redhat.com> References: <20170914180310.1426-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/6] conf: Add invalid domain disk encryption test 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.30]); Thu, 14 Sep 2017 18:23:16 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add a test to prove checking for invalid luks disk formatting check Signed-off-by: John Ferlan --- .../qemuxml2argv-luks-disk-invalid.xml | 37 ++++++++++++++++++= ++++ tests/qemuxml2argvtest.c | 1 + 2 files changed, 38 insertions(+) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-luks-disk-invalid.x= ml diff --git a/tests/qemuxml2argvdata/qemuxml2argv-luks-disk-invalid.xml b/te= sts/qemuxml2argvdata/qemuxml2argv-luks-disk-invalid.xml new file mode 100644 index 000000000..bea769584 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-luks-disk-invalid.xml @@ -0,0 +1,37 @@ + + encryptdisk + 496898a6-e6ff-f7c8-5dc2-3cf410945ee9 + 1048576 + 524288 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + + + + + + +
+ + +
+ + + + + +
+ + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index fd05155ef..c8c479cbd 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1647,6 +1647,7 @@ mymain(void) # else DO_TEST_FAILURE("luks-disks", QEMU_CAPS_OBJECT_SECRET); # endif + DO_TEST_PARSE_ERROR("luks-disk-invalid", NONE); =20 DO_TEST("memtune", NONE); DO_TEST("memtune-unlimited", NONE); --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 17:39:33 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 1505415544216815.8999901763403; Thu, 14 Sep 2017 11:59:04 -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 31641C004768; Thu, 14 Sep 2017 18:59:03 +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 E6EF360468; Thu, 14 Sep 2017 18:59:02 +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 B03AE180610F; Thu, 14 Sep 2017 18:59:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8EI3GNQ018342 for ; Thu, 14 Sep 2017 14:03:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id B8E9F17103; Thu, 14 Sep 2017 18:03:16 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-172.phx2.redhat.com [10.3.116.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 833F96685F for ; Thu, 14 Sep 2017 18:03:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 31641C004768 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Thu, 14 Sep 2017 14:03:09 -0400 Message-Id: <20170914180310.1426-6-jferlan@redhat.com> In-Reply-To: <20170914180310.1426-1-jferlan@redhat.com> References: <20170914180310.1426-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/6] conf: Move encryption validation 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.32]); Thu, 14 Sep 2017 18:59:03 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rather than checking during XML processing, move the check for valid into virDomainDiskDefParseValidate. Signed-off-by: John Ferlan --- src/conf/domain_conf.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 07bda1a36..09c5bc1ae 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8605,7 +8605,23 @@ virDomainDiskDefParseValidate(const virDomainDiskDef= *def) } } =20 - return virDomainDiskSourceDefParseAuthValidate(def->src); + if (virDomainDiskSourceDefParseAuthValidate(def->src) < 0) + return -1; + + if (def->src->encryption) { + virStorageEncryptionPtr encryption =3D def->src->encryption; + + if (encryption->format =3D=3D VIR_STORAGE_ENCRYPTION_FORMAT_LUKS && + encryption->encinfo.cipher_name) { + + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("supplying the for a domain is " + "unnecessary")); + return -1; + } + } + + return 0; } =20 =20 @@ -9095,17 +9111,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlop= t, def->startupPolicy =3D val; } =20 - if (encryption) { - if (encryption->format =3D=3D VIR_STORAGE_ENCRYPTION_FORMAT_LUKS && - encryption->encinfo.cipher_name) { - - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("supplying the for a domain is " - "unnecessary")); - goto error; - } - } - def->dst =3D target; target =3D NULL; def->src->auth =3D authdef; --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 17:39:33 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 1505413415408279.4808809801067; Thu, 14 Sep 2017 11:23:35 -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 2A8904A6F1; Thu, 14 Sep 2017 18:23:34 +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 B5F3836F9; Thu, 14 Sep 2017 18:23:33 +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 7C4A91806107; Thu, 14 Sep 2017 18:23:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8EI3HLo018352 for ; Thu, 14 Sep 2017 14:03:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1D8E517103; Thu, 14 Sep 2017 18:03:17 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-172.phx2.redhat.com [10.3.116.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB7B56682E for ; Thu, 14 Sep 2017 18:03:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2A8904A6F1 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Thu, 14 Sep 2017 14:03:10 -0400 Message-Id: <20170914180310.1426-7-jferlan@redhat.com> In-Reply-To: <20170914180310.1426-1-jferlan@redhat.com> References: <20170914180310.1426-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 6/6] conf: Use virXMLFormatElement to format disk source network 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.38]); Thu, 14 Sep 2017 18:23:34 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Commit id 'e02ff020cac' neglected to use the attrBuf and childBuf in the virDomainDiskSourceFormatNetwork call. So make the necessary alterations to allow usage. Signed-off-by: John Ferlan --- src/conf/domain_conf.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 09c5bc1ae..a8771a3a4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -21674,13 +21674,14 @@ virDomainSourceDefFormatSeclabel(virBufferPtr buf, =20 =20 static int -virDomainDiskSourceFormatNetwork(virBufferPtr buf, +virDomainDiskSourceFormatNetwork(virBufferPtr attrBuf, + virBufferPtr childBuf, virStorageSourcePtr src) { size_t n; char *path =3D NULL; =20 - virBufferAsprintf(buf, "protocol)); =20 if (src->volume) { @@ -21688,36 +21689,29 @@ virDomainDiskSourceFormatNetwork(virBufferPtr buf, return -1; } =20 - virBufferEscapeString(buf, " name=3D'%s'", path ? path : src->path); + virBufferEscapeString(attrBuf, " name=3D'%s'", path ? path : src->path= ); =20 VIR_FREE(path); =20 - if (src->nhosts =3D=3D 0 && !src->snapshot && !src->configFile) { - virBufferAddLit(buf, "/>\n"); - } else { - virBufferAddLit(buf, ">\n"); - virBufferAdjustIndent(buf, 2); + if (src->nhosts > 0 || src->snapshot || src->configFile) { =20 for (n =3D 0; n < src->nhosts; n++) { - virBufferAddLit(buf, "hosts[n].name); + virBufferAddLit(childBuf, "hosts[n].= name); =20 if (src->hosts[n].port) - virBufferAsprintf(buf, " port=3D'%u'", src->hosts[n].port); + virBufferAsprintf(childBuf, " port=3D'%u'", src->hosts[n].= port); =20 if (src->hosts[n].transport) - virBufferAsprintf(buf, " transport=3D'%s'", + virBufferAsprintf(childBuf, " transport=3D'%s'", virStorageNetHostTransportTypeToString(s= rc->hosts[n].transport)); =20 - virBufferEscapeString(buf, " socket=3D'%s'", src->hosts[n].soc= ket); - virBufferAddLit(buf, "/>\n"); + virBufferEscapeString(childBuf, " socket=3D'%s'", src->hosts[n= ].socket); + virBufferAddLit(childBuf, "/>\n"); } =20 - virBufferEscapeString(buf, "\n", src->snaps= hot); - virBufferEscapeString(buf, "\n", src->configF= ile); - - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); + virBufferEscapeString(childBuf, "\n", src->= snapshot); + virBufferEscapeString(childBuf, "\n", src->co= nfigFile); } =20 return 0; @@ -21766,7 +21760,7 @@ virDomainDiskSourceFormatInternal(virBufferPtr buf, break; =20 case VIR_STORAGE_TYPE_NETWORK: - if (virDomainDiskSourceFormatNetwork(buf, src) < 0) + if (virDomainDiskSourceFormatNetwork(&attrBuf, &childBuf, src)= < 0) goto error; break; =20 --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list