qemu-e2k/include
Markus Armbruster 3ae59580a0 block: Keep DriveInfo alive until BlockDriverState dies
If the BDS's refcnt > 0, drive_del() destroys the DriveInfo, but not
the BDS.  This can happen in three places:

* Device model destruction during unplug: blockdev_auto_del()

* Xen IDE unplug: pci_piix3_xen_ide_unplug()

* drive_del command when no device model is attached: do_drive_del()

The other callers of drive_del are on error paths where refcnt == 1.

If the user somehow manages to plug in a device model using a BDS that
has gone through drive_del(), the legacy configuration passed in
DriveInfo doesn't reach the device model, and automatic deletion on
unplug doesn't work.  Worse, some device models such as scsi-disk
crash when DriveInfo doesn't exist.

This is theoretical; I didn't research an actual reproducer. The problem
was introduced when we replaced DriveInfo reference counting by BDS
reference counting in commit a94a3fa..fa510eb.

Fix by keeping DriveInfo alive until its BDS dies.

This affects qemu_drive_opts: now you can't reuse the same ID for new
drive options until the BDS dies.  Before, you could, but since the
code always attempts to create a BDS with the same ID next, the
enclosing operation "create a new drive" failed anyway.  Different
error path, same result.

Unfortunately, the fix involves use of blockdev.c stuff from block.c,
which is a layering violation.  Fortunately, my forthcoming
BlockBackend work will get rid of it again.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Benoît Canet <benoit.canet@nodalink.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-09-25 15:24:14 +02:00
..
block async: aio_context_new(): Handle event_notifier_init failure 2014-09-22 11:39:48 +01:00
disas
exec - Memory: improve error reporting and avoid crashes on hotplug 2014-09-12 16:55:49 +01:00
fpu
hw virtio: Fix wrong type cast from pointer to long 2014-09-24 12:51:38 +01:00
libdecnumber
migration
monitor
net
qapi
qemu async: aio_context_new(): Handle event_notifier_init failure 2014-09-22 11:39:48 +01:00
qom cpu-exec: Make debug_excp_handler a QOM CPU method 2014-09-12 14:06:48 +01:00
sysemu block: Keep DriveInfo alive until BlockDriverState dies 2014-09-25 15:24:14 +02:00
ui
config.h
elf.h
glib-compat.h
qemu-common.h cpu: init vmstate for ticks and clock offset 2014-09-11 12:20:32 +02:00
qemu-io.h
trace-tcg.h
trace.h