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 1036017

Summary: Guest agent won't work if excute the "guest-sync-delimited"'s qemu-guest-agent command twice
Product: Red Hat Enterprise Linux 7 Reporter: zhenfeng wang <zhwang>
Component: libvirtAssignee: Michal Privoznik <mprivozn>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: acathrow, ajia, dyuan, gsun, jdenemar, jmiao, mzhan, ydu, zhwang, zsong
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1036021 (view as bug list) Environment:
Last Closed: 2013-12-03 08:10:54 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1036021    

Description zhenfeng wang 2013-11-29 08:21:15 UTC
Description of problem:
Guest agent won't work if excute the "guest-sync-delimited"'s qemu-guest-agent command twice

Version-Release number of selected component (if applicable):
qemu-kvm-rhev-1.5.3-19.el7.x86_64
libvirt-1.1.1-13.el7.x86_64
kernel-3.10.0-47.el7.x86_64
qemu-guest-agent-1.5.3-19.el7.x86_64.rpm
virtio-win-1.6.7-2.el7.noarch
How reproducible:
100%

Steps to Reproduce:
1.Prepare a running guest with the following xml
# vrish dumpxml rhel7
--
<pm>
    <suspend-to-mem enabled='yes'/>
    <suspend-to-disk enabled='yes'/>
  </pm>
--
<channel type='unix'>
      <source mode='bind' path='/var/lib/libvirt/qemu/rhel7.agent'/>
      <target type='virtio' name='org.qemu.guest_agent.0'/>
      <alias name='channel1'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>

2.Install the qemu-guest-agent packet in the guest, then start the qemu-guest-agent service
#systemctl start qemu-guest-agent

3.Excute the following qemu-guest-agent command twice, the guest agent won't work
# virsh qemu-agent-command --domain rhel7 '{ "execute": "guest-sync-delimited", "arguments": { "id": 123456 } }'
error: internal error: cannot parse json �{"return": 123456}: lexical error: invalid char in json text.
                                       �{"return": 123456}
                     (right here) ------^

# virsh qemu-agent-command --domain rhel7 '{ "execute": "guest-sync-delimited", "arguments": { "id": 123456 } }'
error: Guest agent is not responding: QEMU guest agent is not available due to an error

4.Shutdown the guest with the guest-agent, it report error // normally, the guest can be shutdown successfully with the guest-agent

# virsh shutdown rhel7 --mode agent
error: Failed to shutdown domain rhel7
error: Guest agent is not responding: QEMU guest agent is not available due to an error

5.Both the windows and rhel's guest can hit the issue 

6.It works well with qemu-kvm command
# nc -U /tmp/qga.sock 
{"execute":"guest-ping"}
{"return": {}}
{ "execute": "guest-sync-delimited", "arguments": { "id": 123456 } }
�{"return": 123456}
{ "execute": "guest-sync-delimited", "arguments": { "id": 123456 } }
�{"return": 123456}
{ "execute": "guest-sync-delimited", "arguments": { "id": 123456 } }
�{"return": 123456}

Actual results:
Guest agent won't work if excute the "guest-sync-delimited"'s qemu-guest-agent command twice

Expected results:
The guest agent should work well

Additional info:

Comment 2 Jiri Denemark 2013-12-02 10:13:25 UTC
The fact that running guest-sync-delimited agent command manually breaks libvirtd's communication with a guest-agent is not a bug. However, when shutting down a domain, libvirtd should not try to use a guest-agent when it knows it does not work. And this issue likely applies to all other APIs that make use of a guest-agent when it is available but can fall back to another method.

Comment 3 Michal Privoznik 2013-12-02 16:00:58 UTC
(In reply to Jiri Denemark from comment #2)
> The fact that running guest-sync-delimited agent command manually breaks
> libvirtd's communication with a guest-agent is not a bug. However, when
> shutting down a domain, libvirtd should not try to use a guest-agent when it
> knows it does not work. And this issue likely applies to all other APIs that
> make use of a guest-agent when it is available but can fall back to another
> method.


It does not. Indeed, libvirt has some foolproof-ism built in and won't use the guest agent if there's been an error in communication to it. However, in order to fallback user must allow it. If agent shutdown mode is requested directly, libvirt can't fallback to acpi until user allows us to do so. zhenfeng is bare 'virsh shutdown' working? What about 'virsh shutdown --mode acpi'? If these two work, I'll close this one as NOTABUG.

Comment 4 zhenfeng wang 2013-12-03 02:28:12 UTC
Hi Michal
Both "virsh shutdown" and "virsh shutdown --mode acpi" work while the libvirt have the communication or lost the communication with the qemu agent in the guest.

Comment 5 Michal Privoznik 2013-12-03 08:10:54 UTC
Okay, so I'm closing this one.