[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH] launch: appliance: Add custom parameters last.



From: "Richard W.M. Jones" <rjones redhat com>

This allows custom parameters to modify parameters added by
libguestfs, eg. by doing:

  -set drive.hd0.file=rbd:foo/bar

Thanks: infernix @ #libguestfs
---
 src/launch-appliance.c | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/src/launch-appliance.c b/src/launch-appliance.c
index d8d8e03..adaf498 100644
--- a/src/launch-appliance.c
+++ b/src/launch-appliance.c
@@ -261,13 +261,6 @@ launch_appliance (guestfs_h *g, const char *arg)
      */
     alloc_cmdline (g);
 
-    /* Add any qemu parameters. */
-    for (qp = g->qemu_params; qp; qp = qp->next) {
-      add_cmdline (g, qp->qemu_param);
-      if (qp->qemu_value)
-        add_cmdline (g, qp->qemu_value);
-    }
-
     /* CVE-2011-4127 mitigation: Disable SCSI ioctls on virtio-blk
      * devices.  The -global option must exist, but you can pass any
      * strings to it so we don't need to check for the specific virtio
@@ -347,13 +340,6 @@ launch_appliance (guestfs_h *g, const char *arg)
       guestfs___drive_name (g->nr_drives, &appliance_dev[7]);
     }
 
-    if (STRNEQ (QEMU_OPTIONS, "")) {
-      /* Add the extra options for the qemu command line specified
-       * at configure time.
-       */
-      add_cmdline_shell_unquoted (g, QEMU_OPTIONS);
-    }
-
     /* The qemu -machine option (added 2010-12) is a bit more sane
      * since it falls back through various different acceleration
      * modes, so try that first (thanks Markus Armbruster).
@@ -471,6 +457,23 @@ launch_appliance (guestfs_h *g, const char *arg)
       guestfs___appliance_command_line (g, appliance_dev, 0);
     add_cmdline (g, cmdline);
 
+    /* Note: custom command line parameters must come last so that
+     * qemu -set parameters can modify previously added options.
+     */
+
+    /* Add the extra options for the qemu command line specified
+     * at configure time.
+     */
+    if (STRNEQ (QEMU_OPTIONS, ""))
+      add_cmdline_shell_unquoted (g, QEMU_OPTIONS);
+
+    /* Add any qemu parameters. */
+    for (qp = g->qemu_params; qp; qp = qp->next) {
+      add_cmdline (g, qp->qemu_param);
+      if (qp->qemu_value)
+        add_cmdline (g, qp->qemu_value);
+    }
+
     /* Finish off the command line. */
     incr_cmdline_size (g);
     g->app.cmdline[g->app.cmdline_size-1] = NULL;
-- 
1.8.1.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]