int got = nl - (data + used);
for (i = 0; i < strlen(LINE_ENDING); i++)
data[used + got + i] = '\0';
- if (qemuAgentIOProcessLine(mon, data + used, msg) < 0) {
+ if (qemuAgentIOProcessLine(mon, data + used, msg) < 0)
return -1;
- }
used += got + strlen(LINE_ENDING);
} else {
break;
if (is_kvm && (version >= 10000 || kvm_version >= 74))
virQEMUCapsSet(qemuCaps, QEMU_CAPS_VNET_HDR);
- if (strstr(help, ",vhost=")) {
+ if (strstr(help, ",vhost="))
virQEMUCapsSet(qemuCaps, QEMU_CAPS_VHOST_NET);
- }
/* Do not use -no-shutdown if qemu doesn't support it or SIGTERM handling
* is most likely buggy when used with -no-shutdown (which applies for qemu
VIR_FREE(qemuCaps->machineAliases);
VIR_FREE(qemuCaps->machineMaxCpus);
- for (i = 0; i < qemuCaps->ncpuDefinitions; i++) {
+ for (i = 0; i < qemuCaps->ncpuDefinitions; i++)
VIR_FREE(qemuCaps->cpuDefinitions[i]);
- }
VIR_FREE(qemuCaps->cpuDefinitions);
virBitmapFree(qemuCaps->flags);
qemuCaps->arch = VIR_ARCH_NONE;
qemuCaps->usedQMP = false;
- for (i = 0; i < qemuCaps->ncpuDefinitions; i++) {
+ for (i = 0; i < qemuCaps->ncpuDefinitions; i++)
VIR_FREE(qemuCaps->cpuDefinitions[i]);
- }
VIR_FREE(qemuCaps->cpuDefinitions);
qemuCaps->ncpuDefinitions = 0;
size_t i;
for (i = 0; i < nvcpupin; i++) {
- if (vcpuid == vcpupin[i]->vcpuid) {
+ if (vcpuid == vcpupin[i]->vcpuid)
return qemuSetupCgroupEmulatorPin(cgroup, vcpupin[i]->cpumask);
- }
}
return -1;
size_t i;
for (i = 0; i < niothreadspin; i++) {
- if (iothreadid == iothreadspin[i]->vcpuid) {
+ if (iothreadid == iothreadspin[i]->vcpuid)
return qemuSetupCgroupEmulatorPin(cgroup, iothreadspin[i]->cpumask);
- }
}
return -1;
_("network disks are only supported with -drive"));
goto error;
} else {
- if (VIR_STRDUP(file, disk->src->path) < 0) {
+ if (VIR_STRDUP(file, disk->src->path) < 0)
goto error;
- }
}
/* Don't start with source if the tray is open for
start = curr;
/* accept a space in CEPH_ARGS */
- if (STRPREFIX(curr, "CEPH_ARGS=-m ")) {
+ if (STRPREFIX(curr, "CEPH_ARGS=-m "))
start += strlen("CEPH_ARGS=-m ");
- }
if (*start == '\'') {
if (start == curr)
curr++;
if (!entry)
return;
- for (i = 0; i < entry->ref; i++) {
+ for (i = 0; i < entry->ref; i++)
VIR_FREE(entry->domains[i]);
- }
VIR_FREE(entry->domains);
VIR_FREE(entry);
}
size_t i;
virBufferAddLit(buf, "<vcpus>\n");
virBufferAdjustIndent(buf, 2);
- for (i = 0; i < priv->nvcpupids; i++) {
+ for (i = 0; i < priv->nvcpupids; i++)
virBufferAsprintf(buf, "<vcpu pid='%d'/>\n", priv->vcpupids[i]);
- }
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</vcpus>\n");
}
for (i = 0; i < numDomains; i++) {
flags[i] = VIR_DOMAIN_SAVE_RUNNING;
if (virDomainGetState(domains[i], &state, NULL, 0) == 0) {
- if (state == VIR_DOMAIN_PAUSED) {
+ if (state == VIR_DOMAIN_PAUSED)
flags[i] = VIR_DOMAIN_SAVE_PAUSED;
- }
}
virDomainSuspend(domains[i]);
}
"%s", _("domain is pmsuspended"));
goto endjob;
} else if (state != VIR_DOMAIN_PAUSED) {
- if (qemuProcessStopCPUs(driver, vm, reason, QEMU_ASYNC_JOB_NONE) < 0) {
+ if (qemuProcessStopCPUs(driver, vm, reason, QEMU_ASYNC_JOB_NONE) < 0)
goto endjob;
- }
if (eventDetail >= 0) {
event = virDomainEventLifecycleNewFromObj(vm,
switch (action) {
case VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_DESTROY:
- if (doCoreDumpToAutoDumpPath(driver, vm, VIR_DUMP_MEMORY_ONLY) < 0) {
+ if (doCoreDumpToAutoDumpPath(driver, vm, VIR_DUMP_MEMORY_ONLY) < 0)
goto cleanup;
- }
/* fall through */
case VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY:
virDomainAuditStop(vm, "destroyed");
- if (!vm->persistent) {
+ if (!vm->persistent)
qemuDomainRemoveInactive(driver, vm);
- }
break;
case VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_RESTART:
- if (doCoreDumpToAutoDumpPath(driver, vm, VIR_DUMP_MEMORY_ONLY) < 0) {
+ if (doCoreDumpToAutoDumpPath(driver, vm, VIR_DUMP_MEMORY_ONLY) < 0)
goto cleanup;
- }
/* fall through */
case VIR_DOMAIN_LIFECYCLE_CRASH_RESTART:
&targetDef) < 0)
goto cleanup;
- if (flags & VIR_DOMAIN_AFFECT_LIVE) {
+ if (flags & VIR_DOMAIN_AFFECT_LIVE)
targetDef = vm->def;
- }
/* Coverity didn't realize that targetDef must be set if we got here. */
sa_assert(targetDef);
if (ncpumaps > targetDef->vcpus)
ncpumaps = targetDef->vcpus;
- if (ncpumaps < 1) {
+ if (ncpumaps < 1)
goto cleanup;
- }
/* initialize cpumaps */
memset(cpumaps, 0xff, maplen * ncpumaps);
/* initialize cpumaps */
memset(cpumaps, 0xff, maplen);
- if (maxcpu % 8) {
+ if (maxcpu % 8)
cpumaps[maplen - 1] &= (1 << maxcpu % 8) - 1;
- }
if (targetDef->cputune.emulatorpin) {
cpumask = targetDef->cputune.emulatorpin->cpumask;
if (period == 0 && quota == 0)
return 0;
- if (priv->nvcpupids == 0 || priv->vcpupids[0] == vm->pid) {
+ if (priv->nvcpupids == 0 || priv->vcpupids[0] == vm->pid)
return 0;
- }
if (virCgroupNewEmulator(cgroup, false, &cgroup_emulator) < 0)
goto cleanup;
/* average is mandatory, peak and burst are optional. So if no
* average is given, we free inbound/outbound here which causes
* inbound/outbound to not be set. */
- if (!bandwidth->in->average) {
+ if (!bandwidth->in->average)
VIR_FREE(bandwidth->in);
- }
- if (!bandwidth->out->average) {
+ if (!bandwidth->out->average)
VIR_FREE(bandwidth->out);
- }
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
if (VIR_ALLOC(newBandwidth) < 0)
virDomainSnapshotObjPtr snap = payload;
virQEMUSnapReparentPtr rep = data;
- if (rep->err < 0) {
+ if (rep->err < 0)
return;
- }
VIR_FREE(snap->def->parent);
snap->parent = rep->parent;
qemuDomainObjExitMonitor(driver, vm);
endjob:
- if (!qemuDomainObjEndJob(driver, vm)) {
+ if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
- }
cleanup:
if (vm)
}
device = qemuDiskPathToAlias(vm, path, &idx);
- if (!device) {
+ if (!device)
goto endjob;
- }
disk = vm->def->disks[idx];
if (disk->mirror) {
virReportError(VIR_ERR_BLOCK_COPY_ACTIVE,
}
device = qemuDiskPathToAlias(vm, disk, NULL);
- if (!device) {
+ if (!device)
goto endjob;
- }
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
qemuDomainObjEnterMonitor(driver, vm);
goto cleanup;
}
- if (!(devstr = qemuBuildControllerDevStr(vm->def, controller, priv->qemuCaps, NULL))) {
+ if (!(devstr = qemuBuildControllerDevStr(vm->def, controller, priv->qemuCaps, NULL)))
goto cleanup;
- }
}
if (VIR_REALLOC_N(vm->def->controllers, vm->def->ncontrollers+1) < 0)
size_t i;
for (i = 0; i < def->ndisks; i++) {
- if (STREQ(def->disks[i]->dst, dst)) {
+ if (STREQ(def->disks[i]->dst, dst))
return i;
- }
}
return -1;
qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, 0);
endjob:
- if (!qemuMigrationJobFinish(driver, vm)) {
+ if (!qemuMigrationJobFinish(driver, vm))
vm = NULL;
- }
goto cleanup;
}
{
const char *action;
int actionID;
- if (!(action = virJSONValueObjectGetString(data, "action"))) {
+ if (!(action = virJSONValueObjectGetString(data, "action")))
VIR_WARN("missing action in watchdog event");
- }
if (action) {
if ((actionID = qemuMonitorWatchdogActionTypeFromString(action)) < 0) {
VIR_WARN("unknown action %s in watchdog event", action);
action = "ignore";
}
- if ((device = virJSONValueObjectGetString(data, "device")) == NULL) {
+ if ((device = virJSONValueObjectGetString(data, "device")) == NULL)
VIR_WARN("missing device in disk io error event");
- }
if (virJSONValueObjectGetBoolean(data, "nospace", &nospc) == 0 && nospc)
reason = "enospc";
virJSONValuePtr result = NULL;
cmd = qemuMonitorJSONMakeCommand("query-block", NULL);
- if (!cmd) {
+ if (!cmd)
return -1;
- }
ret = qemuMonitorJSONCommand(mon, cmd, &result);
virJSONValuePtr reply = NULL;
cmd = qemuMonitorJSONMakeCommand("system_wakeup", NULL);
- if (!cmd) {
+ if (!cmd)
return -1;
- }
ret = qemuMonitorJSONCommand(mon, cmd, &reply);
*/
if (msg->txLength > 0) {
char *tmp;
- if ((tmp = strchr(msg->txBuffer, '\r'))) {
+ if ((tmp = strchr(msg->txBuffer, '\r')))
*tmp = '\0';
- }
}
/* QEMU echos the command back to us, full of control
skip = strstr(data + used, msg->txBuffer);
/* After the junk we should have a line ending... */
- if (skip) {
+ if (skip)
start = strstr(skip + strlen(msg->txBuffer), LINE_ENDING);
- }
/* ... then our command reply data, following by a (qemu) prompt */
if (start) {
cleanup:
if (vm) {
- if (ret == -1) {
+ if (ret == -1)
ignore_value(qemuProcessKill(vm, VIR_QEMU_PROCESS_KILL_FORCE));
- }
if (virObjectUnref(vm))
virObjectUnlock(vm);
}
VIR_FREE(*path);
/* First look for our magic string */
- if (!(tmp = strstr(haystack + *offset, needle))) {
+ if (!(tmp = strstr(haystack + *offset, needle)))
return 1;
- }
tmp += sizeof(needle);
dev = tmp;
priv->agentError = true;
}
- if (qemuUpdateActivePCIHostdevs(driver, obj->def) < 0) {
+ if (qemuUpdateActivePCIHostdevs(driver, obj->def) < 0)
goto error;
- }
if (qemuUpdateActiveUSBHostdevs(driver, obj->def) < 0)
goto error;
}
VIR_DEBUG("Writing early domain status to disk");
- if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) {
+ if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0)
goto cleanup;
- }
VIR_DEBUG("Waiting for handshake from child");
if (virCommandHandshakeWait(cmd) < 0) {
}
VIR_DEBUG("Labelling done, completing handshake to child");
- if (virCommandHandshakeNotify(cmd) < 0) {
+ if (virCommandHandshakeNotify(cmd) < 0)
goto cleanup;
- }
VIR_DEBUG("Handshake complete, child running");
if (migrateFrom)
/* Clear out dynamically assigned labels */
for (i = 0; i < vm->def->nseclabels; i++) {
- if (vm->def->seclabels[i]->type == VIR_DOMAIN_SECLABEL_DYNAMIC) {
+ if (vm->def->seclabels[i]->type == VIR_DOMAIN_SECLABEL_DYNAMIC)
VIR_FREE(vm->def->seclabels[i]->label);
- }
VIR_FREE(vm->def->seclabels[i]->imagelabel);
}