|
|
ca2a74 |
From 37c002682a9e5b87d5793f1567c4ddfb8ca72d11 Mon Sep 17 00:00:00 2001
|
|
|
ca2a74 |
From: Laszlo Ersek <lersek@redhat.com>
|
|
|
ca2a74 |
Date: Sun, 10 Apr 2022 13:38:34 +0200
|
|
|
ca2a74 |
Subject: [PATCH] sysprep: remove lvm2's default "system.devices" file
|
|
|
ca2a74 |
|
|
|
ca2a74 |
(Background: lvm2 commit 83fe6e720f42, "device usage based on devices
|
|
|
ca2a74 |
file", 2021-02-23; first released in v2_03_12.)
|
|
|
ca2a74 |
|
|
|
ca2a74 |
"lvm pvscan" may be -- and in RHEL9, will soon be -- restricted to those
|
|
|
ca2a74 |
block devices whose WWIDs are listed in "/etc/lvm/devices/system.devices".
|
|
|
ca2a74 |
This is a problem when cloning a VM, as cloning may change the WWIDs of
|
|
|
ca2a74 |
the domain's disk devices, and then physical volumes underlying the guest
|
|
|
ca2a74 |
filesystems may not be found. Example:
|
|
|
ca2a74 |
<https://bugzilla.redhat.com/show_bug.cgi?id=2059545#c12>.
|
|
|
ca2a74 |
|
|
|
ca2a74 |
Add the "lvm-system-devices" operation for removing this file, so that
|
|
|
ca2a74 |
"lvm pvscan" investigate all block devices for PVs.
|
|
|
ca2a74 |
|
|
|
ca2a74 |
(Note that this operation is independent from "lvm-uuids". The libguestfs
|
|
|
ca2a74 |
appliance creates a pristine LVM_SYSTEM_DIR in "appliance/init" (see
|
|
|
ca2a74 |
libguestfs commit dd162d2cd56a), thus, when "lvm-uuids" calls "g#pvs" and
|
|
|
ca2a74 |
"g#vgs", those APIs can never be affected by an
|
|
|
ca2a74 |
"$LVM_SYSTEM_DIR/devices/system.devices" file.)
|
|
|
ca2a74 |
|
|
|
ca2a74 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2072493
|
|
|
ca2a74 |
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
ca2a74 |
Message-Id: <20220410113834.6258-1-lersek@redhat.com>
|
|
|
ca2a74 |
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
|
|
|
ca2a74 |
(cherry picked from commit 4fe8a03cd2d3e4570f4298245bb184ccdc4da0cd)
|
|
|
ca2a74 |
---
|
|
|
ca2a74 |
sysprep/Makefile.am | 1 +
|
|
|
ca2a74 |
.../sysprep_operation_lvm_system_devices.ml | 44 +++++++++++++++++++
|
|
|
ca2a74 |
2 files changed, 45 insertions(+)
|
|
|
ca2a74 |
create mode 100644 sysprep/sysprep_operation_lvm_system_devices.ml
|
|
|
ca2a74 |
|
|
|
ca2a74 |
diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am
|
|
|
ca2a74 |
index 0e3afc8a0..7d5e8aadf 100644
|
|
|
ca2a74 |
--- a/sysprep/Makefile.am
|
|
|
ca2a74 |
+++ b/sysprep/Makefile.am
|
|
|
ca2a74 |
@@ -46,6 +46,7 @@ operations = \
|
|
|
ca2a74 |
ipa_client \
|
|
|
ca2a74 |
kerberos_data \
|
|
|
ca2a74 |
kerberos_hostkeytab \
|
|
|
ca2a74 |
+ lvm_system_devices \
|
|
|
ca2a74 |
lvm_uuids \
|
|
|
ca2a74 |
logfiles \
|
|
|
ca2a74 |
machine_id \
|
|
|
ca2a74 |
diff --git a/sysprep/sysprep_operation_lvm_system_devices.ml b/sysprep/sysprep_operation_lvm_system_devices.ml
|
|
|
ca2a74 |
new file mode 100644
|
|
|
ca2a74 |
index 000000000..b41fa5dbc
|
|
|
ca2a74 |
--- /dev/null
|
|
|
ca2a74 |
+++ b/sysprep/sysprep_operation_lvm_system_devices.ml
|
|
|
ca2a74 |
@@ -0,0 +1,44 @@
|
|
|
ca2a74 |
+(* virt-sysprep
|
|
|
ca2a74 |
+ * Copyright (C) 2012-2022 Red Hat Inc.
|
|
|
ca2a74 |
+ *
|
|
|
ca2a74 |
+ * This program is free software; you can redistribute it and/or modify
|
|
|
ca2a74 |
+ * it under the terms of the GNU General Public License as published by
|
|
|
ca2a74 |
+ * the Free Software Foundation; either version 2 of the License, or
|
|
|
ca2a74 |
+ * (at your option) any later version.
|
|
|
ca2a74 |
+ *
|
|
|
ca2a74 |
+ * This program is distributed in the hope that it will be useful,
|
|
|
ca2a74 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
ca2a74 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
ca2a74 |
+ * GNU General Public License for more details.
|
|
|
ca2a74 |
+ *
|
|
|
ca2a74 |
+ * You should have received a copy of the GNU General Public License along
|
|
|
ca2a74 |
+ * with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
ca2a74 |
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
ca2a74 |
+ *)
|
|
|
ca2a74 |
+
|
|
|
ca2a74 |
+open Sysprep_operation
|
|
|
ca2a74 |
+open Common_gettext.Gettext
|
|
|
ca2a74 |
+
|
|
|
ca2a74 |
+module G = Guestfs
|
|
|
ca2a74 |
+
|
|
|
ca2a74 |
+let system_devices_file = "/etc/lvm/devices/system.devices"
|
|
|
ca2a74 |
+
|
|
|
ca2a74 |
+let rec lvm_system_devices_perform g root side_effects =
|
|
|
ca2a74 |
+ let typ = g#inspect_get_type root in
|
|
|
ca2a74 |
+ if typ = "linux" then g#rm_f system_devices_file
|
|
|
ca2a74 |
+
|
|
|
ca2a74 |
+let op = {
|
|
|
ca2a74 |
+ defaults with
|
|
|
ca2a74 |
+ name = "lvm-system-devices";
|
|
|
ca2a74 |
+ enabled_by_default = true;
|
|
|
ca2a74 |
+ heading = s_"Remove LVM2 system.devices file";
|
|
|
ca2a74 |
+ pod_description =
|
|
|
ca2a74 |
+ Some (s_"On Linux guests, LVM2's scanning for physical volumes (PVs) may \
|
|
|
ca2a74 |
+ be restricted to those block devices whose WWIDs are listed in \
|
|
|
ca2a74 |
+ C<" ^ system_devices_file ^ ">. When cloning VMs, WWIDs may \
|
|
|
ca2a74 |
+ change, breaking C<lvm pvscan>. Remove \
|
|
|
ca2a74 |
+ C<" ^ system_devices_file ^ ">.");
|
|
|
ca2a74 |
+ perform_on_filesystems = Some lvm_system_devices_perform;
|
|
|
ca2a74 |
+}
|
|
|
ca2a74 |
+
|
|
|
ca2a74 |
+let () = register_operation op
|
|
|
ca2a74 |
--
|
|
|
ca2a74 |
2.31.1
|
|
|
ca2a74 |
|