~smoser/curtin/yakkety.lp1666986

« back to all changes in this revision

Viewing changes to tools/launch

  • Committer: Scott Moser
  • Date: 2016-08-05 20:47:14 UTC
  • mto: (58.1.1 pkg)
  • mto: This revision was merged to the branch mainline in revision 56.
  • Revision ID: smoser@ubuntu.com-20160805204714-f6j1k61cli5uf614
Tags: upstream-0.1.0~bzr415
ImportĀ upstreamĀ versionĀ 0.1.0~bzr415

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
                        elements. Examine qemu-kvm -device scsi-hd,? for
35
35
                        details.
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
53
 
 
54
    the following are passed through to xkvm:
 
55
        --uefi-nvram
 
56
        --bios
 
57
 
55
58
   use of --kernel/--initrd will seed cloud-init via cmdline
56
59
   rather than the local datasource
57
60
 
249
252
 
250
253
main() {
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"
 
268
    local 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;;
 
317
            --uefi-nvram|--bios)
 
318
                # handle all --opt=* pass through here.
 
319
                pt[${#pt[@]}]="$cur=$next";;
316
320
            -v|--verbose) VERBOSITY=$((${VERBOSITY}+1));;
317
321
               --vnc)
318
322
                    video="-vnc $next"
340
344
    trap cleanup EXIT
341
345
    register_signal_handlers
342
346
 
343
 
    local bios_opts=""
344
 
 
345
 
    bios_opts=( )
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
356
 
                ;;
357
 
            *)
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"
361
 
                ;;
362
 
        esac
363
 
        [ -f "$ovmf_code" ] || {
364
 
            error "no --uefi requires ovmf bios: apt-get install ovmf"
365
 
            return 1;
366
 
        }
367
 
        # user specified where to write nvram data in --uefi param
368
 
        # pre-populate it with the OVMF_VARS.fd template
369
 
        local nvram=${uefi}
370
 
        cp -a "${ovmf_var}" "${nvram}" || {
371
 
            error "failed to create OVMF nvram file: '$nvram'"
372
 
            return 1;
373
 
        }
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"
380
 
        fi
381
 
 
382
 
        bios_opts=( $uefi_opts )
383
 
    fi
384
 
 
385
347
    if [ "${#disks[@]}" -eq 0 ]; then
386
348
        disks=( "${TEMP_D}/disk1.img" )
387
349
    fi
624
586
    # -monitor stdio
625
587
    cmd=(
626
588
        xkvm "${pt[@]}" "${netargs[@]}" --
627
 
        "${bios_opts[@]}"
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"