qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v6 07/27] vl.c: add setter/getter functions for


From: Gonglei (Arei)
Subject: Re: [Qemu-devel] [PATCH v6 07/27] vl.c: add setter/getter functions for bootindex property
Date: Wed, 3 Sep 2014 07:47:17 +0000

Hi, 

> -----Original Message-----
> From: Gonglei (Arei)
> Sent: Saturday, August 30, 2014 6:00 PM
> Subject: [PATCH v6 07/27] vl.c: add setter/getter functions for bootindex
> property
> 
> 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.
> 
> Signed-off-by: Gonglei <address@hidden>
> ---
>  include/sysemu/sysemu.h |  4 ++++
>  vl.c                    | 27 +++++++++++++++++++++++++++
>  2 files changed, 31 insertions(+)
> 
> diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
> index 672984c..ca231e4 100644
> --- a/include/sysemu/sysemu.h
> +++ b/include/sysemu/sysemu.h
> @@ -208,6 +208,10 @@ void do_usb_del(Monitor *mon, const QDict *qdict);
>  void usb_info(Monitor *mon, const QDict *qdict);
> 
>  void check_boot_index(int32_t bootindex, Error **errp);
> +void get_bootindex(int32_t *bootindex, Visitor *v,
> +                   const char *name, Error **errp);
> +void set_bootindex(int32_t *bootindex, Visitor *v,
> +                   const char *name, Error **errp);
>  void del_boot_device_path(DeviceState *dev);
>  void add_boot_device_path(int32_t bootindex, DeviceState *dev,
>                            const char *suffix);
> diff --git a/vl.c b/vl.c
> index f2c3b2d..4363185 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -1252,6 +1252,33 @@ void check_boot_index(int32_t bootindex, Error
> **errp)
>      }
>  }
> 
> +void get_bootindex(int32_t *bootindex, Visitor *v,
> +                   const char *name, Error **errp)
> +{
> +    visit_type_int32(v, bootindex, name, errp);
> +}
> +
> +void set_bootindex(int32_t *bootindex, Visitor *v,
> +                   const char *name, Error **errp)
> +{
> +    int32_t boot_index;
> +    Error *local_err = NULL;
> +
> +    visit_type_int32(v, &boot_index, name, &local_err);
> +
> +    if (local_err == NULL) {
> +        /* check the bootindex existes or not in fw_boot_order list  */
> +        check_boot_index(boot_index, &local_err);
> +    }
> +
> +    if (local_err) {
> +        error_propagate(errp, local_err);
> +        return;
> +    }
> +    /* change bootindex to a new one */
> +    *bootindex = boot_index;
> +}
> +

In this version, I just change devices' bootindex value, but not update 
fw_boot_order
immediately. When we reboot the vm, we will call add_boot_device_path to update
fw_boot_order list. Do you think it is a good method? This method will cause a 
problem
that when we want set a existed bootindex which has been changed, we will get 
failure.
Only after vm rebooting, we can set the same bootindex again.

I have listed the example in PATCH 00/27 cover-letter:

(qemu) qom-get /machine/peripheral/nic1 bootindex
3 (0x3)
(qemu) qom-set /machine/peripheral/nic1 bootindex 3
The bootindex 3 has already been used
(qemu) qom-set /machine/peripheral/nic1 bootindex 0   --->change nic1's 
bootindex to 0, successful
(qemu) qom-get /machine/peripheral/nic1 bootindex
0 (0x0)
(qemu) qom-set /machine/peripheral/floppy1 bootindexA 3 -->set floppy1's 
bootindex to 3, failed
The bootindex 3 has already been used
(qemu) system_reset                             --> reboot vm
(qemu) qom-get /machine/peripheral/nic1 bootindex
0 (0x0)
(qemu) qom-get /machine/peripheral/floppy1 bootindexA
5 (0x5)
(qemu) qom-set /machine/peripheral/floppy1 bootindexA 3  -->set floppy1's 
bootindex to 3, successful
(qemu) qom-get /machine/peripheral/floppy1 bootindexA
3 (0x3)
(qemu)

Any ideas will be appreciated!

Best regards,
-Gonglei

>  static bool is_same_fw_dev_path(DeviceState *src, DeviceState *dst)
>  {
>      bool ret = false;
> --
> 1.7.12.4
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]