Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 628940 (LibvirtHMP)

Summary: libvirt should provide a way to pass through human monitor commands for debuging
Product: Red Hat Enterprise Linux 6 Reporter: Gleb Natapov <gleb>
Component: libvirtAssignee: Daniel Veillard <veillard>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 6.0CC: berrange, dallan, dyuan, eblake, gcosta, hbrock, jdenemar, jyang, knoel, lcapitulino, llim, mkenneth, plyons, tburke, virt-maint, xen-maint, xtian, yoyzhang
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-0.8.7-5.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 644819 (view as bug list) Environment:
Last Closed: 2011-05-19 13:21:09 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Gleb Natapov 2010-08-31 13:26:56 UTC
It is impossible to debug qemu instance without human qemu monitor.

Comment 2 Daniel Berrangé 2010-08-31 13:46:24 UTC
Upstream libvirt has support for adding extra parameters, so you can add a HMP using something along the lines of:

   <qemu:commandline>
     <qemu:arg value='-chardev'/>
     <qemu:arg value='unix:/some/path,id=hmp'/>
     <qemu:arg value='-monitor'/>
     <qemu:arg value='readline,chardev=hmp'/>
   </qemu:commandline>

This functionality won't be available until RHEL-6.1, so will leave this bug open to track the addition.

Comment 3 Luiz Capitulino 2010-08-31 15:34:50 UTC
We've discussed it today and turns out we need a solution for RHEL-6.0, I see two options:

1. Libvirt opens a default human monitor instance to some known location

2. We implement human monitor passthrough from QMP (this is going to be done upstream, for 0.14)

I think there's more work involved in 2, but 1 has security issues.

Comment 4 Daniel Berrangé 2010-08-31 15:58:30 UTC
Option 1 is not desirable in libvirt, because that will set the precedent that libvirt will provide a HMP instance for QEMU guests which is not something we want todo. This is why we want to facilitate it via the command line arg XML extensions, which are clearly marked as unsupported & optional.

Option 2, monitor passthrough from QEMU via libvirt API is also something that is targetted for RHEL-6.1  and not practical for 6.0

