From a7422e57738c8d27e5b83b804978d06013ee7d05 Mon Sep 17 00:00:00 2001 From: Shikha Jhala Date: Mon, 10 Jul 2023 21:34:01 -0400 Subject: [PATCH] CNV-14623: Hot plugging network interfaces --- _topic_maps/_topic_map.yml | 2 + ...plugging-bridge-network-interface-cli.adoc | 99 +++++++++++++++++++ ...plugging-bridge-network-interface-cli.adoc | 31 ++++++ modules/virt-virtctl-commands.adoc | 6 ++ .../virt-hot-plugging-network-interfaces.adoc | 34 +++++++ 5 files changed, 172 insertions(+) create mode 100644 modules/virt-hot-plugging-bridge-network-interface-cli.adoc create mode 100644 modules/virt-hot-unplugging-bridge-network-interface-cli.adoc create mode 100644 virt/vm_networking/virt-hot-plugging-network-interfaces.adoc diff --git a/_topic_maps/_topic_map.yml b/_topic_maps/_topic_map.yml index e70a9c27d2..3993f9b58d 100644 --- a/_topic_maps/_topic_map.yml +++ b/_topic_maps/_topic_map.yml @@ -3766,6 +3766,8 @@ Topics: File: virt-connecting-vm-to-sriov - Name: Using DPDK with SR-IOV File: virt-using-dpdk-with-sriov + - Name: Hot plugging secondary network interfaces + File: virt-hot-plugging-network-interfaces - Name: Connecting a VM to a service mesh File: virt-connecting-vm-to-service-mesh - Name: Configuring a dedicated network for live migration diff --git a/modules/virt-hot-plugging-bridge-network-interface-cli.adoc b/modules/virt-hot-plugging-bridge-network-interface-cli.adoc new file mode 100644 index 0000000000..63c5f9c3d9 --- /dev/null +++ b/modules/virt-hot-plugging-bridge-network-interface-cli.adoc @@ -0,0 +1,99 @@ +// Module included in the following assemblies: +// +// * virt/virtual_machines/vm_networking/virt-hot-plugging-network-interfaces.adoc + +:_content-type: PROCEDURE +[id="virt-hot-plugging-bridge-network-interface_{context}"] += 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 + +. If the VM to which you want to hot plug the network interface is not running, start it by using the following command: ++ +[source,terminal] +---- +$ virtctl start +---- + +. 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. ++ +[source,terminal] +---- +$ virtctl addinterface --network-attachment-definition-name --name +---- ++ +where: + +:: Specifies the name of the `VirtualMachine` object. +:: Specifies the name of `NetworkAttachmentDefinition` object. +:: Specifies the name of the new network interface. + + +. To attach the network interface to the running VM, live migrate the VM by using the following command: ++ +[source,terminal] +---- +$ virtctl migrate +---- + +.Verification + +. Verify that the VM live migration is successful by using the following command: ++ +[source,terminal] +---- +$ oc get VirtualMachineInstanceMigration -w +---- ++ +.Example output +[source,terminal] +---- +NAME PHASE VMI +kubevirt-migrate-vm-lj62q Scheduling vm-fedora +kubevirt-migrate-vm-lj62q Scheduled vm-fedora +kubevirt-migrate-vm-lj62q PreparingTarget vm-fedora +kubevirt-migrate-vm-lj62q TargetReady vm-fedora +kubevirt-migrate-vm-lj62q Running vm-fedora +kubevirt-migrate-vm-lj62q Succeeded vm-fedora +---- + +. Verify that the new interface is added to the VM by checking the VMI status: ++ +[source,terminal] +---- +$ oc get vmi vm-fedora -ojsonpath="{ @.status.interfaces }" +---- ++ +.Example output +[source,json] +---- +[ + { + "infoSource": "domain, guest-agent", + "interfaceName": "eth0", + "ipAddress": "10.130.0.195", + "ipAddresses": [ + "10.130.0.195", + "fd02:0:0:3::43c" + ], + "mac": "52:54:00:0e:ab:25", + "name": "default", + "queueCount": 1 + }, + { + "infoSource": "domain, guest-agent, multus-status", + "interfaceName": "eth1", + "mac": "02:d8:b8:00:00:2a", + "name": "bridge-interface", <1> + "queueCount": 1 + } +] +---- +<1> The hot-plugged interface appears in the VMI status. \ No newline at end of file diff --git a/modules/virt-hot-unplugging-bridge-network-interface-cli.adoc b/modules/virt-hot-unplugging-bridge-network-interface-cli.adoc new file mode 100644 index 0000000000..0323cb9412 --- /dev/null +++ b/modules/virt-hot-unplugging-bridge-network-interface-cli.adoc @@ -0,0 +1,31 @@ +// Module included in the following assemblies: +// +// * virt/virtual_machines/vm_networking/virt-hot-plugging-network-interfaces.adoc + +:_content-type: PROCEDURE +[id="virt-hot-unplugging-bridge-network-interface_{context}"] += 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 {VirtProductName} 4.14 or later. +* The VM must have a bridge network interface attached. + +.Procedure + +. 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. ++ +[source,terminal] +---- +$ virtctl removeinterface --name +---- + +. Remove the interface from the pod by migrating the VM: ++ +[source,terminal] +---- +$ virtctl migrate +---- \ No newline at end of file diff --git a/modules/virt-virtctl-commands.adoc b/modules/virt-virtctl-commands.adoc index b4aa284ae9..7b4172dbb7 100644 --- a/modules/virt-virtctl-commands.adoc +++ b/modules/virt-virtctl-commands.adoc @@ -254,6 +254,12 @@ Optional: |`virtctl removevolume --volume-name=` |Hot unplug a virtual disk. + +|`virtctl addinterface --network-attachment-definition-name --name ` +|Hot plug a Linux bridge network interface. + +|`virtctl removeinterface --name ` +|Hot unplug a Linux bridge network interface. |=== [id='image-upload-commands_{context}'] diff --git a/virt/vm_networking/virt-hot-plugging-network-interfaces.adoc b/virt/vm_networking/virt-hot-plugging-network-interfaces.adoc new file mode 100644 index 0000000000..f8296b4747 --- /dev/null +++ b/virt/vm_networking/virt-hot-plugging-network-interfaces.adoc @@ -0,0 +1,34 @@ +:_content-type: ASSEMBLY +[id="virt-hot-plugging-network-interfaces"] += Hot plugging secondary network interfaces +include::_attributes/common-attributes.adoc[] +:context: virt-hot-plugging-network-interfaces + +toc::[] + +You can add or remove secondary network interfaces without stopping your virtual machine (VM). {VirtProductName} supports hot plugging and hot unplugging for Linux bridge interfaces that use the VirtIO device driver. + +:FeatureName: Hot plugging and hot unplugging bridge network interfaces +include::snippets/technology-preview.adoc[] + +[id="virtio-limitations_virt-hot-plugging-network-interfaces"] +== 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. {VirtProductName} 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. + +[NOTE] +==== +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 link:https://libvirt.org/pci-hotplug.html[libvirt documentation]. +==== + +If you restart the VM after hot plugging an interface, that interface becomes part of the standard network interfaces. + +include::modules/virt-hot-plugging-bridge-network-interface-cli.adoc[leveloffset=+1] + +include::modules/virt-hot-unplugging-bridge-network-interface-cli.adoc[leveloffset=+1] + +[role="_additional-resources"] +[id="additional-resources_virt-hot-plugging-network-interfaces"] +== Additional resources + +* xref:../../virt/getting_started/virt-using-the-cli-tools.adoc#installing-virtctl_virt-using-the-cli-tools[Installing virtctl] +* xref:../../virt/vm_networking/virt-connecting-vm-to-linux-bridge.adoc#creating-linux-bridge-nad[Creating a Linux bridge network attachment definition] \ No newline at end of file