From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33800) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1c7M-0007ou-EX for qemu-devel@nongnu.org; Mon, 30 Jun 2014 09:59:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X1c7B-0006O0-AR for qemu-devel@nongnu.org; Mon, 30 Jun 2014 09:59:36 -0400 Received: from zimbra3.corp.accelance.fr ([2001:4080:204::2:8]:46808) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1c7A-0006No-UW for qemu-devel@nongnu.org; Mon, 30 Jun 2014 09:59:25 -0400 From: Sebastian Tanase Date: Mon, 30 Jun 2014 15:59:05 +0200 Message-Id: <1404136749-523-3-git-send-email-sebastian.tanase@openwide.fr> In-Reply-To: <1404136749-523-1-git-send-email-sebastian.tanase@openwide.fr> References: <1404136749-523-1-git-send-email-sebastian.tanase@openwide.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [RFC PATCH V3 2/6] icount: Add align option to icount List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, peter.maydell@linaro.org, alex@alex.org.uk, wenchaoqemu@gmail.com, quintela@redhat.com, mjt@tls.msk.ru, mst@redhat.com, stefanha@redhat.com, armbru@redhat.com, lcapitulino@redhat.com, michael@walle.cc, aliguori@amazon.com, crobinso@redhat.com, pbonzini@redhat.com, Sebastian Tanase , afaerber@suse.de, rth@twiddle.net The align option is used for activating the align algorithm in order to synchronise the host clock and the guest clock. Signed-off-by: Sebastian Tanase Tested-by: Camille B=C3=A9gu=C3=A9 --- cpus.c | 13 +++++++++++++ include/qemu-common.h | 1 + qemu-options.hx | 15 +++++++++++++-- vl.c | 4 ++++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/cpus.c b/cpus.c index dcca96a..3fa8ce7 100644 --- a/cpus.c +++ b/cpus.c @@ -448,13 +448,24 @@ void configure_icount(QemuOpts *opts, Error **errp) vmstate_register(NULL, 0, &vmstate_timers, &timers_state); option =3D qemu_opt_get(opts, "shift"); if (!option) { + if (qemu_opt_get(opts, "align") !=3D NULL) { + error_setg(errp, "Please specify shift option when using ali= gn"); + } return; } + icount_align_option =3D qemu_opt_get_bool(opts, "align", false); /* 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"); } + /* When using icount [shift=3D]N|auto -icount align, shift becomes + align therefore we have to specify align=3Don|off. + We do however inform the user whenever the case. */ + if (strcmp(option, "align") =3D=3D 0) { + error_setg(errp, "Please specify align=3Don or off so as not " + "to create confusion between the shift and align options"); + } =20 icount_warp_timer =3D timer_new_ns(QEMU_CLOCK_REALTIME, icount_warp_rt, NULL); @@ -462,6 +473,8 @@ void configure_icount(QemuOpts *opts, Error **errp) icount_time_shift =3D strtol(option, NULL, 0); use_icount =3D 1; return; + } else if (icount_align_option) { + error_setg(errp, "shift=3Dauto and align=3Don are incompatible")= ; } =20 use_icount =3D 2; diff --git a/include/qemu-common.h b/include/qemu-common.h index cc346ec..860bb15 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -108,6 +108,7 @@ static inline char *realpath(const char *path, char *= resolved_path) /* icount */ void configure_icount(QemuOpts *opts, Error **errp); extern int use_icount; +extern int icount_align_option; =20 #include "qemu/osdep.h" #include "qemu/bswap.h" diff --git a/qemu-options.hx b/qemu-options.hx index 143def4..379d932 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3011,9 +3011,9 @@ re-inject them. ETEXI =20 DEF("icount", HAS_ARG, QEMU_OPTION_icount, \ - "-icount [shift=3DN|auto]\n" \ + "-icount [shift=3DN|auto][,align=3Don|off]\n" \ " enable virtual instruction counter with 2^N clock t= icks per\n" \ - " instruction\n", QEMU_ARCH_ALL) + " instruction and enable aligning the host and virtua= l clocks\n", QEMU_ARCH_ALL) STEXI @item -icount [shift=3D@var{N}|auto] @findex -icount @@ -3026,6 +3026,17 @@ Note that while this option can give deterministic= behavior, it does not provide cycle accurate emulation. Modern CPUs contain superscalar out o= f order cores with complex cache hierarchies. The number of instructions executed often has little or no correlation with actual performance. + +@option{align=3Don} will activate the delay algorithm which will try to +to synchronise the host clock and the virtual clock. The goal is to +have a guest running at the real frequency imposed by the shift option. +Whenever the guest clock is behind the host clock and if +@option{align=3Don} is specified then we print a messsage to the user +to inform about the delay. +Currently this option does not work when @option{shift} is @code{auto}. +Note: The sync algorithm will work for those shift values for which +the guest clock runs ahead of the host clock. Typically this happens +when the shift value is high (how high depends on the host machine). ETEXI =20 DEF("watchdog", HAS_ARG, QEMU_OPTION_watchdog, \ diff --git a/vl.c b/vl.c index 103027f..d270070 100644 --- a/vl.c +++ b/vl.c @@ -183,6 +183,7 @@ uint8_t *boot_splash_filedata; size_t boot_splash_filedata_size; uint8_t qemu_extra_params_fw[2]; =20 +int icount_align_option; typedef struct FWBootEntry FWBootEntry; =20 struct FWBootEntry { @@ -546,6 +547,9 @@ static QemuOptsList qemu_icount_opts =3D { { .name =3D "shift", .type =3D QEMU_OPT_STRING, + }, { + .name =3D "align", + .type =3D QEMU_OPT_BOOL, }, { /* end of list */ } }, --=20 2.0.0.rc2