From: Gerd Hoffmann <kraxel@redhat.com>
To: arei.gonglei@huawei.com
Cc: peter.maydell@linaro.org, weidong.huang@huawei.com,
mst@redhat.com, aik@ozlabs.ru, qemu-devel@nongnu.org,
agraf@suse.de, dmitry@daynix.com, akong@redhat.com,
armbru@redhat.com, lersek@redhat.com, marcel.a@redhat.com,
somlo@cmu.edu, luonengjun@huawei.com, peter.huangpeng@huawei.com,
alex.williamson@redhat.com, stefanha@redhat.com,
pbonzini@redhat.com, lcapitulino@redhat.com, rth@twiddle.net,
kwolf@redhat.com, peter.crosthwaite@xilinx.com,
Chenliang <chenliang88@huawei.com>,
imammedo@redhat.com, afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH v2 1/7] bootindex: add modify_boot_device_path function
Date: Fri, 25 Jul 2014 11:46:26 +0200 [thread overview]
Message-ID: <1406281586.20767.3.camel@nilsson.home.kraxel.org> (raw)
In-Reply-To: <1406271172-1192-2-git-send-email-arei.gonglei@huawei.com>
Hi,
> +void modify_boot_device_path(int32_t bootindex, DeviceState *dev,
> + const char *suffix)
> +{
> + FWBootEntry *node, *i;
> +
> + assert(dev != NULL || suffix != NULL);
> +
> + QTAILQ_FOREACH(i, &fw_boot_order, link) {
> + if (i->bootindex == bootindex) {
> + qerror_report(ERROR_CLASS_GENERIC_ERROR,
> + "The bootindex %d has already been used", bootindex);
> + return;
> + }
> + /* delete the same original dev */
> + if (i->dev->id && !strcmp(i->dev->id, dev->id)) {
> + QTAILQ_REMOVE(&fw_boot_order, i, link);
Ok ...
> + g_free(i->suffix);
> + g_free(i);
... but you should free the old entry later ...
> +
> + break;
> + }
> + }
> +
> + if (bootindex >= 0) {
> + node = g_malloc0(sizeof(FWBootEntry));
> + node->bootindex = bootindex;
> + node->suffix = g_strdup(suffix);
... because you can just copy the suffix from the old entry here,
instead of expecting the caller pass it in.
cheers,
Gerd
next prev parent reply other threads:[~2014-07-25 9:47 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-25 6:52 [Qemu-devel] [PATCH v2 0/7] modify boot order of guest, and take effect after rebooting arei.gonglei
2014-07-25 6:52 ` [Qemu-devel] [PATCH v2 1/7] bootindex: add modify_boot_device_path function arei.gonglei
2014-07-25 9:46 ` Gerd Hoffmann [this message]
2014-07-26 1:58 ` Gonglei (Arei)
2014-07-28 8:30 ` Gerd Hoffmann
2014-07-28 8:37 ` Gonglei (Arei)
2014-07-28 9:27 ` Gerd Hoffmann
2014-07-28 9:36 ` Gonglei (Arei)
2014-07-28 10:02 ` Gerd Hoffmann
2014-07-28 10:15 ` Gonglei (Arei)
2014-07-29 3:56 ` Gonglei (Arei)
2014-07-29 9:16 ` Gonglei (Arei)
2014-07-25 6:52 ` [Qemu-devel] [PATCH v2 2/7] bootindex: add del_boot_device_path function arei.gonglei
2014-07-25 6:52 ` [Qemu-devel] [PATCH v2 3/7] fw_cfg: add fw_cfg_machine_reset function arei.gonglei
2014-07-25 6:52 ` [Qemu-devel] [PATCH v2 4/7] bootindex: delete bootindex when device is removed arei.gonglei
2014-07-25 9:51 ` Gerd Hoffmann
2014-07-26 1:49 ` Gonglei (Arei)
2014-07-30 7:29 ` Gonglei (Arei)
2014-08-01 14:33 ` Eduardo Habkost
2014-08-04 6:23 ` Gonglei (Arei)
2014-07-25 6:52 ` [Qemu-devel] [PATCH v2 5/7] qmp: add set-bootindex command arei.gonglei
2014-08-01 15:07 ` Eduardo Habkost
2014-08-04 6:36 ` Gonglei (Arei)
2014-08-04 8:14 ` Markus Armbruster
2014-08-04 8:34 ` Gonglei (Arei)
2014-08-04 10:00 ` Markus Armbruster
2014-08-04 11:04 ` Gonglei (Arei)
2014-08-04 11:46 ` Markus Armbruster
2014-08-04 12:13 ` Gonglei (Arei)
2014-08-04 13:09 ` Markus Armbruster
2014-08-05 2:29 ` Gonglei (Arei)
2014-08-04 17:35 ` Eduardo Habkost
2014-07-25 6:52 ` [Qemu-devel] [PATCH v2 6/7] qemu-monitor: HMP set-bootindex wrapper arei.gonglei
2014-07-25 6:52 ` [Qemu-devel] [PATCH v2 7/7] spapr: fix possible memory leak arei.gonglei
2014-07-28 10:45 ` Alexander Graf
2014-07-29 0:54 ` Gonglei (Arei)
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=1406281586.20767.3.camel@nilsson.home.kraxel.org \
--to=kraxel@redhat.com \
--cc=afaerber@suse.de \
--cc=agraf@suse.de \
--cc=aik@ozlabs.ru \
--cc=akong@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=arei.gonglei@huawei.com \
--cc=armbru@redhat.com \
--cc=chenliang88@huawei.com \
--cc=dmitry@daynix.com \
--cc=imammedo@redhat.com \
--cc=kwolf@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=lersek@redhat.com \
--cc=luonengjun@huawei.com \
--cc=marcel.a@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.crosthwaite@xilinx.com \
--cc=peter.huangpeng@huawei.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
--cc=somlo@cmu.edu \
--cc=stefanha@redhat.com \
--cc=weidong.huang@huawei.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).