[Libguestfs] [p2v PATCH 02/11] Introduce "p2v.output.misc" for passing "-oo" options to virt-v2v

Laszlo Ersek lersek at redhat.com
Mon Jan 30 14:22:19 UTC 2023


From: Alban Lecorps <alban.lecorps at ubisoft.com>

The "-oo" option will be useful primarily for the openstack output mode
(currently disabled, from commit b74c126629e3, "Ignore 'openstack'
driver", 2020-03-16).

Use a ConfigStringList knob for "-oo", and for each OPTION=VALUE element
in that list, create a separate "-oo OPTION=VALUE" option. Do this because
there are too many "-oo" options, and because they are output-dependent,
and because even virt-v2v "blindly" forwards some of those (such as "-oo
os-*=*" for openstack).

The "p2v.oo" shorthand is not needed for compatibility, but it's still a
good idea for user convenience.

(Various tweaks, documentation, and test case update, by Laszlo.)

Cc: Alban Lecorps <alban.lecorps at ubisoft.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1792141
Signed-off-by: Laszlo Ersek <lersek at redhat.com>
---
 generate-p2v-config.pl   | 10 ++++++++++
 conversion.c             |  9 +++++++++
 test-virt-p2v-cmdline.sh |  2 ++
 3 files changed, 21 insertions(+)

diff --git a/generate-p2v-config.pl b/generate-p2v-config.pl
index 47487f7b0f35..5e1d8519bd91 100755
--- a/generate-p2v-config.pl
+++ b/generate-p2v-config.pl
@@ -147,6 +147,7 @@ my @fields = [
       ConfigString->new(name => 'connection'),
       ConfigString->new(name => 'format'),
       ConfigString->new(name => 'storage'),
+      ConfigStringList->new(name => 'misc'),
     ],
   ),
 ];
@@ -168,6 +169,7 @@ my @cmdline_aliases = (
   ["p2v.output.connection", "p2v.oc"],
   ["p2v.output.format",     "p2v.of"],
   ["p2v.output.storage",    "p2v.os"],
+  ["p2v.output.misc",       "p2v.oo"],
 );
 
 # Some config entries are not exposed on the kernel command line.
@@ -379,6 +381,14 @@ option.  See L<virt-v2v(1)/OPTIONS>.
 
 If not specified, the default is F</var/tmp> (on the conversion server).",
   ),
+  "p2v.output.misc" => manual_entry->new(
+    shortopt => "OPTION=VALUE,...",
+    description => "
+Set miscellaneous output option(s) related to the selected output mode.
+This is the same as the virt-v2v I<-oo> option; each C<OPTION=VALUE>
+element in the list will be turned into a separate I<-oo OPTION=VALUE>
+option on the virt-v2v command line.  See L<virt-v2v(1)/OPTIONS>.",
+  ),
 );
 
 # Clean up the program name.
diff --git a/conversion.c b/conversion.c
index b9af47deda74..cc6387c88af8 100644
--- a/conversion.c
+++ b/conversion.c
@@ -526,6 +526,15 @@ generate_wrapper_script (struct config *config, const char *remote_dir,
     print_quoted (fp, config->output.storage);
   }
 
+  if (config->output.misc) { /* -oo */
+    size_t i;
+
+    for (i = 0; config->output.misc[i]; ++i) {
+      fprintf (fp, " -oo ");
+      print_quoted (fp, config->output.misc[i]);
+    }
+  }
+
   fprintf (fp, " --root first");
   fprintf (fp, " physical.xml");
   fprintf (fp, " </dev/null");  /* no stdin */
diff --git a/test-virt-p2v-cmdline.sh b/test-virt-p2v-cmdline.sh
index 7d5434cf8428..bcec86089b00 100755
--- a/test-virt-p2v-cmdline.sh
+++ b/test-virt-p2v-cmdline.sh
@@ -43,6 +43,7 @@ P2V_OPTS=(
   p2v.oc=qemu:///session
   p2v.of=raw
   p2v.os=/var/tmp
+  p2v.oo=opt1=val1,opt2=val2
   p2v.network=em1:wired,other
   p2v.dump_config_and_exit
 )
@@ -69,5 +70,6 @@ grep "^output\.allocation.*sparse" $out
 grep "^output\.connection.*qemu:///session" $out
 grep "^output\.format.*raw" $out
 grep "^output\.storage.*/var/tmp" $out
+grep "^output\.misc.*opt1=val1 opt2=val2" $out
 
 rm $out



More information about the Libguestfs mailing list