Bug 853673 - virsh qemu-agent-command returns 0 and without any error message on parsing json char lexical error
virsh qemu-agent-command returns 0 and without any error message on parsing j...
Status: CLOSED CURRENTRELEASE
Product: Virtualization Tools
Classification: Community
Component: libvirt (Show other bugs)
unspecified
x86_64 Linux
medium Severity medium
: ---
: ---
Assigned To: Libvirt Maintainers
:
: 853705 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-09-01 23:26 EDT by Alex Jia
Modified: 2016-03-23 20:45 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-03-23 20:45:49 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Alex Jia 2012-09-01 23:26:21 EDT
Description of problem:
To pass a invalid command such as 'hello' to 'virsh qemu-agent-command' then command exits status is 0, but we can find a json lexical error in libvirtd.log. 

Version-Release number of selected component (if applicable):
# rpm -q libvirt qemu-kvm-rhev kernel                                                                                                                 
libvirt-0.10.1-1.el6.x86_64
qemu-kvm-rhev-0.12.1.2-2.302.el6.x86_64
kernel-2.6.32-288.el6.x86_64


How reproducible:
always

Steps to Reproduce:
1. virsh start <domain>
2. virsh qemu-agent-command <domain> hello
3. echo $?

  
Actual results:

# virsh qemu-agent-command foo hello

# echo $?
0

# cat /var/log/libvirt/libvirtd.log  (to enable '1:json' in libvirtd.conf)

<snip>

2012-09-02 03:12:14.660+0000: 30900: debug : qemuDispatchDomainAgentCommandHelper:19 : server=0x2089dc0 client=0x2093140 msg=0x2092570 rerr=0x7fb437755b80 args=0x7fb418000a60 ret=0x7fb418000b40
2012-09-02 03:12:14.660+0000: 30900: debug : virDomainQemuAgentCommand:217 : domain=0x7fb418000c00, cmd=hello, timeout=-1, flags=0
2012-09-02 03:12:14.660+0000: 30900: debug : qemuDomainObjBeginJobInternal:807 : Starting job: modify (async=none)
2012-09-02 03:12:14.660+0000: 30900: debug : virJSONValueFromString:975 : string=hello
2012-09-02 03:12:14.660+0000: 30900: error : virJSONValueFromString:1001 : internal error cannot parse json hello: lexical error: invalid char in json text.
                                       hello
                     (right here) ------^

2012-09-02 03:12:14.660+0000: 30900: debug : virJSONValueFromString:1019 : result=(nil)
2012-09-02 03:12:14.660+0000: 30900: error : qemuDomainAgentCommand:13904 : internal error Failed to execute agent command

</snip>

Expected results:

Libivirt should raise a error information and 'virsh qemu-agent-command' should exit with status 1.

Additional info:
Comment 2 Alex Jia 2012-09-01 23:40:58 EDT
BTW, I haven't do any guest agent configuration in guest XML.
Comment 3 Jiri Denemark 2012-09-03 05:59:28 EDT
*** Bug 853705 has been marked as a duplicate of this bug. ***
Comment 4 Jiri Denemark 2012-09-03 06:01:31 EDT
qemuDomainAgentCommand correctly reports the error but it seems it is not properly propagated to the end user. Anyway, qemu-agent-command (all qemu-* commands to be precise) is not supported, I'm moving this bug upstream.
Comment 5 Alex Jia 2012-09-03 06:32:39 EDT
(In reply to comment #4)
> qemuDomainAgentCommand correctly reports the error but it seems it is not
> properly propagated to the end user. Anyway, qemu-agent-command (all qemu-*
> commands to be precise) is not supported, I'm moving this bug upstream.

Jiri, in fact, the 'qemu-agent-command' does work for me if I passed correct commands to it and correctly configure qemu-guest-agent in the guest, for example:

# virsh qemu-agent-command myRHEL6 --cmd '{"execute":"guest-ping"}'
{"return":{}}

# virsh qemu-agent-command myRHEL6 --cmd '{ "execute": "guest-sync", "arguments": { "id": 123456 } }'
{"return":123456}

# virsh qemu-agent-command myRHEL6 --cmd '{"execute":"guest-fsfreeze-status"}'
{"return":"thawed"}

# virsh qemu-agent-command myRHEL6 --cmd '{"execute":"guest-fsfreeze-freeze"}'
{"return":2}

# virsh qemu-agent-command myRHEL6 --cmd '{"execute":"guest-fsfreeze-status"}'
{"return":"frozen"}

# virsh snapshot-create-as --quiesce myRHEL6 --disk-only
Domain snapshot 1346642071 created

# virsh qemu-agent-command myRHEL6 --cmd '{"execute":"guest-fsfreeze-status"}'
{"return":"thawed"}

# virsh qemu-agent-command myRHEL6 --cmd '{"execute":"guest-network-get-interfaces"}'
{"return":[{"name":"lo","ip-addresses":[{"ip-address-type":"ipv4","ip-address":"127.0.0.1","prefix":8},{"ip-address-type":"ipv6","ip-address":"::1","prefix":128}],"hardware-address":"00:00:00:00:00:00"},{"name":"eth7","ip-addresses":[{"ip-address-type":"ipv4","ip-address":"192.168.122.156","prefix":24},{"ip-address-type":"ipv6","ip-address":"fe80::5054:ff:feda:4aeb","prefix":64}],"hardware-address":"52:54:00:da:4a:eb"}]}
Comment 6 Alex Jia 2013-11-05 21:46:59 EST
(In reply to Jiri Denemark from comment #4)
> qemuDomainAgentCommand correctly reports the error but it seems it is not
> properly propagated to the end user. Anyway, qemu-agent-command (all qemu-*
> commands to be precise) is not supported, I'm moving this bug upstream.

The qemu-monitor-command has the same issue of the return value on libvirt-0.10.2-29.el6.x86_64.
Comment 7 Cole Robinson 2016-03-23 20:45:49 EDT
Seems fixed upstream:

$ sudo virsh qemu-monitor-command f23 hello
error: internal error: cannot parse json hello: lexical error: invalid char in json text.
                                       hello
                     (right here) ------^

Note You need to log in before you can comment on or make changes to this bug.