[guestfs-tools PATCH] sysprep: remove system-local NetworkManager connection profiles (keyfiles)
by Laszlo Ersek
Add a simple (default) operation to remove
/etc/NetworkManager/system-connections/*.nmconnection
which arguably carry stale information after the initial creation of the
system disk image.
Note: no side effect callback is invoked. Before commit 576f1541a20c
("sysprep: Use customize module for customizing the guest after
sysprepping.", 2014-03-25), the "delete" operation had been native to
virt-sysprep ("sysprep/sysprep_operation_delete.ml"), and it didn't invoke
side effects. In said commit, "delete" was delegated to virt-customize,
and that was when "side_effects#created_file" was introduced (most likely)
as a catch-all. (We still have the "XXX Did we?" comment today.)
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1980922
Signed-off-by: Laszlo Ersek <lersek(a)redhat.com>
---
Notes:
Tested with:
$ virt-sysprep -v -x --enable=net-nmconn \
-a CentOS-Stream-GenericCloud-9-20211201.1.x86_64.qcow2
(Download directory:
<https://cloud.centos.org/centos/9-stream/x86_64/images/>.)
Log excerpt:
> libguestfs: trace: inspect_get_distro = "centos"
> libguestfs: trace: glob_expand "/etc/NetworkManager/system-connections/*.nmconnection"
> [...]
> libguestfs: trace: glob_expand = ["/etc/NetworkManager/system-connections/ens3.nmconnection"]
> libguestfs: trace: rm_f "/etc/NetworkManager/system-connections/ens3.nmconnection"
> [...]
> libguestfs: trace: rm_f = 0
And indeed the file got removed (checked with guestfish afterwards).
sysprep/Makefile.am | 1 +
sysprep/sysprep_operation_net_nmconn.ml | 43 ++++++++++++++++++++
2 files changed, 44 insertions(+)
diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am
index e213244bc17a..0e3afc8a01c7 100644
--- a/sysprep/Makefile.am
+++ b/sysprep/Makefile.am
@@ -52,6 +52,7 @@ operations = \
mail_spool \
net_hostname \
net_hwaddr \
+ net_nmconn \
pacct_log \
package_manager_cache \
pam_data \
diff --git a/sysprep/sysprep_operation_net_nmconn.ml b/sysprep/sysprep_operation_net_nmconn.ml
new file mode 100644
index 000000000000..2d8667f19dfa
--- /dev/null
+++ b/sysprep/sysprep_operation_net_nmconn.ml
@@ -0,0 +1,43 @@
+(* virt-sysprep
+ * Copyright (C) 2012-2021 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *)
+
+open Common_gettext.Gettext
+open Sysprep_operation
+
+let glob = "/etc/NetworkManager/system-connections/*.nmconnection"
+
+let net_nmconn_perform (g : Guestfs.guestfs) root side_effects =
+ let typ = g#inspect_get_type root in
+ let distro = g#inspect_get_distro root in
+ match typ, distro with
+ | "linux", ("fedora"|"rhel"|"centos"|"scientificlinux"|"oraclelinux"|
+ "redhat-based") -> Array.iter g#rm_f (g#glob_expand glob)
+ | _ -> ()
+
+let op = {
+ defaults with
+ name = "net-nmconn";
+ enabled_by_default = true;
+ heading = s_"Remove system-local NetworkManager connection profiles \
+ (keyfiles)";
+ pod_description = Some (s_"On Fedora and Red Hat Enterprise Linux, remove \
+ the C<" ^ glob ^ "> files.");
+ perform_on_filesystems = Some net_nmconn_perform;
+}
+
+let () = register_operation op
base-commit: 05946b64f896b334a337f6982033e0e98545207b
--
2.19.1.3.g30247aa5d201
2 years, 11 months
[virt-v2v wave 2 PATCH v2 00/16] replace QXL (and Cirrus) with standard VGA
by Laszlo Ersek
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1961107
v1: https://listman.redhat.com/archives/libguestfs/2021-November/msg00150.html
Please see the v2 changes (relative to the v1 posting) in the Notes
sections of the individual patches.
The v2v QE team at Red Hat has helped a lot with testing (see again the
per-patch v2 notes); the only part that still needs good test results is
the OVF output.
Cc: Arik Hadas <ahadas(a)redhat.com>
Cc: Fabian Deutsch <fdeutsch(a)redhat.com>
Cc: Gerd Hoffmann <kraxel(a)redhat.com>
Cc: Kashyap Chamarthy <kchamart(a)redhat.com>
Cc: Liran Rotenberg <lrotenbe(a)redhat.com>
Thanks!
Laszlo
Laszlo Ersek (16):
lib/types: introduce "Standard_VGA" constructor for
"guestcaps_video_type"
output: handle Standard_VGA in the libvirt XML and QEMU cmdline
formats
output: handle Standard_VGA in the OpenStack format
output: handle Standard_VGA in the JSON format
convert_linux: flip target display to Standard_VGA
convert/windows_virtio: flip target display to Standard_VGA
lib/create_ovf: fix "qxl_resourcetype" misnomer
lib/create_ovf: place a standard VGA video device in the OVF xml
lib/types: remove "QXL" constructor for "guestcaps_video_type"
tests: remove the fake Windows guest drivers for the QXL device
tests: remove the remaining QXL references (for completeness)
lib/types: remove "Cirrus" constructor for "guestcaps_video_type"
convert/windows_virtio: fix documentation of "install_drivers" return
type
lib/types: remove "guestcaps_video_type"
lib/types: replace "source_video" type with plain "string"
lib/types: remove the "source.s_video" field
convert/convert_linux.ml | 3 +--
convert/convert_windows.ml | 2 --
convert/windows_virtio.ml | 18 ++-------------
convert/windows_virtio.mli | 11 +++++-----
input/input.ml | 2 --
input/parse_domain_from_vmx.ml | 8 -------
input/parse_libvirt_xml.ml | 16 --------------
lib/create_ovf.ml | 22 +++++++++++--------
lib/types.ml | 23 --------------------
lib/types.mli | 18 ++++-----------
output/create_json.ml | 5 +----
output/create_libvirt_xml.ml | 4 +---
output/openstack_image_properties.ml | 5 +----
output/output.ml | 3 +--
test-data/fake-virtio-win/Makefile.am | 16 --------------
test-data/fake-virtio-win/drivers/amd64/Win2008R2/qxl.cat | 1 -
test-data/fake-virtio-win/drivers/amd64/Win2008R2/qxl.inf | 2 --
test-data/fake-virtio-win/drivers/amd64/Win2008R2/qxl.sys | 1 -
test-data/fake-virtio-win/drivers/amd64/Win2008R2/qxldd.dll | 1 -
test-data/fake-virtio-win/drivers/amd64/Win7/qxl.cat | 1 -
test-data/fake-virtio-win/drivers/amd64/Win7/qxl.inf | 2 --
test-data/fake-virtio-win/drivers/amd64/Win7/qxl.sys | 1 -
test-data/fake-virtio-win/drivers/amd64/Win7/qxldd.dll | 1 -
test-data/fake-virtio-win/drivers/i386/Win7/qxl.cat | 1 -
test-data/fake-virtio-win/drivers/i386/Win7/qxl.inf | 2 --
test-data/fake-virtio-win/drivers/i386/Win7/qxl.sys | 1 -
test-data/fake-virtio-win/drivers/i386/Win7/qxldd.dll | 1 -
test-data/fake-virtio-win/drivers/i386/WinXP/qxl.cat | 1 -
test-data/fake-virtio-win/drivers/i386/WinXP/qxl.inf | 2 --
test-data/fake-virtio-win/drivers/i386/WinXP/qxl.sys | 1 -
test-data/fake-virtio-win/drivers/i386/WinXP/qxldd.dll | 1 -
test-data/phony-guests/guests.xml.in | 2 +-
tests/test-v2v-i-ova-formats.expected | 1 -
tests/test-v2v-i-ova-gz.expected | 1 -
tests/test-v2v-i-ova-snapshots.expected | 1 -
tests/test-v2v-i-ova-snapshots.expected2 | 1 -
tests/test-v2v-i-ova-subfolders.expected | 1 -
tests/test-v2v-i-ova-subfolders.expected2 | 1 -
tests/test-v2v-i-ova-tar.expected | 1 -
tests/test-v2v-i-ova-tar.expected2 | 1 -
tests/test-v2v-i-ova-two-disks.expected | 1 -
tests/test-v2v-i-ova-two-disks.expected2 | 1 -
tests/test-v2v-i-ova.xml | 2 +-
tests/test-v2v-i-vmx-1.expected | 1 -
tests/test-v2v-i-vmx-2.expected | 1 -
tests/test-v2v-i-vmx-3.expected | 1 -
tests/test-v2v-i-vmx-4.expected | 1 -
tests/test-v2v-i-vmx-5.expected | 1 -
tests/test-v2v-in-place.sh | 2 +-
tests/test-v2v-o-rhv.ovf.expected | 4 ++--
tests/test-v2v-o-vdsm-options.ovf.expected | 4 ++--
tests/test-v2v-print-source.expected | 1 -
tests/test-v2v-print-source.xml.in | 2 +-
tests/test-v2v-windows-conversion.sh | 2 +-
v2v/v2v_unit_tests.ml | 16 --------------
55 files changed, 38 insertions(+), 188 deletions(-)
delete mode 100644 test-data/fake-virtio-win/drivers/amd64/Win2008R2/qxl.cat
delete mode 100644 test-data/fake-virtio-win/drivers/amd64/Win2008R2/qxl.inf
delete mode 100644 test-data/fake-virtio-win/drivers/amd64/Win2008R2/qxl.sys
delete mode 100644 test-data/fake-virtio-win/drivers/amd64/Win2008R2/qxldd.dll
delete mode 100644 test-data/fake-virtio-win/drivers/amd64/Win7/qxl.cat
delete mode 100644 test-data/fake-virtio-win/drivers/amd64/Win7/qxl.inf
delete mode 100644 test-data/fake-virtio-win/drivers/amd64/Win7/qxl.sys
delete mode 100644 test-data/fake-virtio-win/drivers/amd64/Win7/qxldd.dll
delete mode 100644 test-data/fake-virtio-win/drivers/i386/Win7/qxl.cat
delete mode 100644 test-data/fake-virtio-win/drivers/i386/Win7/qxl.inf
delete mode 100644 test-data/fake-virtio-win/drivers/i386/Win7/qxl.sys
delete mode 100644 test-data/fake-virtio-win/drivers/i386/Win7/qxldd.dll
delete mode 100644 test-data/fake-virtio-win/drivers/i386/WinXP/qxl.cat
delete mode 100644 test-data/fake-virtio-win/drivers/i386/WinXP/qxl.inf
delete mode 100644 test-data/fake-virtio-win/drivers/i386/WinXP/qxl.sys
delete mode 100644 test-data/fake-virtio-win/drivers/i386/WinXP/qxldd.dll
base-commit: ddc96fc5aae4c0249f7485c728ccb102e8301424
--
2.19.1.3.g30247aa5d201
2 years, 11 months