From: Gonglei <arei.gonglei@huawei.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: "peter.maydell@linaro.org" <peter.maydell@linaro.org>,
"mst@redhat.com" <mst@redhat.com>,
"Huangpeng (Peter)" <peter.huangpeng@huawei.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
Blue Swirl <blauwirbel@gmail.com>, Alexander Graf <agraf@suse.de>,
"qemu-ppc@nongnu.org" <qemu-ppc@nongnu.org>,
"pbonzini@redhat.com" <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 5/5] bootdevice: add Error **errp argument for QEMUBootSetHandler
Date: Sat, 20 Dec 2014 09:52:39 +0800 [thread overview]
Message-ID: <5494D667.6010002@huawei.com> (raw)
In-Reply-To: <87wq5nwo11.fsf@blackfin.pond.sub.org>
On 2014/12/20 1:24, Markus Armbruster wrote:
> <arei.gonglei@huawei.com> writes:
>
>> From: Gonglei <arei.gonglei@huawei.com>
>>
>> We can use it 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 <mst@redhat.com>
>> Cc: Alexander Graf <agraf@suse.de>
>> Cc: Blue Swirl <blauwirbel@gmail.com>
>> Cc: qemu-ppc@nongnu.org
>> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
>> ---
>> bootdevice.c | 5 +----
>> hw/i386/pc.c | 23 +++++++++++++----------
>> 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, 24 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..6b7fdea 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,10 @@ 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));
>> + error_free(local_err);
>> exit(1);
>> }
>>
>
> I wouldn't bother freeing stuff right before exit(). But it's not
> wrong.
>
Will remove it, thanks.
Regards,
-Gonglei
next prev parent reply other threads:[~2014-12-20 1:53 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-17 10:54 [Qemu-devel] [PATCH v2 0/5] bootdevice: Refactor and improvement arei.gonglei
2014-12-17 10:54 ` [Qemu-devel] [PATCH v2 1/5] bootdevice: move code about bootorder from vl.c to bootdevice.c arei.gonglei
2014-12-19 17:14 ` Markus Armbruster
2014-12-17 10:54 ` [Qemu-devel] [PATCH v2 2/5] bootdevice: add Error **errp argument for validate_bootdevices() arei.gonglei
2014-12-19 17:17 ` Markus Armbruster
2014-12-20 1:50 ` Gonglei
2014-12-17 10:54 ` [Qemu-devel] [PATCH v2 3/5] bootdevice: add Error **errp argument for qemu_boot_set() arei.gonglei
2014-12-19 17:21 ` Markus Armbruster
2014-12-17 10:54 ` [Qemu-devel] [PATCH v2 4/5] bootdevice: add validate check " arei.gonglei
2014-12-17 10:54 ` [Qemu-devel] [PATCH v2 5/5] bootdevice: add Error **errp argument for QEMUBootSetHandler arei.gonglei
2014-12-19 17:24 ` Markus Armbruster
2014-12-20 1:52 ` Gonglei [this message]
2014-12-19 17:27 ` [Qemu-devel] [PATCH v2 0/5] bootdevice: Refactor and improvement Markus Armbruster
2014-12-20 1:36 ` Gonglei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5494D667.6010002@huawei.com \
--to=arei.gonglei@huawei.com \
--cc=agraf@suse.de \
--cc=armbru@redhat.com \
--cc=blauwirbel@gmail.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.huangpeng@huawei.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.