虚拟机网卡管理
virsh attach-interface 添加网卡:
[root@ubuntu ~]# virsh domiflist CentOS-V6.5.23-server01
Interface Type Source Model MAC
-------------------------------------------------------
vnet0 network default rtl8139 52:54:00:90:0a:7a
[root@ubuntu ~]# virsh attach-interface CentOS-V6.5.23-server01 --type network --source default --model rtl8139 --current
Interface attached successfully
[root@ubuntu ~]# virsh domiflist CentOS-V6.5.23-server01
Interface Type Source Model MAC
-------------------------------------------------------
vnet0 network default rtl8139 52:54:00:90:0a:7a
vnet1 network default rtl8139 52:54:00:ae:84:d0
- --current 立即生效,但不会将配置保存到配置,重启失效,需要手动dump出配置导入xml文件
- --config 下次重启生效,可以将配置保存到配置,然后将配置dump回物理文件使其永久生效
virsh dumpxml 导出配置:
[root@ ~]# virsh dumpxml CentOS-V6.5.23-server01 > /etc/libvirt/qemu/CentOS-V6.5.23-server01.xml
virsh detach-interface 删除网卡:
[root@ubuntu ~]# virsh detach-interface CentOS-V6.5.23-server01 --type network --mac 52:54:00:00:34:55 --current
Interface detached successfully
[root@ubuntu ~]# virsh domiflist CentOS-V6.5.23-server01
Interface Type Source Model MAC
-------------------------------------------------------
vnet0 network default rtl8139 52:54:00:90:0a:7a
- --current 立即生效,但不会将配置保存到配置,重启失效,需要手动dump出配置导入xml文件
- --config 下次重启生效,可以将配置保存到配置,然后将配置dump回物理文件使其永久生效