virsh XML 接口配置

virsh XML 接口配置

我正在尝试使用 XML 启动虚拟机。此虚拟机将有 5 个接口,每个接口都连接到某个桥接器。这里的问题是这些接口的分配是随机的。我的 XML

<interface type='bridge'>
    <mac address='52:54:00:9f:14:b3'/>
    <source bridge='br0'/>
    <target dev='vnet1'/>
    <model type='e1000'/>
    <alias name='net0'/>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<interface type='bridge'>
    <mac address='52:54:00:9f:14:b4'/>
    <source bridge='br1'/>
    <target dev='vnet2'/>
    <model type='e1000'/>
    <alias name='net1'/>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x10' function='0x0'/>
</interface>
<interface type='bridge'>
    <mac address='52:54:00:9f:14:b5'/>
    <source bridge='br2'/>
    <target dev='vnet2'/>
    <model type='e1000'/>
    <alias name='net3'/>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x12' function='0x0'/>
</interface>
<interface type='bridge'>
    <mac address='52:54:00:9f:14:c4'/>
    <source bridge='br3'/>
    <target dev='vnet3'/>
    <model type='e1000'/>
    <alias name='net4'/>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x18' function='0x0'/>
</interface>

接口的分配是随机的,意味着 th6 将连接到 br3;eth7 --> br4 eth8 --> br2 eth9 --> br0。

有什么办法可以使它变为静态的吗?

同时,是否有任何方法可以通过 XML 文件本身为这些 eth 接口分配 IP 地址?

答案1

您实际上无法从主机上执行此操作。

一个糟糕的解决方法是使用第一个界面启动客户机,让它完全启动,然后关闭。修改 XML 以添加第二个界面,启动,关闭...然后重复。在大多数现代 Linux 发行版中,这将按正确的顺序添加内容。

相关内容