Blame SOURCES/0004-vgimportclone-fix-importing-PV-without-metadata.patch

337b9c
From 8f7b4456ad93c3907a82fd03d0feceb9785e3bfc Mon Sep 17 00:00:00 2001
337b9c
From: David Teigland <teigland@redhat.com>
337b9c
Date: Thu, 5 Jan 2023 14:28:31 -0600
337b9c
Subject: [PATCH 1/3] vgimportclone: fix importing PV without metadata
337b9c
337b9c
If one of the PVs in the VG does not hold metadata, then the
337b9c
command would fail, thinking that PV was from a different VG.
337b9c
Also add missing free on that error path.
337b9c
337b9c
(cherry picked from commit c4b898a53eec39bc28b5451e7fde87945303a644)
337b9c
---
337b9c
 tools/vgimportclone.c | 6 ++++--
337b9c
 1 file changed, 4 insertions(+), 2 deletions(-)
337b9c
337b9c
diff --git a/tools/vgimportclone.c b/tools/vgimportclone.c
337b9c
index 60ef20762..93fa3b18d 100644
337b9c
--- a/tools/vgimportclone.c
337b9c
+++ b/tools/vgimportclone.c
337b9c
@@ -203,7 +203,7 @@ int vgimportclone(struct cmd_context *cmd, int argc, char **argv)
337b9c
 	struct device *dev;
337b9c
 	struct device_list *devl;
337b9c
 	struct dm_list other_devs;
337b9c
-	struct volume_group *vg, *error_vg;
337b9c
+	struct volume_group *vg, *error_vg = NULL;
337b9c
 	const char *vgname;
337b9c
 	char base_vgname[NAME_LEN] = { 0 };
337b9c
 	char tmp_vgname[NAME_LEN] = { 0 };
337b9c
@@ -322,7 +322,7 @@ int vgimportclone(struct cmd_context *cmd, int argc, char **argv)
337b9c
 			goto out;
337b9c
 		}
337b9c
 
337b9c
-		if (!(vgname = lvmcache_vgname_from_info(info))) {
337b9c
+		if (!(vgname = lvmcache_vgname_from_info(info)) || is_orphan_vg(vgname)) {
337b9c
 			/* The PV may not have metadata, this will be resolved in
337b9c
 			   the process_each_vg/vg_read at the end. */
337b9c
 			continue;
337b9c
@@ -503,6 +503,8 @@ retry_name:
337b9c
 	}
337b9c
 	ret = ECMD_PROCESSED;
337b9c
 out:
337b9c
+	if (error_vg)
337b9c
+		release_vg(error_vg);
337b9c
 	unlock_devices_file(cmd);
337b9c
 	return ret;
337b9c
 }
337b9c
-- 
337b9c
2.39.1
337b9c