Follows on the heels of other bool cleanups, such as commit 93002b98. * src/qemu/qemu_monitor.h (qemuMonitorOpen, qemuMonitorOpenFD): Update json parameter type. * src/qemu/qemu_monitor.c (qemuMonitorOpen, qemuMonitorOpenFD): Likewise. (_qemuMonitor): Adjust field type. * src/qemu/qemu_domain.h (_qemuDomainObjPrivate): Likewise. * src/qemu/qemu_domain.c (qemuDomainObjPrivateXMLParse): Adjust client. * src/qemu/qemu_process.c (qemuProcessStart): Likewise. * tests/qemumonitortestutils.c (qemuMonitorTestNew): Likewise. Signed-off-by: Eric Blake <eblake@xxxxxxxxxx> --- src/qemu/qemu_domain.c | 7 ++----- src/qemu/qemu_domain.h | 2 +- src/qemu/qemu_monitor.c | 18 +++++++++--------- src/qemu/qemu_monitor.h | 4 ++-- src/qemu/qemu_process.c | 8 ++------ tests/qemumonitortestutils.c | 2 +- 6 files changed, 17 insertions(+), 24 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index d927716..8a476e6 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -363,11 +363,8 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, void *data) priv->monConfig->type = VIR_DOMAIN_CHR_TYPE_PTY; VIR_FREE(tmp); - if (virXPathBoolean("count(./monitor[@json = '1']) > 0", ctxt)) { - priv->monJSON = 1; - } else { - priv->monJSON = 0; - } + priv->monJSON = virXPathBoolean("count(./monitor[@json = '1']) > 0", + ctxt) > 0; switch (priv->monConfig->type) { case VIR_DOMAIN_CHR_TYPE_PTY: diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index da04377..81e2f91 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -131,7 +131,7 @@ struct _qemuDomainObjPrivate { qemuMonitorPtr mon; virDomainChrSourceDefPtr monConfig; - int monJSON; + bool monJSON; bool monError; unsigned long long monStart; diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 1b1d4a1..5f714d6 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -76,8 +76,8 @@ struct _qemuMonitor { int nextSerial; - unsigned json: 1; - unsigned wait_greeting: 1; + bool json; + bool waitGreeting; }; static virClassPtr qemuMonitorClass; @@ -356,8 +356,8 @@ qemuMonitorIOProcess(qemuMonitorPtr mon) if (len < 0) return -1; - if (len && mon->wait_greeting) - mon->wait_greeting = 0; + if (len && mon->waitGreeting) + mon->waitGreeting = false; if (len < mon->bufferOffset) { memmove(mon->buffer, mon->buffer + len, mon->bufferOffset - len); @@ -536,7 +536,7 @@ static void qemuMonitorUpdateWatch(qemuMonitorPtr mon) events |= VIR_EVENT_HANDLE_READABLE; if ((mon->msg && mon->msg->txOffset < mon->msg->txLength) && - !mon->wait_greeting) + !mon->waitGreeting) events |= VIR_EVENT_HANDLE_WRITABLE; } @@ -682,7 +682,7 @@ static qemuMonitorPtr qemuMonitorOpenInternal(virDomainObjPtr vm, int fd, bool hasSendFD, - int json, + bool json, qemuMonitorCallbacksPtr cb) { qemuMonitorPtr mon; @@ -715,7 +715,7 @@ qemuMonitorOpenInternal(virDomainObjPtr vm, mon->vm = vm; mon->json = json; if (json) - mon->wait_greeting = 1; + mon->waitGreeting = true; mon->cb = cb; if (virSetCloseExec(mon->fd) < 0) { @@ -769,7 +769,7 @@ cleanup: qemuMonitorPtr qemuMonitorOpen(virDomainObjPtr vm, virDomainChrSourceDefPtr config, - int json, + bool json, qemuMonitorCallbacksPtr cb) { int fd; @@ -804,7 +804,7 @@ qemuMonitorOpen(virDomainObjPtr vm, qemuMonitorPtr qemuMonitorOpenFD(virDomainObjPtr vm, int sockfd, - int json, + bool json, qemuMonitorCallbacksPtr cb) { return qemuMonitorOpenInternal(vm, sockfd, true, json, cb); diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index f39f009..527da0a 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -147,12 +147,12 @@ char *qemuMonitorUnescapeArg(const char *in); qemuMonitorPtr qemuMonitorOpen(virDomainObjPtr vm, virDomainChrSourceDefPtr config, - int json, + bool json, qemuMonitorCallbacksPtr cb) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4); qemuMonitorPtr qemuMonitorOpenFD(virDomainObjPtr vm, int sockfd, - int json, + bool json, qemuMonitorCallbacksPtr cb) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index f12d7d5..3bf9443 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3550,11 +3550,7 @@ int qemuProcessStart(virConnectPtr conn, if (qemuProcessPrepareMonitorChr(cfg, priv->monConfig, vm->def->name) < 0) goto cleanup; - if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MONITOR_JSON)) - priv->monJSON = 1; - else - priv->monJSON = 0; - + priv->monJSON = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MONITOR_JSON); priv->monError = false; priv->monStart = 0; priv->gotShutdown = false; @@ -3594,7 +3590,7 @@ int qemuProcessStart(virConnectPtr conn, VIR_DEBUG("Building emulator command line"); if (!(cmd = qemuBuildCommandLine(conn, driver, vm->def, priv->monConfig, - priv->monJSON != 0, priv->qemuCaps, + priv->monJSON, priv->qemuCaps, migrateFrom, stdin_fd, snapshot, vmop))) goto cleanup; diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index 43e7cb9..11d264e 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -502,7 +502,7 @@ qemuMonitorTestPtr qemuMonitorTestNew(bool json, virDomainXMLOptionPtr xmlopt) if (!(test->mon = qemuMonitorOpen(test->vm, &src, - json ? 1 : 0, + json, &qemuCallbacks))) goto error; virObjectLock(test->mon); -- 1.8.1.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list