From nobody Mon Feb 9 18:22:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646409150509760.2432245600752; Fri, 4 Mar 2022 07:52:30 -0800 (PST) Received: from localhost ([::1]:36314 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQAEH-0000Ra-DL for importer@patchew.org; Fri, 04 Mar 2022 10:52:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56700) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ9qS-0001wT-1p for qemu-devel@nongnu.org; Fri, 04 Mar 2022 10:27:52 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:42080) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ9qK-0004z6-1e for qemu-devel@nongnu.org; Fri, 04 Mar 2022 10:27:45 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-299-xcYAOgmUMZOm5_ZdWGJluA-1; Fri, 04 Mar 2022 10:27:42 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 943AF8145F7; Fri, 4 Mar 2022 15:27:40 +0000 (UTC) Received: from localhost (unknown [10.39.208.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46D1D1064275; Fri, 4 Mar 2022 15:27:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646407663; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5ntRqMb9zItiX8LVU47zdYtH2GTJ7IQfCQ2jg6NXQgU=; b=T0JzWpe9xLs5siSfiaN5o43p0oKSd2ne6Tn9wWgM6z6OY5m0idOeFY/A3qw4iweFnikg3m qnMxitHr4WNGBcqc3F+APSAm5b8Kqrhl9nre8xD9n7npVL2TeIVKLyKm3Y2G+w6sewWySW 413enpK31FbFTxr5/aonEWksLanzo8E= X-MC-Unique: xcYAOgmUMZOm5_ZdWGJluA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH 1/4] m68k/nios2-semi: fix gettimeofday() result check Date: Fri, 4 Mar 2022 19:27:01 +0400 Message-Id: <20220304152704.3466036-2-marcandre.lureau@redhat.com> In-Reply-To: <20220304152704.3466036-1-marcandre.lureau@redhat.com> References: <20220304152704.3466036-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marek Vasut , Kevin Wolf , Thomas Huth , "Michael S. Tsirkin" , qemu-block@nongnu.org, David Hildenbrand , Laurent Vivier , Michael Roth , Chris Wulff , Laurent Vivier , Markus Armbruster , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Hanna Reitz , qemu-ppc@nongnu.org, Stefan Weil , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646409152566100003 From: Marc-Andr=C3=A9 Lureau gettimeofday() returns 0 for success. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Laurent Vivier Reviewed-by: Richard Henderson --- target/m68k/m68k-semi.c | 2 +- target/nios2/nios2-semi.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/target/m68k/m68k-semi.c b/target/m68k/m68k-semi.c index 44ec7e4612c6..c5c164e096c8 100644 --- a/target/m68k/m68k-semi.c +++ b/target/m68k/m68k-semi.c @@ -381,7 +381,7 @@ void do_m68k_semihosting(CPUM68KState *env, int nr) qemu_timeval tv; struct gdb_timeval *p; result =3D qemu_gettimeofday(&tv); - if (result !=3D 0) { + if (result =3D=3D 0) { if (!(p =3D lock_user(VERIFY_WRITE, arg0, sizeof(struct gdb_timeval), 0)))= { /* FIXME - check error code? */ diff --git a/target/nios2/nios2-semi.c b/target/nios2/nios2-semi.c index fe5598bae4d7..5a7ad0c7108d 100644 --- a/target/nios2/nios2-semi.c +++ b/target/nios2/nios2-semi.c @@ -403,7 +403,7 @@ void do_nios2_semihosting(CPUNios2State *env) qemu_timeval tv; struct gdb_timeval *p; result =3D qemu_gettimeofday(&tv); - if (result !=3D 0) { + if (result =3D=3D 0) { p =3D lock_user(VERIFY_WRITE, arg0, sizeof(struct gdb_time= val), 0); if (!p) { --=20 2.35.1.273.ge6ebfd0e8cbb From nobody Mon Feb 9 18:22:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646409247825853.5155867291052; Fri, 4 Mar 2022 07:54:07 -0800 (PST) Received: from localhost ([::1]:40608 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQAFq-0003Pu-NB for importer@patchew.org; Fri, 04 Mar 2022 10:54:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56842) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ9qt-0003r9-8b for qemu-devel@nongnu.org; Fri, 04 Mar 2022 10:28:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:38705) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ9qr-00051w-JR for qemu-devel@nongnu.org; Fri, 04 Mar 2022 10:28:18 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-481-ROSoKTbkPBSo2S-KbMKpmA-1; Fri, 04 Mar 2022 10:28:14 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 576A48070ED; Fri, 4 Mar 2022 15:28:12 +0000 (UTC) Received: from localhost (unknown [10.39.208.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8BA6F83C01; Fri, 4 Mar 2022 15:27:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646407697; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d9Ezg3SoBLNIiYQXy/QeYboxFvin78kHN6KT16YCW+k=; b=ZglDFoxAk8GJ0Xp3AmESO9dXFcDv2ACoGbpAjpmY7oXRzaRH5mBUD3wVcgw/lfv2aDaAOt 0rzlQ0MihXxxbX4q74J+4A33gCwImpaa0Lcopi+1+owz6zHeJH8OKa6CvULRJ7sN7D/i0W 1izoUhhw+7irIBkAmSy0DX8KoqwAQDs= X-MC-Unique: ROSoKTbkPBSo2S-KbMKpmA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH 2/4] qtest: replace gettimeofday with GTimer Date: Fri, 4 Mar 2022 19:27:02 +0400 Message-Id: <20220304152704.3466036-3-marcandre.lureau@redhat.com> In-Reply-To: <20220304152704.3466036-1-marcandre.lureau@redhat.com> References: <20220304152704.3466036-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marek Vasut , Kevin Wolf , Thomas Huth , "Michael S. Tsirkin" , qemu-block@nongnu.org, David Hildenbrand , Laurent Vivier , Michael Roth , Chris Wulff , Laurent Vivier , Markus Armbruster , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Hanna Reitz , qemu-ppc@nongnu.org, Stefan Weil , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646409249654100001 From: Marc-Andr=C3=A9 Lureau glib provides a convenience helper to measure elapsed time. It isn't subject to wall-clock time changes. Note that this changes the initial OPENED time, which used to print the current time. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Laurent Vivier --- softmmu/qtest.c | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/softmmu/qtest.c b/softmmu/qtest.c index 8b7cb6aa8e46..b2bb7777d17d 100644 --- a/softmmu/qtest.c +++ b/softmmu/qtest.c @@ -58,12 +58,12 @@ static FILE *qtest_log_fp; static QTest *qtest; static GString *inbuf; static int irq_levels[MAX_IRQ]; -static qemu_timeval start_time; +static GTimer *timer; static bool qtest_opened; static void (*qtest_server_send)(void*, const char*); static void *qtest_server_send_opaque; =20 -#define FMT_timeval "%ld.%06ld" +#define FMT_timeval "%.06f" =20 /** * DOC: QTest Protocol @@ -264,28 +264,13 @@ static int hex2nib(char ch) } } =20 -static void qtest_get_time(qemu_timeval *tv) -{ - qemu_gettimeofday(tv); - tv->tv_sec -=3D start_time.tv_sec; - tv->tv_usec -=3D start_time.tv_usec; - if (tv->tv_usec < 0) { - tv->tv_usec +=3D 1000000; - tv->tv_sec -=3D 1; - } -} - static void qtest_send_prefix(CharBackend *chr) { - qemu_timeval tv; - if (!qtest_log_fp || !qtest_opened) { return; } =20 - qtest_get_time(&tv); - fprintf(qtest_log_fp, "[S +" FMT_timeval "] ", - (long) tv.tv_sec, (long) tv.tv_usec); + fprintf(qtest_log_fp, "[S +" FMT_timeval "] ", g_timer_elapsed(timer, = NULL)); } =20 static void GCC_FMT_ATTR(1, 2) qtest_log_send(const char *fmt, ...) @@ -386,12 +371,9 @@ static void qtest_process_command(CharBackend *chr, gc= har **words) command =3D words[0]; =20 if (qtest_log_fp) { - qemu_timeval tv; int i; =20 - qtest_get_time(&tv); - fprintf(qtest_log_fp, "[R +" FMT_timeval "]", - (long) tv.tv_sec, (long) tv.tv_usec); + fprintf(qtest_log_fp, "[R +" FMT_timeval "]", g_timer_elapsed(time= r, NULL)); for (i =3D 0; words[i]; i++) { fprintf(qtest_log_fp, " %s", words[i]); } @@ -846,21 +828,20 @@ static void qtest_event(void *opaque, QEMUChrEvent ev= ent) for (i =3D 0; i < ARRAY_SIZE(irq_levels); i++) { irq_levels[i] =3D 0; } - qemu_gettimeofday(&start_time); + + g_clear_pointer(&timer, g_timer_destroy); + timer =3D g_timer_new(); qtest_opened =3D true; if (qtest_log_fp) { - fprintf(qtest_log_fp, "[I " FMT_timeval "] OPENED\n", - (long) start_time.tv_sec, (long) start_time.tv_usec); + fprintf(qtest_log_fp, "[I " FMT_timeval "] OPENED\n", g_timer_= elapsed(timer, NULL)); } break; case CHR_EVENT_CLOSED: qtest_opened =3D false; if (qtest_log_fp) { - qemu_timeval tv; - qtest_get_time(&tv); - fprintf(qtest_log_fp, "[I +" FMT_timeval "] CLOSED\n", - (long) tv.tv_sec, (long) tv.tv_usec); + fprintf(qtest_log_fp, "[I +" FMT_timeval "] CLOSED\n", g_timer= _elapsed(timer, NULL)); } + g_clear_pointer(&timer, g_timer_destroy); break; default: break; --=20 2.35.1.273.ge6ebfd0e8cbb From nobody Mon Feb 9 18:22:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646408618068880.4085452456223; Fri, 4 Mar 2022 07:43:38 -0800 (PST) Received: from localhost ([::1]:39334 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQA5h-0008SX-1C for importer@patchew.org; Fri, 04 Mar 2022 10:43:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57026) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ9ra-00060s-Di for qemu-devel@nongnu.org; Fri, 04 Mar 2022 10:29:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44924) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ9rY-00056e-3b for qemu-devel@nongnu.org; Fri, 04 Mar 2022 10:29:02 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-548-vyCpHsT1N3i8MGnCbleyUQ-1; Fri, 04 Mar 2022 10:28:56 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 85156501E0; Fri, 4 Mar 2022 15:28:54 +0000 (UTC) Received: from localhost (unknown [10.39.208.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F4B1303DF; Fri, 4 Mar 2022 15:28:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646407739; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jt+POAXQSSXabPGYImyGXTJurtqjiS1J9CivSI696j0=; b=WYDXIYTIrvFYfk5KfBp26LeQISA45Ditj1WqgDGcsH9yUZWlFW7huSQkrkB6UQyJ6bdNxw DCPZehcEXJdL7F+lWT6BVhS4aEfNSYetG35cjY4W9tG3WOTDrB7BxFP1O9njVLngBYaven ivKkggxz8G8n51EQnIh6TtDCw6FWKPc= X-MC-Unique: vyCpHsT1N3i8MGnCbleyUQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH 3/4] Replace qemu_gettimeofday() with g_get_real_time() Date: Fri, 4 Mar 2022 19:27:03 +0400 Message-Id: <20220304152704.3466036-4-marcandre.lureau@redhat.com> In-Reply-To: <20220304152704.3466036-1-marcandre.lureau@redhat.com> References: <20220304152704.3466036-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marek Vasut , Kevin Wolf , Thomas Huth , "Michael S. Tsirkin" , qemu-block@nongnu.org, David Hildenbrand , Laurent Vivier , Michael Roth , Chris Wulff , Laurent Vivier , Markus Armbruster , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Hanna Reitz , qemu-ppc@nongnu.org, Stefan Weil , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646408618647100001 From: Marc-Andr=C3=A9 Lureau GLib g_get_real_time() is an alternative to gettimeofday(). For semihosting, a few bits are lost on POSIX host, but this shouldn't be a big concern. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: BALATON Zoltan Reviewed-by: Laurent Vivier --- blockdev.c | 8 ++++---- hw/rtc/m41t80.c | 6 +++--- hw/virtio/virtio-balloon.c | 9 +-------- qapi/qmp-event.c | 12 +++++------- qemu-img.c | 8 ++++---- qga/commands-posix.c | 11 +---------- target/m68k/m68k-semi.c | 22 ++++++++++------------ target/nios2/nios2-semi.c | 24 +++++++++++------------- 8 files changed, 39 insertions(+), 61 deletions(-) diff --git a/blockdev.c b/blockdev.c index 42e098b458b1..4b07dbfbdefc 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1235,7 +1235,7 @@ static void internal_snapshot_prepare(BlkActionState = *common, BlockDriverState *bs; QEMUSnapshotInfo old_sn, *sn; bool ret; - qemu_timeval tv; + int64_t rt; BlockdevSnapshotInternal *internal; InternalSnapshotState *state; AioContext *aio_context; @@ -1305,9 +1305,9 @@ static void internal_snapshot_prepare(BlkActionState = *common, /* 3. take the snapshot */ sn =3D &state->sn; pstrcpy(sn->name, sizeof(sn->name), name); - qemu_gettimeofday(&tv); - sn->date_sec =3D tv.tv_sec; - sn->date_nsec =3D tv.tv_usec * 1000; + rt =3D g_get_real_time(); + sn->date_sec =3D rt / G_USEC_PER_SEC; + sn->date_nsec =3D (rt % G_USEC_PER_SEC) * 1000; sn->vm_clock_nsec =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); if (replay_mode !=3D REPLAY_MODE_NONE) { sn->icount =3D replay_get_current_icount(); diff --git a/hw/rtc/m41t80.c b/hw/rtc/m41t80.c index a00971a67e1c..e045c864bb44 100644 --- a/hw/rtc/m41t80.c +++ b/hw/rtc/m41t80.c @@ -47,7 +47,7 @@ static uint8_t m41t80_recv(I2CSlave *i2c) { M41t80State *s =3D M41T80(i2c); struct tm now; - qemu_timeval tv; + int64_t rt; =20 if (s->addr < 0) { s->addr =3D 0; @@ -57,8 +57,8 @@ static uint8_t m41t80_recv(I2CSlave *i2c) } switch (s->addr++) { case 0: - qemu_gettimeofday(&tv); - return to_bcd(tv.tv_usec / 10000); + rt =3D g_get_real_time(); + return to_bcd((rt % G_USEC_PER_SEC) / 10000); case 1: return to_bcd(now.tm_sec); case 2: diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index e6c1b0aa46fe..b1bada84cecc 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -452,7 +452,6 @@ static void virtio_balloon_receive_stats(VirtIODevice *= vdev, VirtQueue *vq) VirtQueueElement *elem; VirtIOBalloonStat stat; size_t offset =3D 0; - qemu_timeval tv; =20 elem =3D virtqueue_pop(vq, sizeof(VirtQueueElement)); if (!elem) { @@ -484,13 +483,7 @@ static void virtio_balloon_receive_stats(VirtIODevice = *vdev, VirtQueue *vq) s->stats[tag] =3D val; } s->stats_vq_offset =3D offset; - - if (qemu_gettimeofday(&tv) < 0) { - warn_report("%s: failed to get time of day", __func__); - goto out; - } - - s->stats_last_update =3D tv.tv_sec; + s->stats_last_update =3D g_get_real_time() / G_USEC_PER_SEC; =20 out: if (balloon_stats_enabled(s)) { diff --git a/qapi/qmp-event.c b/qapi/qmp-event.c index 19d3cd003833..025716b3ec37 100644 --- a/qapi/qmp-event.c +++ b/qapi/qmp-event.c @@ -20,15 +20,13 @@ =20 static void timestamp_put(QDict *qdict) { - int err; QDict *ts; - qemu_timeval tv; + int64_t rt =3D g_get_real_time(); =20 - err =3D qemu_gettimeofday(&tv); - /* Put -1 to indicate failure of getting host time */ - ts =3D qdict_from_jsonf_nofail("{ 'seconds': %lld, 'microseconds': %ll= d }", - err < 0 ? -1LL : (long long)tv.tv_sec, - err < 0 ? -1LL : (long long)tv.tv_usec); + ts =3D qdict_from_jsonf_nofail("{ 'seconds': %" G_GINT64_FORMAT + ", 'microseconds': %" G_GINT64_FORMAT "}", + rt / G_USEC_PER_SEC, + rt % G_USEC_PER_SEC); qdict_put(qdict, "timestamp", ts); } =20 diff --git a/qemu-img.c b/qemu-img.c index 6fe2466032f9..e26773909684 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -3304,11 +3304,11 @@ static int img_snapshot(int argc, char **argv) char *filename, *snapshot_name =3D NULL; int c, ret =3D 0, bdrv_oflags; int action =3D 0; - qemu_timeval tv; bool quiet =3D false; Error *err =3D NULL; bool image_opts =3D false; bool force_share =3D false; + int64_t rt; =20 bdrv_oflags =3D BDRV_O_RDWR; /* Parse commandline parameters */ @@ -3405,9 +3405,9 @@ static int img_snapshot(int argc, char **argv) memset(&sn, 0, sizeof(sn)); pstrcpy(sn.name, sizeof(sn.name), snapshot_name); =20 - qemu_gettimeofday(&tv); - sn.date_sec =3D tv.tv_sec; - sn.date_nsec =3D tv.tv_usec * 1000; + rt =3D g_get_real_time(); + sn.date_sec =3D rt / G_USEC_PER_SEC; + sn.date_nsec =3D (rt % G_USEC_PER_SEC) * 1000; =20 ret =3D bdrv_snapshot_create(bs, &sn); if (ret) { diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 75dbaab68ea9..3311a4ca0167 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -138,16 +138,7 @@ void qmp_guest_shutdown(bool has_mode, const char *mod= e, Error **errp) =20 int64_t qmp_guest_get_time(Error **errp) { - int ret; - qemu_timeval tq; - - ret =3D qemu_gettimeofday(&tq); - if (ret < 0) { - error_setg_errno(errp, errno, "Failed to get time"); - return -1; - } - - return tq.tv_sec * 1000000000LL + tq.tv_usec * 1000; + return g_get_real_time(); } =20 void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp) diff --git a/target/m68k/m68k-semi.c b/target/m68k/m68k-semi.c index c5c164e096c8..54f735743165 100644 --- a/target/m68k/m68k-semi.c +++ b/target/m68k/m68k-semi.c @@ -378,19 +378,17 @@ void do_m68k_semihosting(CPUM68KState *env, int nr) arg0, arg1); return; } else { - qemu_timeval tv; struct gdb_timeval *p; - result =3D qemu_gettimeofday(&tv); - if (result =3D=3D 0) { - if (!(p =3D lock_user(VERIFY_WRITE, - arg0, sizeof(struct gdb_timeval), 0)))= { - /* FIXME - check error code? */ - result =3D -1; - } else { - p->tv_sec =3D cpu_to_be32(tv.tv_sec); - p->tv_usec =3D cpu_to_be64(tv.tv_usec); - unlock_user(p, arg0, sizeof(struct gdb_timeval)); - } + int64_t rt =3D g_get_real_time(); + if (!(p =3D lock_user(VERIFY_WRITE, + arg0, sizeof(struct gdb_timeval), 0))) { + /* FIXME - check error code? */ + result =3D -1; + } else { + result =3D 0; + p->tv_sec =3D cpu_to_be32(rt / G_USEC_PER_SEC); + p->tv_usec =3D cpu_to_be64(rt % G_USEC_PER_SEC); + unlock_user(p, arg0, sizeof(struct gdb_timeval)); } } break; diff --git a/target/nios2/nios2-semi.c b/target/nios2/nios2-semi.c index 5a7ad0c7108d..4600bf0a39d9 100644 --- a/target/nios2/nios2-semi.c +++ b/target/nios2/nios2-semi.c @@ -400,20 +400,18 @@ void do_nios2_semihosting(CPUNios2State *env) arg0, 0); return; } else { - qemu_timeval tv; struct gdb_timeval *p; - result =3D qemu_gettimeofday(&tv); - if (result =3D=3D 0) { - p =3D lock_user(VERIFY_WRITE, arg0, sizeof(struct gdb_time= val), - 0); - if (!p) { - result =3D -1; - errno =3D EFAULT; - } else { - p->tv_sec =3D cpu_to_be32(tv.tv_sec); - p->tv_usec =3D cpu_to_be64(tv.tv_usec); - unlock_user(p, arg0, sizeof(struct gdb_timeval)); - } + int64_t rt =3D g_get_real_time(); + p =3D lock_user(VERIFY_WRITE, arg0, sizeof(struct gdb_timeval), + 0); + if (!p) { + result =3D -1; + errno =3D EFAULT; + } else { + result =3D 0; + p->tv_sec =3D cpu_to_be32(rt / G_USEC_PER_SEC); + p->tv_usec =3D cpu_to_be64(rt % G_USEC_PER_SEC); + unlock_user(p, arg0, sizeof(struct gdb_timeval)); } } break; --=20 2.35.1.273.ge6ebfd0e8cbb From nobody Mon Feb 9 18:22:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646409391825234.85990106337283; Fri, 4 Mar 2022 07:56:31 -0800 (PST) Received: from localhost ([::1]:47532 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQAIA-0008Lg-RT for importer@patchew.org; Fri, 04 Mar 2022 10:56:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57222) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ9sW-0008Qq-Ed for qemu-devel@nongnu.org; Fri, 04 Mar 2022 10:30:00 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:43715) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ9sU-0005ib-TX for qemu-devel@nongnu.org; Fri, 04 Mar 2022 10:30:00 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-504-EKZrKsnaNOyZ9C3NxPhD8Q-1; Fri, 04 Mar 2022 10:29:55 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E4A5A501E0; Fri, 4 Mar 2022 15:29:53 +0000 (UTC) Received: from localhost (unknown [10.39.208.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1035D83796; Fri, 4 Mar 2022 15:28:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646407798; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q26w0Lu+TCcd1kWx5gxgPO+Z+aTJe0aRGlCAHcBtqTY=; b=hR/8FrfX54dV4i7XBEPnPYunXBVBNqLSzMOtpLwPmsFmpHUvj2+vIZkZjnz5oeCGgjSsvy 4CasMpZoCMO0prD8PmF8eEQu5OUNkzZMNMkmo7I9nLKV38z4wQGNpE4DMPxhRUT4d6GGP5 ZnZKsURZpK+6JBD9zR0N8tzpZ//VHcQ= X-MC-Unique: EKZrKsnaNOyZ9C3NxPhD8Q-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH 4/4] oslib: drop qemu_gettimeofday() Date: Fri, 4 Mar 2022 19:27:04 +0400 Message-Id: <20220304152704.3466036-5-marcandre.lureau@redhat.com> In-Reply-To: <20220304152704.3466036-1-marcandre.lureau@redhat.com> References: <20220304152704.3466036-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marek Vasut , Kevin Wolf , Thomas Huth , "Michael S. Tsirkin" , qemu-block@nongnu.org, David Hildenbrand , Laurent Vivier , Michael Roth , Chris Wulff , Laurent Vivier , Markus Armbruster , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Hanna Reitz , qemu-ppc@nongnu.org, Stefan Weil , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646409392469100001 From: Marc-Andr=C3=A9 Lureau No longer used after the previous patches. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Laurent Vivier Reviewed-by: Richard Henderson Reviewed-by: Stefan Weil --- include/sysemu/os-posix.h | 3 --- include/sysemu/os-win32.h | 6 ------ util/oslib-win32.c | 20 -------------------- 3 files changed, 29 deletions(-) diff --git a/include/sysemu/os-posix.h b/include/sysemu/os-posix.h index 2edf33658a44..c9b1d63fedda 100644 --- a/include/sysemu/os-posix.h +++ b/include/sysemu/os-posix.h @@ -52,9 +52,6 @@ int os_mlock(void); #define closesocket(s) close(s) #define ioctlsocket(s, r, v) ioctl(s, r, v) =20 -typedef struct timeval qemu_timeval; -#define qemu_gettimeofday(tp) gettimeofday(tp, NULL) - bool is_daemonized(void); =20 /** diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h index 43f569b5c216..4d4be826f48c 100644 --- a/include/sysemu/os-win32.h +++ b/include/sysemu/os-win32.h @@ -71,12 +71,6 @@ int getpagesize(void); # define EPROTONOSUPPORT EINVAL #endif =20 -typedef struct { - long tv_sec; - long tv_usec; -} qemu_timeval; -int qemu_gettimeofday(qemu_timeval *tp); - static inline bool is_daemonized(void) { return false; diff --git a/util/oslib-win32.c b/util/oslib-win32.c index af559ef3398d..7faf59e9aaea 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -265,26 +265,6 @@ void qemu_set_cloexec(int fd) { } =20 -/* Offset between 1/1/1601 and 1/1/1970 in 100 nanosec units */ -#define _W32_FT_OFFSET (116444736000000000ULL) - -int qemu_gettimeofday(qemu_timeval *tp) -{ - union { - unsigned long long ns100; /*time since 1 Jan 1601 in 100ns units */ - FILETIME ft; - } _now; - - if(tp) { - GetSystemTimeAsFileTime (&_now.ft); - tp->tv_usec=3D(long)((_now.ns100 / 10ULL) % 1000000ULL ); - tp->tv_sec=3D (long)((_now.ns100 - _W32_FT_OFFSET) / 10000000ULL); - } - /* Always return 0 as per Open Group Base Specifications Issue 6. - Do not set errno on error. */ - return 0; -} - int qemu_get_thread_id(void) { return GetCurrentThreadId(); --=20 2.35.1.273.ge6ebfd0e8cbb