From 645a8ad6e1909d36307f37f3dc4efca9e964334a Mon Sep 17 00:00:00 2001 From: Zhi Yong Wu Date: Thu, 4 Aug 2011 15:40:35 +0800 Subject: [PATCH 1/3] scsi-bus: use DO_UPCAST Signed-off-by: Zhi Yong Wu Reviewed-by: Markus Armbruster Signed-off-by: Stefan Hajnoczi --- hw/scsi-bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c index 0b0344c1fd..d1ef55985d 100644 --- a/hw/scsi-bus.c +++ b/hw/scsi-bus.c @@ -725,7 +725,7 @@ void scsi_device_purge_requests(SCSIDevice *sdev) static char *scsibus_get_fw_dev_path(DeviceState *dev) { - SCSIDevice *d = (SCSIDevice*)dev; + SCSIDevice *d = DO_UPCAST(SCSIDevice, qdev, dev); SCSIBus *bus = scsi_bus_from_device(d); char path[100]; int i; From e92714c71a2f50b8420126e952cadb653fa0ef93 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Wed, 3 Aug 2011 23:49:04 +0100 Subject: [PATCH 2/3] hw/qdev: Don't crash if qdev_create(NULL, ...) fails If an attempt to create a qdev device on the default sysbus (by passing NULL as the bus to qdev_create) fails, print a useful error message rather than crashing trying to dereference a NULL pointer. Signed-off-by: Peter Maydell Reviewed-by: Markus Armbruster Signed-off-by: Stefan Hajnoczi --- hw/qdev.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/qdev.c b/hw/qdev.c index 6819537648..d8114c6d93 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -111,7 +111,12 @@ DeviceState *qdev_create(BusState *bus, const char *name) dev = qdev_try_create(bus, name); if (!dev) { - hw_error("Unknown device '%s' for bus '%s'\n", name, bus->info->name); + if (bus) { + hw_error("Unknown device '%s' for bus '%s'\n", name, + bus->info->name); + } else { + hw_error("Unknown device '%s' for default sysbus\n", name); + } } return dev; From 85d59fef9defc78790c8b6cee833d4a77c22a490 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Fri, 12 Aug 2011 13:18:14 +0200 Subject: [PATCH 3/3] fix QLIST usage for RAM list Spotted while reviewing the migration thread patches. Signed-off-by: Paolo Bonzini Signed-off-by: Stefan Hajnoczi --- cpu-all.h | 2 +- exec.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cpu-all.h b/cpu-all.h index fa0205c28f..f5c82cdebd 100644 --- a/cpu-all.h +++ b/cpu-all.h @@ -488,7 +488,7 @@ typedef struct RAMBlock { typedef struct RAMList { uint8_t *phys_dirty; - QLIST_HEAD(ram, RAMBlock) blocks; + QLIST_HEAD(, RAMBlock) blocks; } RAMList; extern RAMList ram_list; diff --git a/exec.c b/exec.c index be7e4b2451..63adb189e7 100644 --- a/exec.c +++ b/exec.c @@ -110,7 +110,7 @@ static uint8_t *code_gen_ptr; int phys_ram_fd; static int in_migration; -RAMList ram_list = { .blocks = QLIST_HEAD_INITIALIZER(ram_list) }; +RAMList ram_list = { .blocks = QLIST_HEAD_INITIALIZER(ram_list.blocks) }; static MemoryRegion *system_memory; static MemoryRegion *system_io;