[libvirt] [PATCH 1/2] qemu_monitor: Fix tray-open attribute in query-block

Peter Krempa pkrempa at redhat.com
Fri Jan 25 13:35:11 UTC 2013


On 01/25/13 14:31, Eric Blake wrote:
> On 01/25/2013 06:05 AM, Peter Krempa wrote:
>> On 01/25/13 13:20, Michal Privoznik wrote:
>>> With our code, we fail to query for tray-open attribute currently.
>>> That's because in HMP it is 'tray-open' and in QMP it's 'tray_open'.
>>> It always has been. However, we got it exactly the opposite.
>>> ---
>>>    src/qemu/qemu_monitor_json.c | 2 +-
>>>    src/qemu/qemu_monitor_text.c | 6 +++---
>>>    2 files changed, 4 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
>>> index de5f115..0aa3bcb 100644
>>> --- a/src/qemu/qemu_monitor_json.c
>>> +++ b/src/qemu/qemu_monitor_json.c
>>> @@ -1588,7 +1588,7 @@ int qemuMonitorJSONGetBlockInfo(qemuMonitorPtr mon,
>>>            /* Don't check for success here, because 'tray-open' is
>>> presented iff
>>>             * medium is ejected.
>>>             */
>>> -        ignore_value(virJSONValueObjectGetBoolean(dev, "tray-open",
>>> +        ignore_value(virJSONValueObjectGetBoolean(dev, "tray_open",
>>>                                                      &info->tray_open));
>>
>> Indeed. The returned value is with the underscore, while the
>> documentation uses the dash.
> 
> Where did you find that?  Because qemu.git/qapi-schema.json says:
> 
> { 'type': 'BlockInfo',
>    'data': {'device': 'str', 'type': 'str', 'removable': 'bool',
>             'locked': 'bool', '*inserted': 'BlockDeviceInfo',
>             '*tray_open': 'bool', '*io-status': 'BlockDeviceIoStatus',
>             '*dirty': 'BlockDirtyInfo' } }
> 
> with the underscore, and that's the file I refer to for documentation of
> QMP.
> 
I usualy refer to qemu.git/qmp-commands.hx:

query-block
-----------

Show the block devices.

Each block device information is stored in a json-object and the returned value
is a json-array of all devices.

Each json-object contain the following:

- "device": device name (json-string)
- "type": device type (json-string)
         - deprecated, retained for backward compatibility
         - Possible values: "unknown"
- "removable": true if the device is removable, false otherwise (json-bool)
- "locked": true if the device is locked, false otherwise (json-bool)
- "tray-open": only present if removable, true if the device has a tray,
               and it is open (json-bool)
- "inserted": only present if the device is inserted, it is a json-object
   containing the following:
[...]




More information about the libvir-list mailing list