說明如何使用 cloud-init 組態檔在 KVM 上安裝和啟動虛擬 Edge。

如果您決定使用 SR-IOV 模式,請在 KVM 上啟用 SR-IOV。如需相關步驟,請參閱在 KVM 上啟用 SR-IOV

若要使用 libvirt 在 KVM 上執行 VMware 虛擬 Edge:
  1. 使用 gunzip 將 qcow2 檔案解壓縮到映像位置 (例如 /var/lib/libvirt/images)。
  2. 使用 SR-IOV 和 OpenVswitch 建立要用於裝置的網路集區。

    使用 SR-IOV

    以下是使用 SR-IOV 的 Intel X710/XL710 NIC 卡專用的網路介面範本範例。

        <interface type='hostdev' managed='yes'>
            <mac address='52:54:00:79:19:3d'/>
            <driver name='vfio'/>
            <source>
                <address type='pci' domain='0x0000' bus='0x83' slot='0x0a' function='0x0'/>
            </source>
            <model type='virtio'/>
        </interface>
    

    使用 OpenVSwitch

    <network> 
     <name>passthrough</name> 
     <model type='virtio'/> 
     <forward mode="bridge"/> 
     <bridge name="passthrough"/> 
     <virtualport type='openvswitch'> 
     </virtualport> 
     <vlan trunk='yes'> 
     <tag id='33' nativeMode='untagged'/> 
     <tag id='200'/> 
     <tag id='201'/> 
     <tag id='202'/> 
     </vlan> 
     </network> 
     Bridge 
     <network> 
     <name>passthrough</name> 
     <model type='virtio'/> 
     <forward mode="bridge"/> 
     </network> 
    <domain type='kvm'> 
     <name>vedge1</name> 
     <memory unit='KiB'>4194304</memory> 
     <currentMemory unit='KiB'>4194304</currentMemory> 
     <vcpu placement='static'>2</vcpu> 
     <resource> 
     <partition>/machine</partition> 
     </resource> 
     <os> 
     <type arch='x86_64' machine='pc-i440fx-trusty'>hvm</type> 
     <boot dev='hd'/> 
     </os> 
     <features> 
     <acpi/> 
     <apic/> 
     <pae/> 
     </features> 
    <!--
    Set the CPU mode to host model to leverage all the available features on the host CPU 
    -->
     <cpu mode='host-model'> 
     <model fallback='allow'/> 
     </cpu> 
     <clock offset='utc'/> 
     <on_poweroff>destroy</on_poweroff> 
     <on_reboot>restart</on_reboot> 
     <on_crash>restart</on_crash> 
     <devices> 
     <emulator>/usr/bin/kvm-spice</emulator> 
     <!-- 
     Below is the location of the qcow2 disk image 
     --> 
     <disk type='file' device='disk'> 
     <driver name='qemu' type='qcow2'/> 
     <source file='/var/lib/libvirt/images/edge-VC_KVM_GUEST-x86_64-2.3.0-18- R23-20161114-GA-updatable-ext4.qcow2'/> 
     <target dev='sda' bus='sata'/> 
     <address type='drive' controller='0' bus='0' target='0' unit='0'/> 
     </disk> 
     <!-- 
     If using cloud-init to boot up virtual edge, attach the 2nd disk as CD-ROM 
     --> 
     <disk type='file' device='cdrom'> 
     <driver name='qemu' type='raw'/> 
     <source file='/home/vcadmin/cloud-init/vedge1/seed.iso'/> 
     <target dev='sdb' bus='sata'/> 
     <readonly/> 
     <address type='drive' controller='1' bus='0' target='0' unit='0'/> 
     </disk> 
     <controller type='usb' index='0'> 
     <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> 
     </controller> 
     <controller type='pci' index='0' model='pci-root'/> 
     <controller type='sata' index='0'> 
     <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> 
     </controller> 
     <controller type='ide' index='0'> 
     <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> 
     </controller> 
     <!-- 
     The first two interfaces are for the default L2 interfaces, NOTE VLAN support just for SR-IOV and OpenvSwitch  
     --> 
     < interfacetype='network'>  
     < modeltype='virtio'/>  
     < sourcenetwork='LAN1'/>  
     < vlan>< tagid='#hole2_vlan#'/></ vlan>  
     < aliasname=LAN1/>  
     < addresstype='pci' domain='0x0000' bus='0x00' slot='0x12' function='0x0'/>  
     </ interface>  
     < interfacetype='network'>  
     < modeltype='virtio'/>  
     < sourcenetwork=LAN2/>  
     < vlan>< tagid='#LAN2_VLAN#'/></ vlan>  
     < aliasname='hostdev1'/>  
     < addresstype='pci' domain='0x0000' bus=' 0x00' slot='0x13' function='0x0'/>  
     </ interface>  
    <!--
     The next two interfaces are for the default L3 interfaces. Note that additional 6 routed interfaces 
    are supported for a combination of 8 interfaces total  
     --> 
     < interfacetype='network'>  
     < modeltype='virtio'/>  
     < sourcenetwork=WAN1/>  
     < vlan>< tagid='#hole2_vlan#'/></ vlan>  
     < aliasname=LAN1/>  
     < addresstype='pci' domain='0x0000' bus='0x00' slot='0x12' function='0x0'/>  
     </ interface>  
     < interfacetype='network'>  
     < modeltype='virtio'/>  
     < source network=LAN2/>  
     < vlan>< tag id='#LAN2_VLAN#'/></ vlan>  
     < aliasname='hostdev1'/>  
     < addresstype='pci' domain='0x0000' bus='0x00' slot='0x13' function='0x0'/>  
     </ interface>  
     <serial type='pty'> 
     <target port='0'/> 
     </serial> 
     <console type='pty'> 
     <target type='serial' port='0'/> 
     </console> 
     <input type='mouse' bus='ps2'/> 
     <input type='keyboard' bus='ps2'/> 
     <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'> 
     <listen type='address' address='127.0.0.1'/> 
     </graphics> 
     <sound model='ich6'> 
     <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> 
     </sound> 
     <video> 
     <model type='cirrus' vram='9216' heads='1'/> 
     <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> 
     </video> 
     <memballoon model='virtio'> 
     <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> 
     </memballoon> 
     </devices> 
     </domain>             
             
  3. 儲存定義虛擬機器的網域 XML 檔案 (例如,在步驟 2 中建立的 vedge1.xml)。
  4. 執行下列步驟來啟動虛擬機器:
    1. 建立虛擬機器。
      virsh define vedge1.xml
    2. 啟動虛擬機器。
      virsh start vedge1
    備註: vedge1 是在網域 XML 檔案的 <name> 元素中定義之虛擬機器的名稱。請將 vedge1 取代為您在 <name> 元素中指定的名稱。
  5. 如果您使用 SR-IOV 模式,則在啟動虛擬機器後,請在使用的虛擬功能 (VF) 上設定下列項目:
    1. 將 spoofcheck 設定為關閉。
      ip link set eth1 vf 0 spoofchk off
    2. 將信任模式設定為開啟。
      ip link set dev eth1 vf 0 trust on
    3. 如有需要,請設定 VLAN。
      ip link set eth1 vf 0 vlan 3500
    備註: 虛擬功能設定步驟不適用於 OpenVSwitch (OVS) 模式。
  6. 透過主控台進入虛擬機器。
    virsh list
    Id Name State
    ----------------------------------------------------
    25 test_vcg running
    velocloud@KVMperf2$ virsh console 25
    Connected to domain test_vcg
    Escape character is ^]

cloud-init 已包含在 SD-WAN Orchestrator 上建立新的虛擬 Edge 時產生的啟用金鑰。虛擬 Edge 會使用 cloud-init 檔案中的組態設定進行設定。這將在虛擬 Edge 已開啟電源時設定介面。虛擬 Edge 連線後,它會透過 SD-WAN Orchestrator 使用啟用金鑰來啟動。SD-WAN Orchestrator IP 位址和啟用金鑰已定義在 cloud-init 檔案中。