qemu: use bool in monitor struct

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@redhat.com>
This commit is contained in:
Eric Blake 2013-04-25 20:32:41 -06:00
parent 547a7c778a
commit 764bb5e5aa
6 changed files with 17 additions and 24 deletions

View File

@ -364,11 +364,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:

View File

@ -131,7 +131,7 @@ struct _qemuDomainObjPrivate {
qemuMonitorPtr mon;
virDomainChrSourceDefPtr monConfig;
int monJSON;
bool monJSON;
bool monError;
unsigned long long monStart;

View File

@ -77,8 +77,8 @@ struct _qemuMonitor {
int nextSerial;
unsigned json: 1;
unsigned wait_greeting: 1;
bool json;
bool waitGreeting;
};
static virClassPtr qemuMonitorClass;
@ -357,8 +357,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);
@ -537,7 +537,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;
}
@ -683,7 +683,7 @@ static qemuMonitorPtr
qemuMonitorOpenInternal(virDomainObjPtr vm,
int fd,
bool hasSendFD,
int json,
bool json,
qemuMonitorCallbacksPtr cb)
{
qemuMonitorPtr mon;
@ -716,7 +716,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) {
@ -770,7 +770,7 @@ cleanup:
qemuMonitorPtr
qemuMonitorOpen(virDomainObjPtr vm,
virDomainChrSourceDefPtr config,
int json,
bool json,
qemuMonitorCallbacksPtr cb)
{
int fd;
@ -805,7 +805,7 @@ qemuMonitorOpen(virDomainObjPtr vm,
qemuMonitorPtr qemuMonitorOpenFD(virDomainObjPtr vm,
int sockfd,
int json,
bool json,
qemuMonitorCallbacksPtr cb)
{
return qemuMonitorOpenInternal(vm, sockfd, true, json, cb);

View File

@ -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);

View File

@ -3578,11 +3578,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;
@ -3622,7 +3618,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;

View File

@ -501,7 +501,7 @@ qemuMonitorTestPtr qemuMonitorTestNew(bool json, virDomainXMLOptionPtr xmlopt)
if (!(test->mon = qemuMonitorOpen(test->vm,
&src,
json ? 1 : 0,
json,
&qemuCallbacks)))
goto error;
virObjectLock(test->mon);