按照上述流程搭建好环境后,就可以启动机密虚机。当前支持的启动方式是使用以下libvirt命令启动。
================================================================================== <domain type='kvm' xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0"> <name>cvm</name> <memory unit='GiB'>1</memory> <vcpu placement='static'>1</vcpu> <iothreads>1</iothreads> <cputune> <vcpupin vcpu='0' cpuset='4'/> <emulatorpin cpuset='4'/> </cputune> <numatune> <memnode cellid='0' mode='strict' nodeset='0'/> </numatune> <os> <type arch='aarch64' machine='virt'>hvm</type> <kernel>/home/virsh/cvm/Image</kernel> <cmdline>swiotlb=262144,force console=tty0 console=ttyAMA0 kaslr.disabled=1 root=/dev/vda rw rodata=off cma=64M cvm_guest=1 virtcca_cvm_guest=1</cmdline> </os> <features> <gic version='3'/> </features> <cpu mode='host-passthrough'> <topology sockets='1' cores='1' threads='1'/> <numa> <cell id='0' cpus='0' memory='1' unit='GiB'/> </numa> </cpu> <clock offset='utc'/> <devices> <emulator>/usr/libexec/qemu-kvm</emulator> <console type='pty'/> <disk type='file' device='disk' model='virtio-non-transitional'> <driver name='qemu' type='raw' queues='2' cache='none' iommu='on'/> <source file='/home/virsh/cvm/rootfs.img'/> <target dev='vda' bus='virtio'/> </disk> <interface type='bridge'> <source bridge='br1'/> <driver iommu='on'/> <model type='virtio-non-transitional'/> </interface> </devices> <launchSecurity type='cvm'> </launchSecurity> <qemu:commandline> <qemu:arg value='-object'/> <qemu:arg value='tmm-guest,id=tmm0,sve-vector-length=128,num-pmu-counters=1'/> </qemu:commandline> </domain> ==================================================================================
virsh define cvm.xml
virsh list --all
Name与xml中<name>cvm</name>一致。
virsh start cvm
virsh console cvm
<numatune> <memnode cellid='0' mode='strict' nodeset='1-3' /> </numatune>
对于上述配置,虚机安全内存将会尝试在NUMA 1、2、3上分配。等价写法为:nodeset='1,2,3'。
<numatune> <memnode cellid='0' mode='strict' nodeset='0' /> <memnode cellid='1' mode='strict' nodeset='3' /> </numatune> <cpu mode='host-passthrough'> <topology sockets='1' dies='1' clusters='1' cores='8' threads='1'/> <numa> <cell id='0' cpus='0-3' memory='4' unit='GiB'/> <cell id='1' cpus='4-7' memory='4' unit='GiB'/> </numa> </cpu>