Skip to content

Commit 9317dfc

Browse files
authored
Merge pull request #62426 from sjhala-ccs/cnv-14623
CNV-14623: Hot plugging network interfaces
2 parents 820f81b + 7a3dc85 commit 9317dfc

File tree

5 files changed

+172
-0
lines changed

5 files changed

+172
-0
lines changed

_topic_maps/_topic_map.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3776,6 +3776,8 @@ Topics:
37763776
File: virt-connecting-vm-to-sriov
37773777
- Name: Using DPDK with SR-IOV
37783778
File: virt-using-dpdk-with-sriov
3779+
- Name: Hot plugging secondary network interfaces
3780+
File: virt-hot-plugging-network-interfaces
37793781
- Name: Connecting a VM to a service mesh
37803782
File: virt-connecting-vm-to-service-mesh
37813783
- Name: Configuring a dedicated network for live migration
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * virt/virtual_machines/vm_networking/virt-hot-plugging-network-interfaces.adoc
4+
5+
:_content-type: PROCEDURE
6+
[id="virt-hot-plugging-bridge-network-interface_{context}"]
7+
= Hot plugging a bridge network interface using the CLI
8+
9+
Hot plug a bridge network interface to a virtual machine (VM) while the VM is running.
10+
11+
.Prerequisites
12+
13+
* A network attachment definition is configured in the same namespace as your VM.
14+
* You have installed the `virtctl` tool.
15+
16+
.Procedure
17+
18+
. If the VM to which you want to hot plug the network interface is not running, start it by using the following command:
19+
+
20+
[source,terminal]
21+
----
22+
$ virtctl start <vm_name>
23+
----
24+
25+
. 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.
26+
+
27+
[source,terminal]
28+
----
29+
$ virtctl addinterface <vm_name> --network-attachment-definition-name <net_attach_def_name> --name <interface_name>
30+
----
31+
+
32+
where:
33+
34+
<vm_name>:: Specifies the name of the `VirtualMachine` object.
35+
<net_attach_def_name>:: Specifies the name of `NetworkAttachmentDefinition` object.
36+
<interface_name>:: Specifies the name of the new network interface.
37+
38+
39+
. To attach the network interface to the running VM, live migrate the VM by using the following command:
40+
+
41+
[source,terminal]
42+
----
43+
$ virtctl migrate <vm_name>
44+
----
45+
46+
.Verification
47+
48+
. Verify that the VM live migration is successful by using the following command:
49+
+
50+
[source,terminal]
51+
----
52+
$ oc get VirtualMachineInstanceMigration -w
53+
----
54+
+
55+
.Example output
56+
[source,terminal]
57+
----
58+
NAME PHASE VMI
59+
kubevirt-migrate-vm-lj62q Scheduling vm-fedora
60+
kubevirt-migrate-vm-lj62q Scheduled vm-fedora
61+
kubevirt-migrate-vm-lj62q PreparingTarget vm-fedora
62+
kubevirt-migrate-vm-lj62q TargetReady vm-fedora
63+
kubevirt-migrate-vm-lj62q Running vm-fedora
64+
kubevirt-migrate-vm-lj62q Succeeded vm-fedora
65+
----
66+
67+
. Verify that the new interface is added to the VM by checking the VMI status:
68+
+
69+
[source,terminal]
70+
----
71+
$ oc get vmi vm-fedora -ojsonpath="{ @.status.interfaces }"
72+
----
73+
+
74+
.Example output
75+
[source,json]
76+
----
77+
[
78+
{
79+
"infoSource": "domain, guest-agent",
80+
"interfaceName": "eth0",
81+
"ipAddress": "10.130.0.195",
82+
"ipAddresses": [
83+
"10.130.0.195",
84+
"fd02:0:0:3::43c"
85+
],
86+
"mac": "52:54:00:0e:ab:25",
87+
"name": "default",
88+
"queueCount": 1
89+
},
90+
{
91+
"infoSource": "domain, guest-agent, multus-status",
92+
"interfaceName": "eth1",
93+
"mac": "02:d8:b8:00:00:2a",
94+
"name": "bridge-interface", <1>
95+
"queueCount": 1
96+
}
97+
]
98+
----
99+
<1> The hot-plugged interface appears in the VMI status.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * virt/virtual_machines/vm_networking/virt-hot-plugging-network-interfaces.adoc
4+
5+
:_content-type: PROCEDURE
6+
[id="virt-hot-unplugging-bridge-network-interface_{context}"]
7+
= Hot unplugging a bridge network interface using the CLI
8+
9+
You can remove a bridge network interface from a running virtual machine (VM).
10+
11+
.Prerequisites
12+
13+
* Your VM must be running.
14+
* The VM must be created on a cluster running {VirtProductName} 4.14 or later.
15+
* The VM must have a bridge network interface attached.
16+
17+
.Procedure
18+
19+
. 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.
20+
+
21+
[source,terminal]
22+
----
23+
$ virtctl removeinterface <vm_name> --name <interface_name>
24+
----
25+
26+
. Remove the interface from the pod by migrating the VM:
27+
+
28+
[source,terminal]
29+
----
30+
$ virtctl migrate <vm_name>
31+
----

modules/virt-virtctl-commands.adoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,12 @@ Optional:
254254

255255
|`virtctl removevolume <vm_name> --volume-name=<virtual_disk>`
256256
|Hot unplug a virtual disk.
257+
258+
|`virtctl addinterface <vm_name> --network-attachment-definition-name <net_attach_def_name> --name <interface_name>`
259+
|Hot plug a Linux bridge network interface.
260+
261+
|`virtctl removeinterface <vm_name> --name <interface_name>`
262+
|Hot unplug a Linux bridge network interface.
257263
|===
258264

259265
[id='image-upload-commands_{context}']
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
:_content-type: ASSEMBLY
2+
[id="virt-hot-plugging-network-interfaces"]
3+
= Hot plugging secondary network interfaces
4+
include::_attributes/common-attributes.adoc[]
5+
:context: virt-hot-plugging-network-interfaces
6+
7+
toc::[]
8+
9+
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.
10+
11+
:FeatureName: Hot plugging and hot unplugging bridge network interfaces
12+
include::snippets/technology-preview.adoc[]
13+
14+
[id="virtio-limitations_virt-hot-plugging-network-interfaces"]
15+
== VirtIO limitations
16+
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.
17+
18+
[NOTE]
19+
====
20+
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].
21+
====
22+
23+
If you restart the VM after hot plugging an interface, that interface becomes part of the standard network interfaces.
24+
25+
include::modules/virt-hot-plugging-bridge-network-interface-cli.adoc[leveloffset=+1]
26+
27+
include::modules/virt-hot-unplugging-bridge-network-interface-cli.adoc[leveloffset=+1]
28+
29+
[role="_additional-resources"]
30+
[id="additional-resources_virt-hot-plugging-network-interfaces"]
31+
== Additional resources
32+
33+
* xref:../../virt/getting_started/virt-using-the-cli-tools.adoc#installing-virtctl_virt-using-the-cli-tools[Installing virtctl]
34+
* xref:../../virt/vm_networking/virt-connecting-vm-to-linux-bridge.adoc#creating-linux-bridge-nad[Creating a Linux bridge network attachment definition]

0 commit comments

Comments
 (0)