From nobody Mon Apr 29 14:28:39 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1518620607072431.4255138034048; Wed, 14 Feb 2018 07:03:27 -0800 (PST) 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 D0CC87485B; Wed, 14 Feb 2018 15:03:24 +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 A0D2F60467; Wed, 14 Feb 2018 15:03:24 +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 43DCB18033EA; Wed, 14 Feb 2018 15:03:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1EEw8rn017118 for ; Wed, 14 Feb 2018 09:58:09 -0500 Received: by smtp.corp.redhat.com (Postfix) id D9DF0B3011; Wed, 14 Feb 2018 14:58:08 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 65CB61C707; Wed, 14 Feb 2018 14:58:08 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 14 Feb 2018 15:57:24 +0100 Message-Id: <4fae7d8450ee2d202265751cb8376e467c3bc897.1518618392.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 1/3] virsh: detach-disk: Add --print-xml switch 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.26]); Wed, 14 Feb 2018 15:03:25 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Similarly to other commands add an argument which allows to check the XML which would be used to execute the operation instead. Signed-off-by: Peter Krempa --- tools/virsh-domain.c | 10 ++++++++++ tools/virsh.pod | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 5a0e0c1b21..c10bf184f9 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -12432,6 +12432,10 @@ static const vshCmdOptDef opts_detach_disk[] =3D { VIRSH_COMMON_OPT_DOMAIN_CONFIG, VIRSH_COMMON_OPT_DOMAIN_LIVE, VIRSH_COMMON_OPT_DOMAIN_CURRENT, + {.name =3D "print-xml", + .type =3D VSH_OT_BOOL, + .help =3D N_("print XML document rather than attach the interface") + }, {.name =3D NULL} }; @@ -12487,6 +12491,12 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd) goto cleanup; } + if (vshCommandOptBool(cmd, "print-xml")) { + vshPrint(ctl, "%s", disk_xml); + functionReturn =3D true; + goto cleanup; + } + if (flags !=3D 0 || current) ret =3D virDomainDetachDeviceFlags(dom, disk_xml, flags); else diff --git a/tools/virsh.pod b/tools/virsh.pod index 69cc42338d..8f0e8d74b0 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -3113,6 +3113,7 @@ I<--persistent>. =3Ditem B I I [[[I<--live>] [I<--config>] | [I<--current>]] | [I<--persistent>]] +[I<--print-xml>] Detach a disk device from a domain. The I is the device as seen from the domain. @@ -3130,6 +3131,9 @@ an offline domain, and like I<--live> I<--config> for= a running domain. Note that older versions of virsh used I<--config> as an alias for I<--persistent>. +If B<--print-xml> is specified, then the XML which would be used to detach= the +disk is printed instead. + =3Ditem B I I [I<--mac mac>] [[[I<--live>] [I<--config>] | [I<--current>]] | [I<--persistent>]] --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 14:28:39 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 151862043406722.34170163479166; Wed, 14 Feb 2018 07:00:34 -0800 (PST) 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 69BF2A328D; Wed, 14 Feb 2018 15:00: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 168FE67656; Wed, 14 Feb 2018 15:00:32 +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 C84A04A476; Wed, 14 Feb 2018 15:00:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1EEw97U017125 for ; Wed, 14 Feb 2018 09:58:09 -0500 Received: by smtp.corp.redhat.com (Postfix) id 91950B3016; Wed, 14 Feb 2018 14:58:09 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1DA25B3015; Wed, 14 Feb 2018 14:58:08 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 14 Feb 2018 15:57:25 +0100 Message-Id: <2798d6f8e7160bc14fe7419c9426429f02e170f5.1518618392.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 2/3] util: storage: Remove detected authentication data for backing chains 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.39]); Wed, 14 Feb 2018 15:00:32 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We can't really detect all the authentication data in a sane manner for disk backing chains. Since the old RBD parser parses it in some cases as the argv->XML convertor requires it, we can't just drop it. Instead clear any detected authentication data in the code paths related to disk backing chain lookup and fix the tests to cope with the change. https://bugzilla.redhat.com/show_bug.cgi?id=3D1544659 Signed-off-by: Peter Krempa --- src/util/virstoragefile.c | 8 ++++++++ tests/virstoragetest.c | 15 +++------------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 7f878039ba..440d2b3040 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3399,6 +3399,14 @@ virStorageSourceNewFromBackingAbsolute(const char *p= ath) goto error; virStorageSourceNetworkAssignDefaultPorts(ret); + + /* Some of the legacy parsers parse authentication data since they= are + * also used in other places. For backing store detection the + * authentication data would be invalid anyways, so we clear it */ + if (ret->auth) { + virStorageAuthDefFree(ret->auth); + ret->auth =3D NULL; + } } return ret; diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 6eed7134ed..a39c00bab5 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -308,8 +308,7 @@ static const char testStorageChainFormat[] =3D "type:%d\n" "format:%d\n" "protocol:%s\n" - "hostname:%s\n" - "secret:%s\n"; + "hostname:%s\n"; static int testStorageChain(const void *args) @@ -374,8 +373,7 @@ testStorageChain(const void *args) data->files[i]->type, data->files[i]->format, virStorageNetProtocolTypeToString(data->files[i]->= protocol), - NULLSTR(data->files[i]->hostname), - NULLSTR(data->files[i]->secret)) < 0 || + NULLSTR(data->files[i]->hostname)) < 0 || virAsprintf(&actual, testStorageChainFormat, i, NULLSTR(elt->path), @@ -386,8 +384,7 @@ testStorageChain(const void *args) elt->type, elt->format, virStorageNetProtocolTypeToString(elt->protocol), - NULLSTR(elt->nhosts ? elt->hosts[0].name : NULL), - NULLSTR(elt->auth ? elt->auth->username : NULL)) <= 0) { + NULLSTR(elt->nhosts ? elt->hosts[0].name : NULL)) = < 0) { VIR_FREE(expect); VIR_FREE(actual); goto cleanup; @@ -1361,9 +1358,6 @@ mymain(void) TEST_BACKING_PARSE("rbd:testshare:id=3Dasdf:mon_host=3Dexample.com", "\n" " \n" - " \n" - " \n" - " \n" "\n"); TEST_BACKING_PARSE("nbd:example.org:6000:exportname=3Dblah", "\n" @@ -1529,9 +1523,6 @@ mymain(void) "}", "\n" " \n" - " \n" - " \n" - " \n" "\n"); TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"rbd\"," "\"image\":\"test\"," --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 14:28:39 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1518620437147356.09858183671133; Wed, 14 Feb 2018 07:00:37 -0800 (PST) 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 9C759C024FE1; Wed, 14 Feb 2018 15:00:34 +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 6AF8A5D971; Wed, 14 Feb 2018 15:00:34 +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 2D04C4A475; Wed, 14 Feb 2018 15:00:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1EEwAlq017133 for ; Wed, 14 Feb 2018 09:58:10 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4A4A9B3015; Wed, 14 Feb 2018 14:58:10 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id C9D02B3034; Wed, 14 Feb 2018 14:58:09 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 14 Feb 2018 15:57:26 +0100 Message-Id: <829454ad2ac69d17ae59551f016592cd80de398a.1518618392.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 3/3] virsh: Remove sub-element in virshFindDisk 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.32]); Wed, 14 Feb 2018 15:00:35 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Previously we've removed the data only in virshUpdateDiskXML when changing the disk source for the CDROM since the backing store would be invalid. Move the code into a separate function and callit from virshFindDisk which is also used when detaching disk. The detaching code does not necessarily need to get the full backing chain since it will need to act on the one managed by libvirt anyways and this also takes care of problems when parts of the backing store were invalid due to buggy RBD detection code. Signed-off-by: Peter Krempa --- tools/virsh-domain.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index c10bf184f9..d158327bd7 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -12151,6 +12151,26 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *= cmd) return ret; } + +static void +virshDiskDropBackingStore(xmlNodePtr disk_node) +{ + xmlNodePtr tmp; + + for (tmp =3D disk_node->children; tmp; tmp =3D tmp->next) { + if (tmp->type !=3D XML_ELEMENT_NODE) + continue; + + if (virXMLNodeNameEqual(tmp, "backingStore")) { + xmlUnlinkNode(tmp); + xmlFreeNode(tmp); + + return; + } + } +} + + typedef enum { VIRSH_FIND_DISK_NORMAL, VIRSH_FIND_DISK_CHANGEABLE, @@ -12228,6 +12248,8 @@ virshFindDisk(const char *doc, if (STREQ_NULLABLE(tmp, path)) { ret =3D xmlCopyNode(obj->nodesetval->nodeTab[i], 1); + /* drop backing store since they are not needed here */ + virshDiskDropBackingStore(ret); VIR_FREE(tmp); goto cleanup; } @@ -12266,7 +12288,6 @@ virshUpdateDiskXML(xmlNodePtr disk_node, { xmlNodePtr tmp =3D NULL; xmlNodePtr source =3D NULL; - xmlNodePtr backingStore =3D NULL; xmlNodePtr target_node =3D NULL; xmlNodePtr text_node =3D NULL; char *device_type =3D NULL; @@ -12307,22 +12328,13 @@ virshUpdateDiskXML(xmlNodePtr disk_node, if (virXMLNodeNameEqual(tmp, "target")) target_node =3D tmp; - if (virXMLNodeNameEqual(tmp, "backingStore")) - backingStore =3D tmp; - /* * We've found all we needed. */ - if (source && target_node && backingStore) + if (source && target_node) break; } - /* drop the subtree since it would become invalid */ - if (backingStore) { - xmlUnlinkNode(backingStore); - xmlFreeNode(backingStore); - } - if (type =3D=3D VIRSH_UPDATE_DISK_XML_EJECT) { if (!source) { vshError(NULL, _("The disk device '%s' doesn't have media"), t= arget); --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list