Virtual Network interfaces can be attached or detached from a guest virtual machine (domU) while the virtual machine is up and running. The below Xen networking steps gives details on those.

xm network-list” is the command to display the virtual network interfaces attached to a the guest Xen virtual machine. In this example, the command lists 3 NICs for the virtual machine “vm455”. We’ll try to remove and add back the third vif.

[root@host203 ~]# xm network-list vm455
Idx BE MAC Addr. handle state evt-ch tx-/rx-ring-ref BE-path
0 0 00:16:3E:47:AA:FD 0 4 12 2304 /2305 /local/domain/0/backend/vif/1/0
1 0 00:16:3E:22:33:44 1 4 13 2306 /2307 /local/domain/0/backend/vif/1/1
2 0 00:16:3E:40:22:12 2 4 14 2308 /2309 /local/domain/0/backend/vif/1/2
[root@host203 ~]#

To remove a NIC card from the virtual machine, use “xm network-detach”, with the corresponding options. In this example, the interface 3 is removed from the virtual machine. This command has to be executed on the Xen server.

[root@host203 ~]# xm network-detach vm455 2
[root@host203 ~]# xm network-list vm455
Idx BE MAC Addr. handle state evt-ch tx-/rx-ring-ref BE-path
0 0 00:16:3E:47:AA:FD 0 4 12 2304 /2305 /local/domain/0/backend/vif/1/0
1 0 00:16:3E:22:33:44 1 4 13 2306 /2307 /local/domain/0/backend/vif/1/1
[root@host203 ~]#

Once the network is detached, you can only 2 virtual NICs using “xm network-list” on the Xen server. If you check the virtual machine, it will have only 2 NICS. Use ifconfig to check on the guest virtual machine.

To add a NIC to the virtual machine, use the command “xm network-attach”. Pass the MAC-id , bridge name and the script to create the VIF as arguments. The default vif creation script is “vif-bridge”.  This is defined in /etc/xen/xend-config.sxp .

[root@host203 ~]# xm network-attach vm455 bridge=xenbr1 script=vif-bridge mac=00:16:3E:40:22:12
[root@host203 ~]# xm network-list vm455
Idx BE MAC Addr. handle state evt-ch tx-/rx-ring-ref BE-path
0 0 00:16:3E:47:AA:FD 0 4 12 2304 /2305 /local/domain/0/backend/vif/1/0
1 0 00:16:3E:22:33:44 1 4 13 2306 /2307 /local/domain/0/backend/vif/1/1
2 0 00:16:3E:40:22:12 2 4 14 2308 /2309 /local/domain/0/backend/vif/1/2
[root@host203 ~]#

The xm network-attach/detach command adds and removes NIC on a live machine. To make the changes permanent, edit the virtual machine configuration file in /etc/xen and edit the vifs. The same steps apply to Oracle Virtual machine also.

0 comments

Disclaimer

All the information presented on this blog is provided on the basis of as is and is meant for reference purpose only without any expressed or implied warranty. Use of the information and its application in any form is sole discretion and responsibility of the user. unixfoo.blogspot.com is not responsible for any damage or loss arising out of use of information presented here. This web site has links to external web sites and unixfoo.blogspot.com is not responsible for the contents at those sites.