lost and found ( for me ? )

KVM virsh : add/remove vNICs on the fly

Reference
http://builder.virt-tools.org/artifacts/libvirt-virshcmdref/html/sect-attach-interface.html

KVM host
# tail -1 /etc/lsb-release
DISTRIB_DESCRIPTION="Ubuntu 14.04 LTS"

# uname -ri
3.13.0-30-generic x86_64

# kvm --version
QEMU emulator version 2.0.0 (Debian 2.0.0+dfsg-2ubuntu1.1), Copyright (c) 2003-2008 Fabrice Bellard

[ add vNICs ]

One virtual machine “ubuntu1404-vm1” is running.

on the KVM, add one vNIC onto the VM.
virsh # attach-interface --domain ubuntu1404-vm2 --type network --source network1 --model virtio --persistent
Interface attached successfully

--type network : interface type
--source network1 : virutal network called "network1"

login to the VM
virsh # console ubuntu1404-vm2

Here are logs of the VM
# tail -f /var/log/syslog
Jul  2 21:09:09 ubuntu1404-vm1 kernel: [456827.012608] pci 0000:00:05.0: [1af4:1000] type 00 class 0x020000
Jul  2 21:09:09 ubuntu1404-vm1 kernel: [456827.012759] pci 0000:00:05.0: reg 0x10: [io  0x0000-0x001f]
Jul  2 21:09:09 ubuntu1404-vm1 kernel: [456827.012812] pci 0000:00:05.0: reg 0x14: [mem 0x00000000-0x00000fff]
Jul  2 21:09:09 ubuntu1404-vm1 kernel: [456827.013048] pci 0000:00:05.0: reg 0x30: [mem 0x00000000-0x0003ffff pref]
Jul  2 21:09:09 ubuntu1404-vm1 kernel: [456827.020582] ACPI: Error installing CMOS-RTC region handler
Jul  2 21:09:09 ubuntu1404-vm1 kernel: [456827.020812] pci 0000:00:05.0: BAR 6: assigned [mem 0x40000000-0x4003ffff pref]
Jul  2 21:09:09 ubuntu1404-vm1 kernel: [456827.020817] pci 0000:00:05.0: BAR 1: assigned [mem 0x40040000-0x40040fff]
Jul  2 21:09:09 ubuntu1404-vm1 kernel: [456827.020856] pci 0000:00:05.0: BAR 0: assigned [io  0x1000-0x101f]
Jul  2 21:09:09 ubuntu1404-vm1 kernel: [456827.020892] pci 0000:00:00.0: no hotplug settings from platform

[ remove vNICs ]

virsh # detach-interface --domain ubuntu1404-vm1 --mac '52:54:00:fe:66:14' --type network
Interface detached successfully

syslog of the VM
Jul  2 21:25:30 ubuntu1404-vm1 dhclient: receive_packet failed on eth1: Network is down
Jul  2 21:25:30 ubuntu1404-vm1 dhclient: Internet Systems Consortium DHCP Client 4.2.4
Jul  2 21:25:30 ubuntu1404-vm1 dhclient: Copyright 2004-2012 Internet Systems Consortium.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.