All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] error-report: Fix GDateTime usage
@ 2022-04-25 20:41 Eric Farman
  2022-04-26  6:41 ` Marc-André Lureau
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Farman @ 2022-04-25 20:41 UTC (permalink / raw)
  To: Marc-André Lureau, Paolo Bonzini, Daniel P. Berrangé
  Cc: Eric Farman, qemu-devel, Matthew Rosato

According to the glib manual:

 - g_date_time_new_from_unix_utc() takes a parameter of the number of
   SECONDS since the unix epoch
 - g_get_real_time() returns the number of MICROSECONDS since the
   unix epoch

Rather than convert the latter with G_USECS_PER_SEC, use the convenient
g_date_time_new_now_utc() routine to create the GDateTime object.
This fixes a userspace fault seen when messages get sent to monitor,
such as when a guest is destroyed.

Fixes: 73dab893b569 ("error-report: replace deprecated g_get_current_time() with glib >= 2.62")
Signed-off-by: Eric Farman <farman@linux.ibm.com>
---
 util/error-report.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/util/error-report.c b/util/error-report.c
index dbadaf206d..5edb2e6040 100644
--- a/util/error-report.c
+++ b/util/error-report.c
@@ -173,7 +173,7 @@ static char *
 real_time_iso8601(void)
 {
 #if GLIB_CHECK_VERSION(2,62,0)
-    g_autoptr(GDateTime) dt = g_date_time_new_from_unix_utc(g_get_real_time());
+    g_autoptr(GDateTime) dt = g_date_time_new_now_utc();
     /* ignore deprecation warning, since GLIB_VERSION_MAX_ALLOWED is 2.56 */
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-- 
2.32.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] error-report: Fix GDateTime usage
  2022-04-25 20:41 [PATCH] error-report: Fix GDateTime usage Eric Farman
@ 2022-04-26  6:41 ` Marc-André Lureau
  0 siblings, 0 replies; 2+ messages in thread
From: Marc-André Lureau @ 2022-04-26  6:41 UTC (permalink / raw)
  To: Eric Farman; +Cc: Paolo Bonzini, Daniel P. Berrangé, QEMU, Matthew Rosato

[-- Attachment #1: Type: text/plain, Size: 1564 bytes --]

Hi

On Tue, Apr 26, 2022 at 12:43 AM Eric Farman <farman@linux.ibm.com> wrote:

> According to the glib manual:
>
>  - g_date_time_new_from_unix_utc() takes a parameter of the number of
>    SECONDS since the unix epoch
>  - g_get_real_time() returns the number of MICROSECONDS since the
>    unix epoch
>
> Rather than convert the latter with G_USECS_PER_SEC, use the convenient
> g_date_time_new_now_utc() routine to create the GDateTime object.
> This fixes a userspace fault seen when messages get sent to monitor,
> such as when a guest is destroyed.
>
> Fixes: 73dab893b569 ("error-report: replace deprecated
> g_get_current_time() with glib >= 2.62")
> Signed-off-by: Eric Farman <farman@linux.ibm.com>
>

Same patch as:
https://patchew.org/QEMU/20220424105036.291370-1-haiyue.wang@intel.com/

thanks

---
>  util/error-report.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/util/error-report.c b/util/error-report.c
> index dbadaf206d..5edb2e6040 100644
> --- a/util/error-report.c
> +++ b/util/error-report.c
> @@ -173,7 +173,7 @@ static char *
>  real_time_iso8601(void)
>  {
>  #if GLIB_CHECK_VERSION(2,62,0)
> -    g_autoptr(GDateTime) dt =
> g_date_time_new_from_unix_utc(g_get_real_time());
> +    g_autoptr(GDateTime) dt = g_date_time_new_now_utc();
>      /* ignore deprecation warning, since GLIB_VERSION_MAX_ALLOWED is 2.56
> */
>  #pragma GCC diagnostic push
>  #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
> --
> 2.32.0
>
>
>

-- 
Marc-André Lureau

[-- Attachment #2: Type: text/html, Size: 2397 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-26  6:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-25 20:41 [PATCH] error-report: Fix GDateTime usage Eric Farman
2022-04-26  6:41 ` Marc-André Lureau

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.