Laszlo Ersek
2022-Jun-28 11:57 UTC
[Libguestfs] [guestfs-tools PATCH 4/4] 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 at redhat.com> --- sysprep/main.ml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sysprep/main.ml b/sysprep/main.ml index b760618ad58a..1f722dfb06be 100644 --- a/sysprep/main.ml +++ b/sysprep/main.ml @@ -42,10 +42,11 @@ let main () let dryrun = ref false in let files = ref [] in 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 let format_consumed = ref true in let set_format s @@ -129,11 +130,11 @@ let main () [ L"enable" ], Getopt.String (s_"operations", set_enable), s_"Enable specific operations"; [ L"format" ], Getopt.String (s_"format", set_format), s_"Set format (default: auto)"; [ 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 let usage_msg sprintf (f_"\ @@ -186,10 +187,11 @@ read the man page virt-sysprep(1). in (* 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 * not_enabled_check_args method of all *disabled* operations, so * they have a chance to check for unused command line args. @@ -206,11 +208,12 @@ read the man page virt-sysprep(1). message (f_"Examining the guest ..."); (* 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 (); operations, g, mount_opts, opthandle.ks in -- 2.19.1.3.g30247aa5d201
Richard W.M. Jones
2022-Jun-28 14:59 UTC
[Libguestfs] [guestfs-tools PATCH 4/4] sysprep: set networking for "--key ID:clevis"
For this guestfs tools series: Reviewed-by: Richard W.M. Jones <rjones at redhat.com> -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top