mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
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:
parent
547a7c778a
commit
764bb5e5aa
@ -364,11 +364,8 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, void *data)
|
|||||||
priv->monConfig->type = VIR_DOMAIN_CHR_TYPE_PTY;
|
priv->monConfig->type = VIR_DOMAIN_CHR_TYPE_PTY;
|
||||||
VIR_FREE(tmp);
|
VIR_FREE(tmp);
|
||||||
|
|
||||||
if (virXPathBoolean("count(./monitor[@json = '1']) > 0", ctxt)) {
|
priv->monJSON = virXPathBoolean("count(./monitor[@json = '1']) > 0",
|
||||||
priv->monJSON = 1;
|
ctxt) > 0;
|
||||||
} else {
|
|
||||||
priv->monJSON = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (priv->monConfig->type) {
|
switch (priv->monConfig->type) {
|
||||||
case VIR_DOMAIN_CHR_TYPE_PTY:
|
case VIR_DOMAIN_CHR_TYPE_PTY:
|
||||||
|
@ -131,7 +131,7 @@ struct _qemuDomainObjPrivate {
|
|||||||
|
|
||||||
qemuMonitorPtr mon;
|
qemuMonitorPtr mon;
|
||||||
virDomainChrSourceDefPtr monConfig;
|
virDomainChrSourceDefPtr monConfig;
|
||||||
int monJSON;
|
bool monJSON;
|
||||||
bool monError;
|
bool monError;
|
||||||
unsigned long long monStart;
|
unsigned long long monStart;
|
||||||
|
|
||||||
|
@ -77,8 +77,8 @@ struct _qemuMonitor {
|
|||||||
|
|
||||||
int nextSerial;
|
int nextSerial;
|
||||||
|
|
||||||
unsigned json: 1;
|
bool json;
|
||||||
unsigned wait_greeting: 1;
|
bool waitGreeting;
|
||||||
};
|
};
|
||||||
|
|
||||||
static virClassPtr qemuMonitorClass;
|
static virClassPtr qemuMonitorClass;
|
||||||
@ -357,8 +357,8 @@ qemuMonitorIOProcess(qemuMonitorPtr mon)
|
|||||||
if (len < 0)
|
if (len < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (len && mon->wait_greeting)
|
if (len && mon->waitGreeting)
|
||||||
mon->wait_greeting = 0;
|
mon->waitGreeting = false;
|
||||||
|
|
||||||
if (len < mon->bufferOffset) {
|
if (len < mon->bufferOffset) {
|
||||||
memmove(mon->buffer, mon->buffer + len, mon->bufferOffset - len);
|
memmove(mon->buffer, mon->buffer + len, mon->bufferOffset - len);
|
||||||
@ -537,7 +537,7 @@ static void qemuMonitorUpdateWatch(qemuMonitorPtr mon)
|
|||||||
events |= VIR_EVENT_HANDLE_READABLE;
|
events |= VIR_EVENT_HANDLE_READABLE;
|
||||||
|
|
||||||
if ((mon->msg && mon->msg->txOffset < mon->msg->txLength) &&
|
if ((mon->msg && mon->msg->txOffset < mon->msg->txLength) &&
|
||||||
!mon->wait_greeting)
|
!mon->waitGreeting)
|
||||||
events |= VIR_EVENT_HANDLE_WRITABLE;
|
events |= VIR_EVENT_HANDLE_WRITABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -683,7 +683,7 @@ static qemuMonitorPtr
|
|||||||
qemuMonitorOpenInternal(virDomainObjPtr vm,
|
qemuMonitorOpenInternal(virDomainObjPtr vm,
|
||||||
int fd,
|
int fd,
|
||||||
bool hasSendFD,
|
bool hasSendFD,
|
||||||
int json,
|
bool json,
|
||||||
qemuMonitorCallbacksPtr cb)
|
qemuMonitorCallbacksPtr cb)
|
||||||
{
|
{
|
||||||
qemuMonitorPtr mon;
|
qemuMonitorPtr mon;
|
||||||
@ -716,7 +716,7 @@ qemuMonitorOpenInternal(virDomainObjPtr vm,
|
|||||||
mon->vm = vm;
|
mon->vm = vm;
|
||||||
mon->json = json;
|
mon->json = json;
|
||||||
if (json)
|
if (json)
|
||||||
mon->wait_greeting = 1;
|
mon->waitGreeting = true;
|
||||||
mon->cb = cb;
|
mon->cb = cb;
|
||||||
|
|
||||||
if (virSetCloseExec(mon->fd) < 0) {
|
if (virSetCloseExec(mon->fd) < 0) {
|
||||||
@ -770,7 +770,7 @@ cleanup:
|
|||||||
qemuMonitorPtr
|
qemuMonitorPtr
|
||||||
qemuMonitorOpen(virDomainObjPtr vm,
|
qemuMonitorOpen(virDomainObjPtr vm,
|
||||||
virDomainChrSourceDefPtr config,
|
virDomainChrSourceDefPtr config,
|
||||||
int json,
|
bool json,
|
||||||
qemuMonitorCallbacksPtr cb)
|
qemuMonitorCallbacksPtr cb)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
@ -805,7 +805,7 @@ qemuMonitorOpen(virDomainObjPtr vm,
|
|||||||
|
|
||||||
qemuMonitorPtr qemuMonitorOpenFD(virDomainObjPtr vm,
|
qemuMonitorPtr qemuMonitorOpenFD(virDomainObjPtr vm,
|
||||||
int sockfd,
|
int sockfd,
|
||||||
int json,
|
bool json,
|
||||||
qemuMonitorCallbacksPtr cb)
|
qemuMonitorCallbacksPtr cb)
|
||||||
{
|
{
|
||||||
return qemuMonitorOpenInternal(vm, sockfd, true, json, cb);
|
return qemuMonitorOpenInternal(vm, sockfd, true, json, cb);
|
||||||
|
@ -147,12 +147,12 @@ char *qemuMonitorUnescapeArg(const char *in);
|
|||||||
|
|
||||||
qemuMonitorPtr qemuMonitorOpen(virDomainObjPtr vm,
|
qemuMonitorPtr qemuMonitorOpen(virDomainObjPtr vm,
|
||||||
virDomainChrSourceDefPtr config,
|
virDomainChrSourceDefPtr config,
|
||||||
int json,
|
bool json,
|
||||||
qemuMonitorCallbacksPtr cb)
|
qemuMonitorCallbacksPtr cb)
|
||||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4);
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4);
|
||||||
qemuMonitorPtr qemuMonitorOpenFD(virDomainObjPtr vm,
|
qemuMonitorPtr qemuMonitorOpenFD(virDomainObjPtr vm,
|
||||||
int sockfd,
|
int sockfd,
|
||||||
int json,
|
bool json,
|
||||||
qemuMonitorCallbacksPtr cb)
|
qemuMonitorCallbacksPtr cb)
|
||||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4);
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4);
|
||||||
|
|
||||||
|
@ -3578,11 +3578,7 @@ int qemuProcessStart(virConnectPtr conn,
|
|||||||
if (qemuProcessPrepareMonitorChr(cfg, priv->monConfig, vm->def->name) < 0)
|
if (qemuProcessPrepareMonitorChr(cfg, priv->monConfig, vm->def->name) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MONITOR_JSON))
|
priv->monJSON = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MONITOR_JSON);
|
||||||
priv->monJSON = 1;
|
|
||||||
else
|
|
||||||
priv->monJSON = 0;
|
|
||||||
|
|
||||||
priv->monError = false;
|
priv->monError = false;
|
||||||
priv->monStart = 0;
|
priv->monStart = 0;
|
||||||
priv->gotShutdown = false;
|
priv->gotShutdown = false;
|
||||||
@ -3622,7 +3618,7 @@ int qemuProcessStart(virConnectPtr conn,
|
|||||||
|
|
||||||
VIR_DEBUG("Building emulator command line");
|
VIR_DEBUG("Building emulator command line");
|
||||||
if (!(cmd = qemuBuildCommandLine(conn, driver, vm->def, priv->monConfig,
|
if (!(cmd = qemuBuildCommandLine(conn, driver, vm->def, priv->monConfig,
|
||||||
priv->monJSON != 0, priv->qemuCaps,
|
priv->monJSON, priv->qemuCaps,
|
||||||
migrateFrom, stdin_fd, snapshot, vmop)))
|
migrateFrom, stdin_fd, snapshot, vmop)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
@ -501,7 +501,7 @@ qemuMonitorTestPtr qemuMonitorTestNew(bool json, virDomainXMLOptionPtr xmlopt)
|
|||||||
|
|
||||||
if (!(test->mon = qemuMonitorOpen(test->vm,
|
if (!(test->mon = qemuMonitorOpen(test->vm,
|
||||||
&src,
|
&src,
|
||||||
json ? 1 : 0,
|
json,
|
||||||
&qemuCallbacks)))
|
&qemuCallbacks)))
|
||||||
goto error;
|
goto error;
|
||||||
virObjectLock(test->mon);
|
virObjectLock(test->mon);
|
||||||
|
Loading…
Reference in New Issue
Block a user