Browse files

launch: appliance: Add custom parameters last.

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

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

[infernix adds the comment below:]

This works for recent versions of QEMU. The way to use this is:

guestfish
><fs> add-drive /dev/null
><fs> config -set drive.hd0.file=rbd:pool/volume
><fs> run

This will probably work for more types (sheepdog, iscsi et al), but
with the caveat that the libguestfs layers are bypassed so you'll
*always* end up directly accessing the disk in rw mode.
  • Loading branch information...
1 parent 0b285cd commit b17c3a7eb384a32b93acb32597db9e6290b6e22c @infernix infernix committed with rwmjones Mar 12, 2013
Showing with 17 additions and 14 deletions.
  1. +17 −14 src/launch-appliance.c
View
31 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;

0 comments on commit b17c3a7

Please sign in to comment.