[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v11 07/34] bootindex: add a setter/getter functi
From: |
Paolo Bonzini |
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 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.1 |
Il 07/10/2014 10:00, address@hidden ha scritto:
> From: Gonglei <address@hidden>
>
> 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 <address@hidden>
> Reviewed-by: Gerd Hoffmann <address@hidden>
> ---
> 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 <address@hidden>
- [Qemu-devel] [PATCH v11 00/34] modify boot order of guest, and take effect after rebooting, arei.gonglei, 2014/10/07
- [Qemu-devel] [PATCH v11 02/34] bootindex: add check bootindex function, arei.gonglei, 2014/10/07
- [Qemu-devel] [PATCH v11 07/34] bootindex: add a setter/getter functions wrapper for bootindex property, arei.gonglei, 2014/10/07
- Re: [Qemu-devel] [PATCH v11 07/34] bootindex: add a setter/getter functions wrapper for bootindex property,
Paolo Bonzini <=
- [Qemu-devel] [PATCH v11 03/34] bootindex: add del_boot_device_path function, arei.gonglei, 2014/10/07
- [Qemu-devel] [PATCH v11 10/34] eepro100: add bootindex to qom property, arei.gonglei, 2014/10/07
- [Qemu-devel] [PATCH v11 08/34] virtio-net: add bootindex to qom property, arei.gonglei, 2014/10/07
- [Qemu-devel] [PATCH v11 11/34] ne2000: add bootindex to qom property, arei.gonglei, 2014/10/07
- [Qemu-devel] [PATCH v11 14/34] spapr_lian: add bootindex to qom property, arei.gonglei, 2014/10/07
- [Qemu-devel] [PATCH v11 20/34] pci-assign: remove bootindex property from qdev to qom, arei.gonglei, 2014/10/07
- [Qemu-devel] [PATCH v11 13/34] rtl8139: add bootindex to qom property, arei.gonglei, 2014/10/07
- [Qemu-devel] [PATCH v11 18/34] virtio-net: alias bootindex property explicitly for virt-net-pci/ccw/s390, arei.gonglei, 2014/10/07
- [Qemu-devel] [PATCH v11 12/34] pcnet: add bootindex to qom property, arei.gonglei, 2014/10/07
- [Qemu-devel] [PATCH v11 19/34] host-libusb: remove bootindex property from qdev to qom, arei.gonglei, 2014/10/07