From patchwork Mon Dec 22 08:56:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gonglei (Arei)" X-Patchwork-Id: 423305 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5EF381400B7 for ; Mon, 22 Dec 2014 19:58:03 +1100 (AEDT) Received: from localhost ([::1]:39643 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y2yoT-0003Jw-Ln for incoming@patchwork.ozlabs.org; Mon, 22 Dec 2014 03:58:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43717) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y2ynn-00020q-SQ for qemu-devel@nongnu.org; Mon, 22 Dec 2014 03:57:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y2yng-0007DR-Lg for qemu-devel@nongnu.org; Mon, 22 Dec 2014 03:57:19 -0500 Received: from szxga02-in.huawei.com ([119.145.14.65]:28941) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y2ynf-0007An-I3; Mon, 22 Dec 2014 03:57:12 -0500 Received: from 172.24.2.119 (EHLO szxeml456-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CEI98373; Mon, 22 Dec 2014 16:57:02 +0800 (CST) Received: from localhost (10.177.19.102) by szxeml456-hub.china.huawei.com (10.82.67.199) with Microsoft SMTP Server id 14.3.158.1; Mon, 22 Dec 2014 16:56:50 +0800 From: To: Date: Mon, 22 Dec 2014 16:56:41 +0800 Message-ID: <1419238601-5844-6-git-send-email-arei.gonglei@huawei.com> X-Mailer: git-send-email 1.7.3.1.msysgit.0 In-Reply-To: <1419238601-5844-1-git-send-email-arei.gonglei@huawei.com> References: <1419238601-5844-1-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.19.102] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.65 Cc: peter.maydell@linaro.org, "Michael S. Tsirkin" , Alexander Graf , Blue Swirl , Gonglei , qemu-ppc@nongnu.org Subject: [Qemu-devel] [PULL 5/5] bootdevice: add Error **errp argument for QEMUBootSetHandler X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Gonglei It will be useful for checking when we change traditional boot order dynamically and propagate error message to the monitor. For x86 architecture, we pass &local_err to set_boot_dev() when vm startup in pc_coms_init(). Cc: Michael S. Tsirkin Cc: Alexander Graf Cc: Blue Swirl Cc: qemu-ppc@nongnu.org Signed-off-by: Gonglei Reviewed-by: Markus Armbruster --- bootdevice.c | 5 +---- hw/i386/pc.c | 22 ++++++++++++---------- hw/ppc/mac_newworld.c | 4 ++-- hw/ppc/mac_oldworld.c | 5 ++--- hw/sparc/sun4m.c | 4 ++-- hw/sparc64/sun4u.c | 4 ++-- include/sysemu/sysemu.h | 4 ++-- 7 files changed, 23 insertions(+), 25 deletions(-) diff --git a/bootdevice.c b/bootdevice.c index 9de34ba..5914417 100644 --- a/bootdevice.c +++ b/bootdevice.c @@ -63,10 +63,7 @@ void qemu_boot_set(const char *boot_order, Error **errp) return; } - if (boot_set_handler(boot_set_opaque, boot_order)) { - error_setg(errp, "setting boot device list failed"); - return; - } + boot_set_handler(boot_set_opaque, boot_order, errp); } void validate_bootdevices(const char *devices, Error **errp) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index c0e55a6..1ec7290 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -282,7 +282,7 @@ static int boot_device2nibble(char boot_device) return 0; } -static int set_boot_dev(ISADevice *s, const char *boot_device) +static void set_boot_dev(ISADevice *s, const char *boot_device, Error **errp) { #define PC_MAX_BOOT_DEVICES 3 int nbds, bds[3] = { 0, }; @@ -290,25 +290,24 @@ static int set_boot_dev(ISADevice *s, const char *boot_device) nbds = strlen(boot_device); if (nbds > PC_MAX_BOOT_DEVICES) { - error_report("Too many boot devices for PC"); - return(1); + error_setg(errp, "Too many boot devices for PC"); + return; } for (i = 0; i < nbds; i++) { bds[i] = boot_device2nibble(boot_device[i]); if (bds[i] == 0) { - error_report("Invalid boot device for PC: '%c'", - boot_device[i]); - return(1); + error_setg(errp, "Invalid boot device for PC: '%c'", + boot_device[i]); + return; } } rtc_set_memory(s, 0x3d, (bds[1] << 4) | bds[0]); rtc_set_memory(s, 0x38, (bds[2] << 4) | (fd_bootchk ? 0x0 : 0x1)); - return(0); } -static int pc_boot_set(void *opaque, const char *boot_device) +static void pc_boot_set(void *opaque, const char *boot_device, Error **errp) { - return set_boot_dev(opaque, boot_device); + set_boot_dev(opaque, boot_device, errp); } typedef struct pc_cmos_init_late_arg { @@ -365,6 +364,7 @@ void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size, FDriveType fd_type[2] = { FDRIVE_DRV_NONE, FDRIVE_DRV_NONE }; static pc_cmos_init_late_arg arg; PCMachineState *pc_machine = PC_MACHINE(machine); + Error *local_err = NULL; /* various important CMOS locations needed by PC/Bochs bios */ @@ -412,7 +412,9 @@ void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size, object_property_set_link(OBJECT(machine), OBJECT(s), "rtc_state", &error_abort); - if (set_boot_dev(s, boot_device)) { + set_boot_dev(s, boot_device, &local_err); + if (local_err) { + error_report("%s", error_get_pretty(local_err)); exit(1); } diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index 89aee71..ee1ed8a 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -116,10 +116,10 @@ static const MemoryRegionOps unin_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; -static int fw_cfg_boot_set(void *opaque, const char *boot_device) +static void fw_cfg_boot_set(void *opaque, const char *boot_device, + Error **errp) { fw_cfg_add_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]); - return 0; } static uint64_t translate_kernel_address(void *opaque, uint64_t addr) diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index 32c21a4..15109c2 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -49,13 +49,12 @@ #define CLOCKFREQ 266000000UL #define BUSFREQ 66000000UL -static int fw_cfg_boot_set(void *opaque, const char *boot_device) +static void fw_cfg_boot_set(void *opaque, const char *boot_device, + Error **errp) { fw_cfg_add_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]); - return 0; } - static uint64_t translate_kernel_address(void *opaque, uint64_t addr) { return (addr & 0x0fffffff) + KERNEL_LOAD_ADDR; diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c index 8273199..df259ad 100644 --- a/hw/sparc/sun4m.c +++ b/hw/sparc/sun4m.c @@ -121,10 +121,10 @@ void DMA_register_channel (int nchan, { } -static int fw_cfg_boot_set(void *opaque, const char *boot_device) +static void fw_cfg_boot_set(void *opaque, const char *boot_device, + Error **errp) { fw_cfg_add_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]); - return 0; } static void nvram_init(M48t59State *nvram, uint8_t *macaddr, diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c index f42112c..acac8f9 100644 --- a/hw/sparc64/sun4u.c +++ b/hw/sparc64/sun4u.c @@ -124,10 +124,10 @@ void DMA_register_channel (int nchan, { } -static int fw_cfg_boot_set(void *opaque, const char *boot_device) +static void fw_cfg_boot_set(void *opaque, const char *boot_device, + Error **errp) { fw_cfg_add_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]); - return 0; } static int sun4u_NVRAM_set_params(M48t59State *nvram, uint16_t NVRAM_size, diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index ee7fee7..503e5a4 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -220,8 +220,8 @@ void restore_boot_order(void *opaque); void validate_bootdevices(const char *devices, Error **errp); /* handler to set the boot_device order for a specific type of QEMUMachine */ -/* return 0 if success */ -typedef int QEMUBootSetHandler(void *opaque, const char *boot_order); +typedef void QEMUBootSetHandler(void *opaque, const char *boot_order, + Error **errp); void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque); void qemu_boot_set(const char *boot_order, Error **errp);