KVM / qemu / libvirt虚拟机PCI域/总线/插槽/function分配使用virt-install

我正在尝试使用virt-install实用程序创build一个虚拟机,虽然这很容易做到我想要做的事情certificate相当困难。

我希望能够指定我添加的以太网接口的域/总线/插槽/function。 我意识到,我可以在创build域后使用virsh编辑来修改这些设置,但是我想知道是否有人知道它是否可以使用virt-install实用程序从命令行完成,如果是可以做,你知道什么是正确的语法是?

谢谢。

肖恩

是的,您可以在virt-install命令行中指定所有这些。 检查virt-install --network=? 了解您可以指定的完整列表。 这些对应于XML中设置的属性 。

例如,如果你的<interface>看起来像这样:

  <interface type='bridge'> <mac address='52:54:00:c2:de:ce'/> <source bridge='br0'/> <model type='virtio'/> <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/> </interface> 

你可以像这样指定它:

 virt-install ... -network bridge=br0,model=virtio,mac=52:54:00:c2:de:ce,address.type=pci,address.domain=0,address.bus=1,address.slot=0,address.function=0 ... 

您也可以不使用安装来使用--print-xml来获取生成的XML。 然后,您可以根据自己的喜好进行自定义,并直接自动执行许多安装,而无需通过virt-install

  --print-xml [STEP] Print the generated XML of the guest, instead of defining it. By default this WILL do storage creation (can be disabled with --dry-run). This option implies --quiet. If the VM install has multiple phases, by default this will print all generated XML. If you want to print a particular step, use --print-xml 2 (for the second phase XML).