qemu-e2k/hw
Markus Armbruster 7afcc1f9ba 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>
2015-03-17 14:23:52 +01:00
..
9pfs virtio: Fix memory leaks reported by Coverity 2015-03-16 13:32:24 +05:30
acpi acpi: specify format for build_append_namestring 2015-03-11 18:24:29 +01:00
alpha QOM infrastructure fixes and device conversions 2015-03-02 13:20:43 +00:00
arm integrator/cp: Implement CARDIN and WPROT signals 2015-03-11 13:21:06 +00:00
audio
block - scsi: improvements to error reporting and conversion to realize, 2015-03-10 18:03:02 +00:00
bt
char target-arm queue: 2015-03-11 16:30:33 +00:00
core migration: Allow to suppress vmdesc submission 2015-03-16 14:35:20 +01:00
cpu
cris
display Allow the use of X11 from a non standard location. 2015-03-12 15:50:11 +01:00
dma pl330.c: remove superfluous '\n' around error_setg 2015-03-10 08:15:33 +03:00
gpio
i2c
i386 pc: Disable vmdesc submission for old machines 2015-03-16 14:35:37 +01:00
ide Block patches for 2.3 2015-03-10 14:01:22 +00:00
input adb.c: include ADBDevice parent state in KBDState and MouseState 2015-03-09 15:00:04 +01:00
intc target-arm queue: 2015-03-16 13:56:10 +00:00
ipack
isa
lm32 configure: opengl overhaul 2015-03-12 15:49:57 +01:00
m68k m68k: Use cpu_m68k_init() 2015-03-10 17:07:28 +01:00
mem pc-dimm: add a function to calculate VM's current RAM size 2015-03-04 13:00:04 -05:00
microblaze Remove superfluous '\n' around error_report() 2015-03-10 08:15:33 +03:00
mips QOM infrastructure fixes and device conversions 2015-03-02 13:20:43 +00:00
misc stm32f2xx_SYSCFG: Add the stm32f2xx SYSCFG 2015-03-11 13:21:05 +00:00
moxie
net fix GCC 5.0.0 logical-not-parentheses warnings 2015-03-10 08:15:34 +03:00
nvram spapr_vio: Convert to realize() 2015-03-09 15:00:07 +01:00
openrisc
pci pci: Convert pci_nic_init() to Error to avoid qdev_init() 2015-03-11 18:24:13 +01:00
pci-bridge pci, pc, virtio fixes and cleanups 2015-03-09 09:14:28 +00:00
pci-host machine: replace qemu opts with iommu property 2015-03-11 18:10:43 +01:00
pcmcia
ppc misc fixes and cleanups 2015-03-12 09:13:07 +00:00
s390x s390x/pci: fix length in sei_nt2 event 2015-03-16 10:20:17 +01:00
scsi misc fixes and cleanups 2015-03-12 09:13:07 +00:00
sd
sh4
sparc qemu-sparc update 2015-03-11 08:44:59 +00:00
sparc64 sun4u: switch m48t59 NVRAM to MMIO access 2015-03-10 09:36:19 +00:00
ssi
timer stm32f2xx_timer: Add the stm32f2xx Timer 2015-03-11 13:21:05 +00:00
tpm tpm: Move memory subregion function into realize function 2015-03-11 18:24:13 +01:00
tricore
unicore32 unicore32: Use uc32_cpu_init() 2015-03-10 17:07:28 +01:00
usb usb/dev-storage: Fix QMP device_add missing encryption key failure 2015-03-17 14:23:52 +01:00
vfio vfio: Remove superfluous '\n' around error_report() 2015-03-10 08:15:33 +03:00
virtio virtio-pci: Convert to realize() 2015-03-11 18:24:13 +01:00
watchdog pci, pc, virtio fixes and cleanups 2015-03-09 09:14:28 +00:00
xen xen-pt: fix Out-of-bounds read 2015-03-10 08:15:33 +03:00
xenpv
xtensa xtensa: Remove superfluous '\n' around error_report() 2015-03-10 08:15:33 +03:00
Makefile.objs