mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
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.
(cherry picked from commit bbbc982bf5)
This commit is contained in:
18
lib/qemu.c
18
lib/qemu.c
@@ -67,6 +67,7 @@ generic_qmp_test (guestfs_h *g, const char *qmp_command, char **outp)
|
|||||||
CLEANUP_FREE char *line = NULL;
|
CLEANUP_FREE char *line = NULL;
|
||||||
size_t allocsize = 0;
|
size_t allocsize = 0;
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
|
unsigned lineno;
|
||||||
|
|
||||||
guestfs_int_cmd_add_string_unquoted (cmd, "echo ");
|
guestfs_int_cmd_add_string_unquoted (cmd, "echo ");
|
||||||
/* QMP is modal. You have to send the qmp_capabilities command first. */
|
/* 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");
|
perrorf (g, "fdopen");
|
||||||
return -1;
|
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) {
|
if (len == -1 || strstr (line, "\"QMP\"") == NULL) {
|
||||||
parse_failure:
|
parse_failure:
|
||||||
error (g, "did not understand QMP monitor output from %s", g->hv);
|
error (g, "did not understand QMP monitor output from %s", g->hv);
|
||||||
return -1;
|
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)
|
if (len == -1 || strstr (line, "\"return\"") == NULL)
|
||||||
goto parse_failure;
|
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)
|
if (len == -1 || strstr (line, "\"return\"") == NULL)
|
||||||
goto parse_failure;
|
goto parse_failure;
|
||||||
|
|
||||||
*outp = safe_strdup (g, line);
|
*outp = safe_strdup (g, line);
|
||||||
|
|
||||||
/* The other lines we don't care about, so finish parsing here. */
|
/* 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 4 */
|
||||||
ignore_value (getline (&line, &allocsize, fp)); /* line 5 */
|
ignore_value (getline (&line, &allocsize, fp)); /* line 5 */
|
||||||
|
|||||||
Reference in New Issue
Block a user