From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59318) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VmhVX-00006r-OL for qemu-devel@nongnu.org; Sat, 30 Nov 2013 05:10:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VmhVS-0005jp-9G for qemu-devel@nongnu.org; Sat, 30 Nov 2013 05:10:39 -0500 Received: from mail-pd0-f174.google.com ([209.85.192.174]:65288) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VmhVS-0005ja-09 for qemu-devel@nongnu.org; Sat, 30 Nov 2013 05:10:34 -0500 Received: by mail-pd0-f174.google.com with SMTP id y13so15143923pdi.33 for ; Sat, 30 Nov 2013 02:10:32 -0800 (PST) Message-ID: <5299B992.3060906@ozlabs.ru> Date: Sat, 30 Nov 2013 21:10:26 +1100 From: Alexey Kardashevskiy MIME-Version: 1.0 References: <1384155875-26999-1-git-send-email-aik@ozlabs.ru> <1384155875-26999-2-git-send-email-aik@ozlabs.ru> In-Reply-To: <1384155875-26999-2-git-send-email-aik@ozlabs.ru> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH v3 1/6] cpu: add suboptions support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alexey Kardashevskiy , qemu-ppc@nongnu.org, Alexander Graf , =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= On 11/11/2013 06:44 PM, Alexey Kardashevskiy wrote: > This adds suboptions support for -cpu. > > Cc: Andreas Färber > Signed-off-by: Alexey Kardashevskiy > --- > 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