From 793e2b1e3f8f3a067627122eb927e41dc13d5368 Mon Sep 17 00:00:00 2001 From: Lucas Alvares Gomes Date: Wed, 21 Sep 2016 15:40:30 -0300 Subject: [PATCH] DevStack: Support for creating UEFI VMs This patch is enhancing the create-node.sh script to allow creating UEFI capable VMs. Two new options were added: * -L (UEFI Loader): For specifying the absolute path to the UEFI LOADER * -N (UEFI NVRAM): For specifying the absolute path to the non-volatile memory to store the UEFI variables, if needed. Partial-Bug: #1625616 Change-Id: I3a05ff339877ff31eefda8a5a35b6e343bd4627b --- devstack/tools/ironic/scripts/configure-vm.py | 10 +++++++++- devstack/tools/ironic/scripts/create-node.sh | 20 +++++++++++++++++-- devstack/tools/ironic/templates/vm.xml | 17 ++++++++++++++-- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/devstack/tools/ironic/scripts/configure-vm.py b/devstack/tools/ironic/scripts/configure-vm.py index 5a235b6dd1..e78932d55b 100755 --- a/devstack/tools/ironic/scripts/configure-vm.py +++ b/devstack/tools/ironic/scripts/configure-vm.py @@ -80,6 +80,12 @@ def main(): help='Path to emulator bin for vm template') parser.add_argument('--disk-format', default='qcow2', help='Disk format to use.') + parser.add_argument('--uefi-loader', default='', + help='The absolute path of the UEFI firmware blob.') + parser.add_argument('--uefi-nvram', default='', + help=('The absolute path of the non-volatile memory ' + 'to store the UEFI variables. Should be used ' + 'only when --uefi-loader is also specified.')) args = parser.parse_args() env = jinja2.Environment(loader=jinja2.FileSystemLoader(templatedir)) @@ -96,7 +102,9 @@ def main(): 'bridge': args.bridge, 'nicdriver': args.libvirt_nic_driver, 'emulator': args.emulator, - 'disk_format': args.disk_format + 'disk_format': args.disk_format, + 'uefi_loader': args.uefi_loader, + 'uefi_nvram': args.uefi_nvram, } if args.emulator: diff --git a/devstack/tools/ironic/scripts/create-node.sh b/devstack/tools/ironic/scripts/create-node.sh index 8c0229f0c1..e349b4d662 100755 --- a/devstack/tools/ironic/scripts/create-node.sh +++ b/devstack/tools/ironic/scripts/create-node.sh @@ -9,7 +9,7 @@ set -ex # Keep track of the DevStack directory TOP_DIR=$(cd $(dirname "$0")/.. && pwd) -while getopts "n:c:m:d:a:b:e:E:p:f:l:" arg; do +while getopts "n:c:m:d:a:b:e:E:p:f:l:L:N:" arg; do case $arg in n) NAME=$OPTARG;; c) CPU=$OPTARG;; @@ -24,11 +24,18 @@ while getopts "n:c:m:d:a:b:e:E:p:f:l:" arg; do p) VBMC_PORT=$OPTARG;; f) DISK_FORMAT=$OPTARG;; l) LOGDIR=$OPTARG;; + L) UEFI_LOADER=$OPTARG;; + N) UEFI_NVRAM=$OPTARG;; esac done shift $(( $OPTIND - 1 )) +if [ -z "$UEFI_LOADER" ] && [ ! -z "$UEFI_NVRAM" ]; then + echo "Parameter -N (UEFI NVRAM) cannot be used without -L (UEFI Loader)" + exit 1 +fi + LIBVIRT_NIC_DRIVER=${LIBVIRT_NIC_DRIVER:-"virtio"} LIBVIRT_STORAGE_POOL=${LIBVIRT_STORAGE_POOL:-"default"} LIBVIRT_CONNECT_URI=${LIBVIRT_CONNECT_URI:-"qemu:///system"} @@ -63,6 +70,15 @@ else fi VOL_NAME="${NAME}.${DISK_FORMAT}" +UEFI_OPTS="" +if [ ! -z "$UEFI_LOADER" ]; then + UEFI_OPTS="--uefi-loader $UEFI_LOADER" + + if [ ! -z "$UEFI_NVRAM" ]; then + UEFI_OPTS+=" --uefi-nvram $UEFI_NVRAM" + fi +fi + # Create bridge and add VM interface to it. # Additional interface will be added to this bridge and # it will be plugged to OVS. @@ -90,7 +106,7 @@ if ! virsh list --all | grep -q $NAME; then $TOP_DIR/scripts/configure-vm.py \ --bootdev network --name $NAME --image "$volume_path" \ --arch $ARCH --cpus $CPU --memory $MEM --libvirt-nic-driver $LIBVIRT_NIC_DRIVER \ - --bridge br-$NAME --disk-format $DISK_FORMAT $VM_LOGGING --engine $ENGINE $vm_opts >&2 + --bridge br-$NAME --disk-format $DISK_FORMAT $VM_LOGGING --engine $ENGINE $UEFI_OPTS $vm_opts >&2 # Createa Virtual BMC for the node if IPMI is used if [[ $(type -P vbmc) != "" ]]; then diff --git a/devstack/tools/ironic/templates/vm.xml b/devstack/tools/ironic/templates/vm.xml index fd752e41ed..31f36ce2ce 100644 --- a/devstack/tools/ironic/templates/vm.xml +++ b/devstack/tools/ironic/templates/vm.xml @@ -5,6 +5,12 @@ hvm + {% if uefi_loader %} + {{ uefi_loader }} + {% if uefi_nvram %} + {{ uefi_nvram }} + {% endif %} + {% endif %} @@ -25,8 +31,15 @@ - -
+ + {% if uefi_loader %} + +
+ {% else %} + +
+ {% endif %}