2

I tried to instantiate a VM using virt-install command with few interfaces as needed. The exact command is as follows:

virt-install \
    --name VM \
    --noautoconsole \
    --input keyboard \
    --os-variant rhel7.0 \
    --memory 8192 \
    --vcpus 4 \
    --boot hd \
    --sound none \
    --disk "vol=default,boot_order=1,bus=sata" \
    --disk sda6 \
    --network bridge=eth0

Immediately after this, I tried to attach an interface using virsh attach-interface command as follows:

virsh attach-interface --domain VM --type direct --source eth1 --model virtio

I was happy with the XML configuration of the VM as the interfaces showed up correctly.

$ virsh domiflist VM
Interface  Type       Source     Model       MAC
-------------------------------------------------------
vnet16     bridge     eth0       virtio      52:54:00:e9:d5:4c
macvtap0   direct     eth1       virtio      52:54:00:70:be:74

But when a virsh shutdown was issued and later the VM was started, somehow the interface which was attached did not show up in the XML. I was left with only the eth0 interface. Not sure how/why the eth1 vanished.

$ virsh domiflist VM
Interface  Type       Source     Model       MAC
-------------------------------------------------------
vnet16     bridge     eth0       virtio      52:54:00:e9:d5:4c

Please let me know what can be done to avoid this situation such that the interfaces are preserved as-is like before the VM was shutdown.

2 Answers2

0

You should try the same but adding the --config flag:

virsh attach-interface --domain VM --type direct --source eth1 --model virtio --config

That should persist across reboots.

Tomas
  • 106
0

add "--persistent" or "--config"

ref:

virsh attach-interface --help

NAME attach-interface - attach network interface

SYNOPSIS attach-interface [--target ] [--mac ] [--script ] [--model ] [--inbound ] [--outbound ] [--persistent] [--config] [--live] [--current] [--print-xml] [--managed]

DESCRIPTION Attach new network interface.

OPTIONS [--domain] domain name, id or uuid [--type] network interface type [--source] source of network interface --target target network name --mac MAC address --script script used to bridge network interface --model model type --inbound control domain's incoming traffics --outbound control domain's outgoing traffics --persistent make live change persistent --config affect next boot --live affect running domain --current affect current domain --print-xml print XML document rather than attach the interface --managed libvirt will automatically detach/attach the device from/to host