From: Paolo Bonzini <pbonzini@redhat.com>
To: arei.gonglei@huawei.com, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, weidong.huang@huawei.com,
mst@redhat.com, aik@ozlabs.ru, agraf@suse.de, kraxel@redhat.com,
dmitry@daynix.com, akong@redhat.com, armbru@redhat.com,
lersek@redhat.com, ehabkost@redhat.com, marcel.a@redhat.com,
somlo@cmu.edu, luonengjun@huawei.com, peter.huangpeng@huawei.com,
alex.williamson@redhat.com, stefanha@redhat.com,
lcapitulino@redhat.com, rth@twiddle.net, kwolf@redhat.com,
peter.crosthwaite@xilinx.com, chenliang88@huawei.com,
imammedo@redhat.com, afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH v11 07/34] bootindex: add a setter/getter functions wrapper for bootindex property
Date: Thu, 09 Oct 2014 13:14:31 +0200 [thread overview]
Message-ID: <54366E17.7060505@redhat.com> (raw)
In-Reply-To: <1412668838-8656-8-git-send-email-arei.gonglei@huawei.com>
Il 07/10/2014 10:00, arei.gonglei@huawei.com ha scritto:
> From: Gonglei <arei.gonglei@huawei.com>
>
> when we remove bootindex form qdev.property to qom.property,
> we can use those functions set/get bootindex property for all
> correlative devices. Meanwhile set the initial value of
> bootindex to -1.
>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> bootdevice.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++
> include/sysemu/sysemu.h | 3 ++
> 2 files changed, 76 insertions(+)
>
> diff --git a/bootdevice.c b/bootdevice.c
> index a38479a..69cffd8 100644
> --- a/bootdevice.c
> +++ b/bootdevice.c
> @@ -23,6 +23,7 @@
> */
>
> #include "sysemu/sysemu.h"
> +#include "qapi/visitor.h"
>
> typedef struct FWBootEntry FWBootEntry;
>
> @@ -178,3 +179,75 @@ char *get_boot_devices_list(size_t *size, bool ignore_suffixes)
> }
> return list;
> }
> +
> +typedef struct {
> + int32_t *bootindex;
> + const char *suffix;
> + DeviceState *dev;
> +} BootIndexProperty;
> +
> +static void device_get_bootindex(Object *obj, Visitor *v, void *opaque,
> + const char *name, Error **errp)
> +{
> + BootIndexProperty *prop = opaque;
> + visit_type_int32(v, prop->bootindex, name, errp);
> +}
> +
> +static void device_set_bootindex(Object *obj, Visitor *v, void *opaque,
> + const char *name, Error **errp)
> +{
> + BootIndexProperty *prop = opaque;
> + int32_t boot_index;
> + Error *local_err = NULL;
> +
> + visit_type_int32(v, &boot_index, name, &local_err);
> + if (local_err) {
> + goto out;
> + }
> + /* check whether bootindex is present in fw_boot_order list */
> + check_boot_index(boot_index, &local_err);
> + if (local_err) {
> + goto out;
> + }
> + /* change bootindex to a new one */
> + *prop->bootindex = boot_index;
> +
> +out:
> + if (local_err) {
> + error_propagate(errp, local_err);
> + }
> +}
> +
> +static void property_release_bootindex(Object *obj, const char *name,
> + void *opaque)
> +
> +{
> + BootIndexProperty *prop = opaque;
> + g_free(prop);
> +}
> +
> +void device_add_bootindex_property(Object *obj, int32_t *bootindex,
> + const char *name, const char *suffix,
> + DeviceState *dev, Error **errp)
> +{
> + Error *local_err = NULL;
> + BootIndexProperty *prop = g_malloc0(sizeof(*prop));
> +
> + prop->bootindex = bootindex;
> + prop->suffix = suffix;
> + prop->dev = dev;
> +
> + object_property_add(obj, name, "int32",
> + device_get_bootindex,
> + device_set_bootindex,
> + property_release_bootindex,
> + prop, &local_err);
> +
> + if (local_err) {
> + error_propagate(errp, local_err);
> + g_free(prop);
> + return;
> + }
> + /* initialize devices' bootindex property to -1 */
> + object_property_set_int(obj, -1, name, NULL);
> +}
> diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
> index b3489be..0037a69 100644
> --- a/include/sysemu/sysemu.h
> +++ b/include/sysemu/sysemu.h
> @@ -215,6 +215,9 @@ char *get_boot_devices_list(size_t *size, bool ignore_suffixes);
> DeviceState *get_boot_device(uint32_t position);
> void check_boot_index(int32_t bootindex, Error **errp);
> void del_boot_device_path(DeviceState *dev, const char *suffix);
> +void device_add_bootindex_property(Object *obj, int32_t *bootindex,
> + const char *name, const char *suffix,
> + DeviceState *dev, Error **errp);
>
> QemuOpts *qemu_get_machine_opts(void);
>
>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
next prev parent reply other threads:[~2014-10-09 11:14 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-07 8:00 [Qemu-devel] [PATCH v11 00/34] modify boot order of guest, and take effect after rebooting arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 01/34] bootdevice: move bootdevice related code to new file bootdevice.c arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 02/34] bootindex: add check bootindex function arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 03/34] bootindex: add del_boot_device_path function arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 04/34] fw_cfg: add fw_cfg_machine_reset function arei.gonglei
2014-10-09 11:12 ` Paolo Bonzini
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 05/34] bootindex: rework add_boot_device_path function arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 06/34] bootindex: support to set a existent device's bootindex to -1 arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 07/34] bootindex: add a setter/getter functions wrapper for bootindex property arei.gonglei
2014-10-09 11:14 ` Paolo Bonzini [this message]
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 08/34] virtio-net: add bootindex to qom property arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 09/34] e1000: " arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 10/34] eepro100: " arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 11/34] ne2000: " arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 12/34] pcnet: " arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 13/34] rtl8139: " arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 14/34] spapr_lian: " arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 15/34] vmxnet3: " arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 16/34] usb-net: " arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 17/34] net: remove bootindex property from qdev to qom arei.gonglei
2014-10-09 11:15 ` Paolo Bonzini
2014-10-09 11:56 ` Gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 18/34] virtio-net: alias bootindex property explicitly for virt-net-pci/ccw/s390 arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 19/34] host-libusb: remove bootindex property from qdev to qom arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 20/34] pci-assign: " arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 21/34] vfio: " arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 22/34] redirect: " arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 23/34] isa-fdc: remove bootindexA/B " arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 24/34] scsi: add bootindex to qom property arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 25/34] ide: " arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 26/34] virtio-blk: " arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 27/34] block: remove bootindex property from qdev to qom arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 28/34] virtio-blk: alias bootindex property explicitly for virt-blk-pci/ccw/s390 arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 29/34] usb-storage: add bootindex to qom property arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 30/34] nvma: ide: " arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 31/34] ide: add calling add_boot_device_patch in bootindex setter function arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 32/34] bootindex: move calling add_boot_device_patch to " arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 33/34] bootindex: delete bootindex when device is removed arei.gonglei
2014-10-07 8:00 ` [Qemu-devel] [PATCH v11 34/34] bootindex: change fprintf to error_report arei.gonglei
2014-10-08 11:00 ` [Qemu-devel] [PATCH v11 00/34] modify boot order of guest, and take effect after rebooting Gonglei
2014-10-09 9:47 ` Gerd Hoffmann
2014-10-09 10:09 ` Gonglei
2014-10-09 11:10 ` Andreas Färber
2014-10-09 11:07 ` Michael Mueller
2014-10-09 12:04 ` Gonglei
2014-10-09 11:17 ` Paolo Bonzini
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=54366E17.7060505@redhat.com \
--to=pbonzini@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=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=kraxel@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=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).