diff mbox series

[v3,14/16] qemu-common: move error-report

Message ID 20220810124857.1360211-15-marcandre.lureau@redhat.com (mailing list archive)
State New, archived
Headers show
Series Preliminary patches for subproject split | expand

Commit Message

Marc-André Lureau Aug. 10, 2022, 12:48 p.m. UTC
From: Marc-André Lureau <marcandre.lureau@redhat.com>

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 .../qemu-common/include}/qemu/error-report.h  |  2 ++
 .../qemu-common/src}/error-is-detailed.c      |  1 -
 .../qemu-common/src}/error-report.c           |  4 +++-
 .../qemu-common/src/error-vprintf.c           |  5 ++---
 stubs/meson.build                             |  2 --
 subprojects/qemu-common/meson.build           | 20 ++++++++++++++++---
 subprojects/qemu-common/src/meson.build       |  5 +++++
 util/meson.build                              |  2 +-
 8 files changed, 30 insertions(+), 11 deletions(-)
 rename {include => subprojects/qemu-common/include}/qemu/error-report.h (98%)
 rename {stubs => subprojects/qemu-common/src}/error-is-detailed.c (77%)
 rename {util => subprojects/qemu-common/src}/error-report.c (99%)
 rename stubs/error-printf.c => subprojects/qemu-common/src/error-vprintf.c (78%)
 create mode 100644 subprojects/qemu-common/src/meson.build
diff mbox series

Patch

diff --git a/include/qemu/error-report.h b/subprojects/qemu-common/include/qemu/error-report.h
similarity index 98%
rename from include/qemu/error-report.h
rename to subprojects/qemu-common/include/qemu/error-report.h
index 6ab25d4583..c62dd1a633 100644
--- a/include/qemu/error-report.h
+++ b/subprojects/qemu-common/include/qemu/error-report.h
@@ -13,6 +13,8 @@ 
 #ifndef QEMU_ERROR_REPORT_H
 #define QEMU_ERROR_REPORT_H
 
+#include "glib-compat.h"
+
 typedef struct Location {
     /* all members are private to qemu-error.c */
     enum { LOC_NONE, LOC_CMDLINE, LOC_FILE } kind;
diff --git a/stubs/error-is-detailed.c b/subprojects/qemu-common/src/error-is-detailed.c
similarity index 77%
rename from stubs/error-is-detailed.c
rename to subprojects/qemu-common/src/error-is-detailed.c
index c47cd23693..c3d9c3454d 100644
--- a/stubs/error-is-detailed.c
+++ b/subprojects/qemu-common/src/error-is-detailed.c
@@ -1,4 +1,3 @@ 
-#include "qemu/osdep.h"
 #include "qemu/error-report.h"
 
 bool error_is_detailed(void)
diff --git a/util/error-report.c b/subprojects/qemu-common/src/error-report.c
similarity index 99%
rename from util/error-report.c
rename to subprojects/qemu-common/src/error-report.c
index 4d1d66fc06..616428fe95 100644
--- a/util/error-report.c
+++ b/subprojects/qemu-common/src/error-report.c
@@ -10,7 +10,9 @@ 
  * See the COPYING file in the top-level directory.
  */
 
-#include "qemu/osdep.h"
+#include <stdio.h>
+#include <assert.h>
+
 #include "qemu/error-report.h"
 
 /*
diff --git a/stubs/error-printf.c b/subprojects/qemu-common/src/error-vprintf.c
similarity index 78%
rename from stubs/error-printf.c
rename to subprojects/qemu-common/src/error-vprintf.c
index 1afa0f62ca..b815d88dfe 100644
--- a/stubs/error-printf.c
+++ b/subprojects/qemu-common/src/error-vprintf.c
@@ -1,13 +1,12 @@ 
-#include "qemu/osdep.h"
+#include <stdio.h>
 #include "qemu/error-report.h"
-#include "monitor/monitor.h"
 
 int error_vprintf(const char *fmt, va_list ap)
 {
     int ret;
 
     if (g_test_initialized() && !g_test_subprocess() &&
-        getenv("QTEST_SILENT_ERRORS")) {
+        g_getenv("QTEST_SILENT_ERRORS")) {
         char *msg = g_strdup_vprintf(fmt, ap);
         g_test_message("%s", msg);
         ret = strlen(msg);
diff --git a/stubs/meson.build b/stubs/meson.build
index 14548633b0..865b677f2a 100644
--- a/stubs/meson.build
+++ b/stubs/meson.build
@@ -9,8 +9,6 @@  stub_ss.add(files('cpus-get-virtual-clock.c'))
 stub_ss.add(files('qemu-timer-notify-cb.c'))
 stub_ss.add(files('icount.c'))
 stub_ss.add(files('dump.c'))
-stub_ss.add(files('error-is-detailed.c'))
-stub_ss.add(files('error-printf.c'))
 stub_ss.add(files('fdset.c'))
 stub_ss.add(files('gdbstub.c'))
 stub_ss.add(files('get-vm-name.c'))
diff --git a/subprojects/qemu-common/meson.build b/subprojects/qemu-common/meson.build
index 207e539910..05bca6d30d 100644
--- a/subprojects/qemu-common/meson.build
+++ b/subprojects/qemu-common/meson.build
@@ -3,8 +3,22 @@  project('qemu-common', 'c',
   default_options: ['c_std=gnu11']
 )
 
-qemu_common_dep = declare_dependency(
-  include_directories: include_directories('include'),
-)
+glib_dep = dependency('glib-2.0')
+inc = include_directories('include')
+
+sources = []
 
 subdir('scripts')
+subdir('src')
+
+lib = static_library(
+  'qemu-common', sources,
+  dependencies: [glib_dep],
+  include_directories: inc,
+)
+
+qemu_common_dep = declare_dependency(
+  link_with: lib,
+  include_directories: inc,
+  dependencies: [glib_dep],
+)
diff --git a/subprojects/qemu-common/src/meson.build b/subprojects/qemu-common/src/meson.build
new file mode 100644
index 0000000000..d85a314065
--- /dev/null
+++ b/subprojects/qemu-common/src/meson.build
@@ -0,0 +1,5 @@ 
+sources += files(
+  'error-is-detailed.c',
+  'error-report.c',
+  'error-vprintf.c',
+)
diff --git a/util/meson.build b/util/meson.build
index 5e282130df..38bb08675b 100644
--- a/util/meson.build
+++ b/util/meson.build
@@ -29,7 +29,7 @@  util_ss.add(files('host-utils.c'))
 util_ss.add(files('bitmap.c', 'bitops.c'))
 util_ss.add(files('fifo8.c'))
 util_ss.add(files('cacheflush.c'))
-util_ss.add(files('error.c', 'error-report.c'))
+util_ss.add(files('error.c'))
 util_ss.add(files('qemu-print.c'))
 util_ss.add(files('id.c'))
 util_ss.add(files('qemu-config.c', 'notify.c'))