不重启虚拟机在线增加网卡
[root@daixuan qemu]# virsh domiflist daixuan2 //查看daixuan2子机的网卡列表
Interface Type Source Model MAC
-------------------------------------------------------
vnet2 bridge br1 virtio 52:54:00:3a:2a:71
命令行增加一块网卡:
[root@daixuan qemu]# virsh attach-interface daixuan2 --type bridge --source br1
成功附加接口
命令行增加的网卡只保存在内存中,重启就失效,所以需要保存到配置文件中,其中 /etc/libvirsh/qemu/daixuan2.xml 为daixuan2子机的配置文件
[root@daixuan qemu]# virsh dumpxml daixuan2 > /etc/libvirt/qemu/daixuan2.xml
[root@daixuan qemu]# virsh console daixuan2
连接到域 daixuan2
Escape character is ^]
在线增加了eth3网卡
[root@localhost ~]# ifconfig -a
eth3 Link encap:Ethernet HWaddr 52:54:00:3A:2A:71
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
eth4 Link encap:Ethernet HWaddr 52:54:00:A6:C7:6A
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:11 Base address:0x8000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
调整cpu和内存查看子机配置:
virsh dominfo daixuan1
[root@daixuan ~]# virsh edit daixuan1
修改:
<memory unit='KiB'>524288</memory> //最大可用内存
<currentMemory unit='KiB'>524288</currentMemory> //现在的内存
<vcpu placement='static'>1</vcpu> //cpu核数
为:
<memory unit='KiB'>624288</memory>
<currentMemory unit='KiB'>624288</currentMemory>
<vcpu placement='static'>2</vcpu>
重启虚拟机:
virsh destroy daixuan1
virsh start daixuan1