From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54488) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1tuD-0005EP-K7 for qemu-devel@nongnu.org; Tue, 01 Jul 2014 04:59:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X1tu5-0001ix-HF for qemu-devel@nongnu.org; Tue, 01 Jul 2014 04:59:13 -0400 Received: from greensocs.com ([178.33.234.66]:46966) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1tu5-0001ie-9A for qemu-devel@nongnu.org; Tue, 01 Jul 2014 04:59:05 -0400 Message-ID: <53B27856.2010602@greensocs.com> Date: Tue, 01 Jul 2014 10:59:02 +0200 From: Frederic Konrad MIME-Version: 1.0 References: <1404136749-523-1-git-send-email-sebastian.tanase@openwide.fr> <1404136749-523-2-git-send-email-sebastian.tanase@openwide.fr> In-Reply-To: <1404136749-523-2-git-send-email-sebastian.tanase@openwide.fr> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [RFC PATCH V3 1/6] icount: Add QemuOpts for icount List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sebastian Tanase , qemu-devel@nongnu.org Cc: kwolf@redhat.com, peter.maydell@linaro.org, wenchaoqemu@gmail.com, quintela@redhat.com, mst@redhat.com, mjt@tls.msk.ru, armbru@redhat.com, lcapitulino@redhat.com, michael@walle.cc, alex@alex.org.uk, crobinso@redhat.com, pbonzini@redhat.com, rth@twiddle.net, stefanha@redhat.com, afaerber@suse.de, aliguori@amazon.com On 30/06/2014 15:59, Sebastian Tanase wrote: > Make icount parameter use QemuOpts style options in order > to easily add other suboptions. > > Signed-off-by: Sebastian Tanase > Tested-by: Camille B=C3=A9gu=C3=A9 > --- > cpus.c | 10 +++++++++- > include/qemu-common.h | 3 ++- > qemu-options.hx | 4 ++-- > qtest.c | 13 +++++++++++-- > vl.c | 35 ++++++++++++++++++++++++++++------- > 5 files changed, 52 insertions(+), 13 deletions(-) > > diff --git a/cpus.c b/cpus.c > index 5e7f2cf..dcca96a 100644 > --- a/cpus.c > +++ b/cpus.c > @@ -440,13 +440,21 @@ static const VMStateDescription vmstate_timers =3D= { > } > }; > =20 > -void configure_icount(const char *option) > +void configure_icount(QemuOpts *opts, Error **errp) > { > + const char *option; > + > seqlock_init(&timers_state.vm_clock_seqlock, NULL); > vmstate_register(NULL, 0, &vmstate_timers, &timers_state); > + option =3D qemu_opt_get(opts, "shift"); > if (!option) { > return; > } > + /* When using -icount shift, the shift option will be > + misinterpreted as a boolean */ > + if (strcmp(option, "on") =3D=3D 0 || strcmp(option, "off") =3D=3D = 0) { > + error_setg(errp, "The shift option must be a number or auto"); > + } > =20 > icount_warp_timer =3D timer_new_ns(QEMU_CLOCK_REALTIME, > icount_warp_rt, NULL); > diff --git a/include/qemu-common.h b/include/qemu-common.h > index ae76197..cc346ec 100644 > --- a/include/qemu-common.h > +++ b/include/qemu-common.h > @@ -41,6 +41,7 @@ > #include > #include > #include "glib-compat.h" > +#include "qemu/option.h" > =20 > #ifdef _WIN32 > #include "sysemu/os-win32.h" > @@ -105,7 +106,7 @@ static inline char *realpath(const char *path, char= *resolved_path) > #endif > =20 > /* icount */ > -void configure_icount(const char *option); > +void configure_icount(QemuOpts *opts, Error **errp); > extern int use_icount; > =20 > #include "qemu/osdep.h" > diff --git a/qemu-options.hx b/qemu-options.hx > index 9e54686..143def4 100644 > --- a/qemu-options.hx > +++ b/qemu-options.hx > @@ -3011,11 +3011,11 @@ re-inject them. > ETEXI > =20 > DEF("icount", HAS_ARG, QEMU_OPTION_icount, \ > - "-icount [N|auto]\n" \ > + "-icount [shift=3DN|auto]\n" \ > " enable virtual instruction counter with 2^N cloc= k ticks per\n" \ > " instruction\n", QEMU_ARCH_ALL) > STEXI > -@item -icount [@var{N}|auto] > +@item -icount [shift=3D@var{N}|auto] > @findex -icount > Enable virtual instruction counter. The virtual cpu will execute one > instruction every 2^@var{N} ns of virtual time. If @code{auto} is sp= ecified > diff --git a/qtest.c b/qtest.c > index 04a6dc1..ef0d991 100644 > --- a/qtest.c > +++ b/qtest.c > @@ -19,6 +19,9 @@ > #include "hw/irq.h" > #include "sysemu/sysemu.h" > #include "sysemu/cpus.h" > +#include "qemu/config-file.h" > +#include "qemu/option.h" > +#include "qemu/error-report.h" > =20 > #define MAX_IRQ 256 > =20 > @@ -509,10 +512,16 @@ static void qtest_event(void *opaque, int event) > } > } > =20 > -int qtest_init_accel(MachineClass *mc) > +static void configure_qtest_icount(const char *options) > { > - configure_icount("0"); > + QemuOpts *opts =3D qemu_opts_parse(qemu_find_opts("icount"), opti= ons, 1); > + configure_icount(opts, &error_abort); > + qemu_opts_del(opts); > +} > =20 > +int qtest_init_accel(MachineClass *mc) > +{ > + configure_qtest_icount("0"); > return 0; > } > =20 > diff --git a/vl.c b/vl.c > index 41ddcd2..103027f 100644 > --- a/vl.c > +++ b/vl.c > @@ -537,6 +537,20 @@ static QemuOptsList qemu_mem_opts =3D { > }, > }; > =20 > +static QemuOptsList qemu_icount_opts =3D { > + .name =3D "icount", > + .implied_opt_name =3D "shift", > + .merge_lists =3D true, > + .head =3D QTAILQ_HEAD_INITIALIZER(qemu_icount_opts.head), > + .desc =3D { > + { > + .name =3D "shift", > + .type =3D QEMU_OPT_STRING, > + }, > + { /* end of list */ } > + }, > +}; > + > /** > * Get machine options > * > @@ -2896,13 +2910,12 @@ int main(int argc, char **argv, char **envp) > { > int i; > int snapshot, linux_boot; > - const char *icount_option =3D NULL; > const char *initrd_filename; > const char *kernel_filename, *kernel_cmdline; > const char *boot_order; > DisplayState *ds; > int cyls, heads, secs, translation; > - QemuOpts *hda_opts =3D NULL, *opts, *machine_opts; > + QemuOpts *hda_opts =3D NULL, *opts, *machine_opts, *icount_opts =3D= NULL; > QemuOptsList *olist; > int optind; > const char *optarg; > @@ -2967,6 +2980,7 @@ int main(int argc, char **argv, char **envp) > qemu_add_opts(&qemu_msg_opts); > qemu_add_opts(&qemu_name_opts); > qemu_add_opts(&qemu_numa_opts); > + qemu_add_opts(&qemu_icount_opts); > =20 > runstate_init(); > =20 > @@ -3817,7 +3831,11 @@ int main(int argc, char **argv, char **envp) > } > break; > case QEMU_OPTION_icount: > - icount_option =3D optarg; > + icount_opts =3D qemu_opts_parse(qemu_find_opts("icount= "), > + optarg, 1); > + if (!icount_opts) { > + exit(1); > + } > break; > case QEMU_OPTION_incoming: > incoming =3D optarg; > @@ -4294,11 +4312,14 @@ int main(int argc, char **argv, char **envp) > qemu_spice_init(); > #endif > =20 > - if (icount_option && (kvm_enabled() || xen_enabled())) { > - fprintf(stderr, "-icount is not allowed with kvm or xen\n"); > - exit(1); > + if (icount_opts) { > + if (kvm_enabled() || xen_enabled()) { > + fprintf(stderr, "-icount is not allowed with kvm or xen\n"= ); > + exit(1); > + } > + configure_icount(icount_opts, &error_abort); > + qemu_opts_del(icount_opts); > } > - configure_icount(icount_option); > =20 > /* clean up network at qemu process termination */ > atexit(&net_cleanup); Looks ok to me ;). Fred