From patchwork Thu Oct 18 07:12:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artem Pisarenko X-Patchwork-Id: 10646801 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A37D3109C for ; Thu, 18 Oct 2018 07:20:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87FE328516 for ; Thu, 18 Oct 2018 07:20:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C62F2852B; Thu, 18 Oct 2018 07:20:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 18B7528516 for ; Thu, 18 Oct 2018 07:20:01 +0000 (UTC) Received: from localhost ([::1]:40627 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD2bA-0000Vu-88 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 18 Oct 2018 03:20:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33014) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD2V4-0004XR-9f for qemu-devel@nongnu.org; Thu, 18 Oct 2018 03:13:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gD2V2-0000AA-MG for qemu-devel@nongnu.org; Thu, 18 Oct 2018 03:13:42 -0400 Received: from mail-lf1-x141.google.com ([2a00:1450:4864:20::141]:38440) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gD2V1-00005Z-6k for qemu-devel@nongnu.org; Thu, 18 Oct 2018 03:13:40 -0400 Received: by mail-lf1-x141.google.com with SMTP id x24-v6so6009464lfe.5 for ; Thu, 18 Oct 2018 00:13:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=+4YIQzikY7eCJOvD47I5wo8oEHs+wdfAXhWlAO5cskE=; b=oudz1FHXzxiIK8obuQYtPHN7Ail+F6+zfKfJR2beTuRmUH6QMzbibd5ohnFHpXZ4W6 aGbq51gMCSD1dp8WmY+ViqDECWwKLqq7jPWe8Ejajm/1D6CWLHC90uNYg9h60waOwwIU 7S78+4JVi4S2JWmWKFY28oWMzL3P+7I65nUTgrETkOt2PYqxJIOc07uUtNDtd5KkX1Pb 6TFxrIgMj0Qydpa2Lv++WxPnHMXx5RlVrvklA3nss8EktjLX0qeT5850mlv7pgqZvSHC Dv/D0nn8lrI0lQ4/waECK62K7LFL8CpUAusHvK2eHWT1peJ/jHNQrwDqxO4nUcNRydy4 Ektw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=+4YIQzikY7eCJOvD47I5wo8oEHs+wdfAXhWlAO5cskE=; b=qJe1FIsRi2rSo4yAi1lOgYa86ybYH0aWoBUrkHmWjEBJisduw3ftnHu3jN2HxkQKn6 hI4O7LhIYabBTACMF337079WmDfCI9l64PCvMClSWD32X/1Axy/OCyIc+heNlWLJ5loE W0J1s/tfkNJIL85c8586gv4s9fW/9o4S5ExqsDlmdwubQtb33ygWAZIO7nWRNlHhmJhT 0bQJvynM9yG8VpmR/FM3WRYmxi5/2PVJCn+d1j4YacaDr1xIsFruErGL4mewoqOj6+xl DiO+X0ukcf/RgTZ9iY3uNejgULVJI959ZrdOmBgpJ67hQi8u4fO24m2EHCQhhfIWtgGl tNow== X-Gm-Message-State: ABuFfoiVvj0qdV/Du9gSWnyrYne0CtOZJnHgGS6QNdUIPt4Rx6ncOP1a GMmnXub+4Fd8ZXCUrV9tD+c80il+qHU= X-Google-Smtp-Source: ACcGV62FcX8gA5eJEDQUTbhvCNmgyLzYdRjzC7dq6nQgyov9rWrX/4AtICp24EcETb52yrIJBrHkaA== X-Received: by 2002:a19:d408:: with SMTP id l8-v6mr18474354lfg.25.1539846817606; Thu, 18 Oct 2018 00:13:37 -0700 (PDT) Received: from localhost.localdomain ([77.221.221.49]) by smtp.gmail.com with ESMTPSA id r4-v6sm4445426ljg.12.2018.10.18.00.13.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Oct 2018 00:13:36 -0700 (PDT) From: Artem Pisarenko To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2018 13:12:55 +0600 Message-Id: <1fc12c77e8b7115d3842919a8b586d9cbe4efca6.1539846575.git.artem.k.pisarenko@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::141 Subject: [Qemu-devel] [PATCH v3 4/4] vl, qapi: offset calculation in RTC_CHANGE event reverted X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Artem Pisarenko , Markus Armbruster , Paolo Bonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Return value of qemu_timedate_diff(), used for calculation offset in QAPI 'RTC_CHANGE' event, restored to keep compatibility. Since it wasn't documented that difference is relative to host clock advancement, this change also adds important note to 'RTC_CHANGE' event description to highlight established implementation specifics. Signed-off-by: Artem Pisarenko --- qapi/misc.json | 3 ++- vl.c | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/qapi/misc.json b/qapi/misc.json index ada9af5..d0f5381 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -3070,7 +3070,8 @@ # Emitted when the guest changes the RTC time. # # @offset: offset between base RTC clock (as specified by -rtc base), and -# new RTC clock value +# new RTC clock value. Note that value will be different depending +# on clock chosen to drive RTC (specified by -rtc clock). # # Note: This event is rate-limited. # diff --git a/vl.c b/vl.c index 78a8a68..c350aba 100644 --- a/vl.c +++ b/vl.c @@ -788,10 +788,10 @@ void qemu_system_vmstop_request(RunState state) /***********************************************************/ /* RTC reference time/date access */ -static time_t qemu_ref_timedate(void) +static time_t qemu_ref_timedate(QEMUClockType clock) { - time_t value = qemu_clock_get_ms(rtc_clock) / 1000; - switch (rtc_clock) { + time_t value = qemu_clock_get_ms(clock) / 1000; + switch (clock) { case QEMU_CLOCK_REALTIME: value -= rtc_realtime_clock_offset; /* no break */ @@ -811,7 +811,7 @@ static time_t qemu_ref_timedate(void) void qemu_get_timedate(struct tm *tm, int offset) { - time_t ti = qemu_ref_timedate(); + time_t ti = qemu_ref_timedate(rtc_clock); ti += offset; @@ -849,7 +849,7 @@ int qemu_timedate_diff(struct tm *tm) break; } - return seconds - qemu_ref_timedate(); + return seconds - qemu_ref_timedate(QEMU_CLOCK_HOST); } static void configure_rtc_base_datetime(const char *startdate)