From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37826) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNXbQ-0007W9-IB for qemu-devel@nongnu.org; Mon, 16 Feb 2015 21:09:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YNXbM-0005kp-H9 for qemu-devel@nongnu.org; Mon, 16 Feb 2015 21:09:32 -0500 Received: from e8.ny.us.ibm.com ([32.97.182.138]:36235) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNXbM-0005kl-Ca for qemu-devel@nongnu.org; Mon, 16 Feb 2015 21:09:28 -0500 Received: from /spool/local by e8.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 16 Feb 2015 21:09:27 -0500 Received: from b01cxnp22035.gho.pok.ibm.com (b01cxnp22035.gho.pok.ibm.com [9.57.198.25]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id F292CC90046 for ; Mon, 16 Feb 2015 21:00:34 -0500 (EST) Received: from d01av05.pok.ibm.com (d01av05.pok.ibm.com [9.56.224.195]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t1H29Fpu24969392 for ; Tue, 17 Feb 2015 02:09:23 GMT Received: from d01av05.pok.ibm.com (localhost [127.0.0.1]) by d01av05.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t1H28paU026005 for ; Mon, 16 Feb 2015 21:08:51 -0500 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Roth References: In-Reply-To: Message-ID: <20150217013430.13315.27642@loki> Date: Mon, 16 Feb 2015 19:34:30 -0600 Subject: Re: [Qemu-devel] [PATCH] qemu-ga-win: Fail loudly on bare 'set-time' List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michal Privoznik , qemu-devel@nongnu.org Quoting Michal Privoznik (2015-01-21 05:09:50) > The command is not implemented correctly yet. The documentation allows > to not pass any value to set, in which case the time is re-read from > RTC. However, reading CMOS on Windows is not trivial to implement. So > instead of pretending we've set the correct time, fail explicitly. > = > Signed-off-by: Michal Privoznik Thanks, applied to QGA tree: https://github.com/mdroth/qemu/commits/qga > --- > qga/commands-win32.c | 44 ++++++++++++++++++++++---------------------- > qga/qapi-schema.json | 5 ++++- > 2 files changed, 26 insertions(+), 23 deletions(-) > = > diff --git a/qga/commands-win32.c b/qga/commands-win32.c > index 3bcbeae..4fe45f0 100644 > --- a/qga/commands-win32.c > +++ b/qga/commands-win32.c > @@ -395,31 +395,31 @@ void qmp_guest_set_time(bool has_time, int64_t time= _ns, Error **errp) > FILETIME tf; > LONGLONG time; > = > - if (has_time) { > - /* Okay, user passed a time to set. Validate it. */ > - if (time_ns < 0 || time_ns / 100 > INT64_MAX - W32_FT_OFFSET) { > - error_setg(errp, "Time %" PRId64 "is invalid", time_ns); > - return; > - } > + if (!has_time) { > + /* Unfortunately, Windows libraries don't provide an easy way to= access > + * RTC yet: > + * > + * https://msdn.microsoft.com/en-us/library/aa908981.aspx > + */ > + error_setg(errp, "Time argument is required on this platform"); > + return; > + } > = > - time =3D time_ns / 100 + W32_FT_OFFSET; > + /* Validate time passed by user. */ > + if (time_ns < 0 || time_ns / 100 > INT64_MAX - W32_FT_OFFSET) { > + error_setg(errp, "Time %" PRId64 "is invalid", time_ns); > + return; > + } > = > - tf.dwLowDateTime =3D (DWORD) time; > - tf.dwHighDateTime =3D (DWORD) (time >> 32); > + time =3D time_ns / 100 + W32_FT_OFFSET; > = > - if (!FileTimeToSystemTime(&tf, &ts)) { > - error_setg(errp, "Failed to convert system time %d", > - (int)GetLastError()); > - return; > - } > - } else { > - /* Otherwise read the time from RTC which contains the correct v= alue. > - * Hopefully. */ > - GetSystemTime(&ts); > - if (ts.wYear < 1601 || ts.wYear > 30827) { > - error_setg(errp, "Failed to get time"); > - return; > - } > + tf.dwLowDateTime =3D (DWORD) time; > + tf.dwHighDateTime =3D (DWORD) (time >> 32); > + > + if (!FileTimeToSystemTime(&tf, &ts)) { > + error_setg(errp, "Failed to convert system time %d", > + (int)GetLastError()); > + return; > } > = > acquire_privilege(SE_SYSTEMTIME_NAME, &local_err); > diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json > index 376e79f..ce73dd3 100644 > --- a/qga/qapi-schema.json > +++ b/qga/qapi-schema.json > @@ -121,7 +121,10 @@ > # given value, then sets the Hardware Clock (RTC) to the > # current System Time. This will make it easier for a guest > # to resynchronize without waiting for NTP. If no @time is > -# specified, then the time to set is read from RTC. > +# specified, then the time to set is read from RTC. However, > +# this may not be supported on all platforms (i.e. Windows). > +# If that's the case users are advised to always pass a > +# value. > # > # @time: #optional time of nanoseconds, relative to the Epoch > # of 1970-01-01 in UTC. > -- = > 2.0.5