[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 01/15] scsi: give device a parent before setting prop
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 01/15] scsi: give device a parent before setting properties |
Date: |
Mon, 2 Mar 2015 11:08:40 +0100 |
This mimics what is done in qdev_device_add, and lets the device be
freed in case something goes wrong. Otherwise, object_unparent returns
immediately without freeing the device, which is on the other hand left
in the parent bus's list of children.
scsi_bus_legacy_handle_cmdline then returns an error, and the HBA is
destroyed as well with object_unparent. But the lingering device that
was not removed in scsi_bus_legacy_add_drive cannot be removed now either,
and bus_unparent gets stuck in an infinite loop trying to empty the list
of children.
The right fix of course would be to assert in bus_add_child that the
device already has a bus, and remove the "safety net" that adds the
drive to the QOM tree in device_set_realized. I am not yet sure whether
that would entail changing all callers to qdev_create (as well as
isa_create and usb_create and the corresponding _try_create versions).
Reported-by: Markus Armbruster <address@hidden>
Tested-by: Markus Armbruster <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/scsi/scsi-bus.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index db39ae0..dca9576 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -221,11 +221,16 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus,
BlockBackend *blk,
const char *serial, Error **errp)
{
const char *driver;
+ char *name;
DeviceState *dev;
Error *err = NULL;
driver = blk_is_sg(blk) ? "scsi-generic" : "scsi-disk";
dev = qdev_create(&bus->qbus, driver);
+ name = g_strdup_printf("legacy[%d]", unit);
+ object_property_add_child(OBJECT(bus), name, OBJECT(dev), NULL);
+ g_free(name);
+
qdev_prop_set_uint32(dev, "scsi-id", unit);
if (bootindex >= 0) {
object_property_set_int(OBJECT(dev), bootindex, "bootindex",
--
2.3.0
- [Qemu-devel] [PULL 00/15] Misc changes for 2015-03-02, Paolo Bonzini, 2015/03/02
- [Qemu-devel] [PULL 02/15] block: Forbid bdrv_set_aio_context outside BQL, Paolo Bonzini, 2015/03/02
- [Qemu-devel] [PULL 03/15] virtio-scsi-dataplane: Call blk_set_aio_context within BQL, Paolo Bonzini, 2015/03/02
- [Qemu-devel] [PULL 04/15] timer: replace time() with QEMU_CLOCK_HOST, Paolo Bonzini, 2015/03/02
- [Qemu-devel] [PULL 05/15] bootdevice: fix segment fault when booting guest with '-kernel' and '-initrd', Paolo Bonzini, 2015/03/02
- [Qemu-devel] [PULL 06/15] Add specific config options for PCI-E bridges, Paolo Bonzini, 2015/03/02
- [Qemu-devel] [PULL 07/15] Create specific config option for "platform-bus", Paolo Bonzini, 2015/03/02
- [Qemu-devel] [PULL 08/15] Give ivshmem its own config option, Paolo Bonzini, 2015/03/02
- [Qemu-devel] [PULL 01/15] scsi: give device a parent before setting properties,
Paolo Bonzini <=
- [Qemu-devel] [PULL 09/15] iscsi: Handle write protected case in reopen, Paolo Bonzini, 2015/03/02
- [Qemu-devel] [PULL 13/15] virtio-scsi: Allocate op blocker reason before blocking, Paolo Bonzini, 2015/03/02
- [Qemu-devel] [PULL 10/15] Makefile: fix up parallel building under MSYS+MinGW, Paolo Bonzini, 2015/03/02
- [Qemu-devel] [PULL 11/15] Makefile: don't silence mak file test with V=1, Paolo Bonzini, 2015/03/02
- [Qemu-devel] [PULL 14/15] cpus: fix deadlock and segfault in qemu_mutex_lock_iothread, Paolo Bonzini, 2015/03/02
- [Qemu-devel] [PULL 15/15] cpus: be more paranoid in avoiding deadlocks, Paolo Bonzini, 2015/03/02
- [Qemu-devel] [PULL 12/15] Makefile.target: binary depends on config-devices, Paolo Bonzini, 2015/03/02
- Re: [Qemu-devel] [PULL 00/15] Misc changes for 2015-03-02, Eric Blake, 2015/03/02