34
34
elements. Examine qemu-kvm -device scsi-hd,? for
36
36
--vnc D use -vnc D (mutually exclusive with --silent)
37
--uefi N enable uefi boot method, store nvram at N
38
37
-h | --help show this message
39
38
-i | --initrd F use initramfs F
40
39
-k | --kernel F use kernel K
52
51
--no-install-deps do not install insert '--install-deps'
53
52
on curtin command invocations
54
the following are passed through to xkvm:
55
58
use of --kernel/--initrd will seed cloud-init via cmdline
56
59
rather than the local datasource
251
254
local short_opts="a:A:d:h:i:k:n:p:v"
252
local long_opts="add:,append:,arch:,bios:,disk:,dowait,help,initrd:,kernel:,mem:,netdev:,no-dowait,power:,publish:,root-arg:,silent,serial-log:,uefi:,verbose,vnc:"
255
local long_opts="add:,append:,arch:,bios:,disk:,dowait,help,initrd:,kernel:,mem:,netdev:,no-dowait,power:,publish:,root-arg:,silent,serial-log:,uefi-nvram:,verbose,vnc:"
253
256
local getopt_out=""
254
257
getopt_out=$(getopt --name "${0##*/}" \
255
258
--options "${short_opts}" --long "${long_opts}" -- "$@") &&
262
265
local tmp="" top_d
263
266
local initrd="" kernel="" uappend="" iargs="" disk_args=""
264
267
local pubs="" disks="" pstate="null"
265
local uefi="" bios="" bsize="512"
266
269
local netdevs="" install_deps="--install-deps"
267
270
local arch_hint=""
268
271
local video="-curses -vga std" serial_log="serial.log"
290
293
--add) addfiles[${#addfiles[@]}]="$next"; shift;;
291
294
-a|--append) uappend="$next"; shift;;
292
295
-A|--arch) arch_hint="$next"; shift;;
293
--bios) bios="$2"; shift;;
294
296
-d|--disk) disks[${#disks[@]}]="$next"; shift;;
295
297
--dowait) pt[${#pt[@]}]="$cur"; dowait=true;;
296
298
-h|--help) Usage ; exit 0;;
312
314
--root-arg) root_arg="$next";;
313
315
--serial-log) serial_log="$next"; shift;;
314
316
--silent) video="-nographic";;
315
--uefi) uefi="$2"; shift;;
318
# handle all --opt=* pass through here.
319
pt[${#pt[@]}]="$cur=$next";;
316
320
-v|--verbose) VERBOSITY=$((${VERBOSITY}+1));;
318
322
video="-vnc $next"
340
344
trap cleanup EXIT
341
345
register_signal_handlers
346
if [ -n "$bios" ]; then
347
bios_opts=( -drive "if=pflash,format=raw,file=$bios" )
348
elif [ -n "$uefi" ]; then
349
case `lsb_release -sc` in
350
precise|trusty|vivid)
351
# for non-split UEFI firmware, the code and
352
# var space are in the same file. We must
353
# make a copy so we can retain modifications.
354
local ovmf_code="/usr/share/ovmf/OVMF.fd"
355
local ovmf_var=$ovmf_code
358
# anything newer than vivid has split UEFI firmware
359
local ovmf_code="/usr/share/OVMF/OVMF_CODE.fd"
360
local ovmf_var="/usr/share/OVMF/OVMF_VARS.fd"
363
[ -f "$ovmf_code" ] || {
364
error "no --uefi requires ovmf bios: apt-get install ovmf"
367
# user specified where to write nvram data in --uefi param
368
# pre-populate it with the OVMF_VARS.fd template
370
cp -a "${ovmf_var}" "${nvram}" || {
371
error "failed to create OVMF nvram file: '$nvram'"
374
# default to the rw copy of UEFI code
375
local uefi_opts="-drive file=$nvram,if=pflash,format=raw"
376
# if firmware is split, use readonly-code section
377
if [ "$ovmf_code" != "$ovmf_var" ]; then
378
# to ensure bootability, re-order firmware, code then variables
379
uefi_opts="-drive file=$ovmf_code,if=pflash,format=raw,readonly $uefi_opts"
382
bios_opts=( $uefi_opts )
385
347
if [ "${#disks[@]}" -eq 0 ]; then
386
348
disks=( "${TEMP_D}/disk1.img" )
626
588
xkvm "${pt[@]}" "${netargs[@]}" --
628
589
-m ${mem} ${serial_args} ${video}
629
590
-drive "file=$bootimg,if=none,cache=unsafe,format=qcow2,id=boot,index=0"
630
591
-device "virtio-blk,drive=boot"