From: Richard W.M. Jones Date: Mon, 26 Sep 2011 08:58:46 +0000 (+0100) Subject: docs: Show how to use a qemu wrapper to edit the qemu command line. X-Git-Tag: 1.12.8~21 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=4542b7cef2c2953256a090eacfed53f026eace1d;p=libguestfs.git docs: Show how to use a qemu wrapper to edit the qemu command line. (cherry picked from commit 3c7b3634b2c86a4c41fec044ccb59a1fe3224e66) --- diff --git a/src/guestfs.pod b/src/guestfs.pod index 5eb17f2..8f75a3f 100644 --- a/src/guestfs.pod +++ b/src/guestfs.pod @@ -948,6 +948,29 @@ For example: Note that libguestfs also calls qemu with the -help and -version options in order to determine features. +Wrappers can also be used to edit the options passed to qemu. In the +following example, the C<-machine ...> option (C<-machine> and the +following argument) are removed from the command line and replaced +with C<-machine pc,accel=tcg>. The while loop iterates over the +options until it finds the right one to remove, putting the remaining +options into the C array. + + #!/bin/bash - + + i=0 + while [ $# -gt 0 ]; do + case "$1" in + -machine) + shift 2;; + *) + args[i]="$1" + (( i++ )) + shift ;; + esac + done + + exec qemu-kvm -machine pc,accel=tcg "${args[@]}" + =head2 ATTACHING TO RUNNING DAEMONS I This is B and has a tendency to eat