Skip to contentSkip to conversation

tests/qtest/libqtest: Do not overwrite child coredump

PATCH In review Philippe Mathieu-Daudé 3 participants 4 messages Jul 7, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/qtest/libqtest: Do not overwrite child coredump

We are interested by the coredump of the child, not the qtest parent. If the child generated a coredump, simply call exit(EXIT_FAILURE) in the parent to avoid overwriting the child coredump.

Fixes 71a268a5fd ("tests/libqtest: Improve kill_qemu()")
---
 tests/qtest/libqtest.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tests/qtest/libqtest.c +6 -1
index 49075b55a1..bd85d01145 100644
@@ -173,7 +173,12 @@ static void kill_qemu(QTestState *s)
         fprintf(stderr, "%s:%d: kill_qemu() detected QEMU death "
                 "from signal %d (%s)%s\n",
                 __FILE__, __LINE__, sig, signame, dump);
-        abort();
+        if (WCOREDUMP(wstatus)) {
+            /* Preserve child coredump */
+            exit(1);
+        } else {
+            abort();
+        }
     }
 }
 
Signature · 1 line
2.21.3
#1 lore raw
Quoted 18 lines · Philippe Mathieu-Daudé

We are interested by the coredump of the child, not the qtest parent. If the child generated a coredump, simply call exit(EXIT_FAILURE) in the parent to avoid overwriting the child coredump.

Fixes 71a268a5fd ("tests/libqtest: Improve kill_qemu()")
---
 tests/qtest/libqtest.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tests/qtest/libqtest.c +0 -0
index 49075b55a1..bd85d01145 100644
@@ -173,7 +173,12 @@ static void kill_qemu(QTestState *s)
         fprintf(stderr, "%s:%d: kill_qemu() detected QEMU death "
                 "from signal %d (%s)%s\n",

tests/qtest/libqtest.c static void kill_qemu(QTestState *s) · line 183

Quoted 10 lines
tests/qtest/libqtest.c +6 -1
                 __FILE__, __LINE__, sig, signame, dump);
-        abort();
+        if (WCOREDUMP(wstatus)) {
+            /* Preserve child coredump */
+            exit(1);
+        } else {
+            abort();
+        }
     }
 }

Would it maybe rather make sense to always use exit(1) unconditionally here?

Thomas

#2 lore raw
Quoted 7 lines · Thomas Huth
Quoted 7 lines

+++ b/tests/qtest/libqtest.c

tests/qtest/libqtest.c +1 -1
@@ -173,7 +173,12 @@ static void kill_qemu(QTestState *s)
         fprintf(stderr, "%s:%d: kill_qemu() detected QEMU death "
                 "from signal %d (%s)%s\n",
                 __FILE__, __LINE__, sig, signame, dump);
-        abort();
+        if (WCOREDUMP(wstatus)) {
Quoted 8 lines

tests/qtest/libqtest.c static void kill_qemu(QTestState *s) · line 183

Quoted 7 lines
tests/qtest/libqtest.c +5 -0
+            /* Preserve child coredump */
+            exit(1);
+        } else {
+            abort();
+        }
     }
 }

Would it maybe rather make sense to always use exit(1) unconditionally here?

But why is it a problem to overwrite the child core dump? Aren't both stashed away if you use the core.PID name as is common?

Paolo

#3 lore raw
Quoted 17 lines · Paolo Bonzini
Quoted 7 lines · Thomas Huth
Quoted 7 lines

+++ b/tests/qtest/libqtest.c

tests/qtest/libqtest.c +1 -1
@@ -173,7 +173,12 @@ static void kill_qemu(QTestState *s)
         fprintf(stderr, "%s:%d: kill_qemu() detected QEMU death "
                 "from signal %d (%s)%s\n",
                 __FILE__, __LINE__, sig, signame, dump);
-        abort();
+        if (WCOREDUMP(wstatus)) {
Quoted 8 lines

tests/qtest/libqtest.c static void kill_qemu(QTestState *s) · line 183

Quoted 7 lines
tests/qtest/libqtest.c +5 -0
+            /* Preserve child coredump */
+            exit(1);
+        } else {
+            abort();
+        }
     }
 }

Would it maybe rather make sense to always use exit(1) unconditionally here?

Quoted 2 lines

But why is it a problem to overwrite the child core dump? Aren't both stashed away if you use the core.PID name as is common?

I'm not sure what you mean. Without this patch, the coredump I get is qtest parent, coredumpctl list the child but the coredump is unavailable. With this patch I don't get the uninteresting (for my uses) qtest parent but the child coredump. I'm using Fedora 30, I don't remember changing the coredumpctl default config. Travis-CI is based on Ubuntu.

Quoted 4 lines

Paolo