deploy/template/vm: support aarch64 VM 01/46901/2
authorYibo Cai <yibo.cai@arm.com>
Tue, 7 Nov 2017 05:27:38 +0000 (13:27 +0800)
committerYibo Cai <yibo.cai@arm.com>
Mon, 20 Nov 2017 01:49:21 +0000 (09:49 +0800)
- Use architecture specific host-ARCH.xml if available, otherwise
  fallback to default host.xml(x86_64).
- Add "--nvram" to undefine UEFI enabled VMs.

Change-Id: I89a0eb3875f98d18a28463bbf1004f5eca5de324
Signed-off-by: Yibo Cai <yibo.cai@arm.com>
deploy.sh
deploy/host_virtual.sh
deploy/template/vm/host-aarch64.xml [new file with mode: 0644]

index 2f81af3..bccbbd2 100755 (executable)
--- a/deploy.sh
+++ b/deploy.sh
@@ -30,6 +30,8 @@
 
 export OPENSTACK_VERSION=${OPENSTACK_VERSION:-ocata}
 
+export COMPASS_ARCH=$(uname -m)
+
 if [[ "x"$KUBERNETES_VERSION != "x" ]]; then
    unset OPENSTACK_VERSION
 fi
index bd2f49a..03a1230 100755 (executable)
@@ -13,14 +13,32 @@ function tear_down_machines() {
     IFS=,
     for i in $HOSTNAMES; do
         sudo virsh destroy $i
-        sudo virsh undefine $i
+        if [ "$COMPASS_ARCH" = "aarch64" ]; then
+            # --nvram is required for UEFI enabled VM
+            sudo virsh undefine --nvram $i
+        else
+            sudo virsh undefine $i
+        fi
         rm -rf $host_vm_dir/$i
     done
     IFS=$old_ifs
 }
 
 function reboot_hosts() {
-    log_warn "reboot_hosts do nothing"
+    # We do need it for aarch64
+    if [ "$COMPASS_ARCH" = "aarch64" ]; then
+        old_ifs=$IFS
+        IFS=,
+        for i in $HOSTNAMES; do
+            sudo virsh destroy $i
+            sleep 3
+            sudo virsh start $i
+            sleep 3
+        done
+        IFS=$old_ifs
+    else
+        log_warn "reboot_hosts do nothing"
+    fi
 }
 
 function launch_host_vms() {
@@ -28,6 +46,13 @@ function launch_host_vms() {
     IFS=,
     #function_bod
     mac_array=($machines)
+
+    # Select vm template per arch
+    vm_template_dir="$COMPASS_DIR/deploy/template/vm"
+    vm_template_file="$vm_template_dir/host.xml"
+    vm_template_arch="$vm_template_dir/host-$COMPASS_ARCH.xml"
+    [ -f $vm_template_arch ] && vm_template_file=$vm_template_arch
+
     log_info "bringing up pxe boot vms"
     i=0
     for host in $HOSTNAMES; do
@@ -43,7 +68,7 @@ function launch_host_vms() {
           -e "s/REPLACE_BOOT_MAC/${mac_array[i]}/g" \
           -e "s/REPLACE_NET_INSTALL/install/g" \
           -e "s/REPLACE_NET_IAAS/external_nat/g" \
-          $COMPASS_DIR/deploy/template/vm/host.xml\
+          "$vm_template_file" \
           > $vm_dir/libvirt.xml
 
         sudo virsh define $vm_dir/libvirt.xml
diff --git a/deploy/template/vm/host-aarch64.xml b/deploy/template/vm/host-aarch64.xml
new file mode 100644 (file)
index 0000000..7f32a19
--- /dev/null
@@ -0,0 +1,58 @@
+<domain type='kvm'>
+  <name>REPLACE_NAME</name>
+  <memory unit='MiB'>REPLACE_MEM</memory>
+  <currentMemory unit='MiB'>REPLACE_MEM</currentMemory>
+  <vcpu placement='static'>REPLACE_CPU</vcpu>
+  <os>
+    <type arch='aarch64' machine='virt'>hvm</type>
+    <loader readonly='yes' type='pflash'>/usr/share/AAVMF/AAVMF_CODE.fd</loader>
+    <boot dev='hd'/>
+    <boot dev='network'/>
+  </os>
+  <features>
+    <gic version='2'/>
+  </features>
+  <cpu mode='host-passthrough'/>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-aarch64</emulator>
+    <disk type='file' device='disk'>
+      <driver name='qemu' type='raw'/>
+      <source file='REPLACE_IMAGE'/>
+      <target dev='sda' bus='scsi'/>
+    </disk>
+    <controller type='scsi' index='0' model='virtio-scsi'>
+      <address type='virtio-mmio'/>
+    </controller>
+    <interface type='network'>
+      <mac address=REPLACE_BOOT_MAC/>
+      <source network='REPLACE_NET_INSTALL'/>
+      <model type='virtio'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+    </interface>
+    <interface type='network'>
+      <source network='REPLACE_NET_IAAS'/>
+      <model type='virtio'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
+    </interface>
+    <interface type='network'>
+      <source network='default'/>
+      <model type='virtio'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
+    </interface>
+    <interface type='network'>
+      <source network='default'/>
+      <model type='virtio'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
+    </interface>
+    <serial type='pty'>
+      <target port='0'/>
+    </serial>
+    <console type='pty'>
+      <target type='serial' port='0'/>
+    </console>
+  </devices>
+</domain>