User Tools

Site Tools


kvm:hot_attach_and_hot_detach_network_interface_to_kvm_guest

This is an old revision of the document!


KVM - Hot attach and hot detach network interface to kvm guest

1. Get to know the name of the guest, run below command on the kvm host:

sudo virsh list
 
 Id Name                 State
----------------------------------
  1 kvm-guest running

2. Check whether module acpiphp is loaded on the guest:

sudo lsmod | grep -i acpiphp

3. If yes, proceed to step 4. If no, run below command:

sudo modprobe acpiphp

4. Hot attach the network interface:

sudo virsh attach-interface kvm-guest network --model virtio --persistent
 
Interface attached successfully

5. Run dmesg on guest to verify that the interface has been attached successfully:

dmesg | tail 
 
[38613567.591261] virtio-pci 0000:00:04.0: using default PCI settings
[38613567.591283] pci 0000:00:05.0: no hotplug settings from platform
[38613567.591285] pci 0000:00:05.0: using default PCI settings
[38613567.591741] virtio-pci 0000:00:05.0: enabling device (0000 -> 0003)
[38613567.593361] ACPI: PCI Interrupt Link [LNKA] enabled at IRQ 10
[38613567.601486] virtio-pci 0000:00:05.0: PCI INT A -> Link[LNKA] -> GSI 10 (level, high) -> IRQ 10
[38613567.601524] virtio-pci 0000:00:05.0: setting latency timer to 64
[38613567.602328] virtio-pci 0000:00:05.0: irq 43 for MSI/MSI-X
[38613567.602343] virtio-pci 0000:00:05.0: irq 44 for MSI/MSI-X
[38613567.602357] virtio-pci 0000:00:05.0: irq 45 for MSI/MSI-X

6. Set ipaddress for the new interface:

sudo touch /etc/sysconfig/network-scripts/ifcfg-eth1; sudo echo -e "DEVICE=eth1\nONBOOT=yes\nTYPE=Ethernet\nBOOTPROTO=static\nIPADDR=10.0.0.8\nNETMASK=255.255.255.0" > /etc/sysconfig/ifcfg-eth1

7. Bring up the interface:

sudo ifup eth1

8. Check the interface:

ifconfig eth1
 
eth1      Link encap:Ethernet  HWaddr 52:54:00:D7:10:04
          inet addr:10.0.0.8  Bcast:10.0.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:178767965 errors:0 dropped:0 overruns:0 frame:0
          TX packets:58477452 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:11949338417 (11.1 GiB)  TX bytes:498944480375 (464.6 GiB)
kvm/hot_attach_and_hot_detach_network_interface_to_kvm_guest.1491293398.txt.gz ยท Last modified: 2020/07/15 09:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki