Richard W.M. Jones
2013-Mar-12 17:39 UTC
[Libguestfs] [PATCH] launch: appliance: Add custom parameters last.
From: "Richard W.M. Jones" <rjones at 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
infernix
2013-Mar-12 17:53 UTC
[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 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.
Reasonably Related Threads
- [PATCH] Allow ./configure --without-qemu.
- [PATCH] launch: switch from -nographic to -display none
- [PATCH] Security: Mitigate possible privilege escalation via SG_IO ioctl (CVE-2011-4127, RHBZ#757071)
- [PATCH] Enable running the daemon under valgrind.
- [PATCH 0/5] Assorted patches to add virtio-scsi support.