Hi all,
I have a problem to execute qmp commands via qemu guest agent using
libvirt-Python. In libivrt and qemu tutorial, qmp commands are invoked
by terminal. In my project, I want to invoke the commands natively using
libvirt-Python API, not using Python subprocess module.
(my test shows using subprocess to invoke the commands have some issues)
I'm not sure if libvirt-Python provides such API. If the API is not avaiable,
as libvirt natively use C interface to interact
with QEMU, do we have to implement it by hand?
Another way to invoke qmp commands is communicate the socket of qemu guest
agent. I tried it which did not work. Invoking qmp commands with virsh works
fine.
Sorry if this post should be posted in other libvirt mail lists. Thank you very
much for feedbacks.
Environment
- OS: Centos 8.5(x86_64)
- libvirt 6.0.0
- QEMU 6.0.0
=== qemu guest socket
$ss | grep libvirt
/var/lib/libvirt/qemu/channel/target/domain-71-run-win7/org.qemu.guest_agent.0
8568953
/run/libvirt/libvirt-sock
$sudo socat
unix-connect:/var/lib/libvirt/qemu/channel/target/domain-71-run-win7/org.qemu.guest_agent.0
${"execute":"guest-info"}
// nothing shows
=== invoke qmp commands using Python
import subprocess
cmd = '{"execute": "guest-info"}'
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
result = p.communicate()[0]