Comment 5 Luiz Capitulino 2010-08-31 18:37:22 UTC
(In reply to comment #4)

> Option 2, monitor passthrough from QEMU via libvirt API is also something that
> is targetted for RHEL-6.1  and not practical for 6.0

It's not via libvirt API, it's really via QMP itself. We're going to implement it upstream, something like:

{ "execute": "hmp_passthrough", "arguments": { "info roms" } }
{ "return": "addr=00000000fffe0000 size=0x020000 mem=rom name=\"bios.bin\""}

In theory, this could be used to debug running VMs too. Not really sure how practical this is, I'm just giving options :-)

Comment 6 Gleb Natapov 2010-10-20 10:30:27 UTC
This bug has to be resolved for _rhel6.0_ ASAP. It is impossible to debug KVM otherwise and without working KVM libvirt is useless for rhel6.

Comment 7 Daniel Berrangé 2010-10-20 11:00:27 UTC
I agree with Luiz that the addition of HMP passthrough in QMP is the best approach to this problem. Since QEMU already allows to open multiple connections to the existing QMP monitor socket, I don't see that there's any additional work required in libvirt for this issue. It just needs the QEMU addition of the 'hmp_passthrough' command (or '__com.redhat.hmp_passthrough' if we don't want to wait for upstream).

Comment 8 Gleb Natapov 2010-10-20 11:20:23 UTC
(In reply to comment #7)
> I agree with Luiz that the addition of HMP passthrough in QMP is the best
> approach to this problem. Since QEMU already allows to open multiple
> connections to the existing QMP monitor socket, I don't see that there's any
> additional work required in libvirt for this issue. It just needs the QEMU
> addition of the 'hmp_passthrough' command (or '__com.redhat.hmp_passthrough' if
> we don't want to wait for upstream).

Doing hmp_passthrough is much more complex change for rhel6.0 z-stream than adding hmp from libvirt. For rhel6.1 rhevm will use cmd pass through.

Please in the future refrain from changing bug summary and component without agreement of all involved parties. It you think that hmp_passthrough for qmp is the way to go for 6.0 z stream open separate bug.

Comment 9 Daniel Berrangé 2010-10-20 11:50:30 UTC
As you wish, bug 644819 opened for hmp_passthrough.

It is not simply a matter of complex, we have to consider the long term implications of adding the feature to libvirt. Exposing an 2nd monitor channel for guests is not something we have any desire to support as a solution, but once you add such a capability to RHEL we're stuck with it indefinitely. Since it is already agreed upstream that hmp_passthrough is the desirable solution for this problem, we should focus on that.

Comment 12 Gleb Natapov 2010-10-20 12:02:57 UTC
(In reply to comment #9)
> As you wish, bug 644819 opened for hmp_passthrough.
Thanks. I do not care how exactly the capability will be provides as long as it is provided in rhel6.0.

> 
> It is not simply a matter of complex, we have to consider the long term
> implications of adding the feature to libvirt. Exposing an 2nd monitor channel
> for guests is not something we have any desire to support as a solution, but
> once you add such a capability to RHEL we're stuck with it indefinitely. Since
> it is already agreed upstream that hmp_passthrough is the desirable solution
> for this problem, we should focus on that.
Provide it only when started by vdsm and drop it in rhel6.1 RHEL specific features where added to qemu-kvm too that will work differently in upstream if at all. This is not the end of the world. And BTW how supporting hmp_passthrough
is different from opening HMP from libvirt perspective?

Comment 14 Luiz Capitulino 2010-10-20 12:19:45 UTC
(In reply to comment #9)
> As you wish, bug 644819 opened for hmp_passthrough.
> 
> It is not simply a matter of complex, we have to consider the long term
> implications of adding the feature to libvirt. Exposing an 2nd monitor channel
> for guests is not something we have any desire to support as a solution, but
> once you add such a capability to RHEL we're stuck with it indefinitely. Since
> it is already agreed upstream that hmp_passthrough is the desirable solution
> for this problem, we should focus on that.

We also have to consider what is the most appropriate for the Z-stream.

HMP passthrough is going to be a completely new feature, and it has all its implications: a number of code changes, upstream review cycle, testing, etc.

IMO, this is too much for the Z-stream. We should only do it if it's impossible to do something simpler.

If the only problem with opening a second monitor instance is the RHEL contract, let's put it on the table then.

Comment 15 Glauber Costa 2010-10-21 14:49:05 UTC
How hard is to backport upstream's extra parameter support for 6.0.z ?
It seems to solve the problem, will be in 6.1, and seems to me as less work than hmp_passthrough.

Comment 27 Jiri Denemark 2011-02-02 14:22:11 UTC
Yes, libvirt supports tunneling arbitrary qemu commands using virsh qemu-monitor-command. So you can use it like this:

# virsh qemu-monitor-command rhel6 \
'{"execute":"human-monitor-command","arguments":{"command-line":"info kvm"}}'

Which will print qemu reply:

{"return":"kvm support: enabled\r\n"}

Comment 28 Jiri Denemark 2011-02-03 10:07:47 UTC
Upstream is going to gain a --hmp option for qemu-monitor-command so that the example above can be simplified to just

    virsh qemu-monitor-command --hmp DOM "info kvm"

which would print

    kvm support: enabled

I think this could simplify developers' lives and it's worth backporting for this BZ.

Comment 29 Jiri Denemark 2011-02-03 22:37:39 UTC
Patch implementing comment 28 sent to rhvirt-patches.

Comment 31 zhanghaiyan 2011-02-09 09:13:42 UTC
Failed to verify this bug as it seems related patch is not built in qemu-kvm now. So please change the bug to post status now
- qemu-kvm-0.12.1.2-2.144.el6.x86_64
- qemu-img-0.12.1.2-2.144.el6.x86_64
- libvirt-0.8.7-5.el6.x86_64
# virsh qemu-monitor-command rhel6 --hmp 'info kvm'
error: internal error unable to execute QEMU command 'human-monitor-command': The command human-monitor-command has not been found

Comment 32 Jiri Denemark 2011-02-09 10:13:48 UTC
That's weird. Are you sure your guest is running with the right version of qemu? According to qemu bug 647447 human-monitor-command is supported since qemu-kvm-0.12.1.2-2.132.el6

Comment 33 Jiri Denemark 2011-02-09 10:21:19 UTC
And it works just fine for me with

libvirt-0.8.7-5.el6.x86_64
qemu-kvm-0.12.1.2-2.144.el6.x86_64

Comment 34 zhanghaiyan 2011-02-10 07:08:50 UTC
After update kernel package, verify this bug passs
- qemu-kvm-0.12.1.2-2.144.el6.x86_64
- qemu-img-0.12.1.2-2.144.el6.x86_64
- libvirt-0.8.7-5.el6.x86_64
- kernel-2.6.32-115.el6.x86_64

# virsh qemu-monitor-command test '{"execute":"human-monitor-command","arguments":{"command-line":"info kvm"}}'
{"return":"kvm support: enabled\r\n"}

# virsh qemu-monitor-command --hmp test "info kvm"
kvm support: enabled

Comment 37 zhanghaiyan 2011-02-26 03:04:43 UTC
Verified this bug pass with libvirt-0.8.7-8.el6.x86_64
- kernel-2.6.32-117.el6.x86_64
- qemu-kvm-0.12.1.2-2.147.el6.x86_64

Test steps and actual result:

# virsh qemu-monitor-command rhel61_i386_1 '{"execute":"human-monitor-command","arguments":{"command-line":"info kvm"}}'
{"return":"kvm support: enabled\r\n"}

#  virsh qemu-monitor-command --hmp rhel61_i386_1 "info kvm" 
kvm support: enabled

Comment 40 errata-xmlrpc 2011-05-19 13:21:09 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-0596.html