Hot plugging secondary network interfaces

You can add or remove secondary network interfaces without stopping your virtual machine (VM). OKD Virtualization supports hot plugging and hot unplugging for Linux bridge interfaces that use the VirtIO device driver.

Hot plugging and hot unplugging bridge network interfaces is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.

For more information about the support scope of Red Hat Technology Preview features, see Technology Preview Features Support Scope.

VirtIO limitations

Each VirtIO interface uses one of the limited Peripheral Connect Interface (PCI) slots in the VM. There are a total of 32 slots available. The PCI slots are also used by other devices and must be reserved in advance, therefore slots might not be available on demand. OKD Virtualization reserves up to four slots for hot plugging interfaces. This includes any existing plugged network interfaces. For example, if your VM has two existing plugged interfaces, you can hot plug two more network interfaces.

The actual number of slots available for hot plugging also depends on the machine type. For example, the default PCI topology for the q35 machine type supports hot plugging one additional PCIe device. For more information on PCI topology and hot plug support, see the libvirt documentation.

If you restart the VM after hot plugging an interface, that interface becomes part of the standard network interfaces.

Hot plugging a bridge network interface using the CLI

Hot plug a bridge network interface to a virtual machine (VM) while the VM is running.

Prerequisites

  • A network attachment definition is configured in the same namespace as your VM.

  • You have installed the virtctl tool.

Procedure

  1. If the VM to which you want to hot plug the network interface is not running, start it by using the following command:

    1. $ virtctl start <vm_name>
  2. Use the following command to hot plug a new network interface to the running VM. The virtctl addinterface command adds the new network interface to the VM and virtual machine instance (VMI) specification but does not attach it to the running VM.

    1. $ virtctl addinterface <vm_name> --network-attachment-definition-name <net_attach_def_name> --name <interface_name>

    where:

    <vm_name>

    Specifies the name of the VirtualMachine object.

    <net_attach_def_name>

    Specifies the name of NetworkAttachmentDefinition object.

    <interface_name>

    Specifies the name of the new network interface.

  3. To attach the network interface to the running VM, live migrate the VM by using the following command:

    1. $ virtctl migrate <vm_name>

Verification

  1. Verify that the VM live migration is successful by using the following command:

    1. $ oc get VirtualMachineInstanceMigration -w

    Example output

    1. NAME PHASE VMI
    2. kubevirt-migrate-vm-lj62q Scheduling vm-fedora
    3. kubevirt-migrate-vm-lj62q Scheduled vm-fedora
    4. kubevirt-migrate-vm-lj62q PreparingTarget vm-fedora
    5. kubevirt-migrate-vm-lj62q TargetReady vm-fedora
    6. kubevirt-migrate-vm-lj62q Running vm-fedora
    7. kubevirt-migrate-vm-lj62q Succeeded vm-fedora
  2. Verify that the new interface is added to the VM by checking the VMI status:

    1. $ oc get vmi vm-fedora -ojsonpath="{ @.status.interfaces }"

    Example output

    1. [
    2. {
    3. "infoSource": "domain, guest-agent",
    4. "interfaceName": "eth0",
    5. "ipAddress": "10.130.0.195",
    6. "ipAddresses": [
    7. "10.130.0.195",
    8. "fd02:0:0:3::43c"
    9. ],
    10. "mac": "52:54:00:0e:ab:25",
    11. "name": "default",
    12. "queueCount": 1
    13. },
    14. {
    15. "infoSource": "domain, guest-agent, multus-status",
    16. "interfaceName": "eth1",
    17. "mac": "02:d8:b8:00:00:2a",
    18. "name": "bridge-interface", (1)
    19. "queueCount": 1
    20. }
    21. ]
    1The hot plugged interface appears in the VMI status.

Hot unplugging a bridge network interface using the CLI

You can remove a bridge network interface from a running virtual machine (VM).

Prerequisites

  • Your VM must be running.

  • The VM must be created on a cluster running OKD Virtualization 4.14 or later.

  • The VM must have a bridge network interface attached.

Procedure

  1. Hot unplug a bridge network interface by running the following command. The virtctl removeinterface command detaches the network interface from the guest, but the interface still exists in the pod.

    1. $ virtctl removeinterface <vm_name> --name <interface_name>
  2. Remove the interface from the pod by migrating the VM:

    1. $ virtctl migrate <vm_name>

Additional resources