MCP: patches: AArch64: Add initial support
[armband.git] / patches / opnfv-fuel / 0003-lib.sh-AArch64-virt-install-Use-virtio-net-pci.patch
1 From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
2 Date: Tue, 11 Jul 2017 19:06:47 +0200
3 Subject: [PATCH] lib.sh: AArch64: virt-install: Use virtio-net-pci
4
5 AArch64 virt tools (i.e. libvirt) default to "virtio-mmio", instead of
6 "virtio-net-pci", at least before libvirt 3.x (see [1]).
7
8 Without PCI bus info, we can't really enforce a specific order for
9 the guest ethernet devices.
10
11 This leads to a mismatch between cloud-init, who expects "pxe"
12 network to reside on "eth0", while in fact it ends up on "eth3".
13 As a consequence, we have no connectivity to the guest, as DHCP
14 is only configured by cloud-init on "eth0", and also the boot
15 sequence waits ~5 minutes for "eth0" to come up, before eventually
16 giving up.
17
18 Moreover, predictable network interface naming is out of the question
19 with virtio-mmio, as there is no bus information to rely on.
20
21 Therefore we will enforce "virtio-net-pci" on AArch64, instead of
22 the default "virtio" (which translates into "virtio-mmio" currently).
23
24 FIXME: Apparently, both legacy and modern virtio (0.9 and 1.0) are
25 active, which leads to triggering bug[2].
26 For now, throw some sed magic at it and disable legacy mode.
27
28 [1] https://www.redhat.com/archives/libvir-list/2016-August/msg00931.html
29 [2] https://bugzilla.redhat.com/show_bug.cgi?id=1370005
30
31 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
32 ---
33  mcp/scripts/lib.sh | 19 +++++++++++++++----
34  1 file changed, 15 insertions(+), 4 deletions(-)
35
36 diff --git a/mcp/scripts/lib.sh b/mcp/scripts/lib.sh
37 index 282ca38..12b1ef1 100644
38 --- a/mcp/scripts/lib.sh
39 +++ b/mcp/scripts/lib.sh
40 @@ -57,23 +57,34 @@ create_vms() {
41
42    # AArch64: prepare arch specific arguments
43    local virt_extra_args=""
44 +  local virt_net_model="virtio"
45    if [ "$(uname -i)" = "aarch64" ]; then
46      # No Cirrus VGA on AArch64, use vga std
47      virt_extra_args="$virt_extra_args --video=vga --noautoconsole"
48 +    # AArch64 networking defaults to virtio-mmio before libvirt 3.x
49 +    virt_net_model="virtio-net-pci"
50    fi
51
52    # create vms with specified options
53    for node in "${vnodes[@]}"; do
54      virt-install --name ${node} --ram ${vnodes_ram[$node]} --vcpus=6 --cpu host --accelerate \
55 -    --network network:pxe,model=virtio \
56 -    --network network:mgmt,model=virtio \
57 -    --network network:internal,model=virtio \
58 -    --network network:public,model=virtio \
59 +    --network network:pxe,model=${virt_net_model} \
60 +    --network network:mgmt,model=${virt_net_model} \
61 +    --network network:internal,model=${virt_net_model} \
62 +    --network network:public,model=${virt_net_model} \
63      --disk path=$(pwd)/images/mcp_${node}.qcow2,format=qcow2,bus=virtio,cache=none,io=native \
64      --os-type linux --os-variant none \
65      --boot hd --vnc --console pty --autostart --noreboot \
66      --disk path=$(pwd)/images/mcp_${node}.iso,device=cdrom \
67      ${virt_extra_args}
68 +
69 +    # NOTE(armband): Disable legacy virtio (0.9) in favor of modern virtio (1.0)
70 +    # http://blog.vmsplice.net/2011/04/how-to-pass-qemu-command-line-options.html
71 +    #  <qemu:commandline>
72 +    #   <qemu:arg value='-global'/>
73 +    #   <qemu:arg value='virtio-pci.disable-legacy=on'/>
74 +    # </qemu:commandline>
75 +    EDITOR="sed -i -e \"s|\(<domain.*\)>|\1 xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>|\" -e \"s|\(</domain>\)|<qemu:commandline><qemu:arg value='-global'/><qemu:arg value='virtio-pci.disable-legacy=on'/></qemu:commandline>\1|\"" virsh edit ${node}
76    done
77  }
78