On Fri, Nov 07, 2014 at 03:28:57PM -0700, Min Du wrote:
Hi,
Now for some reason, I need to add “ -qmp tcp:127.0.0.1:1235” when
creating a KVM VM using libvirt.
You might need to elaborate how exactly you're doing this.
This command meaning in “qemu-kvm --help” is: -qmp dev like
-monitor but opens in 'control' mode.
The above is used if you want to explicitly control a running QEMU
instance via QMP, e.g. manually issue them QMP commands via telnet(1)
for development/testing/debugging.
I added command-line equivalent options into the xml file, like
below
format:
<qemu:commandline> <qemu:arg value="-s"/> <qemu:arg
value="-qmp"/>
<qemu:arg value="tcp:127.0.0.1:1235"/> </qemu:commandline>
In guests created in a regular fashion (e.g. virt-install,
virt-manager), this is all handled by libvirt for you via its APIs.
However when I create VM using this xml file, I got the error:
# virsh create instance-libvirt.xml error: Failed to create domain
from instance-libvirt.xml error: internal error process exited while
connecting to monitor: qemu-kvm: -qmp tcp:127.0.0.1:1235: Duplicate ID
'monitor' for mon duplicate chardev: monitor
The VM I created, without “—qmp” option, has below options showing in
“ps aux | grep qemu-kvm”:
-chardev
socket,id=charmonitor,path=/var/lib/libvirt/qemu/vmifs_test.monitor,server,nowait
-mon chardev=charmonitor,id=monitor,mode=control
Looks like libvirt automatically adds the monitor options upon VM
creation.
As I understand it, libvirt uses its own APIs to handle interactions
with QEMU monitor console, e.g. qemuMonitorOpen(), etc.
If you're fine delving into code, you might want to libvirt
sources, specificially this directory: libvirt/src/qemu.
Is there a way to disable this and use “—qmp” instead when creating
VM?
I doubt libvirt developers will agree with this proposal. But if you're
intending to try QEMU monitor console for testing, here's some old notes
on different ways to access QEMU monitor via QMP:
http://kashyapc.com/2013/03/31/multiple-ways-to-access-qemu-monitor-proto...
--
/kashyap