Hi Eduardo,
On 11/25/20 9:56 PM, Eduardo Habkost wrote:
> This function will be used to replace the xen_available() and
> kvm_available() functions from arch_init.c.
>
> Signed-off-by: Eduardo Habkost <[email protected]>
> ---
> Cc: Richard Henderson <[email protected]>
> Cc: Paolo Bonzini <[email protected]>
> Cc: Claudio Fontana <[email protected]>
> Cc: Roman Bolshakov <[email protected]>
> ---
> include/sysemu/accel.h | 1 +
> accel/accel.c | 5 +++++
> 2 files changed, 6 insertions(+)
>
> diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h
> index e08b8ab8fa..a4a00c75c8 100644
> --- a/include/sysemu/accel.h
> +++ b/include/sysemu/accel.h
> @@ -67,6 +67,7 @@ typedef struct AccelClass {
> OBJECT_GET_CLASS(AccelClass, (obj), TYPE_ACCEL)
>
> AccelClass *accel_find(const char *opt_name);
> +bool accel_available(const char *name);
> int accel_init_machine(AccelState *accel, MachineState *ms);
>
> /* Called just before os_setup_post (ie just before drop OS privs) */
> diff --git a/accel/accel.c b/accel/accel.c
> index cb555e3b06..4a64a2b38a 100644
> --- a/accel/accel.c
> +++ b/accel/accel.c
> @@ -46,6 +46,11 @@ AccelClass *accel_find(const char *opt_name)
> return ac;
> }
>
> +bool accel_available(const char *name)
> +{
> + return accel_find(name) != NULL;
accel_find() in its implementation allocates and then frees memory to generate
the string,
the user of accel_available() might be unaware and overuse leading to
fragmentation/performance issues?
> +}
> +
> int accel_init_machine(AccelState *accel, MachineState *ms)
> {
> AccelClass *acc = ACCEL_GET_CLASS(accel);
>