qemu-patch-raspberry4/include/sysemu
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
..
arch_init.h arch_init: Setting QEMU_ARCH enum straight 2014-09-22 12:09:43 +04:00
balloon.h qapi event: convert BALLOON_CHANGE 2014-06-23 11:12:28 -04:00
blockdev.h block: Keep DriveInfo alive until BlockDriverState dies 2014-09-25 15:24:14 +02:00
bt.h sysemu: avoid proliferation of include/ subdirectories 2013-04-15 18:19:25 +02:00
char.h qemu-char: Rename register_char_driver_qapi() to register_char_driver() 2014-09-16 23:36:32 +01:00
cpus.h NUMA: move numa related code to new file numa.c 2014-06-19 18:44:18 +03:00
device_tree.h device_tree: qemu_fdt_setprop: Rename val_array arg 2013-12-20 01:58:12 +01:00
dma.h block: Extract the block accounting code 2014-09-10 10:41:29 +02:00
dump-arch.h dump: Make DumpState and endian conversion routines available for arch-specific dump code 2014-06-16 13:24:36 +02:00
dump.h dump: Make DumpState and endian conversion routines available for arch-specific dump code 2014-06-16 13:24:36 +02:00
hostmem.h hostmem: add properties for NUMA memory policy 2014-06-19 18:44:21 +03:00
iothread.h iothread: make IOThread struct definition public 2014-04-04 20:48:02 +02:00
kvm.h KVM: Add helper to run KVM_CHECK_EXTENSION on vm fd 2014-09-08 12:50:51 +02:00
memory_mapping.h dump: rebase from host-private RAMBlock offsets to guest-physical addresses 2013-08-08 11:01:46 -04:00
os-posix.h os-posix: include sys/time.h 2014-06-23 11:01:24 -04:00
os-win32.h memory: move preallocation code out of exec.c 2014-06-19 18:44:19 +03:00
qtest.h machine: Replace QEMUMachine by MachineClass in accelerator configuration 2014-05-05 19:08:49 +02:00
rng-random.h sysemu: avoid proliferation of include/ subdirectories 2013-04-15 18:19:25 +02:00
rng.h virtio_rng: replace custom backend API with UserCreatable.complete() callback 2014-01-28 12:47:11 -05:00
seccomp.h softmmu: move include files to include/sysemu/ 2012-12-19 08:32:45 +01:00
sysemu.h numa: Keep track of NUMA nodes present on the command-line 2014-06-29 18:59:41 +03:00
tpm.h Add ACPI tables for TPM 2014-08-25 00:16:06 +02:00
tpm_backend.h Move TPM passthrough specific command line options to backend structure 2013-04-23 10:40:40 -05:00
tpm_backend_int.h tpm: reorganize headers and split hardware part 2013-04-15 18:19:25 +02:00
watchdog.h hw: move headers to include/ 2013-04-08 18:13:10 +02:00
xen-mapcache.h softmmu: move include files to include/sysemu/ 2012-12-19 08:32:45 +01:00