要确保qemu-agent 安装成功才可以通讯
virsh qemu-agent-command centos --cmd '{"execute":"guest-exec","arguments":{"path":"hostnamectl", "arg":["set-hostname","lgj"]}}' linux系统
以下是windows系统,改ip地址以及主机名
改主机名win7没试验成功,改ip地址可以
qemu-agent-command win --cmd '{"execute":"guest-exec","arguments":{"path":"netsh", "arg":["interface","ip","set","addr","以太网","static","192.168.3.234","255.255.255.0","192.168.3.1"}}'
qemu-agent-command win --cmd '{"execute":"guest-exec","arguments":{"path":"netsh", "arg":["interface","ip","set","dns","以太网","static","114.114.114.114"]}}'
这条执行修改不成功
qemu-agent-command win --cmd '{"execute":"guest-exec","arguments":{"path":"WMIC", "arg":["computersystem","where","caption=DESKTOP-UT2CLND","rename","lgj'"]}}'
这条win10的16成功了
qemu-agent-command win --cmd '{"execute":"guest-exec","arguments":{"path":"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe", "arg":["rename-computer","lgj"]}}
qemu-agent-command win '{"execute": "guest-exec-status", "arguments": { "pid": 904 } }' 查看代码输出 检查命令执行返回结果