qemu-ppc
[Top][All Lists]
Advanced

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

Re: [Qemu-ppc] [PATCH v3 1/6] cpu: add suboptions support


From: Alexey Kardashevskiy
Subject: Re: [Qemu-ppc] [PATCH v3 1/6] cpu: add suboptions support
Date: Sat, 30 Nov 2013 21:10:26 +1100
User-agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.1

On 11/11/2013 06:44 PM, Alexey Kardashevskiy wrote:
> This adds suboptions support for -cpu.
> 
> Cc: Andreas Färber <address@hidden>
> Signed-off-by: Alexey Kardashevskiy <address@hidden>
> ---
>  include/qom/cpu.h       | 29 +++++++++++++++++++++++++++++
>  include/sysemu/sysemu.h |  1 +
>  qom/cpu.c               | 27 +++++++++++++++++++++++++++
>  vl.c                    | 42 ++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 99 insertions(+)
> 
> diff --git a/include/qom/cpu.h b/include/qom/cpu.h
> index 7739e00..7d3b043 100644
> --- a/include/qom/cpu.h
> +++ b/include/qom/cpu.h
> @@ -124,6 +124,7 @@ typedef struct CPUClass {
>                              int cpuid, void *opaque);
>      int (*write_elf32_qemunote)(WriteCoreDumpFunction f, CPUState *cpu,
>                                  void *opaque);
> +    void (*parse_options)(CPUState *cpu, Error **errp);
>  
>      const struct VMStateDescription *vmsd;
>      int gdb_num_core_regs;
> @@ -327,6 +328,34 @@ static inline hwaddr cpu_get_phys_page_debug(CPUState 
> *cpu, vaddr addr)
>  #endif
>  
>  /**
> + * cpu_parse_options:
> + * @cpu: The CPU to set options for.
> + */
> +static inline int cpu_parse_options(CPUState *cpu)
> +{
> +    CPUClass *cc = CPU_GET_CLASS(cpu);
> +    Error *err = NULL;
> +
> +    if (cc->parse_options) {
> +        cc->parse_options(cpu, &err);
> +        if (err) {
> +            return -1;
> +        }
> +    }
> +
> +    /* No callback, let arch do it the old way */
> +    return 0;
> +}
> +
> +/**
> + * cpu_default_parse_options_func:
> + * The default handler for CPUClass::parse_options
> + * @cpu: the CPU to set option for.
> + * @errp: the handling error descriptor.
> + */
> +void cpu_default_parse_options_func(CPUState *cpu, Error **errp);
> +
> +/**
>   * cpu_reset:
>   * @cpu: The CPU whose state is to be reset.
>   */
> diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
> index cd5791e..c6e3ea0 100644
> --- a/include/sysemu/sysemu.h
> +++ b/include/sysemu/sysemu.h
> @@ -190,6 +190,7 @@ char *get_boot_devices_list(size_t *size);
>  DeviceState *get_boot_device(uint32_t position);
>  
>  QemuOpts *qemu_get_machine_opts(void);
> +QemuOpts *qemu_get_cpu_opts(void);
>  
>  bool usb_enabled(bool default_usb);
>  
> diff --git a/qom/cpu.c b/qom/cpu.c
> index 818fb26..231dec5 100644
> --- a/qom/cpu.c
> +++ b/qom/cpu.c
> @@ -24,6 +24,8 @@
>  #include "qemu/notify.h"
>  #include "qemu/log.h"
>  #include "sysemu/sysemu.h"
> +#include "qapi/qmp/qerror.h"
> +#include "qemu/config-file.h"
>  
>  bool cpu_exists(int64_t id)
>  {
> @@ -186,6 +188,31 @@ void cpu_reset(CPUState *cpu)
>      }
>  }
>  
> +static int cpu_set_property(const char *name, const char *value, void 
> *opaque)
> +{
> +    Error *err = NULL;
> +
> +    if (strcmp(name, "type") == 0) {
> +        return 0;
> +    }
> +
> +    object_property_parse(opaque, value, name, &err);
> +    if (err != NULL) {
> +        qerror_report_err(err);
> +        error_free(err);
> +        return -1;
> +    }
> +
> +    return 0;
> +}
> +
> +void cpu_default_parse_options_func(CPUState *cpu, Error **errp)
> +{
> +    if (qemu_opt_foreach(qemu_get_cpu_opts(), cpu_set_property, cpu, 1)) {
> +        error_setg(errp, "Bad option");
> +    }
> +}

btw there is a problem - all this qemu_opt stuff normally lives in vl.c so
this patch does not compile with linux-user target.

How to solve this properly before I continue spamming the list? :)



-- 
Alexey



reply via email to

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