Rebase to guestfs-tools 1.50.0
resolves: rhbz#2168626
This commit is contained in:
parent
ae2b06d923
commit
0fc67208a3
@ -1,4 +1,4 @@
|
|||||||
From bbdc10642eff480246271f98180733f732c306b3 Mon Sep 17 00:00:00 2001
|
From 3c9689e96d8b0fb6476eff22953b9c512421b9fc Mon Sep 17 00:00:00 2001
|
||||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
Date: Tue, 7 Jul 2015 09:28:03 -0400
|
Date: Tue, 7 Jul 2015 09:28:03 -0400
|
||||||
Subject: [PATCH] RHEL: Reject use of libguestfs-winsupport features except for
|
Subject: [PATCH] RHEL: Reject use of libguestfs-winsupport features except for
|
||||||
@ -11,7 +11,7 @@ edits.
|
|||||||
1 file changed, 1 insertion(+)
|
1 file changed, 1 insertion(+)
|
||||||
|
|
||||||
diff --git a/test-data/phony-guests/make-windows-img.sh b/test-data/phony-guests/make-windows-img.sh
|
diff --git a/test-data/phony-guests/make-windows-img.sh b/test-data/phony-guests/make-windows-img.sh
|
||||||
index 30908a918..73cf5144e 100755
|
index 16debd129..1c13ddac3 100755
|
||||||
--- a/test-data/phony-guests/make-windows-img.sh
|
--- a/test-data/phony-guests/make-windows-img.sh
|
||||||
+++ b/test-data/phony-guests/make-windows-img.sh
|
+++ b/test-data/phony-guests/make-windows-img.sh
|
||||||
@@ -37,6 +37,7 @@ fi
|
@@ -37,6 +37,7 @@ fi
|
@ -1,100 +0,0 @@
|
|||||||
From 37c002682a9e5b87d5793f1567c4ddfb8ca72d11 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Date: Sun, 10 Apr 2022 13:38:34 +0200
|
|
||||||
Subject: [PATCH] sysprep: remove lvm2's default "system.devices" file
|
|
||||||
|
|
||||||
(Background: lvm2 commit 83fe6e720f42, "device usage based on devices
|
|
||||||
file", 2021-02-23; first released in v2_03_12.)
|
|
||||||
|
|
||||||
"lvm pvscan" may be -- and in RHEL9, will soon be -- restricted to those
|
|
||||||
block devices whose WWIDs are listed in "/etc/lvm/devices/system.devices".
|
|
||||||
This is a problem when cloning a VM, as cloning may change the WWIDs of
|
|
||||||
the domain's disk devices, and then physical volumes underlying the guest
|
|
||||||
filesystems may not be found. Example:
|
|
||||||
<https://bugzilla.redhat.com/show_bug.cgi?id=2059545#c12>.
|
|
||||||
|
|
||||||
Add the "lvm-system-devices" operation for removing this file, so that
|
|
||||||
"lvm pvscan" investigate all block devices for PVs.
|
|
||||||
|
|
||||||
(Note that this operation is independent from "lvm-uuids". The libguestfs
|
|
||||||
appliance creates a pristine LVM_SYSTEM_DIR in "appliance/init" (see
|
|
||||||
libguestfs commit dd162d2cd56a), thus, when "lvm-uuids" calls "g#pvs" and
|
|
||||||
"g#vgs", those APIs can never be affected by an
|
|
||||||
"$LVM_SYSTEM_DIR/devices/system.devices" file.)
|
|
||||||
|
|
||||||
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2072493
|
|
||||||
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Message-Id: <20220410113834.6258-1-lersek@redhat.com>
|
|
||||||
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
|
|
||||||
(cherry picked from commit 4fe8a03cd2d3e4570f4298245bb184ccdc4da0cd)
|
|
||||||
---
|
|
||||||
sysprep/Makefile.am | 1 +
|
|
||||||
.../sysprep_operation_lvm_system_devices.ml | 44 +++++++++++++++++++
|
|
||||||
2 files changed, 45 insertions(+)
|
|
||||||
create mode 100644 sysprep/sysprep_operation_lvm_system_devices.ml
|
|
||||||
|
|
||||||
diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am
|
|
||||||
index 0e3afc8a0..7d5e8aadf 100644
|
|
||||||
--- a/sysprep/Makefile.am
|
|
||||||
+++ b/sysprep/Makefile.am
|
|
||||||
@@ -46,6 +46,7 @@ operations = \
|
|
||||||
ipa_client \
|
|
||||||
kerberos_data \
|
|
||||||
kerberos_hostkeytab \
|
|
||||||
+ lvm_system_devices \
|
|
||||||
lvm_uuids \
|
|
||||||
logfiles \
|
|
||||||
machine_id \
|
|
||||||
diff --git a/sysprep/sysprep_operation_lvm_system_devices.ml b/sysprep/sysprep_operation_lvm_system_devices.ml
|
|
||||||
new file mode 100644
|
|
||||||
index 000000000..b41fa5dbc
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/sysprep/sysprep_operation_lvm_system_devices.ml
|
|
||||||
@@ -0,0 +1,44 @@
|
|
||||||
+(* virt-sysprep
|
|
||||||
+ * Copyright (C) 2012-2022 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 Sysprep_operation
|
|
||||||
+open Common_gettext.Gettext
|
|
||||||
+
|
|
||||||
+module G = Guestfs
|
|
||||||
+
|
|
||||||
+let system_devices_file = "/etc/lvm/devices/system.devices"
|
|
||||||
+
|
|
||||||
+let rec lvm_system_devices_perform g root side_effects =
|
|
||||||
+ let typ = g#inspect_get_type root in
|
|
||||||
+ if typ = "linux" then g#rm_f system_devices_file
|
|
||||||
+
|
|
||||||
+let op = {
|
|
||||||
+ defaults with
|
|
||||||
+ name = "lvm-system-devices";
|
|
||||||
+ enabled_by_default = true;
|
|
||||||
+ heading = s_"Remove LVM2 system.devices file";
|
|
||||||
+ pod_description =
|
|
||||||
+ Some (s_"On Linux guests, LVM2's scanning for physical volumes (PVs) may \
|
|
||||||
+ be restricted to those block devices whose WWIDs are listed in \
|
|
||||||
+ C<" ^ system_devices_file ^ ">. When cloning VMs, WWIDs may \
|
|
||||||
+ change, breaking C<lvm pvscan>. Remove \
|
|
||||||
+ C<" ^ system_devices_file ^ ">.");
|
|
||||||
+ perform_on_filesystems = Some lvm_system_devices_perform;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+let () = register_operation op
|
|
||||||
--
|
|
||||||
2.31.1
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
From 888ecde429ef6fab9567359abae1e2d04d552666 Mon Sep 17 00:00:00 2001
|
From 10a4be467d84f5733cc696b7a0ed971fc1f35f3f Mon Sep 17 00:00:00 2001
|
||||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
Date: Mon, 21 Nov 2022 13:03:22 +0000
|
Date: Mon, 21 Nov 2022 13:03:22 +0000
|
||||||
Subject: [PATCH] RHEL: builder: Disable opensuse repository
|
Subject: [PATCH] RHEL: builder: Disable opensuse repository
|
@ -1,347 +0,0 @@
|
|||||||
From 5792f2e95bcddf476f2fe37e0bc4d97bd881d8fa Mon Sep 17 00:00:00 2001
|
|
||||||
From: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Date: Tue, 10 May 2022 12:50:46 +0200
|
|
||||||
Subject: [PATCH] adopt inversion of SELinux relabeling in virt-customize
|
|
||||||
|
|
||||||
Remove "--selinux-relabel" options.
|
|
||||||
|
|
||||||
Do not add any "--no-selinux-relabel" options; rely on the internal check
|
|
||||||
for SELinux support instead ("is_selinux_guest" in
|
|
||||||
"common/mlcustomize/SELinux_relabel.ml").
|
|
||||||
|
|
||||||
"--no-selinux-relabel" becomes a real option for virt-sysprep now.
|
|
||||||
(Again?)
|
|
||||||
|
|
||||||
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1554735
|
|
||||||
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2075718
|
|
||||||
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Message-Id: <20220510105046.15167-1-lersek@redhat.com>
|
|
||||||
Acked-by: Richard W.M. Jones <rjones@redhat.com>
|
|
||||||
[lersek@redhat.com: incorporate common submodule update]
|
|
||||||
(cherry picked from commit 19de3d1c8d4efb53565dbffe532d41ee9d25a832)
|
|
||||||
---
|
|
||||||
builder/templates/make-template.ml | 8 +-------
|
|
||||||
builder/virt-builder.pod | 20 ++++----------------
|
|
||||||
common | 2 +-
|
|
||||||
customize/customize_run.ml | 2 +-
|
|
||||||
customize/test-settings.sh | 3 ---
|
|
||||||
sysprep/main.ml | 2 --
|
|
||||||
sysprep/test-virt-sysprep-docs.sh | 2 +-
|
|
||||||
7 files changed, 8 insertions(+), 31 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/builder/templates/make-template.ml b/builder/templates/make-template.ml
|
|
||||||
index 6786fec19..b40789284 100755
|
|
||||||
--- a/builder/templates/make-template.ml
|
|
||||||
+++ b/builder/templates/make-template.ml
|
|
||||||
@@ -256,8 +256,7 @@ let rec main () =
|
|
||||||
printf "Sysprepping ...\n%!";
|
|
||||||
let cmd =
|
|
||||||
sprintf "virt-sysprep --quiet -a %s%s"
|
|
||||||
- (quote tmpout)
|
|
||||||
- (if is_selinux_os os then " --selinux-relabel" else "") in
|
|
||||||
+ (quote tmpout) in
|
|
||||||
if Sys.command cmd <> 0 then exit 1
|
|
||||||
);
|
|
||||||
|
|
||||||
@@ -480,11 +479,6 @@ and can_sysprep_os = function
|
|
||||||
| Debian _ | Ubuntu _ -> true
|
|
||||||
| FreeBSD _ | Windows _ -> false
|
|
||||||
|
|
||||||
-and is_selinux_os = function
|
|
||||||
- | RHEL _ | Alma _ | CentOS _ | CentOSStream _ | Fedora _ -> true
|
|
||||||
- | Debian _ | Ubuntu _
|
|
||||||
- | FreeBSD _ | Windows _ -> false
|
|
||||||
-
|
|
||||||
and needs_uefi os arch =
|
|
||||||
match os, arch with
|
|
||||||
| Fedora _, Armv7
|
|
||||||
diff --git a/builder/virt-builder.pod b/builder/virt-builder.pod
|
|
||||||
index f7dd6cdad..aeb505296 100644
|
|
||||||
--- a/builder/virt-builder.pod
|
|
||||||
+++ b/builder/virt-builder.pod
|
|
||||||
@@ -131,12 +131,6 @@ To update the installed packages to the latest version:
|
|
||||||
|
|
||||||
virt-builder debian-7 --update
|
|
||||||
|
|
||||||
-For guests which use SELinux, like Fedora and Red Hat Enterprise
|
|
||||||
-Linux, you may need to do SELinux relabelling after installing or
|
|
||||||
-updating packages (see L</SELINUX> below):
|
|
||||||
-
|
|
||||||
- virt-builder fedora-27 --update --selinux-relabel
|
|
||||||
-
|
|
||||||
=head2 Customizing the installation
|
|
||||||
|
|
||||||
There are many options that let you customize the installation. These
|
|
||||||
@@ -972,7 +966,7 @@ command line.
|
|
||||||
|
|
||||||
=item *
|
|
||||||
|
|
||||||
-SELinux relabelling is done (I<--selinux-relabel>).
|
|
||||||
+SELinux relabelling is done unless disabled with I<--no-selinux-relabel>.
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
@@ -1072,8 +1066,7 @@ A typical virt-builder command would be:
|
|
||||||
--install puppet \
|
|
||||||
--append-line '/etc/puppet/puppet.conf:[agent]' \
|
|
||||||
--append-line '/etc/puppet/puppet.conf:server = puppetmaster.example.com/' \
|
|
||||||
- --run-command 'systemctl enable puppet' \
|
|
||||||
- --selinux-relabel
|
|
||||||
+ --run-command 'systemctl enable puppet'
|
|
||||||
|
|
||||||
The precise instructions vary according to the Linux distro. For
|
|
||||||
further information see:
|
|
||||||
@@ -1753,14 +1746,14 @@ two possible strategies it can use to ensure correct labelling:
|
|
||||||
|
|
||||||
=over 4
|
|
||||||
|
|
||||||
-=item Using I<--selinux-relabel>
|
|
||||||
+=item Automatic relabeling
|
|
||||||
|
|
||||||
This runs L<setfiles(8)> just before finalizing the guest, which sets
|
|
||||||
SELinux labels correctly in the disk image.
|
|
||||||
|
|
||||||
This is the recommended method.
|
|
||||||
|
|
||||||
-=item I<--touch> F</.autorelabel>
|
|
||||||
+=item Using I<--no-selinux-relabel> I<--touch> F</.autorelabel>
|
|
||||||
|
|
||||||
Guest templates may already contain a file called F</.autorelabel> or
|
|
||||||
you may touch it.
|
|
||||||
@@ -1771,11 +1764,6 @@ them, which is normal and harmless.
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
-Please note that if your guest uses SELinux, and you are doing operations
|
|
||||||
-on it which might create new files or change existing ones, you are
|
|
||||||
-recommended to use I<--selinux-relabel>. This will help in making sure
|
|
||||||
-that files have the right SELinux labels.
|
|
||||||
-
|
|
||||||
=head1 MACHINE READABLE OUTPUT
|
|
||||||
|
|
||||||
The I<--machine-readable> option can be used to make the output more
|
|
||||||
Submodule common 0a231b3e6..48527b876:
|
|
||||||
diff --git a/common/mlcustomize/customize-options.pod b/common/mlcustomize/customize-options.pod
|
|
||||||
index 71b545d..a83c80a 100644
|
|
||||||
--- a/common/mlcustomize/customize-options.pod
|
|
||||||
+++ b/common/mlcustomize/customize-options.pod
|
|
||||||
@@ -206,6 +206,19 @@ the image was built, use this option.
|
|
||||||
|
|
||||||
See also: L</LOG FILE>.
|
|
||||||
|
|
||||||
+=item B<--no-selinux-relabel>
|
|
||||||
+
|
|
||||||
+Do not attempt to correct the SELinux labels of files in the guest.
|
|
||||||
+
|
|
||||||
+In such guests that support SELinux, customization automatically
|
|
||||||
+relabels files so that they have the correct SELinux label. (The
|
|
||||||
+relabeling is performed immediately, but if the operation fails,
|
|
||||||
+customization will instead touch F</.autorelabel> on the image to
|
|
||||||
+schedule a relabel operation for the next time the image boots.) This
|
|
||||||
+option disables the automatic relabeling.
|
|
||||||
+
|
|
||||||
+The option is a no-op for guests that do not support SELinux.
|
|
||||||
+
|
|
||||||
=item B<--password> USER:SELECTOR
|
|
||||||
|
|
||||||
Set the password for C<USER>. (Note this option does I<not>
|
|
||||||
@@ -297,16 +310,6 @@ It cannot delete directories, only regular files.
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
-=item B<--selinux-relabel>
|
|
||||||
-
|
|
||||||
-Relabel files in the guest so that they have the correct SELinux label.
|
|
||||||
-
|
|
||||||
-This will attempt to relabel files immediately, but if the operation fails
|
|
||||||
-this will instead touch F</.autorelabel> on the image to schedule a
|
|
||||||
-relabel operation for the next time the image boots.
|
|
||||||
-
|
|
||||||
-You should only use this option for guests which support SELinux.
|
|
||||||
-
|
|
||||||
=item B<--sm-attach> SELECTOR
|
|
||||||
|
|
||||||
Attach to a pool using C<subscription-manager>.
|
|
||||||
diff --git a/common/mlcustomize/customize-synopsis.pod b/common/mlcustomize/customize-synopsis.pod
|
|
||||||
index 5f18540..2520853 100644
|
|
||||||
--- a/common/mlcustomize/customize-synopsis.pod
|
|
||||||
+++ b/common/mlcustomize/customize-synopsis.pod
|
|
||||||
@@ -12,5 +12,5 @@
|
|
||||||
[--truncate-recursive PATH] [--timezone TIMEZONE] [--touch FILE]
|
|
||||||
[--uninstall PKG,PKG..] [--update] [--upload FILE:DEST]
|
|
||||||
[--write FILE:CONTENT] [--no-logfile]
|
|
||||||
- [--password-crypto md5|sha256|sha512] [--selinux-relabel]
|
|
||||||
+ [--password-crypto md5|sha256|sha512] [--no-selinux-relabel]
|
|
||||||
[--sm-credentials SELECTOR]
|
|
||||||
diff --git a/common/mlcustomize/customize_cmdline.ml b/common/mlcustomize/customize_cmdline.ml
|
|
||||||
index 9326baa..5d404e8 100644
|
|
||||||
--- a/common/mlcustomize/customize_cmdline.ml
|
|
||||||
+++ b/common/mlcustomize/customize_cmdline.ml
|
|
||||||
@@ -109,8 +109,8 @@ and flags = {
|
|
||||||
(* --no-logfile *)
|
|
||||||
password_crypto : Password.password_crypto option;
|
|
||||||
(* --password-crypto md5|sha256|sha512 *)
|
|
||||||
- selinux_relabel : bool;
|
|
||||||
- (* --selinux-relabel *)
|
|
||||||
+ no_selinux_relabel : bool;
|
|
||||||
+ (* --no-selinux-relabel *)
|
|
||||||
sm_credentials : Subscription_manager.sm_credentials option;
|
|
||||||
(* --sm-credentials SELECTOR *)
|
|
||||||
}
|
|
||||||
@@ -121,7 +121,7 @@ let rec argspec () =
|
|
||||||
let ops = ref [] in
|
|
||||||
let scrub_logfile = ref false in
|
|
||||||
let password_crypto = ref None in
|
|
||||||
- let selinux_relabel = ref false in
|
|
||||||
+ let no_selinux_relabel = ref false in
|
|
||||||
let sm_credentials = ref None in
|
|
||||||
|
|
||||||
let rec get_ops () = {
|
|
||||||
@@ -131,7 +131,7 @@ let rec argspec () =
|
|
||||||
and get_flags () = {
|
|
||||||
scrub_logfile = !scrub_logfile;
|
|
||||||
password_crypto = !password_crypto;
|
|
||||||
- selinux_relabel = !selinux_relabel;
|
|
||||||
+ no_selinux_relabel = !no_selinux_relabel;
|
|
||||||
sm_credentials = !sm_credentials;
|
|
||||||
}
|
|
||||||
in
|
|
||||||
@@ -459,11 +459,11 @@ let rec argspec () =
|
|
||||||
),
|
|
||||||
Some "md5|sha256|sha512", "When the virt tools change or set a password in the guest, this\noption sets the password encryption of that password to\nC<md5>, C<sha256> or C<sha512>.\n\nC<sha256> and C<sha512> require glibc E<ge> 2.7 (check crypt(3) inside\nthe guest).\n\nC<md5> will work with relatively old Linux guests (eg. RHEL 3), but\nis not secure against modern attacks.\n\nThe default is C<sha512> unless libguestfs detects an old guest that\ndidn't have support for SHA-512, in which case it will use C<md5>.\nYou can override libguestfs by specifying this option.\n\nNote this does not change the default password encryption used\nby the guest when you create new user accounts inside the guest.\nIf you want to do that, then you should use the I<--edit> option\nto modify C</etc/sysconfig/authconfig> (Fedora, RHEL) or\nC</etc/pam.d/common-password> (Debian, Ubuntu).";
|
|
||||||
(
|
|
||||||
- [ L"selinux-relabel" ],
|
|
||||||
- Getopt.Set selinux_relabel,
|
|
||||||
- s_"Relabel files with correct SELinux labels"
|
|
||||||
+ [ L"no-selinux-relabel" ],
|
|
||||||
+ Getopt.Set no_selinux_relabel,
|
|
||||||
+ s_"Do not relabel files with correct SELinux labels"
|
|
||||||
),
|
|
||||||
- None, "Relabel files in the guest so that they have the correct SELinux label.\n\nThis will attempt to relabel files immediately, but if the operation fails\nthis will instead touch F</.autorelabel> on the image to schedule a\nrelabel operation for the next time the image boots.\n\nYou should only use this option for guests which support SELinux.";
|
|
||||||
+ None, "Do not attempt to correct the SELinux labels of files in the guest.\n\nIn such guests that support SELinux, customization automatically\nrelabels files so that they have the correct SELinux label. (The\nrelabeling is performed immediately, but if the operation fails,\ncustomization will instead touch F</.autorelabel> on the image to\nschedule a relabel operation for the next time the image boots.) This\noption disables the automatic relabeling.\n\nThe option is a no-op for guests that do not support SELinux.";
|
|
||||||
(
|
|
||||||
[ L"sm-credentials" ],
|
|
||||||
Getopt.String (
|
|
||||||
diff --git a/common/mlcustomize/customize_cmdline.mli b/common/mlcustomize/customize_cmdline.mli
|
|
||||||
index 14eda49..7ee882a 100644
|
|
||||||
--- a/common/mlcustomize/customize_cmdline.mli
|
|
||||||
+++ b/common/mlcustomize/customize_cmdline.mli
|
|
||||||
@@ -101,8 +101,8 @@ and flags = {
|
|
||||||
(* --no-logfile *)
|
|
||||||
password_crypto : Password.password_crypto option;
|
|
||||||
(* --password-crypto md5|sha256|sha512 *)
|
|
||||||
- selinux_relabel : bool;
|
|
||||||
- (* --selinux-relabel *)
|
|
||||||
+ no_selinux_relabel : bool;
|
|
||||||
+ (* --no-selinux-relabel *)
|
|
||||||
sm_credentials : Subscription_manager.sm_credentials option;
|
|
||||||
(* --sm-credentials SELECTOR *)
|
|
||||||
}
|
|
||||||
diff --git a/common/mlcustomize/test-firstboot.sh b/common/mlcustomize/test-firstboot.sh
|
|
||||||
index b906997..24c67f3 100755
|
|
||||||
--- a/common/mlcustomize/test-firstboot.sh
|
|
||||||
+++ b/common/mlcustomize/test-firstboot.sh
|
|
||||||
@@ -61,9 +61,6 @@ case "$guestname" in
|
|
||||||
extra[${#extra[*]}]='/etc/inittab:
|
|
||||||
s,^#([1-9].*respawn.*/sbin/getty.*),$1,'
|
|
||||||
;;
|
|
||||||
- fedora*|rhel*|centos*)
|
|
||||||
- extra[${#extra[*]}]='--selinux-relabel'
|
|
||||||
- ;;
|
|
||||||
*)
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
diff --git a/common/mlcustomize/test-selinuxrelabel.sh b/common/mlcustomize/test-selinuxrelabel.sh
|
|
||||||
index 86278c6..caf7521 100755
|
|
||||||
--- a/common/mlcustomize/test-selinuxrelabel.sh
|
|
||||||
+++ b/common/mlcustomize/test-selinuxrelabel.sh
|
|
||||||
@@ -41,13 +41,12 @@ virt-builder "$guestname" --quiet -o "$disk"
|
|
||||||
# Test #1: relabel with the default configuration works.
|
|
||||||
rm -f "$disk_overlay"
|
|
||||||
guestfish -- disk-create "$disk_overlay" qcow2 -1 backingfile:"$disk"
|
|
||||||
-virt-customize -a "$disk" --selinux-relabel
|
|
||||||
+virt-customize -a "$disk"
|
|
||||||
|
|
||||||
# Test #2: relabel with no SELINUXTYPE in the configuration.
|
|
||||||
rm -f "$disk_overlay"
|
|
||||||
guestfish -- disk-create "$disk_overlay" qcow2 -1 backingfile:"$disk"
|
|
||||||
virt-customize -a "$disk" \
|
|
||||||
- --edit /etc/selinux/config:"s,^SELINUXTYPE=,#&,g" \
|
|
||||||
- --selinux-relabel
|
|
||||||
+ --edit /etc/selinux/config:"s,^SELINUXTYPE=,#&,g"
|
|
||||||
|
|
||||||
rm "$disk" "$disk_overlay"
|
|
||||||
diff --git a/common/options/uri.c b/common/options/uri.c
|
|
||||||
index 6b696fc..84d393c 100644
|
|
||||||
--- a/common/options/uri.c
|
|
||||||
+++ b/common/options/uri.c
|
|
||||||
@@ -135,7 +135,7 @@ parse (const char *arg, char **path_ret, char **protocol_ret,
|
|
||||||
socket = query_get (uri, "socket");
|
|
||||||
|
|
||||||
if (uri->server && STRNEQ (uri->server, "") && socket) {
|
|
||||||
- fprintf (stderr, _("%s: %s: cannot both a server name and a socket query parameter\n"),
|
|
||||||
+ fprintf (stderr, _("%s: %s: cannot have both a server name and a socket query parameter\n"),
|
|
||||||
getprogname (), arg);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
@@ -347,6 +347,7 @@ make_server (xmlURIPtr uri, const char *socket, char ***ret)
|
|
||||||
*ret = malloc (sizeof (char *) * 2);
|
|
||||||
if (*ret == NULL) {
|
|
||||||
perror ("malloc");
|
|
||||||
+ free (server);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
(*ret)[0] = server;
|
|
||||||
diff --git a/customize/customize_run.ml b/customize/customize_run.ml
|
|
||||||
index f2ee20413..99b5fe14d 100644
|
|
||||||
--- a/customize/customize_run.ml
|
|
||||||
+++ b/customize/customize_run.ml
|
|
||||||
@@ -415,7 +415,7 @@ let run (g : G.guestfs) root (ops : ops) =
|
|
||||||
warning (f_"passwords could not be set for this type of guest")
|
|
||||||
);
|
|
||||||
|
|
||||||
- if ops.flags.selinux_relabel then (
|
|
||||||
+ if not ops.flags.no_selinux_relabel then (
|
|
||||||
message (f_"SELinux relabelling");
|
|
||||||
SELinux_relabel.relabel g
|
|
||||||
);
|
|
||||||
diff --git a/customize/test-settings.sh b/customize/test-settings.sh
|
|
||||||
index ed4c90f2e..e8b492dd1 100755
|
|
||||||
--- a/customize/test-settings.sh
|
|
||||||
+++ b/customize/test-settings.sh
|
|
||||||
@@ -61,9 +61,6 @@ case "$guestname" in
|
|
||||||
extra[${#extra[*]}]='/etc/inittab:
|
|
||||||
s,^#([1-9].*respawn.*/sbin/getty.*),$1,'
|
|
||||||
;;
|
|
||||||
- fedora*|rhel*|centos*)
|
|
||||||
- extra[${#extra[*]}]='--selinux-relabel'
|
|
||||||
- ;;
|
|
||||||
*)
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
diff --git a/sysprep/main.ml b/sysprep/main.ml
|
|
||||||
index 087d1a17f..b760618ad 100644
|
|
||||||
--- a/sysprep/main.ml
|
|
||||||
+++ b/sysprep/main.ml
|
|
||||||
@@ -132,8 +132,6 @@ let main () =
|
|
||||||
[ L"mount-options" ], Getopt.Set_string (s_"opts", mount_opts), s_"Set mount options (eg /:noatime;/var:rw,noatime)";
|
|
||||||
[ L"network" ], Getopt.Set network, s_"Enable appliance network";
|
|
||||||
[ L"no-network" ], Getopt.Clear network, s_"Disable appliance network (default)";
|
|
||||||
- [ L"no-selinux-relabel" ], Getopt.Unit (fun () -> ()),
|
|
||||||
- s_"Compatibility option, does nothing";
|
|
||||||
[ L"operation"; L"operations" ], Getopt.String (s_"operations", set_operations), s_"Enable/disable specific operations";
|
|
||||||
] in
|
|
||||||
let args = basic_args @ Sysprep_operation.extra_args () in
|
|
||||||
diff --git a/sysprep/test-virt-sysprep-docs.sh b/sysprep/test-virt-sysprep-docs.sh
|
|
||||||
index 51500b5e9..9d0298d68 100755
|
|
||||||
--- a/sysprep/test-virt-sysprep-docs.sh
|
|
||||||
+++ b/sysprep/test-virt-sysprep-docs.sh
|
|
||||||
@@ -25,4 +25,4 @@ $top_srcdir/podcheck.pl "$srcdir/virt-sysprep.pod" virt-sysprep \
|
|
||||||
--path $top_srcdir/common/options \
|
|
||||||
--insert sysprep-extra-options.pod:__EXTRA_OPTIONS__ \
|
|
||||||
--insert sysprep-operations.pod:__OPERATIONS__ \
|
|
||||||
- --ignore=--dryrun,--dump-pod,--dump-pod-options,--no-selinux-relabel
|
|
||||||
+ --ignore=--dryrun,--dump-pod,--dump-pod-options
|
|
||||||
--
|
|
||||||
2.31.1
|
|
||||||
|
|
3630
0003-Remove-virt-dib.patch
Normal file
3630
0003-Remove-virt-dib.patch
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,101 +0,0 @@
|
|||||||
From 10e2f3fc7eef6da4d741f7617e80d028257d9884 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Date: Wed, 25 May 2022 13:06:01 +0200
|
|
||||||
Subject: [PATCH] update common submodule
|
|
||||||
|
|
||||||
Shortlog for 48527b8768d7..f8de5508fe75:
|
|
||||||
|
|
||||||
Laszlo Ersek (1):
|
|
||||||
mlcustomize: refresh generated files
|
|
||||||
|
|
||||||
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2089748
|
|
||||||
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
(cherry picked from commit 273de755dfe7eb0f1e81dc62463c125e8bed0cff)
|
|
||||||
---
|
|
||||||
common | 2 +-
|
|
||||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
||||||
|
|
||||||
Submodule common 48527b876..f8de5508f:
|
|
||||||
diff --git a/common/mlcustomize/customize-options.pod b/common/mlcustomize/customize-options.pod
|
|
||||||
index a83c80a..8aafacd 100644
|
|
||||||
--- a/common/mlcustomize/customize-options.pod
|
|
||||||
+++ b/common/mlcustomize/customize-options.pod
|
|
||||||
@@ -310,6 +310,10 @@ It cannot delete directories, only regular files.
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
+=item B<--selinux-relabel>
|
|
||||||
+
|
|
||||||
+This is a compatibility option that does nothing.
|
|
||||||
+
|
|
||||||
=item B<--sm-attach> SELECTOR
|
|
||||||
|
|
||||||
Attach to a pool using C<subscription-manager>.
|
|
||||||
diff --git a/common/mlcustomize/customize-synopsis.pod b/common/mlcustomize/customize-synopsis.pod
|
|
||||||
index 2520853..9e2c4b2 100644
|
|
||||||
--- a/common/mlcustomize/customize-synopsis.pod
|
|
||||||
+++ b/common/mlcustomize/customize-synopsis.pod
|
|
||||||
@@ -13,4 +13,4 @@
|
|
||||||
[--uninstall PKG,PKG..] [--update] [--upload FILE:DEST]
|
|
||||||
[--write FILE:CONTENT] [--no-logfile]
|
|
||||||
[--password-crypto md5|sha256|sha512] [--no-selinux-relabel]
|
|
||||||
- [--sm-credentials SELECTOR]
|
|
||||||
+ [--selinux-relabel] [--sm-credentials SELECTOR]
|
|
||||||
diff --git a/common/mlcustomize/customize_cmdline.ml b/common/mlcustomize/customize_cmdline.ml
|
|
||||||
index 5d404e8..a17bed4 100644
|
|
||||||
--- a/common/mlcustomize/customize_cmdline.ml
|
|
||||||
+++ b/common/mlcustomize/customize_cmdline.ml
|
|
||||||
@@ -111,6 +111,8 @@ and flags = {
|
|
||||||
(* --password-crypto md5|sha256|sha512 *)
|
|
||||||
no_selinux_relabel : bool;
|
|
||||||
(* --no-selinux-relabel *)
|
|
||||||
+ selinux_relabel_ignored : bool;
|
|
||||||
+ (* --selinux-relabel *)
|
|
||||||
sm_credentials : Subscription_manager.sm_credentials option;
|
|
||||||
(* --sm-credentials SELECTOR *)
|
|
||||||
}
|
|
||||||
@@ -122,6 +124,7 @@ let rec argspec () =
|
|
||||||
let scrub_logfile = ref false in
|
|
||||||
let password_crypto = ref None in
|
|
||||||
let no_selinux_relabel = ref false in
|
|
||||||
+ let selinux_relabel_ignored = ref false in
|
|
||||||
let sm_credentials = ref None in
|
|
||||||
|
|
||||||
let rec get_ops () = {
|
|
||||||
@@ -132,6 +135,7 @@ let rec argspec () =
|
|
||||||
scrub_logfile = !scrub_logfile;
|
|
||||||
password_crypto = !password_crypto;
|
|
||||||
no_selinux_relabel = !no_selinux_relabel;
|
|
||||||
+ selinux_relabel_ignored = !selinux_relabel_ignored;
|
|
||||||
sm_credentials = !sm_credentials;
|
|
||||||
}
|
|
||||||
in
|
|
||||||
@@ -464,6 +468,12 @@ let rec argspec () =
|
|
||||||
s_"Do not relabel files with correct SELinux labels"
|
|
||||||
),
|
|
||||||
None, "Do not attempt to correct the SELinux labels of files in the guest.\n\nIn such guests that support SELinux, customization automatically\nrelabels files so that they have the correct SELinux label. (The\nrelabeling is performed immediately, but if the operation fails,\ncustomization will instead touch F</.autorelabel> on the image to\nschedule a relabel operation for the next time the image boots.) This\noption disables the automatic relabeling.\n\nThe option is a no-op for guests that do not support SELinux.";
|
|
||||||
+ (
|
|
||||||
+ [ L"selinux-relabel" ],
|
|
||||||
+ Getopt.Set selinux_relabel_ignored,
|
|
||||||
+ s_"Compatibility option doing nothing"
|
|
||||||
+ ),
|
|
||||||
+ None, "This is a compatibility option that does nothing.";
|
|
||||||
(
|
|
||||||
[ L"sm-credentials" ],
|
|
||||||
Getopt.String (
|
|
||||||
diff --git a/common/mlcustomize/customize_cmdline.mli b/common/mlcustomize/customize_cmdline.mli
|
|
||||||
index 7ee882a..7d14e78 100644
|
|
||||||
--- a/common/mlcustomize/customize_cmdline.mli
|
|
||||||
+++ b/common/mlcustomize/customize_cmdline.mli
|
|
||||||
@@ -103,6 +103,8 @@ and flags = {
|
|
||||||
(* --password-crypto md5|sha256|sha512 *)
|
|
||||||
no_selinux_relabel : bool;
|
|
||||||
(* --no-selinux-relabel *)
|
|
||||||
+ selinux_relabel_ignored : bool;
|
|
||||||
+ (* --selinux-relabel *)
|
|
||||||
sm_credentials : Subscription_manager.sm_credentials option;
|
|
||||||
(* --sm-credentials SELECTOR *)
|
|
||||||
}
|
|
||||||
--
|
|
||||||
2.31.1
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
|||||||
|
From f89df0e54aef85fe1dec995064f7d3ba6453409e Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Sat, 18 Feb 2023 12:03:26 +0000
|
||||||
|
Subject: [PATCH] drivers/drivers.mli: Fix copy and paste error in comment
|
||||||
|
|
||||||
|
(cherry picked from commit de7e4ec1245d40a189dd97a50f28a85b9a80e718)
|
||||||
|
---
|
||||||
|
drivers/drivers.mli | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/drivers/drivers.mli b/drivers/drivers.mli
|
||||||
|
index 4437e461c..8a67b77a2 100644
|
||||||
|
--- a/drivers/drivers.mli
|
||||||
|
+++ b/drivers/drivers.mli
|
||||||
|
@@ -1,4 +1,4 @@
|
||||||
|
-(* virt-get-kernel
|
||||||
|
+(* virt-drivers
|
||||||
|
* Copyright (C) 2013-2023 Red Hat Inc.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
--
|
||||||
|
2.31.1
|
||||||
|
|
312
0005-Rework-Std_utils.Option-so-it-works-like-the-OCaml-s.patch
Normal file
312
0005-Rework-Std_utils.Option-so-it-works-like-the-OCaml-s.patch
Normal file
@ -0,0 +1,312 @@
|
|||||||
|
From a84c1359ed0943e5140e9170fa05126b590c2873 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Mon, 20 Feb 2023 12:01:21 +0000
|
||||||
|
Subject: [PATCH] Rework Std_utils.Option so it works like the OCaml stdlib
|
||||||
|
module
|
||||||
|
|
||||||
|
OCaml 4.08 introduces a stdlib Option module which looks a bit like
|
||||||
|
ours but has a number of differences. In particular our functions
|
||||||
|
Option.may and Option.default have no corresponding functions in
|
||||||
|
stdlib, although there are close enough equivalents.
|
||||||
|
|
||||||
|
This change was automated using this command:
|
||||||
|
|
||||||
|
$ perl -pi.bak \
|
||||||
|
-e 's/Option.may/Option.iter/g; s/Option.default /Option.value ~default:/g' \
|
||||||
|
`git ls-files`
|
||||||
|
|
||||||
|
Update common module to include:
|
||||||
|
|
||||||
|
commit cffa077323fafcdfcf78e230c022afa891a6b3ff
|
||||||
|
Author: Richard W.M. Jones <rjones@redhat.com>
|
||||||
|
Date: Mon Feb 20 12:11:51 2023 +0000
|
||||||
|
|
||||||
|
mlstdutils: Rework the Option module to be compatible with stdlib
|
||||||
|
|
||||||
|
commit 007d0506c538db0a43fec7e9986a95ecdcd48b56
|
||||||
|
Author: Richard W.M. Jones <rjones@redhat.com>
|
||||||
|
Date: Mon Feb 20 12:18:29 2023 +0000
|
||||||
|
|
||||||
|
mltools: Replace Option.may with Option.iter
|
||||||
|
|
||||||
|
(cherry picked from commit 65bde3b531a2bcb7891a940a692c5a249c2f9340)
|
||||||
|
---
|
||||||
|
builder/builder.ml | 6 +++---
|
||||||
|
builder/index.ml | 18 +++++++++---------
|
||||||
|
builder/index_parser.ml | 14 +++++++-------
|
||||||
|
builder/list_entries.ml | 8 ++++----
|
||||||
|
common | 2 +-
|
||||||
|
customize/customize_main.ml | 4 ++--
|
||||||
|
resize/resize.ml | 8 ++++----
|
||||||
|
sysprep/sysprep_operation.ml | 4 ++--
|
||||||
|
8 files changed, 32 insertions(+), 32 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/builder/builder.ml b/builder/builder.ml
|
||||||
|
index 727aa8b23..15ece4e60 100644
|
||||||
|
--- a/builder/builder.ml
|
||||||
|
+++ b/builder/builder.ml
|
||||||
|
@@ -723,8 +723,8 @@ let main () =
|
||||||
|
let g =
|
||||||
|
let g = open_guestfs () in
|
||||||
|
|
||||||
|
- Option.may g#set_memsize cmdline.memsize;
|
||||||
|
- Option.may g#set_smp cmdline.smp;
|
||||||
|
+ Option.iter g#set_memsize cmdline.memsize;
|
||||||
|
+ Option.iter g#set_smp cmdline.smp;
|
||||||
|
g#set_network cmdline.network;
|
||||||
|
|
||||||
|
(* The output disk is being created, so use cache=unsafe here. *)
|
||||||
|
@@ -818,6 +818,6 @@ let main () =
|
||||||
|
Pervasives.flush Pervasives.stdout;
|
||||||
|
Pervasives.flush Pervasives.stderr;
|
||||||
|
|
||||||
|
- Option.may print_string stats
|
||||||
|
+ Option.iter print_string stats
|
||||||
|
|
||||||
|
let () = run_main_and_handle_errors main
|
||||||
|
diff --git a/builder/index.ml b/builder/index.ml
|
||||||
|
index 03680f051..341a62356 100644
|
||||||
|
--- a/builder/index.ml
|
||||||
|
+++ b/builder/index.ml
|
||||||
|
@@ -58,12 +58,12 @@ let print_entry chan (name, { printable_name; file_uri; arch; osinfo;
|
||||||
|
notes; aliases; hidden }) =
|
||||||
|
let fp fs = fprintf chan fs in
|
||||||
|
fp "[%s]\n" name;
|
||||||
|
- Option.may (fp "name=%s\n") printable_name;
|
||||||
|
- Option.may (fp "osinfo=%s\n") osinfo;
|
||||||
|
+ Option.iter (fp "name=%s\n") printable_name;
|
||||||
|
+ Option.iter (fp "osinfo=%s\n") osinfo;
|
||||||
|
fp "file=%s\n" file_uri;
|
||||||
|
fp "arch=%s\n" (string_of_arch arch);
|
||||||
|
- Option.may (fp "sig=%s\n") signature_uri;
|
||||||
|
- Option.may (
|
||||||
|
+ Option.iter (fp "sig=%s\n") signature_uri;
|
||||||
|
+ Option.iter (
|
||||||
|
List.iter (
|
||||||
|
fun c ->
|
||||||
|
fp "checksum[%s]=%s\n"
|
||||||
|
@@ -71,16 +71,16 @@ let print_entry chan (name, { printable_name; file_uri; arch; osinfo;
|
||||||
|
)
|
||||||
|
) checksums;
|
||||||
|
fp "revision=%s\n" (string_of_revision revision);
|
||||||
|
- Option.may (fp "format=%s\n") format;
|
||||||
|
+ Option.iter (fp "format=%s\n") format;
|
||||||
|
fp "size=%Ld\n" size;
|
||||||
|
- Option.may (fp "compressed_size=%Ld\n") compressed_size;
|
||||||
|
- Option.may (fp "expand=%s\n") expand;
|
||||||
|
- Option.may (fp "lvexpand=%s\n") lvexpand;
|
||||||
|
+ Option.iter (fp "compressed_size=%Ld\n") compressed_size;
|
||||||
|
+ Option.iter (fp "expand=%s\n") expand;
|
||||||
|
+ Option.iter (fp "lvexpand=%s\n") lvexpand;
|
||||||
|
List.iter (
|
||||||
|
fun (lang, notes) ->
|
||||||
|
match lang with
|
||||||
|
| "" -> fp "notes=%s\n" notes
|
||||||
|
| lang -> fp "notes[%s]=%s\n" lang notes
|
||||||
|
) notes;
|
||||||
|
- Option.may (fun l -> fp "aliases=%s\n" (String.concat " " l)) aliases;
|
||||||
|
+ Option.iter (fun l -> fp "aliases=%s\n" (String.concat " " l)) aliases;
|
||||||
|
if hidden then fp "hidden=true\n"
|
||||||
|
diff --git a/builder/index_parser.ml b/builder/index_parser.ml
|
||||||
|
index b4cb81e78..1c5bc26ca 100644
|
||||||
|
--- a/builder/index_parser.ml
|
||||||
|
+++ b/builder/index_parser.ml
|
||||||
|
@@ -284,11 +284,11 @@ let write_entry chan (name, { Index.printable_name; file_uri; arch; osinfo;
|
||||||
|
aliases; hidden}) =
|
||||||
|
let fp fs = fprintf chan fs in
|
||||||
|
fp "[%s]\n" name;
|
||||||
|
- Option.may (fp "name=%s\n") printable_name;
|
||||||
|
- Option.may (fp "osinfo=%s\n") osinfo;
|
||||||
|
+ Option.iter (fp "name=%s\n") printable_name;
|
||||||
|
+ Option.iter (fp "osinfo=%s\n") osinfo;
|
||||||
|
fp "file=%s\n" file_uri;
|
||||||
|
fp "arch=%s\n" (Index.string_of_arch arch);
|
||||||
|
- Option.may (fp "sig=%s\n") signature_uri;
|
||||||
|
+ Option.iter (fp "sig=%s\n") signature_uri;
|
||||||
|
(match checksums with
|
||||||
|
| None -> ()
|
||||||
|
| Some checksums ->
|
||||||
|
@@ -299,11 +299,11 @@ let write_entry chan (name, { Index.printable_name; file_uri; arch; osinfo;
|
||||||
|
) checksums
|
||||||
|
);
|
||||||
|
fp "revision=%s\n" (string_of_revision revision);
|
||||||
|
- Option.may (fp "format=%s\n") format;
|
||||||
|
+ Option.iter (fp "format=%s\n") format;
|
||||||
|
fp "size=%Ld\n" size;
|
||||||
|
- Option.may (fp "compressed_size=%Ld\n") compressed_size;
|
||||||
|
- Option.may (fp "expand=%s\n") expand;
|
||||||
|
- Option.may (fp "lvexpand=%s\n") lvexpand;
|
||||||
|
+ Option.iter (fp "compressed_size=%Ld\n") compressed_size;
|
||||||
|
+ Option.iter (fp "expand=%s\n") expand;
|
||||||
|
+ Option.iter (fp "lvexpand=%s\n") lvexpand;
|
||||||
|
|
||||||
|
let format_notes notes =
|
||||||
|
String.concat "\n " (String.nsplit "\n" notes) in
|
||||||
|
diff --git a/builder/list_entries.ml b/builder/list_entries.ml
|
||||||
|
index 470d1b6ed..0690d5858 100644
|
||||||
|
--- a/builder/list_entries.ml
|
||||||
|
+++ b/builder/list_entries.ml
|
||||||
|
@@ -47,7 +47,7 @@ and list_entries_short index =
|
||||||
|
if not hidden then (
|
||||||
|
printf "%-24s" name;
|
||||||
|
printf " %-10s" (Index.string_of_arch arch);
|
||||||
|
- Option.may (printf " %s") printable_name;
|
||||||
|
+ Option.iter (printf " %s") printable_name;
|
||||||
|
printf "\n"
|
||||||
|
)
|
||||||
|
) index
|
||||||
|
@@ -73,13 +73,13 @@ and list_entries_long ~sources index =
|
||||||
|
notes; aliases; hidden }) ->
|
||||||
|
if not hidden then (
|
||||||
|
printf "%-24s %s\n" "os-version:" name;
|
||||||
|
- Option.may (printf "%-24s %s\n" (s_"Full name:")) printable_name;
|
||||||
|
+ Option.iter (printf "%-24s %s\n" (s_"Full name:")) printable_name;
|
||||||
|
printf "%-24s %s\n" (s_"Architecture:") (Index.string_of_arch arch);
|
||||||
|
printf "%-24s %s\n" (s_"Minimum/default size:") (human_size size);
|
||||||
|
- Option.may (fun size ->
|
||||||
|
+ Option.iter (fun size ->
|
||||||
|
printf "%-24s %s\n" (s_"Download size:") (human_size size)
|
||||||
|
) compressed_size;
|
||||||
|
- Option.may (
|
||||||
|
+ Option.iter (
|
||||||
|
fun l -> printf "%-24s %s\n" (s_"Aliases:") (String.concat " " l)
|
||||||
|
) aliases;
|
||||||
|
let notes = Languages.find_notes langs notes in
|
||||||
|
Submodule common 53713420b..007d0506c:
|
||||||
|
diff --git a/common/mlstdutils/std_utils.ml b/common/mlstdutils/std_utils.ml
|
||||||
|
index ab6e71c..323bfec 100644
|
||||||
|
--- a/common/mlstdutils/std_utils.ml
|
||||||
|
+++ b/common/mlstdutils/std_utils.ml
|
||||||
|
@@ -368,7 +368,7 @@ module List = struct
|
||||||
|
end
|
||||||
|
|
||||||
|
module Option = struct
|
||||||
|
- let may f = function
|
||||||
|
+ let iter f = function
|
||||||
|
| None -> ()
|
||||||
|
| Some x -> f x
|
||||||
|
|
||||||
|
@@ -376,8 +376,9 @@ module Option = struct
|
||||||
|
| None -> None
|
||||||
|
| Some x -> Some (f x)
|
||||||
|
|
||||||
|
- let default def = function
|
||||||
|
- | None -> def
|
||||||
|
+ let value x ~default =
|
||||||
|
+ match x with
|
||||||
|
+ | None -> default
|
||||||
|
| Some x -> x
|
||||||
|
end
|
||||||
|
|
||||||
|
diff --git a/common/mlstdutils/std_utils.mli b/common/mlstdutils/std_utils.mli
|
||||||
|
index 782d8fd..d576243 100644
|
||||||
|
--- a/common/mlstdutils/std_utils.mli
|
||||||
|
+++ b/common/mlstdutils/std_utils.mli
|
||||||
|
@@ -277,16 +277,19 @@ end
|
||||||
|
(** Override the List module from stdlib. *)
|
||||||
|
|
||||||
|
module Option : sig
|
||||||
|
- val may : ('a -> unit) -> 'a option -> unit
|
||||||
|
- (** [may f (Some x)] runs [f x]. [may f None] does nothing. *)
|
||||||
|
+ val iter : ('a -> unit) -> 'a option -> unit
|
||||||
|
+ (** [iter f o] is [f v] if [o] is [Some v] and [()] otherwise *)
|
||||||
|
|
||||||
|
val map : ('a -> 'b) -> 'a option -> 'b option
|
||||||
|
(** [map f (Some x)] returns [Some (f x)]. [map f None] returns [None]. *)
|
||||||
|
|
||||||
|
- val default : 'a -> 'a option -> 'a
|
||||||
|
- (** [default x (Some y)] returns [y]. [default x None] returns [x]. *)
|
||||||
|
+ val value : 'a option -> default:'a -> 'a
|
||||||
|
+ (** [value o ~default] is [v] if [o] is [Some v] and [default] otherwise. *)
|
||||||
|
end
|
||||||
|
-(** Functions for dealing with option types. *)
|
||||||
|
+(** Functions for dealing with option types.
|
||||||
|
+
|
||||||
|
+ This module will be removed when we can use baseline OCaml 4.08
|
||||||
|
+ since that version introduces a compatible [Option] module. *)
|
||||||
|
|
||||||
|
val ( // ) : string -> string -> string
|
||||||
|
(** Concatenate directory and filename. *)
|
||||||
|
diff --git a/common/mltools/tools_utils.ml b/common/mltools/tools_utils.ml
|
||||||
|
index 562bfad..8b611e7 100644
|
||||||
|
--- a/common/mltools/tools_utils.ml
|
||||||
|
+++ b/common/mltools/tools_utils.ml
|
||||||
|
@@ -218,7 +218,7 @@ let open_guestfs ?identifier () =
|
||||||
|
g#parse_environment ();
|
||||||
|
if trace () then g#set_trace true;
|
||||||
|
if verbose () then g#set_verbose true;
|
||||||
|
- Option.may g#set_identifier identifier;
|
||||||
|
+ Option.iter g#set_identifier identifier;
|
||||||
|
g
|
||||||
|
|
||||||
|
(* All the OCaml virt-* programs use this wrapper to catch exceptions
|
||||||
|
@@ -523,8 +523,8 @@ and do_run ?(echo_cmd = true) ?stdout_fd ?stderr_fd args =
|
||||||
|
Or 127
|
||||||
|
|
||||||
|
and do_teardown app outfd errfd exitstat =
|
||||||
|
- Option.may Unix.close outfd;
|
||||||
|
- Option.may Unix.close errfd;
|
||||||
|
+ Option.iter Unix.close outfd;
|
||||||
|
+ Option.iter Unix.close errfd;
|
||||||
|
match exitstat with
|
||||||
|
| Unix.WEXITED i ->
|
||||||
|
i
|
||||||
|
diff --git a/customize/customize_main.ml b/customize/customize_main.ml
|
||||||
|
index f05375e1d..8622715ab 100644
|
||||||
|
--- a/customize/customize_main.ml
|
||||||
|
+++ b/customize/customize_main.ml
|
||||||
|
@@ -163,8 +163,8 @@ read the man page virt-customize(1).
|
||||||
|
(* Connect to libguestfs. *)
|
||||||
|
let g =
|
||||||
|
let g = open_guestfs () in
|
||||||
|
- Option.may g#set_memsize memsize;
|
||||||
|
- Option.may g#set_smp smp;
|
||||||
|
+ Option.iter g#set_memsize memsize;
|
||||||
|
+ Option.iter g#set_smp smp;
|
||||||
|
(* [--no-network] from the command line takes precedence over the automatic
|
||||||
|
* network enablement for [--key ID:clevis], so here we intentionally
|
||||||
|
* don't check [key_store_requires_network opthandle.ks].
|
||||||
|
diff --git a/resize/resize.ml b/resize/resize.ml
|
||||||
|
index ee2fb2d92..3c3a5d7e3 100644
|
||||||
|
--- a/resize/resize.ml
|
||||||
|
+++ b/resize/resize.ml
|
||||||
|
@@ -1072,7 +1072,7 @@ read the man page virt-resize(1).
|
||||||
|
let ok =
|
||||||
|
try
|
||||||
|
g#part_init "/dev/sdb" parttype_string;
|
||||||
|
- Option.may (g#part_set_disk_guid "/dev/sdb") disk_guid;
|
||||||
|
+ Option.iter (g#part_set_disk_guid "/dev/sdb") disk_guid;
|
||||||
|
true
|
||||||
|
with G.Error error -> last_error := error; false in
|
||||||
|
if ok then g, true
|
||||||
|
@@ -1266,9 +1266,9 @@ read the man page virt-resize(1).
|
||||||
|
if p.p_bootable then
|
||||||
|
g#part_set_bootable "/dev/sdb" p.p_target_partnum true;
|
||||||
|
|
||||||
|
- Option.may (g#part_set_name "/dev/sdb" p.p_target_partnum) p.p_label;
|
||||||
|
- Option.may (g#part_set_gpt_guid "/dev/sdb" p.p_target_partnum) p.p_guid;
|
||||||
|
- Option.may (g#part_set_gpt_attributes "/dev/sdb" p.p_target_partnum)
|
||||||
|
+ Option.iter (g#part_set_name "/dev/sdb" p.p_target_partnum) p.p_label;
|
||||||
|
+ Option.iter (g#part_set_gpt_guid "/dev/sdb" p.p_target_partnum) p.p_guid;
|
||||||
|
+ Option.iter (g#part_set_gpt_attributes "/dev/sdb" p.p_target_partnum)
|
||||||
|
p.p_attributes;
|
||||||
|
|
||||||
|
match parttype, p.p_id with
|
||||||
|
diff --git a/sysprep/sysprep_operation.ml b/sysprep/sysprep_operation.ml
|
||||||
|
index 17c0440d4..0a5fce065 100644
|
||||||
|
--- a/sysprep/sysprep_operation.ml
|
||||||
|
+++ b/sysprep/sysprep_operation.ml
|
||||||
|
@@ -190,8 +190,8 @@ let dump_pod () =
|
||||||
|
if op.enabled_by_default then printf "*\n";
|
||||||
|
printf "\n";
|
||||||
|
printf "%s.\n\n" op.heading;
|
||||||
|
- Option.may (printf "%s\n\n") op.pod_description;
|
||||||
|
- Option.may (fun notes ->
|
||||||
|
+ Option.iter (printf "%s\n\n") op.pod_description;
|
||||||
|
+ Option.iter (fun notes ->
|
||||||
|
printf "=head3 ";
|
||||||
|
printf (f_"Notes on %s") op.name;
|
||||||
|
printf "\n\n";
|
||||||
|
--
|
||||||
|
2.31.1
|
||||||
|
|
@ -1,378 +0,0 @@
|
|||||||
From 2014844107fc356e945fb637ef9179bc29656864 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Date: Mon, 6 Jun 2022 16:20:42 +0200
|
|
||||||
Subject: [PATCH] customize: rebase to the common/mlcustomize/Guest_packages
|
|
||||||
interface
|
|
||||||
|
|
||||||
Replace the "guest_install_command", "guest_update_command" and
|
|
||||||
"guest_uninstall_command" helper functions with the corresponding
|
|
||||||
functions from libguestfs-common, interface mlcustomize/Guest_packages.
|
|
||||||
|
|
||||||
Add a wrapper function for (a) dealing with the exceptions uniformly
|
|
||||||
(keeping the original behavior of virt-customize), (b) centralizing the
|
|
||||||
[g#inspect_get_package_management root] call. Regarding (b), the wrapper
|
|
||||||
function fills in the last argument [package_management] of the
|
|
||||||
Guest_packages functions; thus, pass partially applied functions to the
|
|
||||||
wrapper at the original call sites.
|
|
||||||
|
|
||||||
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2028764
|
|
||||||
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Message-Id: <20220606142042.16680-1-lersek@redhat.com>
|
|
||||||
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
|
|
||||||
(cherry picked from commit 7eb1ecf467e86374d72b23994d435139e302bca5)
|
|
||||||
---
|
|
||||||
common | 2 +-
|
|
||||||
customize/customize_run.ml | 106 ++++---------------------------------
|
|
||||||
2 files changed, 10 insertions(+), 98 deletions(-)
|
|
||||||
|
|
||||||
Submodule common f8de5508f..9e990f3e4:
|
|
||||||
diff --git a/common/mlcustomize/Makefile.am b/common/mlcustomize/Makefile.am
|
|
||||||
index cd7d897..4e26064 100644
|
|
||||||
--- a/common/mlcustomize/Makefile.am
|
|
||||||
+++ b/common/mlcustomize/Makefile.am
|
|
||||||
@@ -38,10 +38,12 @@ generator_built = \
|
|
||||||
|
|
||||||
SOURCES_MLI = \
|
|
||||||
firstboot.mli \
|
|
||||||
+ guest_packages.mli \
|
|
||||||
SELinux_relabel.mli
|
|
||||||
|
|
||||||
SOURCES_ML = \
|
|
||||||
firstboot.ml \
|
|
||||||
+ guest_packages.ml \
|
|
||||||
SELinux_relabel.ml
|
|
||||||
|
|
||||||
if HAVE_OCAML
|
|
||||||
diff --git a/common/mlcustomize/guest_packages.ml b/common/mlcustomize/guest_packages.ml
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000..4c3c34e
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/common/mlcustomize/guest_packages.ml
|
|
||||||
@@ -0,0 +1,132 @@
|
|
||||||
+(* virt-customize
|
|
||||||
+ * 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 Printf
|
|
||||||
+
|
|
||||||
+open Common_gettext.Gettext
|
|
||||||
+open Std_utils
|
|
||||||
+
|
|
||||||
+exception Unknown_package_manager of string
|
|
||||||
+exception Unimplemented_package_manager of string
|
|
||||||
+
|
|
||||||
+(* Windows has package_management == "unknown". *)
|
|
||||||
+let error_unknown_package_manager flag =
|
|
||||||
+ let msg = sprintf (f_"cannot use ‘%s’ because no package manager has been \
|
|
||||||
+ detected for this guest OS.\n\nIf this guest OS is a \
|
|
||||||
+ common one with ordinary package management then this \
|
|
||||||
+ may have been caused by a failure of libguestfs \
|
|
||||||
+ inspection.\n\nFor OSes such as Windows that lack \
|
|
||||||
+ package management, this is not possible. Try using \
|
|
||||||
+ one of the ‘--firstboot*’ flags instead (described in \
|
|
||||||
+ the virt-customize(1) manual).") flag in
|
|
||||||
+ raise (Unknown_package_manager msg)
|
|
||||||
+
|
|
||||||
+let error_unimplemented_package_manager flag pm =
|
|
||||||
+ let msg = sprintf (f_"sorry, ‘%s’ with the ‘%s’ package manager has not \
|
|
||||||
+ been implemented yet.\n\nYou can work around this by \
|
|
||||||
+ using one of the ‘--run*’ or ‘--firstboot*’ options \
|
|
||||||
+ instead (described in the virt-customize(1) manual).")
|
|
||||||
+ flag pm in
|
|
||||||
+ raise (Unimplemented_package_manager msg)
|
|
||||||
+
|
|
||||||
+(* http://distrowatch.com/dwres.php?resource=package-management *)
|
|
||||||
+let install_command packages package_management =
|
|
||||||
+ let quoted_args = String.concat " " (List.map quote packages) in
|
|
||||||
+ match package_management with
|
|
||||||
+ | "apk" ->
|
|
||||||
+ sprintf "
|
|
||||||
+ apk update
|
|
||||||
+ apk add %s
|
|
||||||
+ " quoted_args
|
|
||||||
+ | "apt" ->
|
|
||||||
+ (* http://unix.stackexchange.com/questions/22820 *)
|
|
||||||
+ sprintf "
|
|
||||||
+ export DEBIAN_FRONTEND=noninteractive
|
|
||||||
+ apt_opts='-q -y -o Dpkg::Options::=--force-confnew'
|
|
||||||
+ apt-get $apt_opts update
|
|
||||||
+ apt-get $apt_opts install %s
|
|
||||||
+ " quoted_args
|
|
||||||
+ | "dnf" ->
|
|
||||||
+ sprintf "dnf%s -y install %s"
|
|
||||||
+ (if verbose () then " --verbose" else "")
|
|
||||||
+ quoted_args
|
|
||||||
+ | "pisi" -> sprintf "pisi it %s" quoted_args
|
|
||||||
+ | "pacman" -> sprintf "pacman -S --noconfirm %s" quoted_args
|
|
||||||
+ | "urpmi" -> sprintf "urpmi %s" quoted_args
|
|
||||||
+ | "xbps" -> sprintf "xbps-install -Sy %s" quoted_args
|
|
||||||
+ | "yum" -> sprintf "yum -y install %s" quoted_args
|
|
||||||
+ | "zypper" -> sprintf "zypper -n in -l %s" quoted_args
|
|
||||||
+
|
|
||||||
+ | "unknown" ->
|
|
||||||
+ error_unknown_package_manager (s_"--install")
|
|
||||||
+ | pm ->
|
|
||||||
+ error_unimplemented_package_manager (s_"--install") pm
|
|
||||||
+
|
|
||||||
+let update_command package_management =
|
|
||||||
+ match package_management with
|
|
||||||
+ | "apk" ->
|
|
||||||
+ "
|
|
||||||
+ apk update
|
|
||||||
+ apk upgrade
|
|
||||||
+ "
|
|
||||||
+ | "apt" ->
|
|
||||||
+ (* http://unix.stackexchange.com/questions/22820 *)
|
|
||||||
+ "
|
|
||||||
+ export DEBIAN_FRONTEND=noninteractive
|
|
||||||
+ apt_opts='-q -y -o Dpkg::Options::=--force-confnew'
|
|
||||||
+ apt-get $apt_opts update
|
|
||||||
+ apt-get $apt_opts upgrade
|
|
||||||
+ "
|
|
||||||
+ | "dnf" ->
|
|
||||||
+ sprintf "dnf%s -y --best upgrade"
|
|
||||||
+ (if verbose () then " --verbose" else "")
|
|
||||||
+ | "pisi" -> "pisi upgrade"
|
|
||||||
+ | "pacman" -> "pacman -Su"
|
|
||||||
+ | "urpmi" -> "urpmi --auto-select"
|
|
||||||
+ | "xbps" -> "xbps-install -Suy"
|
|
||||||
+ | "yum" -> "yum -y update"
|
|
||||||
+ | "zypper" -> "zypper -n update -l"
|
|
||||||
+
|
|
||||||
+ | "unknown" ->
|
|
||||||
+ error_unknown_package_manager (s_"--update")
|
|
||||||
+ | pm ->
|
|
||||||
+ error_unimplemented_package_manager (s_"--update") pm
|
|
||||||
+
|
|
||||||
+let uninstall_command packages package_management =
|
|
||||||
+ let quoted_args = String.concat " " (List.map quote packages) in
|
|
||||||
+ match package_management with
|
|
||||||
+ | "apk" -> sprintf "apk del %s" quoted_args
|
|
||||||
+ | "apt" ->
|
|
||||||
+ (* http://unix.stackexchange.com/questions/22820 *)
|
|
||||||
+ sprintf "
|
|
||||||
+ export DEBIAN_FRONTEND=noninteractive
|
|
||||||
+ apt_opts='-q -y -o Dpkg::Options::=--force-confnew'
|
|
||||||
+ apt-get $apt_opts remove %s
|
|
||||||
+ " quoted_args
|
|
||||||
+ | "dnf" -> sprintf "dnf -y remove %s" quoted_args
|
|
||||||
+ | "pisi" -> sprintf "pisi rm %s" quoted_args
|
|
||||||
+ | "pacman" -> sprintf "pacman -R %s" quoted_args
|
|
||||||
+ | "urpmi" -> sprintf "urpme %s" quoted_args
|
|
||||||
+ | "xbps" -> sprintf "xbps-remove -Sy %s" quoted_args
|
|
||||||
+ | "yum" -> sprintf "yum -y remove %s" quoted_args
|
|
||||||
+ | "zypper" -> sprintf "zypper -n rm %s" quoted_args
|
|
||||||
+
|
|
||||||
+ | "unknown" ->
|
|
||||||
+ error_unknown_package_manager (s_"--uninstall")
|
|
||||||
+ | pm ->
|
|
||||||
+ error_unimplemented_package_manager (s_"--uninstall") pm
|
|
||||||
diff --git a/common/mlcustomize/guest_packages.mli b/common/mlcustomize/guest_packages.mli
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000..7504a6a
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/common/mlcustomize/guest_packages.mli
|
|
||||||
@@ -0,0 +1,44 @@
|
|
||||||
+(* virt-customize
|
|
||||||
+ * 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.
|
|
||||||
+ *)
|
|
||||||
+
|
|
||||||
+exception Unknown_package_manager of string
|
|
||||||
+exception Unimplemented_package_manager of string
|
|
||||||
+(** For all three functions below, [package_management] determines the package
|
|
||||||
+ management system in use by the guest; commonly it should be filled in from
|
|
||||||
+ [Guestfs.inspect_get_package_management], or the equivalent guestfs object
|
|
||||||
+ method.
|
|
||||||
+
|
|
||||||
+ If [package_management] is unknown or unimplemented, the functions raise
|
|
||||||
+ [Unknown_package_manager "error message"] or [Unimplemented_package_manager
|
|
||||||
+ "error message"], correspondingly. *)
|
|
||||||
+
|
|
||||||
+val install_command : string list -> string -> string
|
|
||||||
+(** [install_command packages package_management] produces a properly quoted
|
|
||||||
+ shell command string suitable for execution in the guest (directly or via a
|
|
||||||
+ Firstboot script) for installing the OS packages listed in [packages]. *)
|
|
||||||
+
|
|
||||||
+val update_command : string -> string
|
|
||||||
+(** [update_command package_management] produces a properly quoted shell command
|
|
||||||
+ string suitable for execution in the guest (directly or via a Firstboot
|
|
||||||
+ script) for updating the OS packages that are currently installed in the
|
|
||||||
+ guest. *)
|
|
||||||
+
|
|
||||||
+val uninstall_command : string list -> string -> string
|
|
||||||
+(** [uninstall_command packages package_management] produces a properly quoted
|
|
||||||
+ shell command string suitable for execution in the guest (directly or via a
|
|
||||||
+ Firstboot script) for uninstalling the OS packages listed in [packages]. *)
|
|
||||||
diff --git a/customize/customize_run.ml b/customize/customize_run.ml
|
|
||||||
index 99b5fe14d..bb2ba2a03 100644
|
|
||||||
--- a/customize/customize_run.ml
|
|
||||||
+++ b/customize/customize_run.ml
|
|
||||||
@@ -67,99 +67,11 @@ let run (g : G.guestfs) root (ops : ops) =
|
|
||||||
error (f_"%s: command exited with an error") display
|
|
||||||
in
|
|
||||||
|
|
||||||
- (* http://distrowatch.com/dwres.php?resource=package-management *)
|
|
||||||
- let rec guest_install_command packages =
|
|
||||||
- let quoted_args = String.concat " " (List.map quote packages) in
|
|
||||||
- match g#inspect_get_package_management root with
|
|
||||||
- | "apk" ->
|
|
||||||
- sprintf "
|
|
||||||
- apk update
|
|
||||||
- apk add %s
|
|
||||||
- " quoted_args
|
|
||||||
- | "apt" ->
|
|
||||||
- (* http://unix.stackexchange.com/questions/22820 *)
|
|
||||||
- sprintf "
|
|
||||||
- export DEBIAN_FRONTEND=noninteractive
|
|
||||||
- apt_opts='-q -y -o Dpkg::Options::=--force-confnew'
|
|
||||||
- apt-get $apt_opts update
|
|
||||||
- apt-get $apt_opts install %s
|
|
||||||
- " quoted_args
|
|
||||||
- | "dnf" ->
|
|
||||||
- sprintf "dnf%s -y install %s"
|
|
||||||
- (if verbose () then " --verbose" else "")
|
|
||||||
- quoted_args
|
|
||||||
- | "pisi" -> sprintf "pisi it %s" quoted_args
|
|
||||||
- | "pacman" -> sprintf "pacman -S --noconfirm %s" quoted_args
|
|
||||||
- | "urpmi" -> sprintf "urpmi %s" quoted_args
|
|
||||||
- | "xbps" -> sprintf "xbps-install -Sy %s" quoted_args
|
|
||||||
- | "yum" -> sprintf "yum -y install %s" quoted_args
|
|
||||||
- | "zypper" -> sprintf "zypper -n in -l %s" quoted_args
|
|
||||||
-
|
|
||||||
- | "unknown" ->
|
|
||||||
- error_unknown_package_manager (s_"--install")
|
|
||||||
- | pm ->
|
|
||||||
- error_unimplemented_package_manager (s_"--install") pm
|
|
||||||
-
|
|
||||||
- and guest_update_command () =
|
|
||||||
- match g#inspect_get_package_management root with
|
|
||||||
- | "apk" ->
|
|
||||||
- "
|
|
||||||
- apk update
|
|
||||||
- apk upgrade
|
|
||||||
- "
|
|
||||||
- | "apt" ->
|
|
||||||
- (* http://unix.stackexchange.com/questions/22820 *)
|
|
||||||
- "
|
|
||||||
- export DEBIAN_FRONTEND=noninteractive
|
|
||||||
- apt_opts='-q -y -o Dpkg::Options::=--force-confnew'
|
|
||||||
- apt-get $apt_opts update
|
|
||||||
- apt-get $apt_opts upgrade
|
|
||||||
- "
|
|
||||||
- | "dnf" ->
|
|
||||||
- sprintf "dnf%s -y --best upgrade"
|
|
||||||
- (if verbose () then " --verbose" else "")
|
|
||||||
- | "pisi" -> "pisi upgrade"
|
|
||||||
- | "pacman" -> "pacman -Su"
|
|
||||||
- | "urpmi" -> "urpmi --auto-select"
|
|
||||||
- | "xbps" -> "xbps-install -Suy"
|
|
||||||
- | "yum" -> "yum -y update"
|
|
||||||
- | "zypper" -> "zypper -n update -l"
|
|
||||||
-
|
|
||||||
- | "unknown" ->
|
|
||||||
- error_unknown_package_manager (s_"--update")
|
|
||||||
- | pm ->
|
|
||||||
- error_unimplemented_package_manager (s_"--update") pm
|
|
||||||
-
|
|
||||||
- and guest_uninstall_command packages =
|
|
||||||
- let quoted_args = String.concat " " (List.map quote packages) in
|
|
||||||
- match g#inspect_get_package_management root with
|
|
||||||
- | "apk" -> sprintf "apk del %s" quoted_args
|
|
||||||
- | "apt" ->
|
|
||||||
- (* http://unix.stackexchange.com/questions/22820 *)
|
|
||||||
- sprintf "
|
|
||||||
- export DEBIAN_FRONTEND=noninteractive
|
|
||||||
- apt_opts='-q -y -o Dpkg::Options::=--force-confnew'
|
|
||||||
- apt-get $apt_opts remove %s
|
|
||||||
- " quoted_args
|
|
||||||
- | "dnf" -> sprintf "dnf -y remove %s" quoted_args
|
|
||||||
- | "pisi" -> sprintf "pisi rm %s" quoted_args
|
|
||||||
- | "pacman" -> sprintf "pacman -R %s" quoted_args
|
|
||||||
- | "urpmi" -> sprintf "urpme %s" quoted_args
|
|
||||||
- | "xbps" -> sprintf "xbps-remove -Sy %s" quoted_args
|
|
||||||
- | "yum" -> sprintf "yum -y remove %s" quoted_args
|
|
||||||
- | "zypper" -> sprintf "zypper -n rm %s" quoted_args
|
|
||||||
-
|
|
||||||
- | "unknown" ->
|
|
||||||
- error_unknown_package_manager (s_"--uninstall")
|
|
||||||
- | pm ->
|
|
||||||
- error_unimplemented_package_manager (s_"--uninstall") pm
|
|
||||||
-
|
|
||||||
- (* Windows has package_management == "unknown". *)
|
|
||||||
- and error_unknown_package_manager flag =
|
|
||||||
- error (f_"cannot use ‘%s’ because no package manager has been detected for this guest OS.\n\nIf this guest OS is a common one with ordinary package management then this may have been caused by a failure of libguestfs inspection.\n\nFor OSes such as Windows that lack package management, this is not possible. Try using one of the ‘--firstboot*’ flags instead (described in the manual).") flag
|
|
||||||
-
|
|
||||||
- and error_unimplemented_package_manager flag pm =
|
|
||||||
- error (f_"sorry, ‘%s’ with the ‘%s’ package manager has not been implemented yet.\n\nYou can work around this by using one of the ‘--run*’ or ‘--firstboot*’ options instead (described in the manual).") flag pm
|
|
||||||
+ let guest_pkgs_command f =
|
|
||||||
+ try f (g#inspect_get_package_management root) with
|
|
||||||
+ | Guest_packages.Unknown_package_manager msg
|
|
||||||
+ | Guest_packages.Unimplemented_package_manager msg ->
|
|
||||||
+ error "%s" msg
|
|
||||||
in
|
|
||||||
|
|
||||||
(* Set the random seed. *)
|
|
||||||
@@ -255,7 +167,7 @@ let run (g : G.guestfs) root (ops : ops) =
|
|
||||||
| `FirstbootPackages pkgs ->
|
|
||||||
message (f_"Installing firstboot packages: %s")
|
|
||||||
(String.concat " " pkgs);
|
|
||||||
- let cmd = guest_install_command pkgs in
|
|
||||||
+ let cmd = guest_pkgs_command (Guest_packages.install_command pkgs) in
|
|
||||||
let name = String.concat " " ("install" :: pkgs) in
|
|
||||||
Firstboot.add_firstboot_script g root name cmd
|
|
||||||
|
|
||||||
@@ -271,7 +183,7 @@ let run (g : G.guestfs) root (ops : ops) =
|
|
||||||
|
|
||||||
| `InstallPackages pkgs ->
|
|
||||||
message (f_"Installing packages: %s") (String.concat " " pkgs);
|
|
||||||
- let cmd = guest_install_command pkgs in
|
|
||||||
+ let cmd = guest_pkgs_command (Guest_packages.install_command pkgs) in
|
|
||||||
do_run ~display:cmd ~warn_failed_no_network:true cmd
|
|
||||||
|
|
||||||
| `Link (target, links) ->
|
|
||||||
@@ -365,12 +277,12 @@ let run (g : G.guestfs) root (ops : ops) =
|
|
||||||
|
|
||||||
| `UninstallPackages pkgs ->
|
|
||||||
message (f_"Uninstalling packages: %s") (String.concat " " pkgs);
|
|
||||||
- let cmd = guest_uninstall_command pkgs in
|
|
||||||
+ let cmd = guest_pkgs_command (Guest_packages.uninstall_command pkgs) in
|
|
||||||
do_run ~display:cmd cmd
|
|
||||||
|
|
||||||
| `Update ->
|
|
||||||
message (f_"Updating packages");
|
|
||||||
- let cmd = guest_update_command () in
|
|
||||||
+ let cmd = guest_pkgs_command Guest_packages.update_command in
|
|
||||||
do_run ~display:cmd ~warn_failed_no_network:true cmd
|
|
||||||
|
|
||||||
| `Upload (path, dest) ->
|
|
||||||
--
|
|
||||||
2.31.1
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
|||||||
|
From ac140e5031ca2e1a42427a0f187a9a9e34744b55 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Mon, 20 Feb 2023 15:54:22 +0000
|
||||||
|
Subject: [PATCH] build: Remove non-existent ocaml/ directory from ocaml-dep
|
||||||
|
script
|
||||||
|
|
||||||
|
This was left over from when we split out guestfs-tools from
|
||||||
|
libguestfs. It was harmless except for a warning message about the
|
||||||
|
absent directory when we rebuilt dependencies.
|
||||||
|
|
||||||
|
Fixes: commit 4354a3126152a2748cc9097cba139b3908ccc342
|
||||||
|
(cherry picked from commit c7432768dedfc560618adf63877b8c3d1dda1a76)
|
||||||
|
---
|
||||||
|
ocaml-dep.sh.in | 1 -
|
||||||
|
1 file changed, 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/ocaml-dep.sh.in b/ocaml-dep.sh.in
|
||||||
|
index a97403e18..9546a1d49 100755
|
||||||
|
--- a/ocaml-dep.sh.in
|
||||||
|
+++ b/ocaml-dep.sh.in
|
||||||
|
@@ -43,7 +43,6 @@ common/mlutils
|
||||||
|
common/mlvisit
|
||||||
|
common/mlxml
|
||||||
|
customize
|
||||||
|
-ocaml
|
||||||
|
"
|
||||||
|
|
||||||
|
# Output file is always created in the current directory.
|
||||||
|
--
|
||||||
|
2.31.1
|
||||||
|
|
@ -1,53 +0,0 @@
|
|||||||
From 493060f2ee3d5c1c8d6192bbfd307e0b720f6c11 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Date: Wed, 29 Jun 2022 15:38:46 +0200
|
|
||||||
Subject: [PATCH] update common submodule for CVE-2022-2211 fix
|
|
||||||
|
|
||||||
$ git shortlog 9e990f3e4530..35467027f657
|
|
||||||
|
|
||||||
Laszlo Ersek (1):
|
|
||||||
options: fix buffer overflow in get_keys() [CVE-2022-2211]
|
|
||||||
|
|
||||||
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
(cherry picked from commit b2e7de29b413d531c9540eb46878170e357f4b62)
|
|
||||||
---
|
|
||||||
common | 2 +-
|
|
||||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
||||||
|
|
||||||
Submodule common 9e990f3e4..35467027f:
|
|
||||||
diff --git a/common/options/keys.c b/common/options/keys.c
|
|
||||||
index 798315c..d27a712 100644
|
|
||||||
--- a/common/options/keys.c
|
|
||||||
+++ b/common/options/keys.c
|
|
||||||
@@ -128,17 +128,23 @@ read_first_line_from_file (const char *filename)
|
|
||||||
char **
|
|
||||||
get_keys (struct key_store *ks, const char *device, const char *uuid)
|
|
||||||
{
|
|
||||||
- size_t i, j, len;
|
|
||||||
+ size_t i, j, nmemb;
|
|
||||||
char **r;
|
|
||||||
char *s;
|
|
||||||
|
|
||||||
/* We know the returned list must have at least one element and not
|
|
||||||
* more than ks->nr_keys.
|
|
||||||
*/
|
|
||||||
- len = 1;
|
|
||||||
- if (ks)
|
|
||||||
- len = MIN (1, ks->nr_keys);
|
|
||||||
- r = calloc (len+1, sizeof (char *));
|
|
||||||
+ nmemb = 1;
|
|
||||||
+ if (ks && ks->nr_keys > nmemb)
|
|
||||||
+ nmemb = ks->nr_keys;
|
|
||||||
+
|
|
||||||
+ /* make room for the terminating NULL */
|
|
||||||
+ if (nmemb == (size_t)-1)
|
|
||||||
+ error (EXIT_FAILURE, 0, _("size_t overflow"));
|
|
||||||
+ nmemb++;
|
|
||||||
+
|
|
||||||
+ r = calloc (nmemb, sizeof (char *));
|
|
||||||
if (r == NULL)
|
|
||||||
error (EXIT_FAILURE, errno, "calloc");
|
|
||||||
|
|
||||||
--
|
|
||||||
2.31.1
|
|
||||||
|
|
@ -1,695 +0,0 @@
|
|||||||
From d95394da96af41b03c9347721a177a4ad9b7f1b0 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Date: Fri, 1 Jul 2022 15:20:39 +0200
|
|
||||||
Subject: [PATCH] cat, log, ls, tail, diff, edit, insp.: set networking for
|
|
||||||
"--key ID:clevis"
|
|
||||||
|
|
||||||
Call the C-language helper key_store_requires_network() in those C
|
|
||||||
utilities that understand "OPTION_key".
|
|
||||||
|
|
||||||
(Short log for libguestfs-common commit range 35467027f657..af6cb55bc58a:
|
|
||||||
|
|
||||||
Laszlo Ersek (12):
|
|
||||||
options: fix UUID comparison logic bug in get_keys()
|
|
||||||
mltools/tools_utils: remove unused function "key_store_to_cli"
|
|
||||||
mltools/tools_utils: allow multiple "--key" options for OCaml tools too
|
|
||||||
options: replace NULL-termination with number-of-elements in get_keys()
|
|
||||||
options: wrap each passphrase from get_keys() into a struct
|
|
||||||
options: add back-end for LUKS decryption with Clevis+Tang
|
|
||||||
options: introduce selector type "key_clevis"
|
|
||||||
options: generalize "--key" selector parsing for C-language utilities
|
|
||||||
mltools/tools_utils-c: handle internal type error with abort()
|
|
||||||
mltools/tools_utils: generalize "--key" selector parsing for OCaml utils
|
|
||||||
options, mltools/tools_utils: parse "--key ID:clevis" options
|
|
||||||
options, mltools/tools_utils: add helper for network dependency
|
|
||||||
).
|
|
||||||
|
|
||||||
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1809453
|
|
||||||
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Message-Id: <20220628115702.5584-2-lersek@redhat.com>
|
|
||||||
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
|
|
||||||
(cherry picked from commit 14bf833e21cd89f1273e09f4952999b8da86b6ff)
|
|
||||||
---
|
|
||||||
cat/cat.c | 3 +++
|
|
||||||
cat/log.c | 3 +++
|
|
||||||
cat/ls.c | 3 +++
|
|
||||||
cat/tail.c | 3 +++
|
|
||||||
common | 2 +-
|
|
||||||
diff/diff.c | 8 ++++++++
|
|
||||||
edit/edit.c | 3 +++
|
|
||||||
inspector/inspector.c | 3 +++
|
|
||||||
8 files changed, 27 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/cat/cat.c b/cat/cat.c
|
|
||||||
index 5b51b7df8..ea2021140 100644
|
|
||||||
--- a/cat/cat.c
|
|
||||||
+++ b/cat/cat.c
|
|
||||||
@@ -250,6 +250,9 @@ main (int argc, char *argv[])
|
|
||||||
/* Add drives, inspect and mount. */
|
|
||||||
add_drives (drvs);
|
|
||||||
|
|
||||||
+ if (key_store_requires_network (ks) && guestfs_set_network (g, 1) == -1)
|
|
||||||
+ exit (EXIT_FAILURE);
|
|
||||||
+
|
|
||||||
if (guestfs_launch (g) == -1)
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
|
|
||||||
diff --git a/cat/log.c b/cat/log.c
|
|
||||||
index df7e2be92..0fe486c05 100644
|
|
||||||
--- a/cat/log.c
|
|
||||||
+++ b/cat/log.c
|
|
||||||
@@ -224,6 +224,9 @@ main (int argc, char *argv[])
|
|
||||||
*/
|
|
||||||
add_drives (drvs);
|
|
||||||
|
|
||||||
+ if (key_store_requires_network (ks) && guestfs_set_network (g, 1) == -1)
|
|
||||||
+ exit (EXIT_FAILURE);
|
|
||||||
+
|
|
||||||
if (guestfs_launch (g) == -1)
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
|
|
||||||
diff --git a/cat/ls.c b/cat/ls.c
|
|
||||||
index e062823b8..1b8e87225 100644
|
|
||||||
--- a/cat/ls.c
|
|
||||||
+++ b/cat/ls.c
|
|
||||||
@@ -374,6 +374,9 @@ main (int argc, char *argv[])
|
|
||||||
/* Add drives, inspect and mount. */
|
|
||||||
add_drives (drvs);
|
|
||||||
|
|
||||||
+ if (key_store_requires_network (ks) && guestfs_set_network (g, 1) == -1)
|
|
||||||
+ exit (EXIT_FAILURE);
|
|
||||||
+
|
|
||||||
if (guestfs_launch (g) == -1)
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
|
|
||||||
diff --git a/cat/tail.c b/cat/tail.c
|
|
||||||
index 1cf1d6e0e..2a06e0ebd 100644
|
|
||||||
--- a/cat/tail.c
|
|
||||||
+++ b/cat/tail.c
|
|
||||||
@@ -296,6 +296,9 @@ do_tail (int argc, char *argv[], /* list of files in the guest */
|
|
||||||
/* Add drives, inspect and mount. */
|
|
||||||
add_drives (drvs);
|
|
||||||
|
|
||||||
+ if (key_store_requires_network (ks) && guestfs_set_network (g, 1) == -1)
|
|
||||||
+ exit (EXIT_FAILURE);
|
|
||||||
+
|
|
||||||
if (guestfs_launch (g) == -1)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
Submodule common 35467027f..af6cb55bc:
|
|
||||||
diff --git a/common/mltools/tools_utils-c.c b/common/mltools/tools_utils-c.c
|
|
||||||
index 0814667..4ff42e5 100644
|
|
||||||
--- a/common/mltools/tools_utils-c.c
|
|
||||||
+++ b/common/mltools/tools_utils-c.c
|
|
||||||
@@ -62,24 +62,31 @@ guestfs_int_mllib_inspect_decrypt (value gv, value gpv, value keysv)
|
|
||||||
caml_raise_out_of_memory ();
|
|
||||||
|
|
||||||
v = Field (elemv, 1);
|
|
||||||
- switch (Tag_val (v)) {
|
|
||||||
- case 0: /* KeyString of string */
|
|
||||||
- key.type = key_string;
|
|
||||||
- key.string.s = strdup (String_val (Field (v, 0)));
|
|
||||||
- if (!key.string.s)
|
|
||||||
- caml_raise_out_of_memory ();
|
|
||||||
- break;
|
|
||||||
- case 1: /* KeyFileName of string */
|
|
||||||
- key.type = key_file;
|
|
||||||
- key.file.name = strdup (String_val (Field (v, 0)));
|
|
||||||
- if (!key.file.name)
|
|
||||||
- caml_raise_out_of_memory ();
|
|
||||||
- break;
|
|
||||||
- default:
|
|
||||||
- error (EXIT_FAILURE, 0,
|
|
||||||
- "internal error: unhandled Tag_val (v) = %d",
|
|
||||||
- Tag_val (v));
|
|
||||||
- }
|
|
||||||
+ if (Is_block (v))
|
|
||||||
+ switch (Tag_val (v)) {
|
|
||||||
+ case 0: /* KeyString of string */
|
|
||||||
+ key.type = key_string;
|
|
||||||
+ key.string.s = strdup (String_val (Field (v, 0)));
|
|
||||||
+ if (!key.string.s)
|
|
||||||
+ caml_raise_out_of_memory ();
|
|
||||||
+ break;
|
|
||||||
+ case 1: /* KeyFileName of string */
|
|
||||||
+ key.type = key_file;
|
|
||||||
+ key.file.name = strdup (String_val (Field (v, 0)));
|
|
||||||
+ if (!key.file.name)
|
|
||||||
+ caml_raise_out_of_memory ();
|
|
||||||
+ break;
|
|
||||||
+ default:
|
|
||||||
+ abort ();
|
|
||||||
+ }
|
|
||||||
+ else
|
|
||||||
+ switch (Int_val (v)) {
|
|
||||||
+ case 0: /* KeyClevis */
|
|
||||||
+ key.type = key_clevis;
|
|
||||||
+ break;
|
|
||||||
+ default:
|
|
||||||
+ abort ();
|
|
||||||
+ }
|
|
||||||
|
|
||||||
ks = key_store_import_key (ks, &key);
|
|
||||||
|
|
||||||
diff --git a/common/mltools/tools_utils.ml b/common/mltools/tools_utils.ml
|
|
||||||
index 695fda7..562bfad 100644
|
|
||||||
--- a/common/mltools/tools_utils.ml
|
|
||||||
+++ b/common/mltools/tools_utils.ml
|
|
||||||
@@ -29,11 +29,12 @@ open Getopt.OptionName
|
|
||||||
let prog = ref prog
|
|
||||||
|
|
||||||
type key_store = {
|
|
||||||
- keys : (string, key_store_key) Hashtbl.t;
|
|
||||||
+ keys : (string * key_store_key) list ref;
|
|
||||||
}
|
|
||||||
and key_store_key =
|
|
||||||
| KeyString of string
|
|
||||||
| KeyFileName of string
|
|
||||||
+ | KeyClevis
|
|
||||||
|
|
||||||
external c_inspect_decrypt : Guestfs.t -> int64 -> (string * key_store_key) list -> unit = "guestfs_int_mllib_inspect_decrypt"
|
|
||||||
external c_set_echo_keys : unit -> unit = "guestfs_int_mllib_set_echo_keys" [@@noalloc]
|
|
||||||
@@ -376,7 +377,7 @@ let create_standard_options argspec ?anon_fun ?(key_opts = false)
|
|
||||||
)
|
|
||||||
in
|
|
||||||
let ks = {
|
|
||||||
- keys = Hashtbl.create 13;
|
|
||||||
+ keys = ref [];
|
|
||||||
} in
|
|
||||||
let argspec = ref argspec in
|
|
||||||
let add_argspec = List.push_back argspec in
|
|
||||||
@@ -392,14 +393,28 @@ let create_standard_options argspec ?anon_fun ?(key_opts = false)
|
|
||||||
|
|
||||||
if key_opts then (
|
|
||||||
let parse_key_selector arg =
|
|
||||||
- let parts = String.nsplit ~max:3 ":" arg in
|
|
||||||
+ let parts = String.nsplit ":" arg in
|
|
||||||
match parts with
|
|
||||||
+ | [] ->
|
|
||||||
+ error (f_"selector '%s': missing ID") arg
|
|
||||||
+ | [ _ ] ->
|
|
||||||
+ error (f_"selector '%s': missing TYPE") arg
|
|
||||||
+ | [ _; "key" ]
|
|
||||||
+ | _ :: "key" :: _ :: _ :: _ ->
|
|
||||||
+ error (f_"selector '%s': missing KEY_STRING, or too many fields") arg
|
|
||||||
| [ device; "key"; key ] ->
|
|
||||||
- Hashtbl.replace ks.keys device (KeyString key)
|
|
||||||
+ List.push_back ks.keys (device, KeyString key)
|
|
||||||
+ | [ _; "file" ]
|
|
||||||
+ | _ :: "file" :: _ :: _ :: _ ->
|
|
||||||
+ error (f_"selector '%s': missing FILENAME, or too many fields") arg
|
|
||||||
| [ device; "file"; file ] ->
|
|
||||||
- Hashtbl.replace ks.keys device (KeyFileName file)
|
|
||||||
+ List.push_back ks.keys (device, KeyFileName file)
|
|
||||||
+ | _ :: "clevis" :: _ :: _ ->
|
|
||||||
+ error (f_"selector '%s': too many fields") arg
|
|
||||||
+ | [ device; "clevis" ] ->
|
|
||||||
+ List.push_back ks.keys (device, KeyClevis)
|
|
||||||
| _ ->
|
|
||||||
- error (f_"invalid selector string for --key: %s") arg
|
|
||||||
+ error (f_"selector '%s': invalid TYPE") arg
|
|
||||||
in
|
|
||||||
|
|
||||||
add_argspec ([ L"echo-keys" ], Getopt.Unit c_set_echo_keys, s_"Don’t turn off echo for passphrases");
|
|
||||||
@@ -420,16 +435,6 @@ let create_standard_options argspec ?anon_fun ?(key_opts = false)
|
|
||||||
let getopt = Getopt.create argspec ?anon_fun usage_msg in
|
|
||||||
{ getopt; ks; debug_gc }
|
|
||||||
|
|
||||||
-let key_store_to_cli { keys } =
|
|
||||||
- Hashtbl.fold (
|
|
||||||
- fun k v acc ->
|
|
||||||
- let arg =
|
|
||||||
- match v with
|
|
||||||
- | KeyString s -> sprintf "%s:key:%s" k s
|
|
||||||
- | KeyFileName f -> sprintf "%s:file:%s" k f in
|
|
||||||
- "--key" :: arg :: acc
|
|
||||||
- ) keys []
|
|
||||||
-
|
|
||||||
(* Run an external command, slurp up the output as a list of lines. *)
|
|
||||||
let external_command ?(echo_cmd = true) cmd =
|
|
||||||
if echo_cmd then
|
|
||||||
@@ -691,21 +696,19 @@ let is_btrfs_subvolume g fs =
|
|
||||||
if g#last_errno () = Guestfs.Errno.errno_EINVAL then false
|
|
||||||
else raise exn
|
|
||||||
|
|
||||||
+let key_store_requires_network ks =
|
|
||||||
+ List.exists (function
|
|
||||||
+ | _, KeyClevis -> true
|
|
||||||
+ | _ -> false) !(ks.keys)
|
|
||||||
+
|
|
||||||
let inspect_decrypt g ks =
|
|
||||||
- (* Turn the keys in the key_store into a simpler struct, so it is possible
|
|
||||||
- * to read it using the C API.
|
|
||||||
- *)
|
|
||||||
- let keys_as_list = Hashtbl.fold (
|
|
||||||
- fun k v acc ->
|
|
||||||
- (k, v) :: acc
|
|
||||||
- ) ks.keys [] in
|
|
||||||
(* Note we pass original 'g' even though it is not used by the
|
|
||||||
* callee. This is so that 'g' is kept as a root on the stack, and
|
|
||||||
* so cannot be garbage collected while we are in the c_inspect_decrypt
|
|
||||||
* function.
|
|
||||||
*)
|
|
||||||
c_inspect_decrypt g#ocaml_handle (Guestfs.c_pointer g#ocaml_handle)
|
|
||||||
- keys_as_list
|
|
||||||
+ !(ks.keys)
|
|
||||||
|
|
||||||
let with_timeout op timeout ?(sleep = 2) fn =
|
|
||||||
let start_t = Unix.gettimeofday () in
|
|
||||||
diff --git a/common/mltools/tools_utils.mli b/common/mltools/tools_utils.mli
|
|
||||||
index 5018300..ec900e6 100644
|
|
||||||
--- a/common/mltools/tools_utils.mli
|
|
||||||
+++ b/common/mltools/tools_utils.mli
|
|
||||||
@@ -103,14 +103,6 @@ val create_standard_options : Getopt.speclist -> ?anon_fun:Getopt.anon_fun -> ?k
|
|
||||||
|
|
||||||
Returns a new {!cmdline_options} structure. *)
|
|
||||||
|
|
||||||
-val key_store_to_cli : key_store -> string list
|
|
||||||
-(** Convert a {!key_store} object back to a list of command line
|
|
||||||
- options, essentially undoing the effect of Getopt parsing.
|
|
||||||
- This is used in virt-v2v to pass the keystore to helpers.
|
|
||||||
- It is not particularly secure, especially if you use the
|
|
||||||
- [:key:] selector, although not any less secure than passing
|
|
||||||
- them via the command line in the first place. *)
|
|
||||||
-
|
|
||||||
val external_command : ?echo_cmd:bool -> string -> string list
|
|
||||||
(** Run an external command, slurp up the output as a list of lines.
|
|
||||||
|
|
||||||
@@ -204,6 +196,10 @@ val inspect_mount_root_ro : Guestfs.guestfs -> string -> unit
|
|
||||||
val is_btrfs_subvolume : Guestfs.guestfs -> string -> bool
|
|
||||||
(** Checks if a filesystem is a btrfs subvolume. *)
|
|
||||||
|
|
||||||
+val key_store_requires_network : key_store -> bool
|
|
||||||
+(** [key_store_requires_network ks] returns [true] iff [ks] contains at least
|
|
||||||
+ one "ID:clevis" selector. *)
|
|
||||||
+
|
|
||||||
val inspect_decrypt : Guestfs.guestfs -> key_store -> unit
|
|
||||||
(** Simple implementation of decryption: look for any encrypted
|
|
||||||
partitions and decrypt them, then rescan for VGs. *)
|
|
||||||
diff --git a/common/options/decrypt.c b/common/options/decrypt.c
|
|
||||||
index 1cd7b62..97c8b88 100644
|
|
||||||
--- a/common/options/decrypt.c
|
|
||||||
+++ b/common/options/decrypt.c
|
|
||||||
@@ -124,10 +124,10 @@ decrypt_mountables (guestfs_h *g, const char * const *mountables,
|
|
||||||
while ((mountable = *mnt_scan++) != NULL) {
|
|
||||||
CLEANUP_FREE char *type = NULL;
|
|
||||||
CLEANUP_FREE char *uuid = NULL;
|
|
||||||
- CLEANUP_FREE_STRING_LIST char **keys = NULL;
|
|
||||||
+ struct matching_key *keys;
|
|
||||||
+ size_t nr_matches;
|
|
||||||
CLEANUP_FREE char *mapname = NULL;
|
|
||||||
- const char * const *key_scan;
|
|
||||||
- const char *key;
|
|
||||||
+ size_t scan;
|
|
||||||
|
|
||||||
type = guestfs_vfs_type (g, mountable);
|
|
||||||
if (type == NULL)
|
|
||||||
@@ -144,33 +144,45 @@ decrypt_mountables (guestfs_h *g, const char * const *mountables,
|
|
||||||
/* Grab the keys that we should try with this device, based on device name,
|
|
||||||
* or UUID (if any).
|
|
||||||
*/
|
|
||||||
- keys = get_keys (ks, mountable, uuid);
|
|
||||||
- assert (keys[0] != NULL);
|
|
||||||
+ keys = get_keys (ks, mountable, uuid, &nr_matches);
|
|
||||||
+ assert (nr_matches > 0);
|
|
||||||
|
|
||||||
/* Generate a node name for the plaintext (decrypted) device node. */
|
|
||||||
if (uuid == NULL || asprintf (&mapname, "luks-%s", uuid) == -1)
|
|
||||||
mapname = make_mapname (mountable);
|
|
||||||
|
|
||||||
/* Try each key in turn. */
|
|
||||||
- key_scan = (const char * const *)keys;
|
|
||||||
- while ((key = *key_scan++) != NULL) {
|
|
||||||
+ for (scan = 0; scan < nr_matches; ++scan) {
|
|
||||||
+ struct matching_key *key = keys + scan;
|
|
||||||
int r;
|
|
||||||
|
|
||||||
guestfs_push_error_handler (g, NULL, NULL);
|
|
||||||
- r = guestfs_cryptsetup_open (g, mountable, key, mapname, -1);
|
|
||||||
+ assert (key->clevis == (key->passphrase == NULL));
|
|
||||||
+ if (key->clevis)
|
|
||||||
+#ifdef GUESTFS_HAVE_CLEVIS_LUKS_UNLOCK
|
|
||||||
+ r = guestfs_clevis_luks_unlock (g, mountable, mapname);
|
|
||||||
+#else
|
|
||||||
+ error (EXIT_FAILURE, 0,
|
|
||||||
+ _("'clevis_luks_unlock', needed for decrypting %s, is "
|
|
||||||
+ "unavailable in this libguestfs version"), mountable);
|
|
||||||
+#endif
|
|
||||||
+ else
|
|
||||||
+ r = guestfs_cryptsetup_open (g, mountable, key->passphrase, mapname,
|
|
||||||
+ -1);
|
|
||||||
guestfs_pop_error_handler (g);
|
|
||||||
|
|
||||||
if (r == 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
- if (key == NULL)
|
|
||||||
+ if (scan == nr_matches)
|
|
||||||
error (EXIT_FAILURE, 0,
|
|
||||||
_("could not find key to open LUKS encrypted %s.\n\n"
|
|
||||||
"Try using --key on the command line.\n\n"
|
|
||||||
"Original error: %s (%d)"),
|
|
||||||
mountable, guestfs_last_error (g), guestfs_last_errno (g));
|
|
||||||
|
|
||||||
+ free_keys (keys, nr_matches);
|
|
||||||
decrypted_some = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/common/options/key-option.pod b/common/options/key-option.pod
|
|
||||||
index 90a3b15..6bc04df 100644
|
|
||||||
--- a/common/options/key-option.pod
|
|
||||||
+++ b/common/options/key-option.pod
|
|
||||||
@@ -14,4 +14,13 @@ Use the specified C<KEY_STRING> as passphrase.
|
|
||||||
|
|
||||||
Read the passphrase from F<FILENAME>.
|
|
||||||
|
|
||||||
+=item B<--key> C<ID>:clevis
|
|
||||||
+
|
|
||||||
+Attempt passphrase-less unlocking for C<ID> with Clevis, over the
|
|
||||||
+network. Please refer to L<guestfs(3)/ENCRYPTED DISKS> for more
|
|
||||||
+information on network-bound disk encryption (NBDE).
|
|
||||||
+
|
|
||||||
+Note that if any such option is present on the command line, QEMU user
|
|
||||||
+networking will be automatically enabled for the libguestfs appliance.
|
|
||||||
+
|
|
||||||
=back
|
|
||||||
diff --git a/common/options/keys.c b/common/options/keys.c
|
|
||||||
index d27a712..d987ae5 100644
|
|
||||||
--- a/common/options/keys.c
|
|
||||||
+++ b/common/options/keys.c
|
|
||||||
@@ -125,11 +125,12 @@ read_first_line_from_file (const char *filename)
|
|
||||||
* keystore. There may be multiple. If none are read from the
|
|
||||||
* keystore, ask the user.
|
|
||||||
*/
|
|
||||||
-char **
|
|
||||||
-get_keys (struct key_store *ks, const char *device, const char *uuid)
|
|
||||||
+struct matching_key *
|
|
||||||
+get_keys (struct key_store *ks, const char *device, const char *uuid,
|
|
||||||
+ size_t *nr_matches)
|
|
||||||
{
|
|
||||||
- size_t i, j, nmemb;
|
|
||||||
- char **r;
|
|
||||||
+ size_t i, nmemb;
|
|
||||||
+ struct matching_key *r, *match;
|
|
||||||
char *s;
|
|
||||||
|
|
||||||
/* We know the returned list must have at least one element and not
|
|
||||||
@@ -139,22 +140,20 @@ get_keys (struct key_store *ks, const char *device, const char *uuid)
|
|
||||||
if (ks && ks->nr_keys > nmemb)
|
|
||||||
nmemb = ks->nr_keys;
|
|
||||||
|
|
||||||
- /* make room for the terminating NULL */
|
|
||||||
- if (nmemb == (size_t)-1)
|
|
||||||
+ if (nmemb > (size_t)-1 / sizeof *r)
|
|
||||||
error (EXIT_FAILURE, 0, _("size_t overflow"));
|
|
||||||
- nmemb++;
|
|
||||||
|
|
||||||
- r = calloc (nmemb, sizeof (char *));
|
|
||||||
+ r = malloc (nmemb * sizeof *r);
|
|
||||||
if (r == NULL)
|
|
||||||
- error (EXIT_FAILURE, errno, "calloc");
|
|
||||||
+ error (EXIT_FAILURE, errno, "malloc");
|
|
||||||
|
|
||||||
- j = 0;
|
|
||||||
+ match = r;
|
|
||||||
|
|
||||||
if (ks) {
|
|
||||||
for (i = 0; i < ks->nr_keys; ++i) {
|
|
||||||
struct key_store_key *key = &ks->keys[i];
|
|
||||||
|
|
||||||
- if (STRNEQ (key->id, device) && (uuid && STRNEQ (key->id, uuid)))
|
|
||||||
+ if (STRNEQ (key->id, device) && (!uuid || STRNEQ (key->id, uuid)))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
switch (key->type) {
|
|
||||||
@@ -162,68 +161,101 @@ get_keys (struct key_store *ks, const char *device, const char *uuid)
|
|
||||||
s = strdup (key->string.s);
|
|
||||||
if (!s)
|
|
||||||
error (EXIT_FAILURE, errno, "strdup");
|
|
||||||
- r[j++] = s;
|
|
||||||
+ match->clevis = false;
|
|
||||||
+ match->passphrase = s;
|
|
||||||
+ ++match;
|
|
||||||
break;
|
|
||||||
case key_file:
|
|
||||||
s = read_first_line_from_file (key->file.name);
|
|
||||||
- r[j++] = s;
|
|
||||||
+ match->clevis = false;
|
|
||||||
+ match->passphrase = s;
|
|
||||||
+ ++match;
|
|
||||||
+ break;
|
|
||||||
+ case key_clevis:
|
|
||||||
+ match->clevis = true;
|
|
||||||
+ match->passphrase = NULL;
|
|
||||||
+ ++match;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- if (j == 0) {
|
|
||||||
+ if (match == r) {
|
|
||||||
/* Key not found in the key store, ask the user for it. */
|
|
||||||
s = read_key (device);
|
|
||||||
if (!s)
|
|
||||||
error (EXIT_FAILURE, 0, _("could not read key from user"));
|
|
||||||
- r[0] = s;
|
|
||||||
+ match->clevis = false;
|
|
||||||
+ match->passphrase = s;
|
|
||||||
+ ++match;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ *nr_matches = (size_t)(match - r);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
+void
|
|
||||||
+free_keys (struct matching_key *keys, size_t nr_matches)
|
|
||||||
+{
|
|
||||||
+ size_t i;
|
|
||||||
+
|
|
||||||
+ for (i = 0; i < nr_matches; ++i) {
|
|
||||||
+ struct matching_key *key = keys + i;
|
|
||||||
+
|
|
||||||
+ assert (key->clevis == (key->passphrase == NULL));
|
|
||||||
+ if (!key->clevis)
|
|
||||||
+ free (key->passphrase);
|
|
||||||
+ }
|
|
||||||
+ free (keys);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
struct key_store *
|
|
||||||
key_store_add_from_selector (struct key_store *ks, const char *selector)
|
|
||||||
{
|
|
||||||
- CLEANUP_FREE_STRING_LIST char **fields =
|
|
||||||
- guestfs_int_split_string (':', selector);
|
|
||||||
+ CLEANUP_FREE_STRING_LIST char **fields = NULL;
|
|
||||||
+ size_t field_count;
|
|
||||||
struct key_store_key key;
|
|
||||||
|
|
||||||
+ fields = guestfs_int_split_string (':', selector);
|
|
||||||
if (!fields)
|
|
||||||
error (EXIT_FAILURE, errno, "guestfs_int_split_string");
|
|
||||||
+ field_count = guestfs_int_count_strings (fields);
|
|
||||||
|
|
||||||
- if (guestfs_int_count_strings (fields) != 3) {
|
|
||||||
- invalid_selector:
|
|
||||||
- error (EXIT_FAILURE, 0, "invalid selector for --key: %s", selector);
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- /* 1: device */
|
|
||||||
+ /* field#0: ID */
|
|
||||||
+ if (field_count < 1)
|
|
||||||
+ error (EXIT_FAILURE, 0, _("selector '%s': missing ID"), selector);
|
|
||||||
key.id = strdup (fields[0]);
|
|
||||||
if (!key.id)
|
|
||||||
error (EXIT_FAILURE, errno, "strdup");
|
|
||||||
|
|
||||||
- /* 2: key type */
|
|
||||||
- if (STREQ (fields[1], "key"))
|
|
||||||
+ /* field#1...: TYPE, and TYPE-specific properties */
|
|
||||||
+ if (field_count < 2)
|
|
||||||
+ error (EXIT_FAILURE, 0, _("selector '%s': missing TYPE"), selector);
|
|
||||||
+
|
|
||||||
+ if (STREQ (fields[1], "key")) {
|
|
||||||
key.type = key_string;
|
|
||||||
- else if (STREQ (fields[1], "file"))
|
|
||||||
- key.type = key_file;
|
|
||||||
- else
|
|
||||||
- goto invalid_selector;
|
|
||||||
-
|
|
||||||
- /* 3: actual key */
|
|
||||||
- switch (key.type) {
|
|
||||||
- case key_string:
|
|
||||||
+ if (field_count != 3)
|
|
||||||
+ error (EXIT_FAILURE, 0,
|
|
||||||
+ _("selector '%s': missing KEY_STRING, or too many fields"),
|
|
||||||
+ selector);
|
|
||||||
key.string.s = strdup (fields[2]);
|
|
||||||
if (!key.string.s)
|
|
||||||
error (EXIT_FAILURE, errno, "strdup");
|
|
||||||
- break;
|
|
||||||
- case key_file:
|
|
||||||
+ } else if (STREQ (fields[1], "file")) {
|
|
||||||
+ key.type = key_file;
|
|
||||||
+ if (field_count != 3)
|
|
||||||
+ error (EXIT_FAILURE, 0,
|
|
||||||
+ _("selector '%s': missing FILENAME, or too many fields"),
|
|
||||||
+ selector);
|
|
||||||
key.file.name = strdup (fields[2]);
|
|
||||||
if (!key.file.name)
|
|
||||||
error (EXIT_FAILURE, errno, "strdup");
|
|
||||||
- break;
|
|
||||||
- }
|
|
||||||
+ } else if (STREQ (fields[1], "clevis")) {
|
|
||||||
+ key.type = key_clevis;
|
|
||||||
+ if (field_count != 2)
|
|
||||||
+ error (EXIT_FAILURE, 0, _("selector '%s': too many fields"), selector);
|
|
||||||
+ } else
|
|
||||||
+ error (EXIT_FAILURE, 0, _("selector '%s': invalid TYPE"), selector);
|
|
||||||
|
|
||||||
return key_store_import_key (ks, &key);
|
|
||||||
}
|
|
||||||
@@ -252,6 +284,21 @@ key_store_import_key (struct key_store *ks, const struct key_store_key *key)
|
|
||||||
return ks;
|
|
||||||
}
|
|
||||||
|
|
||||||
+bool
|
|
||||||
+key_store_requires_network (const struct key_store *ks)
|
|
||||||
+{
|
|
||||||
+ size_t i;
|
|
||||||
+
|
|
||||||
+ if (ks == NULL)
|
|
||||||
+ return false;
|
|
||||||
+
|
|
||||||
+ for (i = 0; i < ks->nr_keys; ++i)
|
|
||||||
+ if (ks->keys[i].type == key_clevis)
|
|
||||||
+ return true;
|
|
||||||
+
|
|
||||||
+ return false;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
void
|
|
||||||
free_key_store (struct key_store *ks)
|
|
||||||
{
|
|
||||||
@@ -270,6 +317,9 @@ free_key_store (struct key_store *ks)
|
|
||||||
case key_file:
|
|
||||||
free (key->file.name);
|
|
||||||
break;
|
|
||||||
+ case key_clevis:
|
|
||||||
+ /* nothing */
|
|
||||||
+ break;
|
|
||||||
}
|
|
||||||
free (key->id);
|
|
||||||
}
|
|
||||||
diff --git a/common/options/options.h b/common/options/options.h
|
|
||||||
index 80df91a..60d5d80 100644
|
|
||||||
--- a/common/options/options.h
|
|
||||||
+++ b/common/options/options.h
|
|
||||||
@@ -115,6 +115,7 @@ struct key_store_key {
|
|
||||||
enum {
|
|
||||||
key_string, /* key specified as string */
|
|
||||||
key_file, /* key stored in a file */
|
|
||||||
+ key_clevis, /* key reconstructed with Clevis+Tang */
|
|
||||||
} type;
|
|
||||||
union {
|
|
||||||
struct {
|
|
||||||
@@ -134,6 +135,19 @@ struct key_store {
|
|
||||||
size_t nr_keys;
|
|
||||||
};
|
|
||||||
|
|
||||||
+/* A key matching a particular ID (pathname of the libguestfs device node that
|
|
||||||
+ * stands for the encrypted block device, or LUKS UUID).
|
|
||||||
+ */
|
|
||||||
+struct matching_key {
|
|
||||||
+ /* True iff the passphrase should be reconstructed using Clevis, talking to
|
|
||||||
+ * Tang servers over the network.
|
|
||||||
+ */
|
|
||||||
+ bool clevis;
|
|
||||||
+
|
|
||||||
+ /* Explicit passphrase, otherwise. */
|
|
||||||
+ char *passphrase;
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
/* in config.c */
|
|
||||||
extern void parse_config (void);
|
|
||||||
|
|
||||||
@@ -151,9 +165,12 @@ extern void print_inspect_prompt (void);
|
|
||||||
|
|
||||||
/* in key.c */
|
|
||||||
extern char *read_key (const char *param);
|
|
||||||
-extern char **get_keys (struct key_store *ks, const char *device, const char *uuid);
|
|
||||||
+extern struct matching_key *get_keys (struct key_store *ks, const char *device,
|
|
||||||
+ const char *uuid, size_t *nr_matches);
|
|
||||||
+extern void free_keys (struct matching_key *keys, size_t nr_matches);
|
|
||||||
extern struct key_store *key_store_add_from_selector (struct key_store *ks, const char *selector);
|
|
||||||
extern struct key_store *key_store_import_key (struct key_store *ks, const struct key_store_key *key);
|
|
||||||
+extern bool key_store_requires_network (const struct key_store *ks);
|
|
||||||
extern void free_key_store (struct key_store *ks);
|
|
||||||
|
|
||||||
/* in options.c */
|
|
||||||
diff --git a/diff/diff.c b/diff/diff.c
|
|
||||||
index 6aae88e6a..c73129c82 100644
|
|
||||||
--- a/diff/diff.c
|
|
||||||
+++ b/diff/diff.c
|
|
||||||
@@ -209,6 +209,7 @@ main (int argc, char *argv[])
|
|
||||||
int option_index;
|
|
||||||
struct tree *tree1, *tree2;
|
|
||||||
struct key_store *ks = NULL;
|
|
||||||
+ bool network;
|
|
||||||
|
|
||||||
g = guestfs_create ();
|
|
||||||
if (g == NULL)
|
|
||||||
@@ -378,6 +379,10 @@ main (int argc, char *argv[])
|
|
||||||
/* Mount up first guest. */
|
|
||||||
add_drives (drvs);
|
|
||||||
|
|
||||||
+ network = key_store_requires_network (ks);
|
|
||||||
+ if (guestfs_set_network (g, network) == -1)
|
|
||||||
+ exit (EXIT_FAILURE);
|
|
||||||
+
|
|
||||||
if (guestfs_launch (g) == -1)
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
|
|
||||||
@@ -389,6 +394,9 @@ main (int argc, char *argv[])
|
|
||||||
/* Mount up second guest. */
|
|
||||||
add_drives_handle (g2, drvs2, 0);
|
|
||||||
|
|
||||||
+ if (guestfs_set_network (g2, network) == -1)
|
|
||||||
+ exit (EXIT_FAILURE);
|
|
||||||
+
|
|
||||||
if (guestfs_launch (g2) == -1)
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
|
|
||||||
diff --git a/edit/edit.c b/edit/edit.c
|
|
||||||
index 7f06bce7f..90c6b85d5 100644
|
|
||||||
--- a/edit/edit.c
|
|
||||||
+++ b/edit/edit.c
|
|
||||||
@@ -274,6 +274,9 @@ main (int argc, char *argv[])
|
|
||||||
/* Add drives. */
|
|
||||||
add_drives (drvs);
|
|
||||||
|
|
||||||
+ if (key_store_requires_network (ks) && guestfs_set_network (g, 1) == -1)
|
|
||||||
+ exit (EXIT_FAILURE);
|
|
||||||
+
|
|
||||||
if (guestfs_launch (g) == -1)
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
|
|
||||||
diff --git a/inspector/inspector.c b/inspector/inspector.c
|
|
||||||
index 25ee40f3f..2702e3310 100644
|
|
||||||
--- a/inspector/inspector.c
|
|
||||||
+++ b/inspector/inspector.c
|
|
||||||
@@ -294,6 +294,9 @@ main (int argc, char *argv[])
|
|
||||||
*/
|
|
||||||
add_drives (drvs);
|
|
||||||
|
|
||||||
+ if (key_store_requires_network (ks) && guestfs_set_network (g, 1) == -1)
|
|
||||||
+ exit (EXIT_FAILURE);
|
|
||||||
+
|
|
||||||
if (guestfs_launch (g) == -1)
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
|
|
||||||
--
|
|
||||||
2.31.1
|
|
||||||
|
|
48
0007-valgrind-Update-for-pcre2.patch
Normal file
48
0007-valgrind-Update-for-pcre2.patch
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
From 0488336bcce737b7dce33934d656ea7f07bb69bb Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Mon, 20 Feb 2023 17:39:22 +0000
|
||||||
|
Subject: [PATCH] valgrind: Update for pcre2
|
||||||
|
|
||||||
|
I'm unclear why this error has suddenly appeared. We switched from
|
||||||
|
pcre to pcre2 nearly two years ago. However it is clear that the
|
||||||
|
existing suppression was incorrect and needs to be updated for pcre2.
|
||||||
|
|
||||||
|
==2036392== 154 bytes in 1 blocks are possibly lost in loss record 488 of 544
|
||||||
|
==2036392== at 0x484186F: malloc (vg_replace_malloc.c:393)
|
||||||
|
==2036392== by 0x4884035: pcre2_compile_8 (pcre2_compile.c:10250)
|
||||||
|
==2036392== by 0x21DFA9: guestfs_int_pcre_compile (pcre-c.c:194)
|
||||||
|
==2036392== by 0x2233F0: camlLinux_bootloaders__entry (linux_bootloaders.ml:4
|
||||||
|
1)
|
||||||
|
==2036392== by 0x20B138: caml_program (in /home/rjones/d/guestfs-tools/driver
|
||||||
|
s/virt-drivers)
|
||||||
|
==2036392== by 0x33B7E4: caml_start_program (in /home/rjones/d/guestfs-tools/
|
||||||
|
drivers/virt-drivers)
|
||||||
|
==2036392== by 0x33BB8E: caml_startup_common (in /home/rjones/d/guestfs-tools
|
||||||
|
/drivers/virt-drivers)
|
||||||
|
==2036392== by 0x33BBEC: caml_startup (in /home/rjones/d/guestfs-tools/driver
|
||||||
|
s/virt-drivers)
|
||||||
|
==2036392== by 0x20ABFF: main (in /home/rjones/d/guestfs-tools/drivers/virt-d
|
||||||
|
rivers)
|
||||||
|
|
||||||
|
Fixes: commit 9ba454622b60d7550e892d8a49048014603b8e2a
|
||||||
|
(cherry picked from commit f6c5f0c3d51bfd3cd764e81e5aeb035946643387)
|
||||||
|
---
|
||||||
|
valgrind-suppressions | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/valgrind-suppressions b/valgrind-suppressions
|
||||||
|
index 4c8e37886..75d48f0a1 100644
|
||||||
|
--- a/valgrind-suppressions
|
||||||
|
+++ b/valgrind-suppressions
|
||||||
|
@@ -197,7 +197,7 @@
|
||||||
|
ocaml_pcre_globals
|
||||||
|
Memcheck:Leak
|
||||||
|
fun:malloc
|
||||||
|
- fun:pcre_compile2
|
||||||
|
+ fun:pcre2_compile_8
|
||||||
|
...
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.31.1
|
||||||
|
|
@ -1,59 +0,0 @@
|
|||||||
From 77a10b30f6f6fdb1648b12f68147e6a894526802 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Date: Tue, 28 Jun 2022 13:57:00 +0200
|
|
||||||
Subject: [PATCH] get-kernel, sparsify: set networking for "--key ID:clevis"
|
|
||||||
|
|
||||||
Call the OCaml-language helper "key_store_requires_network" in those OCaml
|
|
||||||
utilities that pass "~key_opts:true" to "create_standard_options", and do
|
|
||||||
not have any code related to networking yet.
|
|
||||||
|
|
||||||
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1809453
|
|
||||||
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Message-Id: <20220628115702.5584-3-lersek@redhat.com>
|
|
||||||
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
|
|
||||||
(cherry picked from commit 4f66f0892e6fd75d10dcfa2f9e94b3e32bdb906e)
|
|
||||||
---
|
|
||||||
get-kernel/get_kernel.ml | 1 +
|
|
||||||
sparsify/copying.ml | 1 +
|
|
||||||
sparsify/in_place.ml | 1 +
|
|
||||||
3 files changed, 3 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/get-kernel/get_kernel.ml b/get-kernel/get_kernel.ml
|
|
||||||
index e485cf495..9c2aa17c2 100644
|
|
||||||
--- a/get-kernel/get_kernel.ml
|
|
||||||
+++ b/get-kernel/get_kernel.ml
|
|
||||||
@@ -176,6 +176,7 @@ let main () =
|
|
||||||
(* Connect to libguestfs. *)
|
|
||||||
let g = open_guestfs () in
|
|
||||||
add g;
|
|
||||||
+ g#set_network (key_store_requires_network ks);
|
|
||||||
g#launch ();
|
|
||||||
|
|
||||||
(* Decrypt the disks. *)
|
|
||||||
diff --git a/sparsify/copying.ml b/sparsify/copying.ml
|
|
||||||
index 39d06c94c..21a603d63 100644
|
|
||||||
--- a/sparsify/copying.ml
|
|
||||||
+++ b/sparsify/copying.ml
|
|
||||||
@@ -187,6 +187,7 @@ You can ignore this warning or change it to a hard failure using the
|
|
||||||
let machine_readable = machine_readable () <> None in
|
|
||||||
Progress.set_up_progress_bar ~machine_readable g
|
|
||||||
);
|
|
||||||
+ g#set_network (key_store_requires_network ks);
|
|
||||||
g#launch ();
|
|
||||||
|
|
||||||
g in
|
|
||||||
diff --git a/sparsify/in_place.ml b/sparsify/in_place.ml
|
|
||||||
index 00f0e0564..0eec63e6f 100644
|
|
||||||
--- a/sparsify/in_place.ml
|
|
||||||
+++ b/sparsify/in_place.ml
|
|
||||||
@@ -58,6 +58,7 @@ let run disk format ignores zeroes ks =
|
|
||||||
let machine_readable = machine_readable () <> None in
|
|
||||||
Progress.set_up_progress_bar ~machine_readable g
|
|
||||||
);
|
|
||||||
+ g#set_network (key_store_requires_network ks);
|
|
||||||
g#launch ();
|
|
||||||
|
|
||||||
(* If discard is not supported in the appliance, we must return exit
|
|
||||||
--
|
|
||||||
2.31.1
|
|
||||||
|
|
53
0008-valgrind-Add-another-libvirt-suppression.patch
Normal file
53
0008-valgrind-Add-another-libvirt-suppression.patch
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
From e911cfc70371d572e71c26eaba4a6419a058241e Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Mon, 20 Feb 2023 17:46:55 +0000
|
||||||
|
Subject: [PATCH] valgrind: Add another libvirt suppression
|
||||||
|
|
||||||
|
It seems as if this is just a variation on the previous libvirt
|
||||||
|
suppression.
|
||||||
|
|
||||||
|
==2042391== 61 (48 direct, 13 indirect) bytes in 1 blocks are definitely lost in
|
||||||
|
loss record 267 of 507
|
||||||
|
==2042391== at 0x4846464: calloc (vg_replace_malloc.c:1340)
|
||||||
|
==2042391== by 0x54EE318: g_malloc0 (gmem.c:163)
|
||||||
|
==2042391== by 0x5017D4C: virClassNew (virobject.c:189)
|
||||||
|
==2042391== by 0x523CCB9: virDataTypesOnce.lto_priv.0 (datatypes.c:111)
|
||||||
|
==2042391== by 0x4D8BE42: __pthread_once_slow (pthread_once.c:116)
|
||||||
|
==2042391== by 0x50345E1: virOnce (virthread.c:44)
|
||||||
|
==2042391== by 0x523CD6A: virGetConnect (datatypes.c:121)
|
||||||
|
==2042391== by 0x51FBC1F: virConnectOpenInternal (libvirt.c:893)
|
||||||
|
==2042391== by 0x51FCC11: virConnectOpenAuth (libvirt.c:1271)
|
||||||
|
==2042391== by 0x4A3ECAD: guestfs_int_open_libvirt_connection.constprop.0 (li
|
||||||
|
bvirt-auth.c:224)
|
||||||
|
==2042391== by 0x4A1D62A: launch_libvirt.lto_priv.0 (launch-libvirt.c:389)
|
||||||
|
==2042391== by 0x4993739: guestfs_launch (launch.c:114)
|
||||||
|
|
||||||
|
(cherry picked from commit 8790af0266a808c8a04927bb5039be06cbc3da54)
|
||||||
|
---
|
||||||
|
valgrind-suppressions | 10 ++++++++++
|
||||||
|
1 file changed, 10 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/valgrind-suppressions b/valgrind-suppressions
|
||||||
|
index 75d48f0a1..a13d82fb7 100644
|
||||||
|
--- a/valgrind-suppressions
|
||||||
|
+++ b/valgrind-suppressions
|
||||||
|
@@ -329,6 +329,16 @@
|
||||||
|
fun:virDataTypesOnce
|
||||||
|
}
|
||||||
|
|
||||||
|
+{
|
||||||
|
+ libvirt_leak_10
|
||||||
|
+ Memcheck:Leak
|
||||||
|
+ ...
|
||||||
|
+ fun:g_malloc0
|
||||||
|
+ fun:virClassNew
|
||||||
|
+ ...
|
||||||
|
+ fun:virOnce
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
# FUSE leaks the per-thread context (although the code looks
|
||||||
|
# like it attempts to clean it up). In older fuse, it uses
|
||||||
|
# malloc. In newer fuse it uses calloc.
|
||||||
|
--
|
||||||
|
2.31.1
|
||||||
|
|
@ -1,47 +0,0 @@
|
|||||||
From fe59e93b27e3bc17b5cc0874e103330e0000b210 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Date: Tue, 28 Jun 2022 13:57:01 +0200
|
|
||||||
Subject: [PATCH] customize: add reminder about "--key ID:clevis"
|
|
||||||
|
|
||||||
virt-customize already enables appliance networking by default;
|
|
||||||
conversely, if the user passes "--no-network", we shouldn't override that
|
|
||||||
for the sake of "--key ID:clevis". Add comments about clevis to the code.
|
|
||||||
|
|
||||||
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1809453
|
|
||||||
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Message-Id: <20220628115702.5584-4-lersek@redhat.com>
|
|
||||||
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
|
|
||||||
(cherry picked from commit e52aea48cbcea3f3b538db0573b58517cbc33da0)
|
|
||||||
---
|
|
||||||
customize/customize_main.ml | 7 +++++++
|
|
||||||
1 file changed, 7 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/customize/customize_main.ml b/customize/customize_main.ml
|
|
||||||
index 8a022342f..32b7eebdd 100644
|
|
||||||
--- a/customize/customize_main.ml
|
|
||||||
+++ b/customize/customize_main.ml
|
|
||||||
@@ -52,7 +52,11 @@ let main () =
|
|
||||||
let libvirturi = ref "" in
|
|
||||||
let memsize = ref None in
|
|
||||||
let set_memsize arg = memsize := Some arg in
|
|
||||||
+
|
|
||||||
+ (* Note that [--key ID:clevis] depends on this default. See more below, near
|
|
||||||
+ * [g#set_network network]. *)
|
|
||||||
let network = ref true in
|
|
||||||
+
|
|
||||||
let smp = ref None in
|
|
||||||
let set_smp arg = smp := Some arg in
|
|
||||||
|
|
||||||
@@ -159,6 +163,9 @@ read the man page virt-customize(1).
|
|
||||||
let g = open_guestfs () in
|
|
||||||
Option.may g#set_memsize memsize;
|
|
||||||
Option.may g#set_smp smp;
|
|
||||||
+ (* [--no-network] from the command line takes precedence over the automatic
|
|
||||||
+ * network enablement for [--key ID:clevis], so here we intentionally don't check
|
|
||||||
+ * [key_store_requires_network opthandle.ks]. *)
|
|
||||||
g#set_network network;
|
|
||||||
|
|
||||||
(* Add disks. *)
|
|
||||||
--
|
|
||||||
2.31.1
|
|
||||||
|
|
60
0009-drivers-Swap-the-names-of-the-tests.patch
Normal file
60
0009-drivers-Swap-the-names-of-the-tests.patch
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
From 64ca97e910cc086af70b8cf0968cf5039afcb108 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Mon, 20 Feb 2023 17:03:41 +0000
|
||||||
|
Subject: [PATCH] drivers: Swap the names of the tests
|
||||||
|
|
||||||
|
The names of the tests were reversed from what they actually did,
|
||||||
|
causing confusion.
|
||||||
|
|
||||||
|
Fixes: commit d38d2ee5a3d4b09277cd97bc6f63004b7b7e697c
|
||||||
|
(cherry picked from commit ecc562601b5f64778f5598d8663e3a052a0b6976)
|
||||||
|
---
|
||||||
|
drivers/test-virt-drivers-linux.sh | 10 +++++-----
|
||||||
|
drivers/test-virt-drivers-windows.sh | 10 +++++-----
|
||||||
|
2 files changed, 10 insertions(+), 10 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/drivers/test-virt-drivers-linux.sh b/drivers/test-virt-drivers-linux.sh
|
||||||
|
index df3f36c64..5404db1e5 100755
|
||||||
|
--- a/drivers/test-virt-drivers-linux.sh
|
||||||
|
+++ b/drivers/test-virt-drivers-linux.sh
|
||||||
|
@@ -20,11 +20,11 @@ set -e
|
||||||
|
|
||||||
|
$TEST_FUNCTIONS
|
||||||
|
skip_if_skipped
|
||||||
|
-skip_unless_phony_guest windows.img
|
||||||
|
+skip_unless_phony_guest fedora.img
|
||||||
|
|
||||||
|
-rm -f actual-windows.xml
|
||||||
|
+rm -f actual-fedora.xml
|
||||||
|
|
||||||
|
-$VG virt-drivers --format=raw -a ../test-data/phony-guests/windows.img > actual-windows.xml
|
||||||
|
-diff -ur -I "generated by" expected-windows.xml actual-windows.xml
|
||||||
|
+$VG virt-drivers --format=raw -a ../test-data/phony-guests/fedora.img > actual-fedora.xml
|
||||||
|
+diff -ur -I "generated by" expected-fedora.xml actual-fedora.xml
|
||||||
|
|
||||||
|
-rm actual-windows.xml
|
||||||
|
+rm actual-fedora.xml
|
||||||
|
diff --git a/drivers/test-virt-drivers-windows.sh b/drivers/test-virt-drivers-windows.sh
|
||||||
|
index 5404db1e5..df3f36c64 100755
|
||||||
|
--- a/drivers/test-virt-drivers-windows.sh
|
||||||
|
+++ b/drivers/test-virt-drivers-windows.sh
|
||||||
|
@@ -20,11 +20,11 @@ set -e
|
||||||
|
|
||||||
|
$TEST_FUNCTIONS
|
||||||
|
skip_if_skipped
|
||||||
|
-skip_unless_phony_guest fedora.img
|
||||||
|
+skip_unless_phony_guest windows.img
|
||||||
|
|
||||||
|
-rm -f actual-fedora.xml
|
||||||
|
+rm -f actual-windows.xml
|
||||||
|
|
||||||
|
-$VG virt-drivers --format=raw -a ../test-data/phony-guests/fedora.img > actual-fedora.xml
|
||||||
|
-diff -ur -I "generated by" expected-fedora.xml actual-fedora.xml
|
||||||
|
+$VG virt-drivers --format=raw -a ../test-data/phony-guests/windows.img > actual-windows.xml
|
||||||
|
+diff -ur -I "generated by" expected-windows.xml actual-windows.xml
|
||||||
|
|
||||||
|
-rm actual-fedora.xml
|
||||||
|
+rm actual-windows.xml
|
||||||
|
--
|
||||||
|
2.31.1
|
||||||
|
|
601
0010-drivers-Look-up-vendor-and-device-names-in-PCI-and-U.patch
Normal file
601
0010-drivers-Look-up-vendor-and-device-names-in-PCI-and-U.patch
Normal file
@ -0,0 +1,601 @@
|
|||||||
|
From 850f26459cdd568db8ee870d41b317f886854750 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
Date: Sat, 18 Feb 2023 12:04:04 +0000
|
||||||
|
Subject: [PATCH] drivers: Look up vendor and device names in PCI and USB IDs
|
||||||
|
database
|
||||||
|
|
||||||
|
(cherry picked from commit ca21ee4918cd7d4472bd875a495752a03a03fa87)
|
||||||
|
---
|
||||||
|
.gitignore | 1 +
|
||||||
|
common | 2 +-
|
||||||
|
configure.ac | 1 +
|
||||||
|
drivers/Makefile.am | 6 +-
|
||||||
|
drivers/drivers.ml | 31 +++++
|
||||||
|
drivers/hwdata.ml | 187 +++++++++++++++++++++++++++
|
||||||
|
drivers/hwdata.mli | 31 +++++
|
||||||
|
drivers/hwdata_config.ml.in | 26 ++++
|
||||||
|
drivers/hwdata_config.mli | 35 +++++
|
||||||
|
drivers/test-virt-drivers-windows.sh | 13 +-
|
||||||
|
m4/guestfs-libraries.m4 | 3 +
|
||||||
|
po/POTFILES-ml | 2 +
|
||||||
|
12 files changed, 334 insertions(+), 4 deletions(-)
|
||||||
|
create mode 100644 drivers/hwdata.ml
|
||||||
|
create mode 100644 drivers/hwdata.mli
|
||||||
|
create mode 100644 drivers/hwdata_config.ml.in
|
||||||
|
create mode 100644 drivers/hwdata_config.mli
|
||||||
|
|
||||||
|
diff --git a/.gitignore b/.gitignore
|
||||||
|
index b0ada2e3c..c0ca330a3 100644
|
||||||
|
--- a/.gitignore
|
||||||
|
+++ b/.gitignore
|
||||||
|
@@ -95,6 +95,7 @@ Makefile.in
|
||||||
|
/customize/virt-customize
|
||||||
|
/df/virt-df
|
||||||
|
/drivers/.depend
|
||||||
|
+/drivers/hwdata_config.ml
|
||||||
|
/drivers/virt-drivers
|
||||||
|
/diff/virt-diff
|
||||||
|
/edit/virt-edit
|
||||||
|
Submodule common 007d0506c..90e0077e2:
|
||||||
|
diff --git a/common/mlstdutils/std_utils.ml b/common/mlstdutils/std_utils.ml
|
||||||
|
index 323bfec..0d2fa22 100644
|
||||||
|
--- a/common/mlstdutils/std_utils.ml
|
||||||
|
+++ b/common/mlstdutils/std_utils.ml
|
||||||
|
@@ -139,13 +139,19 @@ module String = struct
|
||||||
|
done;
|
||||||
|
if not !r then s else Bytes.to_string b2
|
||||||
|
|
||||||
|
+ let break n str =
|
||||||
|
+ let len = String.length str in
|
||||||
|
+ if n < 0 then "", str
|
||||||
|
+ else if n >= len then str, ""
|
||||||
|
+ else sub str 0 n, sub str n (len-n)
|
||||||
|
+
|
||||||
|
let rec split sep str =
|
||||||
|
- let len = length sep in
|
||||||
|
- let seplen = length str in
|
||||||
|
+ let seplen = length sep in
|
||||||
|
+ let strlen = length str in
|
||||||
|
let i = find str sep in
|
||||||
|
if i = -1 then str, ""
|
||||||
|
else (
|
||||||
|
- sub str 0 i, sub str (i + len) (seplen - i - len)
|
||||||
|
+ sub str 0 i, sub str (i + seplen) (strlen - i - seplen)
|
||||||
|
)
|
||||||
|
|
||||||
|
and nsplit ?(max = 0) sep str =
|
||||||
|
@@ -287,6 +293,25 @@ module List = struct
|
||||||
|
| x :: xs when f x -> x :: takewhile f xs
|
||||||
|
| _ -> []
|
||||||
|
|
||||||
|
+ let take n xs =
|
||||||
|
+ if n <= 0 then []
|
||||||
|
+ else (
|
||||||
|
+ (* This optimisation avoids copying xs. *)
|
||||||
|
+ let len = List.length xs in
|
||||||
|
+ if len <= n then xs
|
||||||
|
+ else (
|
||||||
|
+ let rec take n = function
|
||||||
|
+ | x :: xs when n >= 1 -> x :: take (n-1) xs
|
||||||
|
+ | _ -> []
|
||||||
|
+ in
|
||||||
|
+ take n xs
|
||||||
|
+ )
|
||||||
|
+ )
|
||||||
|
+ let rec drop n xs =
|
||||||
|
+ if n <= 0 then xs
|
||||||
|
+ else if xs = [] then []
|
||||||
|
+ else drop (n-1) (List.tl xs)
|
||||||
|
+
|
||||||
|
let rec filter_map f = function
|
||||||
|
| [] -> []
|
||||||
|
| x :: xs ->
|
||||||
|
diff --git a/common/mlstdutils/std_utils.mli b/common/mlstdutils/std_utils.mli
|
||||||
|
index d576243..a39ac5f 100644
|
||||||
|
--- a/common/mlstdutils/std_utils.mli
|
||||||
|
+++ b/common/mlstdutils/std_utils.mli
|
||||||
|
@@ -87,6 +87,10 @@ module String : sig
|
||||||
|
[str] with [s2]. *)
|
||||||
|
val replace_char : string -> char -> char -> string
|
||||||
|
(** Replace character in string. *)
|
||||||
|
+ val break : int -> string -> string * string
|
||||||
|
+ (** [break n str] breaks a string at the nth byte, returning the
|
||||||
|
+ first and second parts. If [n] is beyond the end of the
|
||||||
|
+ string it returns [(str, "")]. *)
|
||||||
|
val split : string -> string -> string * string
|
||||||
|
(** [split sep str] splits [str] at the first occurrence of the
|
||||||
|
separator [sep], returning the part before and the part after.
|
||||||
|
@@ -193,6 +197,16 @@ module List : sig
|
||||||
|
|
||||||
|
For any list [xs] and function [f],
|
||||||
|
[xs = takewhile f xs @ dropwhile f xs] *)
|
||||||
|
+
|
||||||
|
+ val take : int -> 'a list -> 'a list
|
||||||
|
+ (** [take n xs] returns the first [n] elements of [xs]. If [xs] is
|
||||||
|
+ shorter than [n], then it returns [xs]. Note it never fails
|
||||||
|
+ for any input. *)
|
||||||
|
+ val drop : int -> 'a list -> 'a list
|
||||||
|
+ (** [drop n xs] returns the suffix of [xs] after the first [n]
|
||||||
|
+ elements. If [xs] is shorter than [n], then it returns the empty
|
||||||
|
+ list. Note it never fails for any input. *)
|
||||||
|
+
|
||||||
|
val filter_map : ('a -> 'b option) -> 'a list -> 'b list
|
||||||
|
(** [filter_map f xs] applies [f] to each element of [xs]. If
|
||||||
|
[f x] returns [Some y] then [y] is added to the returned list. *)
|
||||||
|
diff --git a/common/mlstdutils/std_utils_tests.ml b/common/mlstdutils/std_utils_tests.ml
|
||||||
|
index d161b5e..3f5bb1a 100644
|
||||||
|
--- a/common/mlstdutils/std_utils_tests.ml
|
||||||
|
+++ b/common/mlstdutils/std_utils_tests.ml
|
||||||
|
@@ -85,6 +85,18 @@ let test_string_find ctx =
|
||||||
|
assert_equal_int (-1) (String.find "" "baz");
|
||||||
|
assert_equal_int (-1) (String.find "foobar" "baz")
|
||||||
|
|
||||||
|
+(* Test Std_utils.String.break. *)
|
||||||
|
+let test_string_break ctx =
|
||||||
|
+ assert_equal_stringpair ("a", "b") (String.break 1 "ab");
|
||||||
|
+ assert_equal_stringpair ("", "ab") (String.break 0 "ab");
|
||||||
|
+ assert_equal_stringpair ("", "ab") (String.break (-1) "ab");
|
||||||
|
+ assert_equal_stringpair ("ab", "") (String.break 2 "ab");
|
||||||
|
+ assert_equal_stringpair ("ab", "") (String.break 3 "ab");
|
||||||
|
+ assert_equal_stringpair ("abc", "def") (String.break 3 "abcdef");
|
||||||
|
+ assert_equal_stringpair ("", "") (String.break 0 "");
|
||||||
|
+ assert_equal_stringpair ("", "") (String.break (-2) "");
|
||||||
|
+ assert_equal_stringpair ("", "") (String.break 2 "")
|
||||||
|
+
|
||||||
|
(* Test Std_utils.String.split. *)
|
||||||
|
let test_string_split ctx =
|
||||||
|
assert_equal_stringpair ("a", "b") (String.split " " "a b");
|
||||||
|
@@ -169,6 +181,7 @@ let suite =
|
||||||
|
"char.mem" >:: test_char_mem;
|
||||||
|
"strings.is_prefix" >:: test_string_is_prefix;
|
||||||
|
"strings.is_suffix" >:: test_string_is_suffix;
|
||||||
|
+ "strings.break" >:: test_string_break;
|
||||||
|
"strings.find" >:: test_string_find;
|
||||||
|
"strings.split" >:: test_string_split;
|
||||||
|
"strings.nsplit" >:: test_string_nsplit;
|
||||||
|
diff --git a/configure.ac b/configure.ac
|
||||||
|
index e7fcff136..059cfbf90 100644
|
||||||
|
--- a/configure.ac
|
||||||
|
+++ b/configure.ac
|
||||||
|
@@ -138,6 +138,7 @@ AC_CONFIG_FILES([Makefile
|
||||||
|
df/Makefile
|
||||||
|
diff/Makefile
|
||||||
|
drivers/Makefile
|
||||||
|
+ drivers/hwdata_config.ml
|
||||||
|
edit/Makefile
|
||||||
|
format/Makefile
|
||||||
|
get-kernel/Makefile
|
||||||
|
diff --git a/drivers/Makefile.am b/drivers/Makefile.am
|
||||||
|
index d27fc2e27..7e0ef659c 100644
|
||||||
|
--- a/drivers/Makefile.am
|
||||||
|
+++ b/drivers/Makefile.am
|
||||||
|
@@ -27,9 +27,13 @@ EXTRA_DIST = \
|
||||||
|
virt-drivers.pod
|
||||||
|
|
||||||
|
SOURCES_MLI = \
|
||||||
|
- drivers.mli
|
||||||
|
+ drivers.mli \
|
||||||
|
+ hwdata_config.mli \
|
||||||
|
+ hwdata.mli
|
||||||
|
|
||||||
|
SOURCES_ML = \
|
||||||
|
+ hwdata_config.ml \
|
||||||
|
+ hwdata.ml \
|
||||||
|
drivers.ml
|
||||||
|
|
||||||
|
SOURCES_C = \
|
||||||
|
diff --git a/drivers/drivers.ml b/drivers/drivers.ml
|
||||||
|
index 57cfb557c..f02165fa4 100644
|
||||||
|
--- a/drivers/drivers.ml
|
||||||
|
+++ b/drivers/drivers.ml
|
||||||
|
@@ -235,8 +235,14 @@ and windows_hardware_to_xml = function
|
||||||
|
(Option.map (fun v -> ("class", sprintf "%06LX" v)) pci_class);
|
||||||
|
List.may_push_back attrs
|
||||||
|
(Option.map (fun v -> ("vendor", sprintf "%04LX" v)) pci_vendor);
|
||||||
|
+ let vendorname = get_pci_vendor pci_vendor in
|
||||||
|
+ List.may_push_back attrs
|
||||||
|
+ (Option.map (fun v -> "vendorname", v) vendorname);
|
||||||
|
List.may_push_back attrs
|
||||||
|
(Option.map (fun v -> ("device", sprintf "%04LX" v)) pci_device);
|
||||||
|
+ let devicename = get_pci_device pci_vendor pci_device in
|
||||||
|
+ List.may_push_back attrs
|
||||||
|
+ (Option.map (fun v -> "devicename", v) devicename);
|
||||||
|
List.may_push_back attrs
|
||||||
|
(Option.map (fun v -> ("subsystem", sprintf "%08LX" v)) pci_subsys);
|
||||||
|
List.may_push_back attrs
|
||||||
|
@@ -261,8 +267,14 @@ and windows_hardware_to_xml = function
|
||||||
|
let attrs = ref [] in
|
||||||
|
List.may_push_back attrs
|
||||||
|
(Option.map (fun v -> ("vendor", sprintf "%04LX" v)) usb_vendor);
|
||||||
|
+ let vendorname = get_usb_vendor usb_vendor in
|
||||||
|
+ List.may_push_back attrs
|
||||||
|
+ (Option.map (fun v -> "vendorname", v) vendorname);
|
||||||
|
List.may_push_back attrs
|
||||||
|
(Option.map (fun v -> ("product", sprintf "%04LX" v)) usb_product);
|
||||||
|
+ let productname = get_usb_device usb_vendor usb_product in
|
||||||
|
+ List.may_push_back attrs
|
||||||
|
+ (Option.map (fun v -> "productname", v) productname);
|
||||||
|
List.may_push_back attrs
|
||||||
|
(Option.map (fun v -> ("revision", sprintf "%02LX" v)) usb_rev);
|
||||||
|
List.may_push_back attrs
|
||||||
|
@@ -272,6 +284,25 @@ and windows_hardware_to_xml = function
|
||||||
|
| Other path ->
|
||||||
|
Comment (sprintf "unknown DeviceId: %s" (String.concat "\\" path))
|
||||||
|
|
||||||
|
+and get_pci_vendor v = get_hwdata'1 Hwdata.pci_vendor v
|
||||||
|
+and get_pci_device v d = get_hwdata'2 Hwdata.pci_device v d
|
||||||
|
+and get_usb_vendor v = get_hwdata'1 Hwdata.usb_vendor v
|
||||||
|
+and get_usb_device v d = get_hwdata'2 Hwdata.usb_device v d
|
||||||
|
+
|
||||||
|
+and get_hwdata'1 f = function
|
||||||
|
+ | Some i64 when i64 >= 0_L && i64 <= 0xffff_L ->
|
||||||
|
+ let i32 = Int64.to_int32 i64 in
|
||||||
|
+ f i32
|
||||||
|
+ | _ -> None
|
||||||
|
+
|
||||||
|
+and get_hwdata'2 f v d =
|
||||||
|
+ match v, d with
|
||||||
|
+ | Some v64, Some d64 when v64 >= 0_L && v64 <= 0xffff_L &&
|
||||||
|
+ d64 >= 0_L && d64 <= 0xffff_L ->
|
||||||
|
+ let v32 = Int64.to_int32 v64 and d32 = Int64.to_int32 d64 in
|
||||||
|
+ f v32 d32
|
||||||
|
+ | _ -> None
|
||||||
|
+
|
||||||
|
(* Main program. *)
|
||||||
|
let main () =
|
||||||
|
let add, ks = parse_cmdline () in
|
||||||
|
diff --git a/drivers/hwdata.ml b/drivers/hwdata.ml
|
||||||
|
new file mode 100644
|
||||||
|
index 000000000..4b46eff68
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/drivers/hwdata.ml
|
||||||
|
@@ -0,0 +1,187 @@
|
||||||
|
+(* virt-drivers
|
||||||
|
+ * Copyright (C) 2009-2023 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 Std_utils
|
||||||
|
+open Tools_utils
|
||||||
|
+open Common_gettext.Gettext
|
||||||
|
+
|
||||||
|
+open Printf
|
||||||
|
+open Scanf
|
||||||
|
+
|
||||||
|
+module DBKey = struct
|
||||||
|
+ type t =
|
||||||
|
+ | Vendor of int32
|
||||||
|
+ | Device of int32 * int32
|
||||||
|
+ let compare = compare
|
||||||
|
+end
|
||||||
|
+module DB = Map.Make (DBKey)
|
||||||
|
+
|
||||||
|
+let is_4_digit_hex id =
|
||||||
|
+ String.length id = 4 &&
|
||||||
|
+ Char.isxdigit id.[0] &&
|
||||||
|
+ Char.isxdigit id.[1] &&
|
||||||
|
+ Char.isxdigit id.[2] &&
|
||||||
|
+ Char.isxdigit id.[3]
|
||||||
|
+let hex_to_int32 id = sscanf id "%lx" identity
|
||||||
|
+
|
||||||
|
+(* Loads one of the [*.ids] files, returning the entries as a
|
||||||
|
+ * 3 level map. Returns [None] if the file could not be opened
|
||||||
|
+ * or parsed.
|
||||||
|
+ *)
|
||||||
|
+let load filename =
|
||||||
|
+ try
|
||||||
|
+ let lines = read_whole_file filename in
|
||||||
|
+ let lines = String.lines_split lines in
|
||||||
|
+
|
||||||
|
+ (* This loop drops blank lines and comments, splits the fields of
|
||||||
|
+ * the database, and returns [(lineno, indent, key, label) list].
|
||||||
|
+ *)
|
||||||
|
+ let rec loop lineno acc = function
|
||||||
|
+ | [] -> List.rev acc
|
||||||
|
+ (* Blank lines. *)
|
||||||
|
+ | "" :: lines ->
|
||||||
|
+ loop (lineno+1) acc lines
|
||||||
|
+ (* Note that # only starts a comment at the beginning of the line. *)
|
||||||
|
+ | comment :: lines when String.is_prefix comment "#" ->
|
||||||
|
+ loop (lineno+1) acc lines
|
||||||
|
+ (* Otherwise its some data. *)
|
||||||
|
+ | line :: lines ->
|
||||||
|
+ let len = String.length line in
|
||||||
|
+ let indent =
|
||||||
|
+ let rec counttabs i =
|
||||||
|
+ if i < len && line.[i] = '\t' then 1 + counttabs (i+1) else 0
|
||||||
|
+ in
|
||||||
|
+ counttabs 0 in
|
||||||
|
+ let line = String.sub line indent (len - indent) in
|
||||||
|
+
|
||||||
|
+ let n = String.cspan line " \t" in
|
||||||
|
+ let key, label = String.break n line in
|
||||||
|
+ let n = String.span label " \t" in
|
||||||
|
+ let _, label = String.break n label in
|
||||||
|
+
|
||||||
|
+ let acc =
|
||||||
|
+ if key = "" && label = "" then acc
|
||||||
|
+ else (lineno, indent, key, label) :: acc in
|
||||||
|
+
|
||||||
|
+ loop (lineno+1) acc lines
|
||||||
|
+ in
|
||||||
|
+ let lines = loop 1 [] lines in
|
||||||
|
+
|
||||||
|
+ (* Since the format is essentially a space-saving one where
|
||||||
|
+ * vendor name
|
||||||
|
+ * \t device name
|
||||||
|
+ * is short for:
|
||||||
|
+ * vendor name
|
||||||
|
+ * vendor device name
|
||||||
|
+ * pull the fields from previous lines down, resulting in
|
||||||
|
+ * a flat list.
|
||||||
|
+ *)
|
||||||
|
+ let rec loop keys acc = function
|
||||||
|
+ | [] -> List.rev acc
|
||||||
|
+ | (lineno, indent, key, label) :: lines ->
|
||||||
|
+ let prefix = List.take indent keys in
|
||||||
|
+ let keys = prefix @ [ key ] in
|
||||||
|
+ let acc = (lineno, keys, label) :: acc in
|
||||||
|
+ loop keys acc lines
|
||||||
|
+ in
|
||||||
|
+ let lines = loop [] [] lines in
|
||||||
|
+
|
||||||
|
+ (*
|
||||||
|
+ List.iter (
|
||||||
|
+ fun (lineno, keys, label) ->
|
||||||
|
+ eprintf "[%s] -> %s # line %d\n"
|
||||||
|
+ (String.concat ";" keys) label lineno
|
||||||
|
+ ) lines;
|
||||||
|
+ *)
|
||||||
|
+
|
||||||
|
+ (* Now we can finally process the database.
|
||||||
|
+ *
|
||||||
|
+ * We currently ignore the [C] (class) and other records
|
||||||
|
+ * that appear at the end of the file. We might want to
|
||||||
|
+ * try parsing these in future. It will require changes to
|
||||||
|
+ * the code above because the label isn't parsed right.
|
||||||
|
+ *)
|
||||||
|
+ let db =
|
||||||
|
+ List.fold_left (
|
||||||
|
+ fun db (lineno, keys, label) ->
|
||||||
|
+ let loc = filename, lineno in
|
||||||
|
+ match keys with
|
||||||
|
+ | [vendor] when is_4_digit_hex vendor ->
|
||||||
|
+ let vendor = hex_to_int32 vendor in
|
||||||
|
+ DB.add (Vendor vendor) (label, loc) db
|
||||||
|
+ | [vendor; device] when is_4_digit_hex vendor &&
|
||||||
|
+ is_4_digit_hex device ->
|
||||||
|
+ let vendor = hex_to_int32 vendor in
|
||||||
|
+ let device = hex_to_int32 device in
|
||||||
|
+ DB.add (Device (vendor, device)) (label, loc) db
|
||||||
|
+ | _ ->
|
||||||
|
+ db
|
||||||
|
+ ) DB.empty lines in
|
||||||
|
+
|
||||||
|
+ Some db
|
||||||
|
+ with exn ->
|
||||||
|
+ warning (f_"hwdata: %s: %s") filename (Printexc.to_string exn);
|
||||||
|
+ None
|
||||||
|
+
|
||||||
|
+(* Lazily load the PCI database, if present. *)
|
||||||
|
+let pci_db =
|
||||||
|
+ let filename = Hwdata_config.pci_ids in
|
||||||
|
+ lazy (match filename with None -> None | Some filename -> load filename)
|
||||||
|
+
|
||||||
|
+(* Look up PCI vendor and device ID. *)
|
||||||
|
+let pci_vendor vendor =
|
||||||
|
+ let db = Lazy.force pci_db in
|
||||||
|
+ match db with
|
||||||
|
+ | None -> None
|
||||||
|
+ | Some db ->
|
||||||
|
+ match DB.find_opt (Vendor vendor) db with
|
||||||
|
+ | None -> None
|
||||||
|
+ | Some (label, _) -> Some label
|
||||||
|
+
|
||||||
|
+let pci_device vendor device =
|
||||||
|
+ let db = Lazy.force pci_db in
|
||||||
|
+ match db with
|
||||||
|
+ | None -> None
|
||||||
|
+ | Some db ->
|
||||||
|
+ match DB.find_opt (Device (vendor, device)) db with
|
||||||
|
+ | None -> None
|
||||||
|
+ | Some (label, _) -> Some label
|
||||||
|
+
|
||||||
|
+(* Lazily load the USB database, if present. *)
|
||||||
|
+let usb_db =
|
||||||
|
+ let filename = Hwdata_config.usb_ids in
|
||||||
|
+ lazy (match filename with None -> None | Some filename -> load filename)
|
||||||
|
+
|
||||||
|
+(* Look up USB vendor and device ID. *)
|
||||||
|
+let usb_vendor vendor =
|
||||||
|
+ let db = Lazy.force usb_db in
|
||||||
|
+ match db with
|
||||||
|
+ | None -> None
|
||||||
|
+ | Some db ->
|
||||||
|
+ match DB.find_opt (Vendor vendor) db with
|
||||||
|
+ | None -> None
|
||||||
|
+ | Some (label, _) -> Some label
|
||||||
|
+
|
||||||
|
+let usb_device vendor device =
|
||||||
|
+ let db = Lazy.force usb_db in
|
||||||
|
+ match db with
|
||||||
|
+ | None -> None
|
||||||
|
+ | Some db ->
|
||||||
|
+ match DB.find_opt (Device (vendor, device)) db with
|
||||||
|
+ | None -> None
|
||||||
|
+ | Some (label, _) -> Some label
|
||||||
|
diff --git a/drivers/hwdata.mli b/drivers/hwdata.mli
|
||||||
|
new file mode 100644
|
||||||
|
index 000000000..972dfe1f6
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/drivers/hwdata.mli
|
||||||
|
@@ -0,0 +1,31 @@
|
||||||
|
+(* virt-drivers
|
||||||
|
+ * Copyright (C) 2013-2023 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.
|
||||||
|
+ *)
|
||||||
|
+
|
||||||
|
+(** Look up PCI and USB vendor and device IDs. *)
|
||||||
|
+
|
||||||
|
+val pci_vendor : int32 -> string option
|
||||||
|
+(** Look up the PCI vendor ID. If found, return the name. *)
|
||||||
|
+
|
||||||
|
+val pci_device : int32 -> int32 -> string option
|
||||||
|
+(** Look up the PCI vendor & device ID. If found, return the name. *)
|
||||||
|
+
|
||||||
|
+val usb_vendor : int32 -> string option
|
||||||
|
+(** Look up the USB vendor ID. If found, return the name. *)
|
||||||
|
+
|
||||||
|
+val usb_device : int32 -> int32 -> string option
|
||||||
|
+(** Look up the USB vendor & device ID. If found, return the name. *)
|
||||||
|
diff --git a/drivers/hwdata_config.ml.in b/drivers/hwdata_config.ml.in
|
||||||
|
new file mode 100644
|
||||||
|
index 000000000..fa792c086
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/drivers/hwdata_config.ml.in
|
||||||
|
@@ -0,0 +1,26 @@
|
||||||
|
+(* virt-drivers
|
||||||
|
+ * @configure_input@
|
||||||
|
+ * Copyright (C) 2009-2023 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 Std_utils
|
||||||
|
+
|
||||||
|
+let dir = "@HWDATA_PKGDATADIR@"
|
||||||
|
+let dir = if dir = "" then None else Some dir
|
||||||
|
+
|
||||||
|
+let pci_ids = Option.map (fun d -> d // "pci.ids") dir
|
||||||
|
+let usb_ids = Option.map (fun d -> d // "usb.ids") dir
|
||||||
|
diff --git a/drivers/hwdata_config.mli b/drivers/hwdata_config.mli
|
||||||
|
new file mode 100644
|
||||||
|
index 000000000..877e9e28a
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/drivers/hwdata_config.mli
|
||||||
|
@@ -0,0 +1,35 @@
|
||||||
|
+(* virt-drivers
|
||||||
|
+ * Copyright (C) 2013-2023 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.
|
||||||
|
+ *)
|
||||||
|
+
|
||||||
|
+val dir : string option
|
||||||
|
+(** [pkgdatadir] variable defined by hwdata.pc
|
||||||
|
+
|
||||||
|
+ This is the name of the directory containing [pci.ids] and
|
||||||
|
+ related files which contain the PCI IDs. *)
|
||||||
|
+
|
||||||
|
+val pci_ids : string option
|
||||||
|
+(** Path to the [pci.ids] file.
|
||||||
|
+
|
||||||
|
+ Note at runtime this is an optional dependency, so it may
|
||||||
|
+ not at exist even if not [None]. *)
|
||||||
|
+
|
||||||
|
+val usb_ids : string option
|
||||||
|
+(** Path to the [usb.ids] file.
|
||||||
|
+
|
||||||
|
+ Note at runtime this is an optional dependency, so it may
|
||||||
|
+ not at exist even if not [None]. *)
|
||||||
|
diff --git a/drivers/test-virt-drivers-windows.sh b/drivers/test-virt-drivers-windows.sh
|
||||||
|
index df3f36c64..4131f6e5e 100755
|
||||||
|
--- a/drivers/test-virt-drivers-windows.sh
|
||||||
|
+++ b/drivers/test-virt-drivers-windows.sh
|
||||||
|
@@ -22,9 +22,18 @@ $TEST_FUNCTIONS
|
||||||
|
skip_if_skipped
|
||||||
|
skip_unless_phony_guest windows.img
|
||||||
|
|
||||||
|
-rm -f actual-windows.xml
|
||||||
|
+rm -f actual-windows.xml actual-windows.xml.bak
|
||||||
|
|
||||||
|
$VG virt-drivers --format=raw -a ../test-data/phony-guests/windows.img > actual-windows.xml
|
||||||
|
+
|
||||||
|
+# We can't predict if hwdata is available, so we don't know if
|
||||||
|
+# vendorname and devicename fields will be present. If present,
|
||||||
|
+# remove them before comparison.
|
||||||
|
+mv actual-windows.xml actual-windows.xml.bak
|
||||||
|
+sed -e "s/ vendorname='\([^']*\)'//g" \
|
||||||
|
+ -e "s/ devicename='\([^']*\)'//g" \
|
||||||
|
+ < actual-windows.xml.bak > actual-windows.xml
|
||||||
|
+
|
||||||
|
diff -ur -I "generated by" expected-windows.xml actual-windows.xml
|
||||||
|
|
||||||
|
-rm actual-windows.xml
|
||||||
|
+rm actual-windows.xml actual-windows.xml.bak
|
||||||
|
diff --git a/m4/guestfs-libraries.m4 b/m4/guestfs-libraries.m4
|
||||||
|
index 2d252bf9e..32f93afda 100644
|
||||||
|
--- a/m4/guestfs-libraries.m4
|
||||||
|
+++ b/m4/guestfs-libraries.m4
|
||||||
|
@@ -169,3 +169,6 @@ PKG_CHECK_MODULES([JANSSON], [jansson >= 2.7])
|
||||||
|
|
||||||
|
dnl Check for libosinfo (mandatory)
|
||||||
|
PKG_CHECK_MODULES([LIBOSINFO], [libosinfo-1.0])
|
||||||
|
+
|
||||||
|
+dnl Check for hwdata directory (containing pci.ids) (optional, for virt-drivers)
|
||||||
|
+PKG_CHECK_VAR([HWDATA_PKGDATADIR], [hwdata], [pkgdatadir])
|
||||||
|
diff --git a/po/POTFILES-ml b/po/POTFILES-ml
|
||||||
|
index 73984796f..7632f374d 100644
|
||||||
|
--- a/po/POTFILES-ml
|
||||||
|
+++ b/po/POTFILES-ml
|
||||||
|
@@ -79,6 +79,8 @@ dib/output_format_tgz.ml
|
||||||
|
dib/output_format_vhd.ml
|
||||||
|
dib/utils.ml
|
||||||
|
drivers/drivers.ml
|
||||||
|
+drivers/hwdata.ml
|
||||||
|
+drivers/hwdata_config.ml
|
||||||
|
get-kernel/get_kernel.ml
|
||||||
|
resize/resize.ml
|
||||||
|
sparsify/cmdline.ml
|
||||||
|
--
|
||||||
|
2.31.1
|
||||||
|
|
@ -1,67 +0,0 @@
|
|||||||
From c2917c9a7f0c23b94d30af2a5a14e67c46e38242 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Date: Tue, 28 Jun 2022 13:57:02 +0200
|
|
||||||
Subject: [PATCH] sysprep: set networking for "--key ID:clevis"
|
|
||||||
|
|
||||||
Similarly to virt-customize, virt-sysprep has prior "--network" and
|
|
||||||
"--no-network" options. Unlike virt-customize though, virt-sysprep
|
|
||||||
defaults to disabling the appliance network. Therefore we can't tell
|
|
||||||
whether the network is disabled "by default" or because the user requested
|
|
||||||
it.
|
|
||||||
|
|
||||||
That's a problem: "--key ID:clevis" is supposed to override the former,
|
|
||||||
but not the latter. Add a separate option for tracking "--no-network", and
|
|
||||||
only if "--no-network" is absent, permit "--network" or "--key ID:clevis"
|
|
||||||
to turn on the network.
|
|
||||||
|
|
||||||
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1809453
|
|
||||||
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Message-Id: <20220628115702.5584-5-lersek@redhat.com>
|
|
||||||
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
|
|
||||||
(cherry picked from commit 1cce13223e9321d1ef333d6ae356c24203990a4a)
|
|
||||||
---
|
|
||||||
sysprep/main.ml | 7 +++++--
|
|
||||||
1 file changed, 5 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/sysprep/main.ml b/sysprep/main.ml
|
|
||||||
index b760618ad..1f722dfb0 100644
|
|
||||||
--- a/sysprep/main.ml
|
|
||||||
+++ b/sysprep/main.ml
|
|
||||||
@@ -44,6 +44,7 @@ let main () =
|
|
||||||
let libvirturi = ref "" in
|
|
||||||
let mount_opts = ref "" in
|
|
||||||
let network = ref false in
|
|
||||||
+ let no_network = ref false in
|
|
||||||
let operations = ref None in
|
|
||||||
|
|
||||||
let format = ref "auto" in
|
|
||||||
@@ -131,7 +132,7 @@ let main () =
|
|
||||||
[ L"list-operations" ], Getopt.Unit list_operations, s_"List supported operations";
|
|
||||||
[ L"mount-options" ], Getopt.Set_string (s_"opts", mount_opts), s_"Set mount options (eg /:noatime;/var:rw,noatime)";
|
|
||||||
[ L"network" ], Getopt.Set network, s_"Enable appliance network";
|
|
||||||
- [ L"no-network" ], Getopt.Clear network, s_"Disable appliance network (default)";
|
|
||||||
+ [ L"no-network" ], Getopt.Set no_network, s_"Disable appliance network (default)";
|
|
||||||
[ L"operation"; L"operations" ], Getopt.String (s_"operations", set_operations), s_"Enable/disable specific operations";
|
|
||||||
] in
|
|
||||||
let args = basic_args @ Sysprep_operation.extra_args () in
|
|
||||||
@@ -188,6 +189,7 @@ read the man page virt-sysprep(1).
|
|
||||||
(* Dereference the rest of the args. *)
|
|
||||||
let dryrun = !dryrun in
|
|
||||||
let network = !network in
|
|
||||||
+ let no_network = !no_network in
|
|
||||||
let operations = !operations in
|
|
||||||
|
|
||||||
(* At this point we know which operations are enabled. So call the
|
|
||||||
@@ -208,7 +210,8 @@ read the man page virt-sysprep(1).
|
|
||||||
|
|
||||||
(* Connect to libguestfs. *)
|
|
||||||
let g = open_guestfs () in
|
|
||||||
- g#set_network network;
|
|
||||||
+ g#set_network (not no_network &&
|
|
||||||
+ (network || key_store_requires_network opthandle.ks));
|
|
||||||
add g dryrun;
|
|
||||||
g#launch ();
|
|
||||||
|
|
||||||
--
|
|
||||||
2.31.1
|
|
||||||
|
|
@ -1,87 +0,0 @@
|
|||||||
From d15d829d20c1a0d21da584257c4634517d4271d1 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Date: Thu, 14 Jul 2022 12:40:04 +0200
|
|
||||||
Subject: [PATCH] sysprep: make an effort to cope with LUKS-on-LVM
|
|
||||||
|
|
||||||
If the guest disk uses the LUKS-on-LVM scheme, then sysprep has a problem:
|
|
||||||
|
|
||||||
- the "fs-uuids" blockdev operation depends on the decrypted LUKS devices
|
|
||||||
being open,
|
|
||||||
|
|
||||||
- the "lvm-uuids" blockdev operation depends on the same devices being
|
|
||||||
closed.
|
|
||||||
|
|
||||||
Attempt to deal with this in "lvm-uuids".
|
|
||||||
|
|
||||||
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2106286
|
|
||||||
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Message-Id: <20220714104005.8334-2-lersek@redhat.com>
|
|
||||||
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
|
|
||||||
(cherry picked from commit 361a447bcb7aef399abad8075ee41197c4071f71)
|
|
||||||
---
|
|
||||||
sysprep/sysprep_operation_lvm_uuids.ml | 42 +++++++++++++++++++++++++-
|
|
||||||
1 file changed, 41 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/sysprep/sysprep_operation_lvm_uuids.ml b/sysprep/sysprep_operation_lvm_uuids.ml
|
|
||||||
index c67b21487..5fc623039 100644
|
|
||||||
--- a/sysprep/sysprep_operation_lvm_uuids.ml
|
|
||||||
+++ b/sysprep/sysprep_operation_lvm_uuids.ml
|
|
||||||
@@ -30,7 +30,46 @@ let rec lvm_uuids_perform g root side_effects =
|
|
||||||
try g#available [|"lvm2"|]; true with G.Error _ -> false in
|
|
||||||
if has_lvm2_feature then (
|
|
||||||
let has_pvs, has_vgs = g#pvs () <> [||], g#vgs () <> [||] in
|
|
||||||
- if has_pvs || has_vgs then g#vg_activate_all false;
|
|
||||||
+ if has_pvs || has_vgs then (
|
|
||||||
+ try g#vg_activate_all false
|
|
||||||
+ with G.Error _ as exn ->
|
|
||||||
+ (* If the "luks" feature is not available, re-raise the exception. *)
|
|
||||||
+ (try g#available [|"luks"|] with G.Error _ -> raise exn);
|
|
||||||
+
|
|
||||||
+ (* Assume VG deactivation failed due to the guest using the
|
|
||||||
+ * FS-on-LUKS-on-LVM scheme.
|
|
||||||
+ *
|
|
||||||
+ * By now, we have unmounted filesystems, but the decrypted LUKS
|
|
||||||
+ * devices still keep the LVs open. Therefore, attempt closing all
|
|
||||||
+ * decrypted LUKS devices that were opened by inspection (i.e., device
|
|
||||||
+ * nodes with pathnames like "/dev/mapper/luks-<uuid>"). Closing the
|
|
||||||
+ * decrypted LUKS devices should remove the references from their
|
|
||||||
+ * underlying LVs, and then VG deactivation should succeed too.
|
|
||||||
+ *
|
|
||||||
+ * Note that closing the decrypted LUKS devices prevents the
|
|
||||||
+ * blockdev-level manipulation of those filesystems that reside on
|
|
||||||
+ * said decrypted LUKS devices, such as the "fs-uuids" operation. But
|
|
||||||
+ * that should be OK, as we order the present operation after all
|
|
||||||
+ * other block device ops.
|
|
||||||
+ *
|
|
||||||
+ * In case the guest uses the FS-on-LVM-on-LUKS scheme, then the
|
|
||||||
+ * original VG deactivation must have failed for a different reason.
|
|
||||||
+ * (As we have unmounted filesystems earlier, and LUKS is below, not
|
|
||||||
+ * on top of, LVM.) The LUKS-closing attempts below will fail then,
|
|
||||||
+ * due to LVM keeping the decrypted LUKS devices open. This failure is
|
|
||||||
+ * harmless and can be considered a no-op. The final, retried VG
|
|
||||||
+ * deactivation should reproduce the original failure.
|
|
||||||
+ *)
|
|
||||||
+ let luks_re = PCRE.compile ("^/dev/mapper/luks" ^
|
|
||||||
+ "-[[:xdigit:]]{8}" ^
|
|
||||||
+ "(?:-[[:xdigit:]]{4}){3}" ^
|
|
||||||
+ "-[[:xdigit:]]{12}$")
|
|
||||||
+ and dmdevs = Array.to_list (g#list_dm_devices ()) in
|
|
||||||
+ let plaintext_devs = List.filter (PCRE.matches luks_re) dmdevs in
|
|
||||||
+ List.iter (fun dev -> try g#cryptsetup_close dev with _ -> ())
|
|
||||||
+ plaintext_devs;
|
|
||||||
+ g#vg_activate_all false
|
|
||||||
+ );
|
|
||||||
if has_pvs then g#pvchange_uuid_all ();
|
|
||||||
if has_vgs then g#vgchange_uuid_all ();
|
|
||||||
if has_pvs || has_vgs then g#vg_activate_all true
|
|
||||||
@@ -39,6 +78,7 @@ let rec lvm_uuids_perform g root side_effects =
|
|
||||||
|
|
||||||
let op = {
|
|
||||||
defaults with
|
|
||||||
+ order = 99; (* Run it after other block device ops. *)
|
|
||||||
name = "lvm-uuids";
|
|
||||||
enabled_by_default = true;
|
|
||||||
heading = s_"Change LVM2 PV and VG UUIDs";
|
|
||||||
--
|
|
||||||
2.31.1
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
|||||||
From 0b92347337e9201140ed2daf77a934c731de6630 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Date: Thu, 14 Jul 2022 12:40:05 +0200
|
|
||||||
Subject: [PATCH] sysprep: advise against cloning VMs with internal full disk
|
|
||||||
encryption
|
|
||||||
|
|
||||||
This is relevant for sysprep because we recommend sysprep for facilitating
|
|
||||||
cloning.
|
|
||||||
|
|
||||||
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2106286
|
|
||||||
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
||||||
Message-Id: <20220714104005.8334-3-lersek@redhat.com>
|
|
||||||
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
|
|
||||||
(cherry picked from commit b49ee909f5d1a0d7b5c668335b9098ca8ff85bfd)
|
|
||||||
---
|
|
||||||
sysprep/virt-sysprep.pod | 7 +++++++
|
|
||||||
1 file changed, 7 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/sysprep/virt-sysprep.pod b/sysprep/virt-sysprep.pod
|
|
||||||
index deeb5341e..232b9f24b 100644
|
|
||||||
--- a/sysprep/virt-sysprep.pod
|
|
||||||
+++ b/sysprep/virt-sysprep.pod
|
|
||||||
@@ -519,6 +519,13 @@ Either or both options can be used multiple times on the command line.
|
|
||||||
|
|
||||||
=head1 SECURITY
|
|
||||||
|
|
||||||
+Virtual machines that employ full disk encryption I<internally to the
|
|
||||||
+guest> should not be considered for cloning and distribution, as it
|
|
||||||
+provides multiple parties with the same internal volume key, enabling
|
|
||||||
+any one such party to decrypt all the other clones. Refer to the L<LUKS
|
|
||||||
+FAQ|https://gitlab.com/cryptsetup/cryptsetup/-/blob/main/FAQ.md> for
|
|
||||||
+details.
|
|
||||||
+
|
|
||||||
Although virt-sysprep removes some sensitive information from the
|
|
||||||
guest, it does not pretend to remove all of it. You should examine
|
|
||||||
the L</OPERATIONS> above and the guest afterwards.
|
|
||||||
--
|
|
||||||
2.31.1
|
|
||||||
|
|
@ -1,144 +0,0 @@
|
|||||||
From 3576da023fb42ceaea80b81aebad345de606a332 Mon Sep 17 00:00:00 2001
|
|
||||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
||||||
Date: Fri, 15 Jul 2022 08:55:53 +0100
|
|
||||||
Subject: [PATCH] builder, dib: Replace On_exit.rmdir with On_exit.rm_rf
|
|
||||||
|
|
||||||
Update common submodule.
|
|
||||||
|
|
||||||
(cherry picked from commit f5baf83e464c276d3dae6f8e878b8f47fe0d43d9)
|
|
||||||
---
|
|
||||||
builder/builder.ml | 2 +-
|
|
||||||
builder/index_parser_tests.ml | 2 +-
|
|
||||||
builder/repository_main.ml | 2 +-
|
|
||||||
common | 2 +-
|
|
||||||
dib/dib.ml | 2 +-
|
|
||||||
5 files changed, 5 insertions(+), 5 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/builder/builder.ml b/builder/builder.ml
|
|
||||||
index 2c9c83085..e34aae6c7 100644
|
|
||||||
--- a/builder/builder.ml
|
|
||||||
+++ b/builder/builder.ml
|
|
||||||
@@ -182,7 +182,7 @@ let main () =
|
|
||||||
* create.
|
|
||||||
*)
|
|
||||||
let tmpdir = Mkdtemp.temp_dir "virt-builder." in
|
|
||||||
- On_exit.rmdir tmpdir;
|
|
||||||
+ On_exit.rm_rf tmpdir;
|
|
||||||
|
|
||||||
(* Download the sources. *)
|
|
||||||
let downloader = Downloader.create ~curl:cmdline.curl ~cache ~tmpdir in
|
|
||||||
diff --git a/builder/index_parser_tests.ml b/builder/index_parser_tests.ml
|
|
||||||
index 39983faba..5262a1607 100644
|
|
||||||
--- a/builder/index_parser_tests.ml
|
|
||||||
+++ b/builder/index_parser_tests.ml
|
|
||||||
@@ -28,7 +28,7 @@ open Tools_utils
|
|
||||||
|
|
||||||
let tmpdir =
|
|
||||||
let tmpdir = Mkdtemp.temp_dir "guestfs-tests." in
|
|
||||||
- On_exit.rmdir tmpdir;
|
|
||||||
+ On_exit.rm_rf tmpdir;
|
|
||||||
tmpdir
|
|
||||||
|
|
||||||
let dummy_sigchecker = Sigchecker.create ~gpg:"gpg"
|
|
||||||
diff --git a/builder/repository_main.ml b/builder/repository_main.ml
|
|
||||||
index c5b656310..c24729c4c 100644
|
|
||||||
--- a/builder/repository_main.ml
|
|
||||||
+++ b/builder/repository_main.ml
|
|
||||||
@@ -420,7 +420,7 @@ let main () =
|
|
||||||
(* Create a temporary folder to work in *)
|
|
||||||
let tmpdir = Mkdtemp.temp_dir ~base_dir:cmdline.repo
|
|
||||||
"virt-builder-repository." in
|
|
||||||
- On_exit.rmdir tmpdir;
|
|
||||||
+ On_exit.rm_rf tmpdir;
|
|
||||||
|
|
||||||
let tmprepo = tmpdir // "repo" in
|
|
||||||
mkdir_p tmprepo 0o700;
|
|
||||||
Submodule common af6cb55bc..fd964c1ba:
|
|
||||||
diff --git a/common/mlcustomize/guest_packages.ml b/common/mlcustomize/guest_packages.ml
|
|
||||||
index 4c3c34e..7c29a2a 100644
|
|
||||||
--- a/common/mlcustomize/guest_packages.ml
|
|
||||||
+++ b/common/mlcustomize/guest_packages.ml
|
|
||||||
@@ -73,9 +73,9 @@ let install_command packages package_management =
|
|
||||||
| "zypper" -> sprintf "zypper -n in -l %s" quoted_args
|
|
||||||
|
|
||||||
| "unknown" ->
|
|
||||||
- error_unknown_package_manager (s_"--install")
|
|
||||||
+ error_unknown_package_manager "--install"
|
|
||||||
| pm ->
|
|
||||||
- error_unimplemented_package_manager (s_"--install") pm
|
|
||||||
+ error_unimplemented_package_manager "--install" pm
|
|
||||||
|
|
||||||
let update_command package_management =
|
|
||||||
match package_management with
|
|
||||||
@@ -103,9 +103,9 @@ let update_command package_management =
|
|
||||||
| "zypper" -> "zypper -n update -l"
|
|
||||||
|
|
||||||
| "unknown" ->
|
|
||||||
- error_unknown_package_manager (s_"--update")
|
|
||||||
+ error_unknown_package_manager "--update"
|
|
||||||
| pm ->
|
|
||||||
- error_unimplemented_package_manager (s_"--update") pm
|
|
||||||
+ error_unimplemented_package_manager "--update" pm
|
|
||||||
|
|
||||||
let uninstall_command packages package_management =
|
|
||||||
let quoted_args = String.concat " " (List.map quote packages) in
|
|
||||||
@@ -127,6 +127,6 @@ let uninstall_command packages package_management =
|
|
||||||
| "zypper" -> sprintf "zypper -n rm %s" quoted_args
|
|
||||||
|
|
||||||
| "unknown" ->
|
|
||||||
- error_unknown_package_manager (s_"--uninstall")
|
|
||||||
+ error_unknown_package_manager "--uninstall"
|
|
||||||
| pm ->
|
|
||||||
- error_unimplemented_package_manager (s_"--uninstall") pm
|
|
||||||
+ error_unimplemented_package_manager "--uninstall" pm
|
|
||||||
diff --git a/common/mltools/on_exit.ml b/common/mltools/on_exit.ml
|
|
||||||
index 53ccb68..cae12e7 100644
|
|
||||||
--- a/common/mltools/on_exit.ml
|
|
||||||
+++ b/common/mltools/on_exit.ml
|
|
||||||
@@ -52,7 +52,7 @@ let do_actions () =
|
|
||||||
List.iter (do_action (fun file -> Unix.unlink file)) !files;
|
|
||||||
List.iter (do_action (
|
|
||||||
fun dir ->
|
|
||||||
- let cmd = sprintf "rm -rf %s" (Filename.quote dir) in
|
|
||||||
+ let cmd = sprintf "rm -rf -- %s" (Filename.quote dir) in
|
|
||||||
ignore (Tools_utils.shell_command cmd)
|
|
||||||
)
|
|
||||||
) !rmdirs;
|
|
||||||
@@ -102,7 +102,7 @@ let unlink filename =
|
|
||||||
register ();
|
|
||||||
List.push_front filename files
|
|
||||||
|
|
||||||
-let rmdir dir =
|
|
||||||
+let rm_rf dir =
|
|
||||||
register ();
|
|
||||||
List.push_front dir rmdirs
|
|
||||||
|
|
||||||
diff --git a/common/mltools/on_exit.mli b/common/mltools/on_exit.mli
|
|
||||||
index a02e3db..9bcf104 100644
|
|
||||||
--- a/common/mltools/on_exit.mli
|
|
||||||
+++ b/common/mltools/on_exit.mli
|
|
||||||
@@ -47,7 +47,7 @@ val f : (unit -> unit) -> unit
|
|
||||||
val unlink : string -> unit
|
|
||||||
(** Unlink a single temporary file on exit. *)
|
|
||||||
|
|
||||||
-val rmdir : string -> unit
|
|
||||||
+val rm_rf : string -> unit
|
|
||||||
(** Recursively remove a temporary directory on exit (using [rm -rf]). *)
|
|
||||||
|
|
||||||
val kill : ?signal:int -> int -> unit
|
|
||||||
diff --git a/dib/dib.ml b/dib/dib.ml
|
|
||||||
index f5ce604c8..a4ba36040 100644
|
|
||||||
--- a/dib/dib.ml
|
|
||||||
+++ b/dib/dib.ml
|
|
||||||
@@ -550,7 +550,7 @@ let main () =
|
|
||||||
let image_basename_d = image_basename ^ ".d" in
|
|
||||||
|
|
||||||
let tmpdir = Mkdtemp.temp_dir "dib." in
|
|
||||||
- On_exit.rmdir tmpdir;
|
|
||||||
+ On_exit.rm_rf tmpdir;
|
|
||||||
let auxtmpdir = tmpdir // "in_target.aux" in
|
|
||||||
do_mkdir auxtmpdir;
|
|
||||||
let hookstmpdir = auxtmpdir // "hooks" in
|
|
||||||
--
|
|
||||||
2.31.1
|
|
||||||
|
|
@ -1,340 +0,0 @@
|
|||||||
From 1bbc3f0f3f61f00230ed5edab0cdd72729423b58 Mon Sep 17 00:00:00 2001
|
|
||||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
||||||
Date: Mon, 10 Oct 2022 13:54:52 +0100
|
|
||||||
Subject: [PATCH] customize: Support Rocky Linux
|
|
||||||
|
|
||||||
Also updates common submodule with equivalent fix for
|
|
||||||
common/mlcustomize
|
|
||||||
|
|
||||||
Reported-by: Harry Benson
|
|
||||||
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2133443
|
|
||||||
(cherry picked from commit 8858fc63e63ae3f7c76d3ca96cbf63f43e76c834)
|
|
||||||
---
|
|
||||||
common | 2 +-
|
|
||||||
customize/hostname.ml | 3 ++-
|
|
||||||
customize/password.ml | 3 ++-
|
|
||||||
customize/random_seed.ml | 3 ++-
|
|
||||||
4 files changed, 7 insertions(+), 4 deletions(-)
|
|
||||||
|
|
||||||
Submodule common fd964c1ba..85f3e4d08:
|
|
||||||
diff --git a/common/mlcustomize/firstboot.ml b/common/mlcustomize/firstboot.ml
|
|
||||||
index 5c7fd0d..0c76283 100644
|
|
||||||
--- a/common/mlcustomize/firstboot.ml
|
|
||||||
+++ b/common/mlcustomize/firstboot.ml
|
|
||||||
@@ -151,7 +151,8 @@ WantedBy=%s
|
|
||||||
|
|
||||||
and install_sysvinit_service g root distro major =
|
|
||||||
match distro with
|
|
||||||
- | "fedora"|"rhel"|"centos"|"scientificlinux"|"oraclelinux"|"redhat-based" ->
|
|
||||||
+ | "fedora"|"rhel"|"centos"|"scientificlinux"|"oraclelinux"|"rocky"|
|
|
||||||
+ "redhat-based" ->
|
|
||||||
install_sysvinit_redhat g
|
|
||||||
| "opensuse"|"sles"|"suse-based" ->
|
|
||||||
install_sysvinit_suse g
|
|
||||||
diff --git a/common/mlpcre/pcre-c.c b/common/mlpcre/pcre-c.c
|
|
||||||
index f780832..6d119ae 100644
|
|
||||||
--- a/common/mlpcre/pcre-c.c
|
|
||||||
+++ b/common/mlpcre/pcre-c.c
|
|
||||||
@@ -278,7 +278,6 @@ guestfs_int_pcre_sub (value nv)
|
|
||||||
CAMLparam1 (nv);
|
|
||||||
const int n = Int_val (nv);
|
|
||||||
CAMLlocal1 (strv);
|
|
||||||
- CLEANUP_FREE char *str = NULL;
|
|
||||||
const struct last_match *m = pthread_getspecific (last_match);
|
|
||||||
PCRE2_SIZE len;
|
|
||||||
int r;
|
|
||||||
diff --git a/common/mltools/on_exit.ml b/common/mltools/on_exit.ml
|
|
||||||
index cae12e7..f8ef74e 100644
|
|
||||||
--- a/common/mltools/on_exit.ml
|
|
||||||
+++ b/common/mltools/on_exit.ml
|
|
||||||
@@ -23,39 +23,39 @@ open Common_gettext.Gettext
|
|
||||||
open Unix
|
|
||||||
open Printf
|
|
||||||
|
|
||||||
-(* List of files to unlink. *)
|
|
||||||
-let files = ref []
|
|
||||||
+type action =
|
|
||||||
+ | Unlink of string (* filename *)
|
|
||||||
+ | Rm_rf of string (* directory *)
|
|
||||||
+ | Kill of int * int (* signal, pid *)
|
|
||||||
+ | Fn of (unit -> unit) (* generic function *)
|
|
||||||
|
|
||||||
-(* List of directories to remove. *)
|
|
||||||
-let rmdirs = ref []
|
|
||||||
-
|
|
||||||
-(* List of PIDs to kill. *)
|
|
||||||
-let kills = ref []
|
|
||||||
-
|
|
||||||
-(* List of functions to call. *)
|
|
||||||
-let fns = ref []
|
|
||||||
+(* List of (priority, action). *)
|
|
||||||
+let actions = ref []
|
|
||||||
|
|
||||||
(* Perform a single exit action, printing any exception but
|
|
||||||
* otherwise ignoring failures.
|
|
||||||
*)
|
|
||||||
-let do_action f arg =
|
|
||||||
- try f arg with exn -> debug "%s" (Printexc.to_string exn)
|
|
||||||
+let do_action action =
|
|
||||||
+ try
|
|
||||||
+ match action with
|
|
||||||
+ | Unlink file -> Unix.unlink file
|
|
||||||
+ | Rm_rf dir ->
|
|
||||||
+ let cmd = sprintf "rm -rf -- %s" (Filename.quote dir) in
|
|
||||||
+ ignore (Tools_utils.shell_command cmd)
|
|
||||||
+ | Kill (signal, pid) ->
|
|
||||||
+ kill pid signal
|
|
||||||
+ | Fn f -> f ()
|
|
||||||
+ with exn -> debug "%s" (Printexc.to_string exn)
|
|
||||||
|
|
||||||
(* Make sure the actions are performed only once. *)
|
|
||||||
let done_actions = ref false
|
|
||||||
|
|
||||||
-(* Perform the exit actions. *)
|
|
||||||
+(* Perform the exit actions in priority order (lowest prio first). *)
|
|
||||||
let do_actions () =
|
|
||||||
if not !done_actions then (
|
|
||||||
- List.iter (do_action (fun f -> f ())) !fns;
|
|
||||||
- List.iter (do_action (fun (signal, pid) -> kill pid signal)) !kills;
|
|
||||||
- List.iter (do_action (fun file -> Unix.unlink file)) !files;
|
|
||||||
- List.iter (do_action (
|
|
||||||
- fun dir ->
|
|
||||||
- let cmd = sprintf "rm -rf -- %s" (Filename.quote dir) in
|
|
||||||
- ignore (Tools_utils.shell_command cmd)
|
|
||||||
- )
|
|
||||||
- ) !rmdirs;
|
|
||||||
+ let actions = List.sort (fun (a, _) (b, _) -> compare a b) !actions in
|
|
||||||
+ let actions = List.map snd actions in
|
|
||||||
+ List.iter do_action actions
|
|
||||||
);
|
|
||||||
done_actions := true
|
|
||||||
|
|
||||||
@@ -94,18 +94,18 @@ let register () =
|
|
||||||
);
|
|
||||||
registered := true
|
|
||||||
|
|
||||||
-let f fn =
|
|
||||||
+let f ?(prio = 5000) fn =
|
|
||||||
register ();
|
|
||||||
- List.push_front fn fns
|
|
||||||
+ List.push_front (prio, Fn fn) actions
|
|
||||||
|
|
||||||
-let unlink filename =
|
|
||||||
+let unlink ?(prio = 5000) filename =
|
|
||||||
register ();
|
|
||||||
- List.push_front filename files
|
|
||||||
+ List.push_front (prio, Unlink filename) actions
|
|
||||||
|
|
||||||
-let rm_rf dir =
|
|
||||||
+let rm_rf ?(prio = 5000) dir =
|
|
||||||
register ();
|
|
||||||
- List.push_front dir rmdirs
|
|
||||||
+ List.push_front (prio, Rm_rf dir) actions
|
|
||||||
|
|
||||||
-let kill ?(signal = Sys.sigterm) pid =
|
|
||||||
+let kill ?(prio = 5000) ?(signal = Sys.sigterm) pid =
|
|
||||||
register ();
|
|
||||||
- List.push_front (signal, pid) kills
|
|
||||||
+ List.push_front (prio, Kill (signal, pid)) actions
|
|
||||||
diff --git a/common/mltools/on_exit.mli b/common/mltools/on_exit.mli
|
|
||||||
index 9bcf104..66a8554 100644
|
|
||||||
--- a/common/mltools/on_exit.mli
|
|
||||||
+++ b/common/mltools/on_exit.mli
|
|
||||||
@@ -28,6 +28,12 @@
|
|
||||||
killing another process, so we provide simple
|
|
||||||
wrappers for those common actions here.
|
|
||||||
|
|
||||||
+ Actions can be ordered by setting the optional [?prio]
|
|
||||||
+ parameter in the range 0..9999. By default actions
|
|
||||||
+ have priority 5000. Lower numbered actions run first.
|
|
||||||
+ Higher numbered actions run last. So to have an action
|
|
||||||
+ run at the very end before exit you might use [~prio:9999]
|
|
||||||
+
|
|
||||||
Note this module registers signal handlers for
|
|
||||||
SIGINT, SIGQUIT, SIGTERM and SIGHUP. This means
|
|
||||||
that any program that links with mltools.cmxa
|
|
||||||
@@ -39,18 +45,20 @@
|
|
||||||
Your cleanup action might no longer run unless the
|
|
||||||
program calls {!Stdlib.exit}. *)
|
|
||||||
|
|
||||||
-val f : (unit -> unit) -> unit
|
|
||||||
+val f : ?prio:int -> (unit -> unit) -> unit
|
|
||||||
(** Register a function [f] which runs when the program exits.
|
|
||||||
Similar to [Stdlib.at_exit] but also runs if the program is
|
|
||||||
- killed with a signal that we can catch. *)
|
|
||||||
+ killed with a signal that we can catch.
|
|
||||||
|
|
||||||
-val unlink : string -> unit
|
|
||||||
+ [?prio] is the priority, default 5000. See the description above. *)
|
|
||||||
+
|
|
||||||
+val unlink : ?prio:int -> string -> unit
|
|
||||||
(** Unlink a single temporary file on exit. *)
|
|
||||||
|
|
||||||
-val rm_rf : string -> unit
|
|
||||||
+val rm_rf : ?prio:int -> string -> unit
|
|
||||||
(** Recursively remove a temporary directory on exit (using [rm -rf]). *)
|
|
||||||
|
|
||||||
-val kill : ?signal:int -> int -> unit
|
|
||||||
+val kill : ?prio:int -> ?signal:int -> int -> unit
|
|
||||||
(** Kill [PID] on exit. The signal sent defaults to [Sys.sigterm].
|
|
||||||
|
|
||||||
Use this with care since you can end up unintentionally killing
|
|
||||||
diff --git a/common/options/decrypt.c b/common/options/decrypt.c
|
|
||||||
index 97c8b88..19fe93c 100644
|
|
||||||
--- a/common/options/decrypt.c
|
|
||||||
+++ b/common/options/decrypt.c
|
|
||||||
@@ -38,6 +38,10 @@
|
|
||||||
|
|
||||||
#include "options.h"
|
|
||||||
|
|
||||||
+#ifndef __clang__
|
|
||||||
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
static void
|
|
||||||
append_char (size_t *idx, char *buffer, char c)
|
|
||||||
{
|
|
||||||
@@ -55,6 +59,8 @@ append_char (size_t *idx, char *buffer, char c)
|
|
||||||
++*idx;
|
|
||||||
}
|
|
||||||
|
|
||||||
+
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* Make a LUKS map name from the partition or logical volume name, eg.
|
|
||||||
* C<"/dev/vda2" =E<gt> "cryptvda2">, or C<"/dev/vg-ssd/lv-root7" =E<gt>
|
|
||||||
@@ -196,8 +202,8 @@ decrypt_mountables (guestfs_h *g, const char * const *mountables,
|
|
||||||
void
|
|
||||||
inspect_do_decrypt (guestfs_h *g, struct key_store *ks)
|
|
||||||
{
|
|
||||||
+ const char *lvm2_feature[] = { "lvm2", NULL };
|
|
||||||
CLEANUP_FREE_STRING_LIST char **partitions = guestfs_list_partitions (g);
|
|
||||||
- CLEANUP_FREE_STRING_LIST char **lvs = NULL;
|
|
||||||
bool need_rescan;
|
|
||||||
|
|
||||||
if (partitions == NULL)
|
|
||||||
@@ -205,13 +211,17 @@ inspect_do_decrypt (guestfs_h *g, struct key_store *ks)
|
|
||||||
|
|
||||||
need_rescan = decrypt_mountables (g, (const char * const *)partitions, ks);
|
|
||||||
|
|
||||||
- if (need_rescan) {
|
|
||||||
- if (guestfs_lvm_scan (g, 1) == -1)
|
|
||||||
+ if (guestfs_feature_available (g, (char **) lvm2_feature) > 0) {
|
|
||||||
+ CLEANUP_FREE_STRING_LIST char **lvs = NULL;
|
|
||||||
+
|
|
||||||
+ if (need_rescan) {
|
|
||||||
+ if (guestfs_lvm_scan (g, 1) == -1)
|
|
||||||
+ exit (EXIT_FAILURE);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ lvs = guestfs_lvs (g);
|
|
||||||
+ if (lvs == NULL)
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
+ decrypt_mountables (g, (const char * const *)lvs, ks);
|
|
||||||
}
|
|
||||||
-
|
|
||||||
- lvs = guestfs_lvs (g);
|
|
||||||
- if (lvs == NULL)
|
|
||||||
- exit (EXIT_FAILURE);
|
|
||||||
- decrypt_mountables (g, (const char * const *)lvs, ks);
|
|
||||||
}
|
|
||||||
diff --git a/common/utils/guestfs-utils.h b/common/utils/guestfs-utils.h
|
|
||||||
index d568ed3..fdd85ca 100644
|
|
||||||
--- a/common/utils/guestfs-utils.h
|
|
||||||
+++ b/common/utils/guestfs-utils.h
|
|
||||||
@@ -32,6 +32,7 @@
|
|
||||||
#ifndef GUESTFS_UTILS_H_
|
|
||||||
#define GUESTFS_UTILS_H_
|
|
||||||
|
|
||||||
+#include <stdio.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#include "guestfs-internal-all.h"
|
|
||||||
diff --git a/common/utils/utils.c b/common/utils/utils.c
|
|
||||||
index 70e55cb..0144dc4 100644
|
|
||||||
--- a/common/utils/utils.c
|
|
||||||
+++ b/common/utils/utils.c
|
|
||||||
@@ -654,7 +654,8 @@ guestfs_int_hexdump (const void *data, size_t len, FILE *fp)
|
|
||||||
const char *
|
|
||||||
guestfs_int_strerror (int errnum, char *buf, size_t buflen)
|
|
||||||
{
|
|
||||||
-#ifdef _GNU_SOURCE
|
|
||||||
+#ifdef HAVE_DECL_STRERROR_R
|
|
||||||
+#ifdef STRERROR_R_CHAR_P
|
|
||||||
/* GNU strerror_r */
|
|
||||||
return strerror_r (errnum, buf, buflen);
|
|
||||||
#else
|
|
||||||
@@ -664,4 +665,7 @@ guestfs_int_strerror (int errnum, char *buf, size_t buflen)
|
|
||||||
snprintf (buf, buflen, "error number %d", errnum);
|
|
||||||
return buf;
|
|
||||||
#endif
|
|
||||||
+#else /* !HAVE_DECL_STRERROR_R */
|
|
||||||
+ return strerror (errnum); /* YOLO it. */
|
|
||||||
+#endif
|
|
||||||
}
|
|
||||||
diff --git a/common/windows/windows.c b/common/windows/windows.c
|
|
||||||
index b441097..355d79a 100644
|
|
||||||
--- a/common/windows/windows.c
|
|
||||||
+++ b/common/windows/windows.c
|
|
||||||
@@ -58,8 +58,6 @@ is_windows (guestfs_h *g, const char *root)
|
|
||||||
return w;
|
|
||||||
}
|
|
||||||
|
|
||||||
-#pragma GCC diagnostic push
|
|
||||||
-#pragma GCC diagnostic ignored "-Wanalyzer-null-argument"
|
|
||||||
/**
|
|
||||||
* Resolves C<path> as possible Windows path according to C<root>,
|
|
||||||
* giving a new path that can be used in libguestfs API calls.
|
|
||||||
@@ -125,7 +123,6 @@ windows_path (guestfs_h *g, const char *root, const char *path, int readonly)
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
-#pragma GCC diagnostic pop
|
|
||||||
|
|
||||||
static void
|
|
||||||
mount_drive_letter (guestfs_h *g, char drive_letter, const char *root,
|
|
||||||
diff --git a/customize/hostname.ml b/customize/hostname.ml
|
|
||||||
index df64a2dab..fabba3cfd 100644
|
|
||||||
--- a/customize/hostname.ml
|
|
||||||
+++ b/customize/hostname.ml
|
|
||||||
@@ -36,7 +36,8 @@ let rec set_hostname (g : Guestfs.guestfs) root hostname =
|
|
||||||
update_etc_machine_info g hostname;
|
|
||||||
true
|
|
||||||
|
|
||||||
- | "linux", ("rhel"|"centos"|"scientificlinux"|"oraclelinux"|"redhat-based"), v
|
|
||||||
+ | "linux", ("rhel"|"centos"|"scientificlinux"|"oraclelinux"|"rocky"|
|
|
||||||
+ "redhat-based"), v
|
|
||||||
when v >= 7 ->
|
|
||||||
update_etc_hostname g hostname;
|
|
||||||
update_etc_machine_info g hostname;
|
|
||||||
diff --git a/customize/password.ml b/customize/password.ml
|
|
||||||
index 608bf95dc..b37b31fcd 100644
|
|
||||||
--- a/customize/password.ml
|
|
||||||
+++ b/customize/password.ml
|
|
||||||
@@ -160,7 +160,8 @@ and default_crypto g root =
|
|
||||||
let distro = g#inspect_get_distro root in
|
|
||||||
let major = g#inspect_get_major_version root in
|
|
||||||
match distro, major with
|
|
||||||
- | ("rhel"|"centos"|"scientificlinux"|"oraclelinux"|"redhat-based"), v when v >= 9 ->
|
|
||||||
+ | ("rhel"|"centos"|"scientificlinux"|"oraclelinux"|"rocky"|
|
|
||||||
+ "redhat-based"), v when v >= 9 ->
|
|
||||||
`YESCRYPT
|
|
||||||
| ("rhel"|"centos"|"scientificlinux"|"oraclelinux"|"redhat-based"), v when v >= 6 ->
|
|
||||||
`SHA512
|
|
||||||
diff --git a/customize/random_seed.ml b/customize/random_seed.ml
|
|
||||||
index f32d3194e..2dcb700ea 100644
|
|
||||||
--- a/customize/random_seed.ml
|
|
||||||
+++ b/customize/random_seed.ml
|
|
||||||
@@ -47,7 +47,8 @@ let rec set_random_seed (g : Guestfs.guestfs) root =
|
|
||||||
let distro = g#inspect_get_distro root in
|
|
||||||
let file =
|
|
||||||
match typ, distro with
|
|
||||||
- | "linux", ("fedora"|"rhel"|"centos"|"scientificlinux"|"oraclelinux"|"redhat-based") ->
|
|
||||||
+ | "linux", ("fedora"|"rhel"|"centos"|"scientificlinux"|"oraclelinux"|
|
|
||||||
+ "rocky"|"redhat-based") ->
|
|
||||||
Some "/var/lib/random-seed"
|
|
||||||
| "linux", ("debian"|"ubuntu"|"kalilinux") ->
|
|
||||||
Some "/var/lib/urandom/random-seed"
|
|
||||||
--
|
|
||||||
2.31.1
|
|
||||||
|
|
@ -7,7 +7,7 @@ set -e
|
|||||||
# ./copy-patches.sh
|
# ./copy-patches.sh
|
||||||
|
|
||||||
project=guestfs-tools
|
project=guestfs-tools
|
||||||
rhel_version=9.2
|
rhel_version=9.3
|
||||||
|
|
||||||
# Check we're in the right directory.
|
# Check we're in the right directory.
|
||||||
if [ ! -f $project.spec ]; then
|
if [ ! -f $project.spec ]; then
|
||||||
|
@ -18,15 +18,15 @@
|
|||||||
%global patches_touch_autotools 1
|
%global patches_touch_autotools 1
|
||||||
|
|
||||||
# The source directory.
|
# The source directory.
|
||||||
%global source_directory 1.48-stable
|
%global source_directory 1.50-stable
|
||||||
|
|
||||||
# Filter perl provides.
|
# Filter perl provides.
|
||||||
%{?perl_default_filter}
|
%{?perl_default_filter}
|
||||||
|
|
||||||
Summary: Tools to access and modify virtual machine disk images
|
Summary: Tools to access and modify virtual machine disk images
|
||||||
Name: guestfs-tools
|
Name: guestfs-tools
|
||||||
Version: 1.48.2
|
Version: 1.50.0
|
||||||
Release: 8%{?dist}
|
Release: 1%{?dist}
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
|
|
||||||
# Build only for architectures that have a kernel
|
# Build only for architectures that have a kernel
|
||||||
@ -52,24 +52,19 @@ Source2: libguestfs.keyring
|
|||||||
Source3: copy-patches.sh
|
Source3: copy-patches.sh
|
||||||
|
|
||||||
# Patches are maintained in the following repository:
|
# Patches are maintained in the following repository:
|
||||||
# https://github.com/rwmjones/guestfs-tools/commits/rhel-9.2
|
# https://github.com/rwmjones/guestfs-tools/commits/rhel-9.3
|
||||||
|
|
||||||
# Patches.
|
# Patches.
|
||||||
Patch0001: 0001-sysprep-remove-lvm2-s-default-system.devices-file.patch
|
Patch0001: 0001-RHEL-Reject-use-of-libguestfs-winsupport-features-ex.patch
|
||||||
Patch0002: 0002-adopt-inversion-of-SELinux-relabeling-in-virt-custom.patch
|
Patch0002: 0002-RHEL-builder-Disable-opensuse-repository.patch
|
||||||
Patch0003: 0003-update-common-submodule.patch
|
Patch0003: 0003-Remove-virt-dib.patch
|
||||||
Patch0004: 0004-RHEL-Reject-use-of-libguestfs-winsupport-features-ex.patch
|
Patch0004: 0004-drivers-drivers.mli-Fix-copy-and-paste-error-in-comm.patch
|
||||||
Patch0005: 0005-customize-rebase-to-the-common-mlcustomize-Guest_pac.patch
|
Patch0005: 0005-Rework-Std_utils.Option-so-it-works-like-the-OCaml-s.patch
|
||||||
Patch0006: 0006-update-common-submodule-for-CVE-2022-2211-fix.patch
|
Patch0006: 0006-build-Remove-non-existent-ocaml-directory-from-ocaml.patch
|
||||||
Patch0007: 0007-cat-log-ls-tail-diff-edit-insp.-set-networking-for-k.patch
|
Patch0007: 0007-valgrind-Update-for-pcre2.patch
|
||||||
Patch0008: 0008-get-kernel-sparsify-set-networking-for-key-ID-clevis.patch
|
Patch0008: 0008-valgrind-Add-another-libvirt-suppression.patch
|
||||||
Patch0009: 0009-customize-add-reminder-about-key-ID-clevis.patch
|
Patch0009: 0009-drivers-Swap-the-names-of-the-tests.patch
|
||||||
Patch0010: 0010-sysprep-set-networking-for-key-ID-clevis.patch
|
Patch0010: 0010-drivers-Look-up-vendor-and-device-names-in-PCI-and-U.patch
|
||||||
Patch0011: 0011-sysprep-make-an-effort-to-cope-with-LUKS-on-LVM.patch
|
|
||||||
Patch0012: 0012-sysprep-advise-against-cloning-VMs-with-internal-ful.patch
|
|
||||||
Patch0013: 0013-builder-dib-Replace-On_exit.rmdir-with-On_exit.rm_rf.patch
|
|
||||||
Patch0014: 0014-customize-Support-Rocky-Linux.patch
|
|
||||||
Patch0015: 0015-RHEL-builder-Disable-opensuse-repository.patch
|
|
||||||
|
|
||||||
%if 0%{patches_touch_autotools}
|
%if 0%{patches_touch_autotools}
|
||||||
BuildRequires: autoconf, automake, libtool, gettext-devel
|
BuildRequires: autoconf, automake, libtool, gettext-devel
|
||||||
@ -78,7 +73,7 @@ BuildRequires: autoconf, automake, libtool, gettext-devel
|
|||||||
# Basic build requirements.
|
# Basic build requirements.
|
||||||
BuildRequires: gcc, gcc-c++
|
BuildRequires: gcc, gcc-c++
|
||||||
BuildRequires: make
|
BuildRequires: make
|
||||||
BuildRequires: libguestfs-devel >= 1:1.48.3-4
|
BuildRequires: libguestfs-devel >= 1:1.49.8-1
|
||||||
BuildRequires: libguestfs-xfs
|
BuildRequires: libguestfs-xfs
|
||||||
BuildRequires: perl(Pod::Simple)
|
BuildRequires: perl(Pod::Simple)
|
||||||
BuildRequires: perl(Pod::Man)
|
BuildRequires: perl(Pod::Man)
|
||||||
@ -90,8 +85,12 @@ BuildRequires: pcre2-devel
|
|||||||
BuildRequires: libxml2-devel
|
BuildRequires: libxml2-devel
|
||||||
BuildRequires: jansson-devel
|
BuildRequires: jansson-devel
|
||||||
BuildRequires: libvirt-devel
|
BuildRequires: libvirt-devel
|
||||||
|
BuildRequires: libosinfo-devel
|
||||||
BuildRequires: libxcrypt-devel
|
BuildRequires: libxcrypt-devel
|
||||||
BuildRequires: ncurses-devel
|
BuildRequires: ncurses-devel
|
||||||
|
%ifarch x86_64
|
||||||
|
BuildRequires: glibc-static
|
||||||
|
%endif
|
||||||
BuildRequires: ocaml-libguestfs-devel
|
BuildRequires: ocaml-libguestfs-devel
|
||||||
BuildRequires: ocaml-findlib-devel
|
BuildRequires: ocaml-findlib-devel
|
||||||
BuildRequires: ocaml-gettext-devel
|
BuildRequires: ocaml-gettext-devel
|
||||||
@ -111,6 +110,7 @@ BuildRequires: perl(Expect)
|
|||||||
BuildRequires: bash-completion
|
BuildRequires: bash-completion
|
||||||
BuildRequires: /usr/bin/qemu-img
|
BuildRequires: /usr/bin/qemu-img
|
||||||
BuildRequires: xorriso
|
BuildRequires: xorriso
|
||||||
|
BuildRequires: hwdata-devel
|
||||||
BuildRequires: perl(Locale::TextDomain)
|
BuildRequires: perl(Locale::TextDomain)
|
||||||
BuildRequires: perl(Sys::Guestfs)
|
BuildRequires: perl(Sys::Guestfs)
|
||||||
BuildRequires: perl(Win::Hivex)
|
BuildRequires: perl(Win::Hivex)
|
||||||
@ -121,8 +121,10 @@ BuildRequires: perl-generators
|
|||||||
BuildRequires: gnupg2
|
BuildRequires: gnupg2
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
# Version containing guestfs_clevis_luks_unlock
|
# Ensure a minimum version of libguestfs is installed. This contains
|
||||||
Requires: libguestfs%{?_isa} >= 1:1.48.3-4
|
# a workaround for openssl bug RHBZ#2133884 and the hang where we
|
||||||
|
# called setenv between fork and exec.
|
||||||
|
Requires: libguestfs >= 1.49.6-1
|
||||||
|
|
||||||
# For virt-builder:
|
# For virt-builder:
|
||||||
Requires: curl
|
Requires: curl
|
||||||
@ -133,6 +135,9 @@ Requires: xz
|
|||||||
# For virt-builder-repository:
|
# For virt-builder-repository:
|
||||||
Suggests: osinfo-db
|
Suggests: osinfo-db
|
||||||
|
|
||||||
|
# For virt-drivers:
|
||||||
|
Recommends: hwdata
|
||||||
|
|
||||||
# For virt-inspector, since Fedora and RHEL >= 7 use XFS:
|
# For virt-inspector, since Fedora and RHEL >= 7 use XFS:
|
||||||
Recommends: libguestfs-xfs
|
Recommends: libguestfs-xfs
|
||||||
|
|
||||||
@ -172,6 +177,8 @@ works for Windows virtual machines.
|
|||||||
|
|
||||||
Virt-diff shows the differences between virtual machines.
|
Virt-diff shows the differences between virtual machines.
|
||||||
|
|
||||||
|
Virt-drivers detects the bootloader, kernel and drivers inside a guest.
|
||||||
|
|
||||||
Virt-edit is a command line tool to edit the contents of a file in a
|
Virt-edit is a command line tool to edit the contents of a file in a
|
||||||
virtual machine.
|
virtual machine.
|
||||||
|
|
||||||
@ -223,24 +230,6 @@ Virt-win-reg lets you look at and modify the Windows Registry of
|
|||||||
Windows virtual machines.
|
Windows virtual machines.
|
||||||
|
|
||||||
|
|
||||||
%if !0%{?rhel}
|
|
||||||
%package -n virt-dib
|
|
||||||
Summary: Safe and secure diskimage-builder replacement
|
|
||||||
License: GPLv2+
|
|
||||||
# This subpackage (only) must have an Epoch of 1 because it
|
|
||||||
# replaces a package in libguestfs which had an Epoch of 1.
|
|
||||||
Epoch: 1
|
|
||||||
|
|
||||||
Requires: libguestfs-dib >= 1:1.45.2-1
|
|
||||||
|
|
||||||
|
|
||||||
%description -n virt-dib
|
|
||||||
Virt-dib is a safe and secure alternative to the OpenStack
|
|
||||||
diskimage-builder command. It is compatible with most
|
|
||||||
diskimage-builder elements.
|
|
||||||
%endif
|
|
||||||
|
|
||||||
|
|
||||||
%package bash-completion
|
%package bash-completion
|
||||||
Summary: Bash tab-completion scripts for %{name}
|
Summary: Bash tab-completion scripts for %{name}
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
@ -298,6 +287,13 @@ make V=1 %{?_smp_mflags}
|
|||||||
|
|
||||||
%check
|
%check
|
||||||
%ifarch %{test_arches}
|
%ifarch %{test_arches}
|
||||||
|
# Only run the tests with non-debug (ie. non-Rawhide) kernels.
|
||||||
|
# XXX This tests for any debug kernel installed.
|
||||||
|
if grep CONFIG_DEBUG_MUTEXES=y /lib/modules/*/config ; then
|
||||||
|
echo "Skipping tests because debug kernel is installed"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
# Enable debugging.
|
# Enable debugging.
|
||||||
export LIBGUESTFS_DEBUG=1
|
export LIBGUESTFS_DEBUG=1
|
||||||
export LIBGUESTFS_TRACE=1
|
export LIBGUESTFS_TRACE=1
|
||||||
@ -337,12 +333,6 @@ find $RPM_BUILD_ROOT -name '*.la' -delete
|
|||||||
mv $RPM_BUILD_ROOT%{_docdir}/%{name} installed-docs
|
mv $RPM_BUILD_ROOT%{_docdir}/%{name} installed-docs
|
||||||
gzip --best installed-docs/*.xml
|
gzip --best installed-docs/*.xml
|
||||||
|
|
||||||
%if 0%{?rhel}
|
|
||||||
# Remove virt-dib if it was built.
|
|
||||||
rm -f $RPM_BUILD_ROOT%{_bindir}/virt-dib
|
|
||||||
rm -f $RPM_BUILD_ROOT%{_mandir}/man1/virt-dib.1*
|
|
||||||
%endif
|
|
||||||
|
|
||||||
# Find locale files.
|
# Find locale files.
|
||||||
%find_lang %{name}
|
%find_lang %{name}
|
||||||
|
|
||||||
@ -373,6 +363,7 @@ end
|
|||||||
%{_bindir}/virt-customize
|
%{_bindir}/virt-customize
|
||||||
%{_bindir}/virt-df
|
%{_bindir}/virt-df
|
||||||
%{_bindir}/virt-diff
|
%{_bindir}/virt-diff
|
||||||
|
%{_bindir}/virt-drivers
|
||||||
%{_bindir}/virt-edit
|
%{_bindir}/virt-edit
|
||||||
%{_bindir}/virt-filesystems
|
%{_bindir}/virt-filesystems
|
||||||
%{_bindir}/virt-format
|
%{_bindir}/virt-format
|
||||||
@ -394,6 +385,7 @@ end
|
|||||||
%{_mandir}/man1/virt-customize.1*
|
%{_mandir}/man1/virt-customize.1*
|
||||||
%{_mandir}/man1/virt-df.1*
|
%{_mandir}/man1/virt-df.1*
|
||||||
%{_mandir}/man1/virt-diff.1*
|
%{_mandir}/man1/virt-diff.1*
|
||||||
|
%{_mandir}/man1/virt-drivers.1*
|
||||||
%{_mandir}/man1/virt-edit.1*
|
%{_mandir}/man1/virt-edit.1*
|
||||||
%{_mandir}/man1/virt-filesystems.1*
|
%{_mandir}/man1/virt-filesystems.1*
|
||||||
%{_mandir}/man1/virt-format.1*
|
%{_mandir}/man1/virt-format.1*
|
||||||
@ -416,15 +408,6 @@ end
|
|||||||
%{_mandir}/man1/virt-win-reg.1*
|
%{_mandir}/man1/virt-win-reg.1*
|
||||||
|
|
||||||
|
|
||||||
%if !0%{?rhel}
|
|
||||||
%files -n virt-dib
|
|
||||||
%license COPYING
|
|
||||||
%doc README
|
|
||||||
%{_bindir}/virt-dib
|
|
||||||
%{_mandir}/man1/virt-dib.1*
|
|
||||||
%endif
|
|
||||||
|
|
||||||
|
|
||||||
%files bash-completion
|
%files bash-completion
|
||||||
%license COPYING
|
%license COPYING
|
||||||
%dir %{_datadir}/bash-completion/completions
|
%dir %{_datadir}/bash-completion/completions
|
||||||
@ -440,6 +423,10 @@ end
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Mar 02 2023 Richard W.M. Jones <rjones@redhat.com> - 1.50.0-1
|
||||||
|
- Rebase to guestfs-tools 1.50.0
|
||||||
|
resolves: rhbz#2168626
|
||||||
|
|
||||||
* Thu Nov 24 2022 Richard W.M. Jones <rjones@redhat.com> - 1.48.2-8
|
* Thu Nov 24 2022 Richard W.M. Jones <rjones@redhat.com> - 1.48.2-8
|
||||||
- Support Rocky Linux in virt-customize
|
- Support Rocky Linux in virt-customize
|
||||||
resolves: rhbz#2133443
|
resolves: rhbz#2133443
|
||||||
|
4
sources
4
sources
@ -1,2 +1,2 @@
|
|||||||
SHA512 (guestfs-tools-1.48.2.tar.gz) = e11cd5a38a1681e8b2fd56419d38ca0aaab659cb59d409b3572cadcd04fd4da3078fa33e7f21c99d11854ad08797ae24a8d71c041b1b7769fc36c1391b6eb162
|
SHA512 (guestfs-tools-1.50.0.tar.gz) = 2ef136161e566bbbbe4e74eb046a954c755a27451469c9024c730cc1598be7326f9636ef9d1bf47ec6812370b6e780f825aaa59a819cc468e8e5d990f5a40315
|
||||||
SHA512 (guestfs-tools-1.48.2.tar.gz.sig) = 7f3d8064109716c4cc91416d170d66b2c336a1d559c60e9d035d6fad52df4227ebc0cce6d63ce95f570339b8e981f255c51c74c720a2cdc221ae5a0d7bc14717
|
SHA512 (guestfs-tools-1.50.0.tar.gz.sig) = 1d2a35485ad328d40ddb72434fbb8d52c6d16c1db431b53cbcbc20d2d93e21551eb9af821a72c054053636d6606b7c93a56faeb0d7501167af978d251958cfd6
|
||||||
|
Loading…
Reference in New Issue
Block a user