} \
} while (0)
+static bool first = true;
static void
printLineSkipEmpty(const char *line,
qemuMonitorSend(qemuMonitorPtr mon,
qemuMonitorMessagePtr msg)
{
+ char *reformatted;
+
REAL_SYM(realQemuMonitorSend);
- fprintf(stderr, "%s", msg->txBuffer);
+ if (!(reformatted = virJSONStringReformat(msg->txBuffer, true))) {
+ fprintf(stderr, "Failed to reformat command string '%s'\n", msg->txBuffer);
+ abort();
+ }
+
+ if (first)
+ first = false;
+ else
+ printLineSkipEmpty("\n", stdout);
+
+ printLineSkipEmpty(reformatted, stdout);
+ VIR_FREE(reformatted);
return realQemuMonitorSend(mon, msg);
}
const char *line,
qemuMonitorMessagePtr msg)
{
- static bool first = true;
virJSONValuePtr value = NULL;
char *json = NULL;
int ret;
abort();
}
- if (first) {
+ /* Ignore QMP greeting */
+ if (virJSONValueObjectHasKey(value, "QMP"))
+ goto cleanup;
+
+ if (first)
first = false;
- } else {
- /* Ignore QMP greeting if it's not the first one */
- if (virJSONValueObjectHasKey(value, "QMP"))
- goto cleanup;
- putchar('\n');
- }
+ else
+ printLineSkipEmpty("\n", stdout);
printLineSkipEmpty(json, stdout);
}