diff options
author | Markus Armbruster <armbru@redhat.com> | 2015-03-12 17:26:49 +0100 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2015-03-17 14:23:52 +0100 |
commit | 7afcc1f9bae3e857834a3bb8247be101e2354998 (patch) | |
tree | 1d61c8a0fc3770b635df4c7182052bec7678e852 /pixman | |
parent | 9b14e0efcc9a6ea41b7265538f6ec4c53e2ba270 (diff) | |
download | hqemu-7afcc1f9bae3e857834a3bb8247be101e2354998.zip hqemu-7afcc1f9bae3e857834a3bb8247be101e2354998.tar.gz |
usb/dev-storage: Fix QMP device_add missing encryption key failure
When the image is encrypted, QMP device_add creates the device, defers
actually attaching it to when the key becomes available, then returns
an error. This is wrong. device_add must either create the device
and succeed, or do nothing and fail.
The bug is in usb_msd_realize_storage(). It posts an error with
qerror_report_err(), and returns success. Device realization relies
on the return value, and completes. The QMP monitor, however, relies
on the posted error, and sends it in an error reply.
Reproducer:
$ qemu-system-x86_64 -nodefaults -display none -usb -qmp stdio -drive if=none,id=foo,file=geheim.qcow2
{"QMP": {"version": {"qemu": {"micro": 50, "minor": 2, "major": 2}, "package": ""}, "capabilities": []}}
{ "execute": "qmp_capabilities" }
{"return": {}}
{ "execute": "device_add", "arguments": { "driver": "usb-storage", "id": "bar", "drive": "foo" } }
{"error": {"class": "DeviceEncrypted", "desc": "'foo' (geheim.qcow2) is encrypted"}}
Even though we got an error back, the device got created just fine.
To demonstrate, let's unplug it again:
{"execute":"device_del","arguments": { "id": "bar" } }
{"timestamp": {"seconds": 1426003440, "microseconds": 237181}, "event": "DEVICE_DELETED", "data": {"path": "/machine/peripheral/bar/bar.0/legacy[0]"}}
{"timestamp": {"seconds": 1426003440, "microseconds": 238231}, "event": "DEVICE_DELETED", "data": {"device": "bar", "path": "/machine/peripheral/bar"}}
{"return": {}}
Fix by making usb_msd_realize_storage() fail properly.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'pixman')
0 files changed, 0 insertions, 0 deletions