From d4960218e5319af15d783c0e01f269ea7fba163e Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 16 Feb 2011 20:28:44 -0200 Subject: [PATCH 1/6] ide: Make ide_init_drive() return success RH-Author: Markus Armbruster Message-id: <1297888126-9565-2-git-send-email-armbru@redhat.com> Patchwork-id: 18353 O-Subject: [PATCH RHEL6.1 qemu-kvm 1/3] ide: Make ide_init_drive() return success Bugzilla: 655735 RH-Acked-by: Paolo Bonzini RH-Acked-by: Kevin Wolf RH-Acked-by: Jes Sorensen It still always succeeds. The next commits will add failures. Signed-off-by: Markus Armbruster Signed-off-by: Kevin Wolf (cherry picked from commit c4d74df726cb3791d9f1661b58067df5608b627e) Conflicts: hw/ide/core.c hw/ide/internal.h hw/ide/qdev.c --- hw/ide/core.c | 9 +++++++-- hw/ide/internal.h | 2 +- hw/ide/qdev.c | 6 +++++- 3 files changed, 13 insertions(+), 4 deletions(-) Signed-off-by: Luiz Capitulino --- hw/ide/core.c | 9 +++++++-- hw/ide/internal.h | 2 +- hw/ide/qdev.c | 6 +++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index 00b0aa6..1901b80 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -29,6 +29,7 @@ #include #include "block.h" #include "block_int.h" +#include "qemu-error.h" #include "qemu-timer.h" #include "sysemu.h" #include "dma.h" @@ -2622,7 +2623,7 @@ void ide_bus_reset(IDEBus *bus) ide_clear_hob(bus); } -void ide_init_drive(IDEState *s, BlockDriverState *bs, const char *version) +int ide_init_drive(IDEState *s, BlockDriverState *bs, const char *version) { int cylinders, heads, secs; uint64_t nb_sectors; @@ -2659,6 +2660,7 @@ void ide_init_drive(IDEState *s, BlockDriverState *bs, const char *version) pstrcpy(s->version, sizeof(s->version), QEMU_VERSION); } ide_reset(s); + return 0; } static void ide_init1(IDEBus *bus, int unit) @@ -2699,7 +2701,10 @@ void ide_init2_with_non_qdev_drives(IDEBus *bus, DriveInfo *hd0, dinfo = i == 0 ? hd0 : hd1; ide_init1(bus, i); if (dinfo) { - ide_init_drive(&bus->ifs[i], dinfo->bdrv, NULL); + if (ide_init_drive(&bus->ifs[i], dinfo->bdrv, NULL) < 0) { + error_report("Can't set up IDE drive %s", dinfo->id); + exit(1); + } } else { ide_reset(&bus->ifs[i]); } diff --git a/hw/ide/internal.h b/hw/ide/internal.h index 644c845..edcca48 100644 --- a/hw/ide/internal.h +++ b/hw/ide/internal.h @@ -558,7 +558,7 @@ uint32_t ide_data_readw(void *opaque, uint32_t addr); void ide_data_writel(void *opaque, uint32_t addr, uint32_t val); uint32_t ide_data_readl(void *opaque, uint32_t addr); -void ide_init_drive(IDEState *s, BlockDriverState *bs, const char *version); +int ide_init_drive(IDEState *s, BlockDriverState *bs, const char *version); void ide_init2(IDEBus *bus, qemu_irq irq); void ide_init2_with_non_qdev_drives(IDEBus *bus, DriveInfo *hd0, DriveInfo *hd1, qemu_irq irq); diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index ca79c90..044f0e0 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -113,7 +113,11 @@ typedef struct IDEDrive { static int ide_drive_initfn(IDEDevice *dev) { IDEBus *bus = DO_UPCAST(IDEBus, qbus, dev->qdev.parent_bus); - ide_init_drive(bus->ifs + dev->unit, dev->conf.bs, dev->version); + + if (ide_init_drive(bus->ifs + dev->unit, dev->conf.bs, dev->version) < 0) { + return -1; + } + add_boot_device_path(dev->conf.bootindex, &dev->qdev, dev->unit ? "/disk@1" : "/disk@0"); -- 1.7.4.rc1.16.gd2f15e