From bbbc982bf526df1745fe2ca13ec47fac191ca917 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 19 Jan 2026 10:27:24 +0000 Subject: [PATCH] lib/qemu.c: Add debugging to generic_qmp_test() This function fails sometimes on s390x, but it's hard to tell what is going on because of insufficient debugging. --- lib/qemu.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/qemu.c b/lib/qemu.c index 6dab0eb32..d74907573 100644 --- a/lib/qemu.c +++ b/lib/qemu.c @@ -67,6 +67,7 @@ generic_qmp_test (guestfs_h *g, const char *qmp_command, char **outp) CLEANUP_FREE char *line = NULL; size_t allocsize = 0; ssize_t len; + unsigned lineno; guestfs_int_cmd_add_string_unquoted (cmd, "echo "); /* QMP is modal. You have to send the qmp_capabilities command first. */ @@ -106,19 +107,30 @@ generic_qmp_test (guestfs_h *g, const char *qmp_command, char **outp) perrorf (g, "fdopen"); return -1; } - len = getline (&line, &allocsize, fp); /* line 1 */ + + lineno = 1; /* line 1 */ + len = getline (&line, &allocsize, fp); + if (len >= 0) debug (g, "generic_qmp_test: %u: %s", lineno, line); if (len == -1 || strstr (line, "\"QMP\"") == NULL) { parse_failure: error (g, "did not understand QMP monitor output from %s", g->hv); return -1; } - len = getline (&line, &allocsize, fp); /* line 2 */ + + lineno++; /* line 2 */ + len = getline (&line, &allocsize, fp); + if (len >= 0) debug (g, "generic_qmp_test: %u: %s", lineno, line); if (len == -1 || strstr (line, "\"return\"") == NULL) goto parse_failure; - len = getline (&line, &allocsize, fp); /* line 3 */ + + lineno++; /* line 3 */ + len = getline (&line, &allocsize, fp); + if (len >= 0) debug (g, "generic_qmp_test: %u: %s", lineno, line); if (len == -1 || strstr (line, "\"return\"") == NULL) goto parse_failure; + *outp = safe_strdup (g, line); + /* The other lines we don't care about, so finish parsing here. */ ignore_value (getline (&line, &allocsize, fp)); /* line 4 */ ignore_value (getline (&line, &allocsize, fp)); /* line 5 */