qemu-rust.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-rust@nongnu.org
Subject: [PATCH 03/14] util/error: expose Error definition to Rust code
Date: Fri, 30 May 2025 10:02:55 +0200	[thread overview]
Message-ID: <20250530080307.2055502-4-pbonzini@redhat.com> (raw)
In-Reply-To: <20250530080307.2055502-1-pbonzini@redhat.com>

This is used to preserve the file and line in a roundtrip from
C Error to Rust and back to C.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 include/qapi/error-internal.h | 26 ++++++++++++++++++++++++++
 rust/wrapper.h                |  1 +
 util/error.c                  | 10 +---------
 3 files changed, 28 insertions(+), 9 deletions(-)
 create mode 100644 include/qapi/error-internal.h

diff --git a/include/qapi/error-internal.h b/include/qapi/error-internal.h
new file mode 100644
index 00000000000..d5c3904adec
--- /dev/null
+++ b/include/qapi/error-internal.h
@@ -0,0 +1,26 @@
+/*
+ * QEMU Error Objects - struct definition
+ *
+ * Copyright IBM, Corp. 2011
+ * Copyright (C) 2011-2015 Red Hat, Inc.
+ *
+ * Authors:
+ *  Anthony Liguori   <aliguori@us.ibm.com>
+ *  Markus Armbruster <armbru@redhat.com>,
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.  See
+ * the COPYING.LIB file in the top-level directory.
+ */
+
+#ifndef QAPI_ERROR_INTERNAL_H
+
+struct Error
+{
+    char *msg;
+    ErrorClass err_class;
+    const char *src, *func;
+    int line;
+    GString *hint;
+};
+
+#endif
diff --git a/rust/wrapper.h b/rust/wrapper.h
index beddd9aab2f..6060d3ba1ab 100644
--- a/rust/wrapper.h
+++ b/rust/wrapper.h
@@ -60,6 +60,7 @@ typedef enum memory_order {
 #include "hw/qdev-properties-system.h"
 #include "hw/irq.h"
 #include "qapi/error.h"
+#include "qapi/error-internal.h"
 #include "migration/vmstate.h"
 #include "chardev/char-serial.h"
 #include "exec/memattrs.h"
diff --git a/util/error.c b/util/error.c
index 673011b89e9..e5bcb7c0225 100644
--- a/util/error.c
+++ b/util/error.c
@@ -15,15 +15,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "qemu/error-report.h"
-
-struct Error
-{
-    char *msg;
-    ErrorClass err_class;
-    const char *src, *func;
-    int line;
-    GString *hint;
-};
+#include "qapi/error-internal.h"
 
 Error *error_abort;
 Error *error_fatal;
-- 
2.49.0



  parent reply	other threads:[~2025-05-30  8:03 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-30  8:02 [PATCH v2 00/14] rust: bindings for Error Paolo Bonzini
2025-05-30  8:02 ` [PATCH 01/14] subprojects: add the anyhow crate Paolo Bonzini
2025-05-30  8:02 ` [PATCH 02/14] subprojects: add the foreign crate Paolo Bonzini
2025-05-30  8:02 ` Paolo Bonzini [this message]
2025-06-03  3:06   ` [PATCH 03/14] util/error: expose Error definition to Rust code Zhao Liu
2025-05-30  8:02 ` [PATCH 04/14] util/error: allow non-NUL-terminated err->src Paolo Bonzini
2025-06-02 10:47   ` Markus Armbruster
2025-05-30  8:02 ` [PATCH 05/14] util/error: make func optional Paolo Bonzini
2025-06-02 10:52   ` Markus Armbruster
2025-05-30  8:02 ` [PATCH 06/14] rust: qemu-api: add bindings to Error Paolo Bonzini
2025-06-02 13:18   ` Markus Armbruster
2025-06-03  9:29     ` Zhao Liu
2025-06-03 10:32       ` Markus Armbruster
2025-06-03 15:05         ` Paolo Bonzini
2025-06-04  5:01           ` Markus Armbruster
2025-06-04 19:19             ` Paolo Bonzini
2025-06-05  6:14               ` Markus Armbruster
2025-06-03 15:37     ` Paolo Bonzini
2025-05-30  8:02 ` [PATCH 07/14] rust: qemu-api: add tests for Error bindings Paolo Bonzini
2025-05-30  8:03 ` [PATCH 08/14] rust: qdev: support returning errors from realize Paolo Bonzini
2025-05-30  8:03 ` [PATCH 09/14] rust/hpet: change type of num_timers to usize Paolo Bonzini
2025-05-30  8:03 ` [PATCH 10/14] hpet: adjust VMState for consistency with Rust version Paolo Bonzini
2025-06-03  3:11   ` Zhao Liu
2025-05-30  8:03 ` [PATCH 11/14] hpet: return errors from realize if properties are incorrect Paolo Bonzini
2025-05-30  8:03 ` [PATCH 12/14] rust/hpet: " Paolo Bonzini
2025-05-30  8:03 ` [PATCH 13/14] rust/hpet: Drop BqlCell wrapper for num_timers Paolo Bonzini
2025-05-30  8:03 ` [PATCH 14/14] docs: update Rust module status Paolo Bonzini
2025-06-03  3:09   ` Zhao Liu
2025-06-02  7:49 ` [PATCH v2 00/14] rust: bindings for Error Markus Armbruster
2025-06-02  9:45   ` Paolo Bonzini
2025-06-03  9:35 ` Zhao Liu
  -- strict thread matches above, loose matches on Subject: below --
2025-06-05 10:15 [PATCH v3 " Paolo Bonzini
2025-06-05 10:15 ` [PATCH 03/14] util/error: expose Error definition to Rust code Paolo Bonzini
2025-06-05 13:31   ` Zhao Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250530080307.2055502-4-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-rust@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).