10.11.3. Hot unplugging a secondary network interface by using the CLI
You can remove a secondary network interface from a running virtual machine (VM).
Hot unplugging is not supported for Single Root I/O Virtualization (SR-IOV) interfaces.
Prerequisites
- Your VM must be running.
- The VM must be created on a cluster running OpenShift Virtualization 4.14 or later.
- The VM must have a bridge network interface attached.
-
You have installed the OpenShift CLI (
oc).
Procedure
Using your preferred text editor, edit the
VirtualMachinemanifest file and set the interface state toabsent. Setting the interface state toabsentdetaches the network interface from the guest, but the interface still exists in the pod.Example VM configuration:
apiVersion: kubevirt.io/v1 kind: VirtualMachine metadata: name: vm-fedora template: spec: domain: devices: interfaces: - name: defaultnetwork masquerade: {} # set the interface state to absent - name: <secondary_nic> state: absent bridge: {} networks: - name: defaultnetwork pod: {} - name: <secondary_nic> multus: networkName: <nad_name> # ...Set the interface state to
absentto detach it from the running VM. Removing the interface details from the VM specification does not hot unplug the secondary network interface.- Save your changes and exit the editor.
For the new configuration to take effect, apply the changes by running the following command. Applying the changes triggers automatic VM live migration and removes the interface from the pod.
$ oc apply -f <filename>.yamlwhere:
- <filename>
-
Specifies the name of your
VirtualMachinemanifest YAML file.