kvm 实用工具总结:
1. libguestfs-tools
直接宿主机安装:
yum -y install libguestfs-tools
virt-df xxx 相当于df命令
virt-cat xxx 相当远cat命令
virt-edit xxx 相当于vi命令
virt-ls xxx 相当于ls命令
参考:http://www.361way.com/kvm-libguestfs-tools/3175.html
2. qemu-guest-agent centos7.1
如果虚拟机可以关闭:
virsh shutdown rhel7
virsh edit rhel7
在device段增加:
<channel type='unix'>
<target type='virtio' name='org.qemu.guest_agent.0'/>
</channel>
保存退出
virsh start rhel7
在虚拟机中安装:
yum install qemu-guest-agent
systemctl start qemu-guest-agent
在运行的虚拟机中:
vi agent.xml
<channel type='unix'>
<source mode='bind' path='/tmp/centos7-1.0'/>
<target type='virtio' name='org.qemu.guest_agent.0'/>
</channel>
将配置粘贴到虚拟机文件
virsh attach-device rhel7 agent.xml
若出现如下错误:
[root@liulianex2 qemu]# virsh attach-device centos7rediscache agent.xml
错误:从 agent.xml 获得设备失败
错误:internal error: no virtio-serial controllers are available
原因:virtio-serial设备每天添加
解决:
注意:
<channel type='spicevmc'>
<target type='virtio' name='com.redhat.spice.0'/>
<address type='virtio-serial' controller='0' bus='0' port='1'/>
</channel>
在input之前增加上面的内容
###<input type='mouse' bus='ps2'/>
<controller type='virtio-serial' index='0'>
<address type='pci' domain='0x0000' bus='0x01' slot='0x05' function='0x0'/>
</controller>
在bridge之前增加上面的内容:
## <interface type='bridge'>
在虚拟机中安装:
yum install qemu-guest-agent
systemctl start qemu-guest-agent
执行命令检测:
修改虚拟机密码:
virsh set-user-password LL_WEBccc3294b02 --user root --password 123
查看网卡信息:
virsh domifaddr LL_WEBccc3294b02 --source agent
####
Name MAC address Protocol Address
-------------------------------------------------------------------------------
lo 00:00:00:00:00:00 ipv4 127.0.0.1/8
- - ipv6 ::1/128
ens3 22:66:0f:56:f2:3f ipv4 172.16.88.192/24
- - ipv6 fe80::2066:fff:fe56:f23f/64
参考文件:
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Virtualization_Deployment_and_Administration_Guide/chap-QEMU_Guest_Agent.html