Skip to contentSkip to conversation

dump/win_dump: Build almost once

PATCH In review Philippe Mathieu-Daudé 2 participants 5 messages Jan 21 – Jan 22 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

v3 cover dump/win_dump: Build almost once

v3:
- Dropped Nikolai patches, rebased again

v2:
- Rebase on Nikolai patches (included) to avoid rebase
- Add Kconfig symbol to only build for x86 targets

Philippe Mathieu-Daudé (2):
dump: Abort in create_win_dump() on non-x86 guests
dump: Build stubs once for non-x86 targets

 dump/win_dump-stubs.c               | 21 +++++++++++++++++++++
 dump/{win_dump.c => win_dump-x86.c} | 20 +-------------------
 Kconfig                             |  1 +
 dump/Kconfig                        |  4 ++++
 dump/meson.build                    |  3 ++-
 5 files changed, 29 insertions(+), 20 deletions(-)
 create mode 100644 dump/win_dump-stubs.c
 rename dump/{win_dump.c => win_dump-x86.c} (97%)
 create mode 100644 dump/Kconfig
Signature · 1 line
2.52.0
#1 lore raw

PATCH v3 1/2 dump: Abort in create_win_dump() on non-x86 guests

qmp_dump_guest_memory() checks win_dump_available() before calling create_win_dump(). On non-x86 targets calling it would be a programming error, so abort.

Message-Id: <[email protected]>

---
 dump/win_dump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
dump/win_dump.c +1 -1
index 3162e8bd487..6e07913dfb4 100644
@@ -489,7 +489,7 @@ bool win_dump_available(Error **errp)
 
 void create_win_dump(DumpState *s, Error **errp)
 {
-    win_dump_available(errp);
+    g_assert_not_reached();
 }
 
 #endif
Signature · 1 line
2.52.0
#2 lore raw

PATCH v3 2/2 dump: Build stubs once for non-x86 targets

In reply to Philippe Mathieu-Daudé

Rather than compiling the same content for all targets (unused most of the time, i.e. qemu-system-avr ...), extract the non x86 specific parts to a stub file and build it once for all non-x86 targets.

Add a Kconfig symbol to only select the target-specific file with the x86 target (rename this file with '-x86' suffix).

Since Kconfig symbols aren't evaluated for user emulation, the file unit is only built for system emulation.

Message-Id: <[email protected]>

---
 dump/win_dump-stubs.c               | 21 +++++++++++++++++++++
 dump/{win_dump.c => win_dump-x86.c} | 20 +-------------------
 Kconfig                             |  1 +
 dump/Kconfig                        |  4 ++++
 dump/meson.build                    |  3 ++-
 5 files changed, 29 insertions(+), 20 deletions(-)
 create mode 100644 dump/win_dump-stubs.c
 rename dump/{win_dump.c => win_dump-x86.c} (97%)
 create mode 100644 dump/Kconfig
dump/win_dump-stubs.c new file +21 -0
new file mode 100644
index 00000000000..96c1095c4e1
@@ -0,0 +1,21 @@
+/*
+ * Windows crashdump stubs
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "win_dump.h"
+
+bool win_dump_available(Error **errp)
+{
+    error_setg(errp, "x86-64 Windows guest dump not built-in");
+
+    return false;
+}
+
+void create_win_dump(DumpState *s, Error **errp)
+{
+    g_assert_not_reached();
+}
dump/win_dump-x86.c renamed from dump/win_dump.c +1 -19
similarity index 97%
rename from dump/win_dump.c
rename to dump/win_dump-x86.c
index 6e07913dfb4..d893dea7f19 100644
@@ -1,5 +1,5 @@
 /*
- * Windows crashdump (target specific implementations)
+ * Windows crashdump (x86 specific implementations)
  *
  * Copyright (c) 2018 Virtuozzo International GmbH
  *
@@ -18,8 +18,6 @@
 #include "win_dump.h"
 #include "cpu.h"
 
-#if defined(TARGET_X86_64)
-
 bool win_dump_available(Error **errp)
 {
     return true;
@@ -477,19 +475,3 @@ out_free:
 out_cr3:
     first_x86_cpu->env.cr[3] = saved_cr3;
 }
-
-#else /* !TARGET_X86_64 */
-
-bool win_dump_available(Error **errp)
-{
-    error_setg(errp, "Windows dump is only available for x86-64");
-
-    return false;
-}
-
-void create_win_dump(DumpState *s, Error **errp)
-{
-    g_assert_not_reached();
-}
-
-#endif
Kconfig +1 -0
index 63ca7f46df7..26388c12838 100644
@@ -1,6 +1,7 @@
 source Kconfig.host
 source backends/Kconfig
 source accel/Kconfig
+source dump/Kconfig
 source target/Kconfig
 source hw/Kconfig
 source semihosting/Kconfig
dump/Kconfig new file +4 -0
new file mode 100644
index 00000000000..cd6e8f2e137
@@ -0,0 +1,4 @@
+config WINDUMP
+    bool
+    default y if X86_64
+    depends on X86_64
dump/meson.build +2 -1
index 4277ce9328a..26e1561ed48 100644
@@ -1,2 +1,3 @@
 system_ss.add([files('dump.c', 'dump-hmp-cmds.c'), snappy, lzo])
-specific_ss.add(when: 'CONFIG_SYSTEM_ONLY', if_true: files('win_dump.c'))
+specific_ss.add(when: 'CONFIG_WINDUMP', if_true: files('win_dump-x86.c'))
+system_ss.add(when: 'CONFIG_WINDUMP', if_false: files('win_dump-stubs.c'))
Signature · 1 line
2.52.0
Reviewed-by on the v3 series
#3 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 17 lines · Philippe Mathieu-Daudé

v3:
- Dropped Nikolai patches, rebased again

v2:
- Rebase on Nikolai patches (included) to avoid rebase
- Add Kconfig symbol to only build for x86 targets

Philippe Mathieu-Daudé (2):
dump: Abort in create_win_dump() on non-x86 guests
dump: Build stubs once for non-x86 targets

  dump/win_dump-stubs.c               | 21 +++++++++++++++++++++
  dump/{win_dump.c => win_dump-x86.c} | 20 +-------------------
  Kconfig                             |  1 +
  dump/Kconfig                        |  4 ++++
  dump/meson.build                    |  3 ++-
  5 files changed, 29 insertions(+), 20 deletions(-)
Quoted 4 lines

create mode 100644 dump/win_dump-stubs.c rename dump/{win_dump.c => win_dump-x86.c} (97%) create mode 100644 dump/Kconfig

r~