As stated in our contributor guidelines, we don't want curly brackets around oneline code block (with some exceptions). Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx> --- src/qemu/qemu_agent.c | 3 +-- src/qemu/qemu_capabilities.c | 15 ++++-------- src/qemu/qemu_cgroup.c | 12 ++++------ src/qemu/qemu_command.c | 42 +++++++++++--------------------- src/qemu/qemu_conf.c | 3 +-- src/qemu/qemu_domain.c | 9 +++---- src/qemu/qemu_driver.c | 57 +++++++++++++++----------------------------- src/qemu/qemu_hotplug.c | 42 +++++++++++--------------------- src/qemu/qemu_migration.c | 18 +++++--------- src/qemu/qemu_monitor_json.c | 30 ++++++++--------------- src/qemu/qemu_monitor_text.c | 9 +++---- src/qemu/qemu_process.c | 36 ++++++++++------------------ 12 files changed, 92 insertions(+), 184 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 9f673bf..8df1330 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -381,9 +381,8 @@ static int qemuAgentIOProcessData(qemuAgentPtr mon, 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; diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index ec6614a..3937870 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -872,9 +872,8 @@ virQEMUCapsInitGuestFromBinary(virCapsPtr caps, kvmbin ? kvmbin : binary, NULL, nmachines, - machines)) == NULL) { + machines)) == NULL) goto cleanup; - } machines = NULL; nmachines = 0; @@ -1178,9 +1177,8 @@ virQEMUCapsComputeCmdFlags(const char *help, 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 @@ -1936,9 +1934,8 @@ void virQEMUCapsDispose(void *obj) 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); @@ -2825,9 +2822,8 @@ virQEMUCapsReset(virQEMUCapsPtr qemuCaps) 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; @@ -2981,9 +2977,8 @@ virQEMUCapsInitHelp(virQEMUCapsPtr qemuCaps, uid_t runUid, gid_t runGid) if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE) && strstr(help, "-device driver,?") && virQEMUCapsExtractDeviceStr(qemuCaps->binary, - qemuCaps, runUid, runGid) < 0) { + qemuCaps, runUid, runGid) < 0) goto cleanup; - } if (virQEMUCapsProbeCPUModels(qemuCaps, runUid, runGid) < 0) goto cleanup; diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index b5bdb36..4b19786 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -294,17 +294,15 @@ qemuSetupHostdevCGroup(virDomainObjPtr vm, if (dev->missing) break; if ((usb = virUSBDeviceNew(usbsrc->bus, usbsrc->device, - NULL)) == NULL) { + NULL)) == NULL) goto cleanup; - } /* oddly, qemuSetupHostUSBDeviceCgroup doesn't ever * reference the usb object we just created */ if (virUSBDeviceFileIterate(usb, qemuSetupHostUSBDeviceCgroup, - vm) < 0) { + vm) < 0) goto cleanup; - } break; case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: { @@ -912,9 +910,8 @@ qemuSetupCgroupVcpuPin(virCgroupPtr cgroup, 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; @@ -929,9 +926,8 @@ qemuSetupCgroupIOThreadsPin(virCgroupPtr cgroup, 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; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index b148d45..51331aa 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -337,9 +337,8 @@ qemuNetworkIfaceConnect(virDomainDefPtr def, } if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VNET_HDR) && - net->model && STREQ(net->model, "virtio")) { + net->model && STREQ(net->model, "virtio")) tap_create_flags |= VIR_NETDEV_TAP_CREATE_VNET_HDR; - } if (cfg->privileged) { if (virNetDevTapCreateInBridgePort(brname, &net->ifname, &net->mac, @@ -378,9 +377,8 @@ qemuNetworkIfaceConnect(virDomainDefPtr def, goto cleanup; if (net->filter && - virDomainConfNWFilterInstantiate(conn, def->uuid, net) < 0) { + virDomainConfNWFilterInstantiate(conn, def->uuid, net) < 0) goto cleanup; - } ret = 0; @@ -973,9 +971,8 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps) */ if (virDomainNetGetActualType(def->nets[i]) != VIR_DOMAIN_NET_TYPE_HOSTDEV && - qemuAssignDeviceNetAlias(def, def->nets[i], i) < 0) { + qemuAssignDeviceNetAlias(def, def->nets[i], i) < 0) return -1; - } } } @@ -1078,9 +1075,8 @@ qemuDomainPrimeVirtioDeviceAddresses(virDomainDefPtr def, for (i = 0; i < def->nnets; i++) { if (STREQ(def->nets[i]->model, "virtio") && - def->nets[i]->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { + def->nets[i]->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) def->nets[i]->info.type = type; - } } for (i = 0; i < def->ncontrollers; i++) { @@ -2010,14 +2006,12 @@ qemuAssignDevicePCISlots(virDomainDefPtr def, STRPREFIX(def->os.machine, "pc-i440") || STREQ(def->os.machine, "pc") || STRPREFIX(def->os.machine, "rhel")) && - qemuValidateDevicePCISlotsPIIX3(def, qemuCaps, addrs) < 0) { + qemuValidateDevicePCISlotsPIIX3(def, qemuCaps, addrs) < 0) goto error; - } if (qemuDomainMachineIsQ35(def) && - qemuDomainValidateDevicePCISlotsQ35(def, qemuCaps, addrs) < 0) { + qemuDomainValidateDevicePCISlotsQ35(def, qemuCaps, addrs) < 0) goto error; - } /* PCI controllers */ for (i = 0; i < def->ncontrollers; i++) { @@ -2073,9 +2067,8 @@ qemuAssignDevicePCISlots(virDomainDefPtr def, * instead of here. */ if ((def->nets[i]->type == VIR_DOMAIN_NET_TYPE_HOSTDEV) || - (def->nets[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)) { + (def->nets[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)) continue; - } if (virDomainPCIAddressReserveNextSlot(addrs, &def->nets[i]->info, flags) < 0) goto error; @@ -8162,9 +8155,8 @@ qemuBuildCommandLine(virConnectPtr conn, } } if (def->clock.offset == VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE && - def->clock.data.timezone) { + def->clock.data.timezone) virCommandAddEnvPair(cmd, "TZ", def->clock.data.timezone); - } for (i = 0; i < def->clock.ntimers; i++) { switch ((virDomainTimerNameType) def->clock.timers[i]->name) { @@ -8290,9 +8282,8 @@ qemuBuildCommandLine(virConnectPtr conn, * watch for this event and do a soft/warm reboot. */ if (monitor_json && allowReboot && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_NO_SHUTDOWN)) { + virQEMUCapsGet(qemuCaps, QEMU_CAPS_NO_SHUTDOWN)) virCommandAddArg(cmd, "-no-shutdown"); - } if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NO_ACPI)) { if (def->features[VIR_DOMAIN_FEATURE_ACPI] != VIR_TRISTATE_SWITCH_ON) @@ -8341,9 +8332,8 @@ qemuBuildCommandLine(virConnectPtr conn, emitBootindex = true; } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX) && (def->os.bootmenu != VIR_TRISTATE_BOOL_YES || - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOT_MENU))) { + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOT_MENU))) emitBootindex = true; - } if (!emitBootindex) { char boot[VIR_DOMAIN_BOOT_LAST+1]; @@ -8542,9 +8532,8 @@ qemuBuildCommandLine(virConnectPtr conn, /* Skip pci-root/pcie-root */ if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI && (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT || - cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT)) { + cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT)) continue; - } /* Only recent QEMU implements a SATA (AHCI) controller */ if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_SATA) { @@ -8799,9 +8788,8 @@ qemuBuildCommandLine(virConnectPtr conn, _("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 @@ -9492,9 +9480,8 @@ qemuBuildCommandLine(virConnectPtr conn, virCommandAddArg(cmd, "-chardev"); if (!(devstr = qemuBuildChrChardevStr(&redirdev->source.chr, redirdev->info.alias, - qemuCaps))) { + qemuCaps))) goto error; - } virCommandAddArg(cmd, devstr); VIR_FREE(devstr); @@ -10081,9 +10068,8 @@ static int qemuStringToArgvEnv(const char *args, 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++; diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 1ae90ff..4764bef 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1018,9 +1018,8 @@ qemuSharedDeviceEntryFree(void *payload, const void *name ATTRIBUTE_UNUSED) 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); } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 0caf1c0..613b735 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -495,9 +495,8 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf, void *data) 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"); } @@ -1025,9 +1024,8 @@ qemuDomainDefPostParse(virDomainDefPtr def, VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE) < 0 || virDomainDefMaybeAddController( def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, 2, - VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE) < 0) { + VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE) < 0) return -1; - } } if (addDefaultMemballoon && !def->memballoon) { @@ -1317,9 +1315,8 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver, retry: if (cfg->maxQueuedJobs && - priv->jobs_queued > cfg->maxQueuedJobs) { + priv->jobs_queued > cfg->maxQueuedJobs) goto error; - } while (!nested && !qemuDomainNestedJobAllowed(priv, job)) { VIR_DEBUG("Waiting for async job (vm=%p name=%s)", obj, obj->def->name); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6e47c8a..0ba8ab1 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -994,9 +994,8 @@ qemuStateStop(void) 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]); } @@ -1839,9 +1838,8 @@ static int qemuDomainSuspend(virDomainPtr dom) "%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, @@ -3221,9 +3219,8 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom, if (!(def = virDomainDefParseString(xmlin, caps, driver->xmlopt, QEMU_EXPECTED_VIRT_TYPES, - VIR_DOMAIN_XML_INACTIVE))) { + VIR_DOMAIN_XML_INACTIVE))) goto endjob; - } if (!qemuDomainDefCheckABIStability(driver, vm->def, def)) { virDomainDefFree(def); goto endjob; @@ -3980,9 +3977,8 @@ doCoreDumpToAutoDumpPath(virQEMUDriverPtr driver, goto cleanup; if (qemuDomainObjBeginAsyncJob(driver, vm, - QEMU_ASYNC_JOB_DUMP) < 0) { + QEMU_ASYNC_JOB_DUMP) < 0) goto cleanup; - } if (!virDomainObjIsActive(vm)) { virReportError(VIR_ERR_OPERATION_INVALID, @@ -4042,9 +4038,8 @@ processGuestPanicEvent(virQEMUDriverPtr driver, 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: @@ -4073,15 +4068,13 @@ processGuestPanicEvent(virQEMUDriverPtr driver, 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: @@ -4854,9 +4847,8 @@ qemuDomainPinVcpuFlags(virDomainPtr dom, goto cleanup; if (snprintf(paramField, VIR_TYPED_PARAM_FIELD_LENGTH, - VIR_DOMAIN_TUNABLE_CPU_VCPUPIN, vcpu) < 0) { + VIR_DOMAIN_TUNABLE_CPU_VCPUPIN, vcpu) < 0) goto cleanup; - } str = virBitmapFormat(pcpumap); if (virTypedParamsAddString(&eventParams, &eventNparams, @@ -4954,9 +4946,8 @@ qemuDomainGetVcpuPinInfo(virDomainPtr dom, &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); @@ -4972,9 +4963,8 @@ qemuDomainGetVcpuPinInfo(virDomainPtr dom, if (ncpumaps > targetDef->vcpus) ncpumaps = targetDef->vcpus; - if (ncpumaps < 1) { + if (ncpumaps < 1) goto cleanup; - } /* initialize cpumaps */ memset(cpumaps, 0xff, maplen * ncpumaps); @@ -5232,9 +5222,8 @@ qemuDomainGetEmulatorPinInfo(virDomainPtr dom, /* 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; @@ -9522,9 +9511,8 @@ qemuSetEmulatorBandwidthLive(virDomainObjPtr vm, virCgroupPtr cgroup, 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; @@ -10500,12 +10488,10 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, /* 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) @@ -13212,9 +13198,8 @@ qemuDomainSnapshotPrepare(virConnectPtr conn, if (dom_disk->src->type == VIR_STORAGE_TYPE_NETWORK && (dom_disk->src->protocol == VIR_STORAGE_NET_PROTOCOL_SHEEPDOG || - dom_disk->src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD)) { + dom_disk->src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD)) break; - } if (vm->def->disks[i]->src->format > 0 && vm->def->disks[i]->src->format != VIR_STORAGE_FILE_QCOW2) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -14847,9 +14832,8 @@ qemuDomainSnapshotReparentChildren(void *payload, virDomainSnapshotObjPtr snap = payload; virQEMUSnapReparentPtr rep = data; - if (rep->err < 0) { + if (rep->err < 0) return; - } VIR_FREE(snap->def->parent); snap->parent = rep->parent; @@ -15023,9 +15007,8 @@ static int qemuDomainQemuMonitorCommand(virDomainPtr domain, const char *cmd, qemuDomainObjExitMonitor(driver, vm); endjob: - if (!qemuDomainObjEndJob(driver, vm)) { + if (!qemuDomainObjEndJob(driver, vm)) vm = NULL; - } cleanup: if (vm) @@ -15892,9 +15875,8 @@ qemuDomainBlockCopyCommon(virDomainObjPtr 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, @@ -16888,9 +16870,8 @@ qemuDomainGetBlockIoTune(virDomainPtr dom, goto endjob; device = qemuDiskPathToAlias(vm, disk, NULL); - if (!device) { + if (!device) goto endjob; - } if (flags & VIR_DOMAIN_AFFECT_LIVE) { priv = vm->privateData; diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 13bcd88..b98ad5e 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -284,9 +284,8 @@ qemuDomainCheckEjectableMedia(virQEMUDriverPtr driver, struct qemuDomainDiskInfo *info; if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK || - disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) { + disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) continue; - } info = qemuMonitorBlockInfoLookup(table, disk->info.alias); if (!info) @@ -468,9 +467,8 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver, 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) @@ -970,9 +968,8 @@ int qemuDomainAttachNetDevice(virConnectPtr conn, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("virtio-s390 net device cannot be hotplugged.")); } else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE) && - virDomainPCIAddressEnsureAddr(priv->pciaddrs, &net->info) < 0) { + virDomainPCIAddressEnsureAddr(priv->pciaddrs, &net->info) < 0) goto cleanup; - } releaseaddr = true; @@ -2002,9 +1999,8 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, /* virtPortProfile: will be examined later, after allocating new actualdev */ if (olddev->tune.sndbuf_specified != newdev->tune.sndbuf_specified || - olddev->tune.sndbuf != newdev->tune.sndbuf) { + olddev->tune.sndbuf != newdev->tune.sndbuf) needReconnect = true; - } if (STRNEQ_NULLABLE(olddev->script, newdev->script)) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", @@ -2029,9 +2025,8 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, */ if (!virDomainDeviceAddressIsValid(&newdev->info, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) && - virDomainDeviceInfoCopy(&newdev->info, &olddev->info) < 0) { + virDomainDeviceInfoCopy(&newdev->info, &olddev->info) < 0) goto cleanup; - } if (!virDevicePCIAddressEqual(&olddev->info.addr.pci, &newdev->info.addr.pci)) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", @@ -2065,9 +2060,8 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, /* (end of device info checks) */ if (STRNEQ_NULLABLE(olddev->filter, newdev->filter) || - !virNWFilterHashTableEqual(olddev->filterparams, newdev->filterparams)) { + !virNWFilterHashTableEqual(olddev->filterparams, newdev->filterparams)) needFilterChange = true; - } /* bandwidth can be modified, and will be checked later */ /* vlan can be modified, and will be checked later */ @@ -2077,9 +2071,8 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, * free it if we fail for any reason */ if (newdev->type == VIR_DOMAIN_NET_TYPE_NETWORK && - networkAllocateActualDevice(vm->def, newdev) < 0) { + networkAllocateActualDevice(vm->def, newdev) < 0) goto cleanup; - } newType = virDomainNetGetActualType(newdev); @@ -2102,9 +2095,8 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, if (STRNEQ_NULLABLE(olddev->data.ethernet.dev, newdev->data.ethernet.dev) || STRNEQ_NULLABLE(olddev->data.ethernet.ipaddr, - newdev->data.ethernet.ipaddr)) { + newdev->data.ethernet.ipaddr)) needReconnect = true; - } break; case VIR_DOMAIN_NET_TYPE_SERVER: @@ -2112,9 +2104,8 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, case VIR_DOMAIN_NET_TYPE_MCAST: if (STRNEQ_NULLABLE(olddev->data.socket.address, newdev->data.socket.address) || - olddev->data.socket.port != newdev->data.socket.port) { + olddev->data.socket.port != newdev->data.socket.port) needReconnect = true; - } break; case VIR_DOMAIN_NET_TYPE_NETWORK: @@ -2133,9 +2124,8 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, case VIR_DOMAIN_NET_TYPE_INTERNAL: if (STRNEQ_NULLABLE(olddev->data.internal.name, - newdev->data.internal.name)) { + newdev->data.internal.name)) needReconnect = true; - } break; case VIR_DOMAIN_NET_TYPE_DIRECT: @@ -2202,9 +2192,8 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, !virNetDevVPortProfileEqual(virDomainNetGetActualVirtPortProfile(olddev), virDomainNetGetActualVirtPortProfile(newdev)) || !virNetDevVlanEqual(virDomainNetGetActualVlan(olddev), - virDomainNetGetActualVlan(newdev))) { + virDomainNetGetActualVlan(newdev))) needReconnect = true; - } if (olddev->linkstate != newdev->linkstate) needLinkStateChange = true; @@ -2249,9 +2238,8 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, } if (needLinkStateChange && - qemuDomainChangeNetLinkState(driver, vm, olddev, newdev->linkstate) < 0) { + qemuDomainChangeNetLinkState(driver, vm, olddev, newdev->linkstate) < 0) goto cleanup; - } if (needReplaceDevDef) { /* the changes above warrant replacing olddev with newdev in @@ -2696,9 +2684,8 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver, VIR_WARN("Failed to remove host device cgroup ACL"); if (virSecurityManagerRestoreHostdevLabel(driver->securityManager, - vm->def, hostdev, NULL) < 0) { + vm->def, hostdev, NULL) < 0) VIR_WARN("Failed to restore host device labelling"); - } virDomainHostdevDefFree(hostdev); @@ -3095,9 +3082,8 @@ qemuFindDisk(virDomainDefPtr def, const char *dst) 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; diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index c797206..3d4b75a 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1206,9 +1206,8 @@ qemuMigrationBakeCookie(qemuMigrationCookiePtr mig, return -1; if (flags & QEMU_MIGRATION_COOKIE_NETWORK && - qemuMigrationCookieAddNetwork(mig, driver, dom) < 0) { + qemuMigrationCookieAddNetwork(mig, driver, dom) < 0) return -1; - } if ((flags & QEMU_MIGRATION_COOKIE_NBD) && qemuMigrationCookieAddNBD(mig, driver, dom) < 0) @@ -1562,9 +1561,8 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver, if (qemuDomainObjEnterMonitorAsync(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT) == 0) { if (qemuMonitorBlockJob(priv->mon, diskAlias, NULL, NULL, 0, - BLOCK_JOB_ABORT, true) < 0) { + BLOCK_JOB_ABORT, true) < 0) VIR_WARN("Unable to cancel block-job on '%s'", diskAlias); - } qemuDomainObjExitMonitor(driver, vm); } else { VIR_WARN("Unable to enter monitor. No block job cancelled"); @@ -1762,9 +1760,8 @@ qemuMigrationIsSafe(virDomainDefPtr def) else if (rc == 1) continue; } else if (disk->src->type == VIR_STORAGE_TYPE_NETWORK && - disk->src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD) { + disk->src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD) continue; - } virReportError(VIR_ERR_MIGRATE_UNSAFE, "%s", _("Migration may lead to data corruption if disks" @@ -2740,9 +2737,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver, goto stop; if (STREQ(protocol, "rdma") && - virProcessSetMaxMemLock(vm->pid, vm->def->mem.hard_limit << 10) < 0) { + virProcessSetMaxMemLock(vm->pid, vm->def->mem.hard_limit << 10) < 0) goto stop; - } if (flags & VIR_MIGRATE_RDMA_PIN_ALL && qemuMigrationSetPinAll(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN) < 0) @@ -2833,9 +2829,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver, qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, 0); endjob: - if (!qemuMigrationJobFinish(driver, vm)) { + if (!qemuMigrationJobFinish(driver, vm)) vm = NULL; - } goto cleanup; } @@ -3733,9 +3728,8 @@ qemuMigrationRun(virQEMUDriverPtr driver, cookieFlags |= QEMU_MIGRATION_COOKIE_PERSISTENT; if (ret == 0 && qemuMigrationBakeCookie(mig, driver, vm, cookieout, - cookieoutlen, cookieFlags) < 0) { + cookieoutlen, cookieFlags) < 0) VIR_WARN("Unable to encode migration cookie"); - } qemuMigrationCookieFree(mig); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 7870664..7306d7b 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -565,9 +565,8 @@ static void qemuMonitorJSONHandleWatchdog(qemuMonitorPtr mon, virJSONValuePtr da { 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); @@ -602,9 +601,8 @@ qemuMonitorJSONHandleIOError(qemuMonitorPtr mon, virJSONValuePtr data) 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"; @@ -1476,9 +1474,8 @@ qemuMonitorJSONSetMemoryStatsPeriod(qemuMonitorPtr mon, prop.val.iv = period; if (qemuMonitorJSONSetObjectProperty(mon, balloonpath, "guest-stats-polling-interval", - &prop) < 0) { + &prop) < 0) return -1; - } return 0; } @@ -1654,19 +1651,16 @@ qemuMonitorJSONDevGetBlockExtent(virJSONValuePtr dev, virJSONValuePtr parent; if ((parent = virJSONValueObjectGet(dev, "parent")) == NULL || - parent->type != VIR_JSON_TYPE_OBJECT) { + parent->type != VIR_JSON_TYPE_OBJECT) return QEMU_MONITOR_BLOCK_EXTENT_ERROR_NOPARENT; - } if ((stats = virJSONValueObjectGet(parent, "stats")) == NULL || - stats->type != VIR_JSON_TYPE_OBJECT) { + stats->type != VIR_JSON_TYPE_OBJECT) return QEMU_MONITOR_BLOCK_EXTENT_ERROR_NOSTATS; - } if (virJSONValueObjectGetNumberUlong(stats, "wr_highest_offset", - extent) < 0) { + extent) < 0) return QEMU_MONITOR_BLOCK_EXTENT_ERROR_NOOFFSET; - } return QEMU_MONITOR_BLOCK_EXTENT_ERROR_OK; } @@ -4411,9 +4405,8 @@ int qemuMonitorJSONGetBlockIoThrottle(qemuMonitorPtr mon, virJSONValuePtr result = NULL; cmd = qemuMonitorJSONMakeCommand("query-block", NULL); - if (!cmd) { + if (!cmd) return -1; - } ret = qemuMonitorJSONCommand(mon, cmd, &result); @@ -4445,9 +4438,8 @@ int qemuMonitorJSONSystemWakeup(qemuMonitorPtr mon) virJSONValuePtr reply = NULL; cmd = qemuMonitorJSONMakeCommand("system_wakeup", NULL); - if (!cmd) { + if (!cmd) return -1; - } ret = qemuMonitorJSONCommand(mon, cmd, &reply); @@ -5368,9 +5360,8 @@ int qemuMonitorJSONGetObjectProps(qemuMonitorPtr mon, ret = qemuMonitorJSONCommand(mon, cmd, &reply); if (ret == 0 && - qemuMonitorJSONHasError(reply, "DeviceNotFound")) { + qemuMonitorJSONHasError(reply, "DeviceNotFound")) goto cleanup; - } if (ret == 0) ret = qemuMonitorJSONCheckError(cmd, reply); @@ -5841,9 +5832,8 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID, bool telnet; if (!(backend = virJSONValueNewObject()) || - !(data = virJSONValueNewObject())) { + !(data = virJSONValueNewObject())) goto error; - } switch ((virDomainChrType) chr->type) { case VIR_DOMAIN_CHR_TYPE_NULL: diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index 46d2782..95736be 100644 --- a/src/qemu/qemu_monitor_text.c +++ b/src/qemu/qemu_monitor_text.c @@ -123,9 +123,8 @@ int qemuMonitorTextIOProcess(qemuMonitorPtr mon ATTRIBUTE_UNUSED, */ 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 @@ -144,9 +143,8 @@ int qemuMonitorTextIOProcess(qemuMonitorPtr mon ATTRIBUTE_UNUSED, 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) { @@ -634,9 +632,8 @@ static int qemuMonitorParseBalloonInfo(char *text, * loop. */ if (parseMemoryStat(&p, VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON, - "actual=", &stats[nr_stats_found]) == 1) { + "actual=", &stats[nr_stats_found]) == 1) nr_stats_found++; - } while (*p && nr_stats_found < nr_stats) { if (parseMemoryStat(&p, VIR_DOMAIN_MEMORY_STAT_SWAP_IN, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 24e5f0f..e0693f8 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -626,9 +626,8 @@ qemuProcessFakeReboot(void *opaque) cleanup: if (vm) { - if (ret == -1) { + if (ret == -1) ignore_value(qemuProcessKill(vm, VIR_QEMU_PROCESS_KILL_FORCE)); - } if (virObjectUnref(vm)) virObjectUnlock(vm); } @@ -1829,9 +1828,8 @@ qemuProcessExtractTTYPath(const char *haystack, 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; @@ -2363,9 +2361,8 @@ qemuProcessSetVcpuAffinities(virDomainObjPtr vm) continue; if (virProcessSetAffinity(priv->vcpupids[n], - pininfo->cpumask) < 0) { + pininfo->cpumask) < 0) goto cleanup; - } } ret = 0; @@ -3203,9 +3200,8 @@ qemuProcessRecoverMigration(virQEMUDriverPtr driver, vm->def->name); if (qemuProcessStartCPUs(driver, vm, conn, VIR_DOMAIN_RUNNING_UNPAUSED, - QEMU_ASYNC_JOB_NONE) < 0) { + QEMU_ASYNC_JOB_NONE) < 0) VIR_WARN("Could not resume domain %s", vm->def->name); - } break; case QEMU_MIGRATION_PHASE_FINISH3: @@ -3244,9 +3240,8 @@ qemuProcessRecoverMigration(virQEMUDriverPtr driver, reason == VIR_DOMAIN_PAUSED_UNKNOWN)) { if (qemuProcessStartCPUs(driver, vm, conn, VIR_DOMAIN_RUNNING_UNPAUSED, - QEMU_ASYNC_JOB_NONE) < 0) { + QEMU_ASYNC_JOB_NONE) < 0) VIR_WARN("Could not resume domain %s", vm->def->name); - } } break; @@ -3265,9 +3260,8 @@ qemuProcessRecoverMigration(virQEMUDriverPtr driver, reason == VIR_DOMAIN_PAUSED_UNKNOWN)) { if (qemuProcessStartCPUs(driver, vm, conn, VIR_DOMAIN_RUNNING_UNPAUSED, - QEMU_ASYNC_JOB_NONE) < 0) { + QEMU_ASYNC_JOB_NONE) < 0) VIR_WARN("Could not resume domain %s", vm->def->name); - } } break; @@ -3467,9 +3461,8 @@ qemuProcessReconnect(void *opaque) 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; @@ -4209,9 +4202,8 @@ int qemuProcessStart(virConnectPtr conn, !graphics->data.vnc.autoport) { if (virPortAllocatorSetUsed(driver->remotePorts, graphics->data.vnc.port, - true) < 0) { + true) < 0) goto cleanup; - } graphics->data.vnc.portReserved = true; @@ -4474,9 +4466,8 @@ int qemuProcessStart(virConnectPtr conn, VIR_DEBUG("Setting up security labelling"); if (virSecurityManagerSetChildProcessLabel(driver->securityManager, - vm->def, cmd) < 0) { + vm->def, cmd) < 0) goto cleanup; - } virCommandSetOutputFD(cmd, &logfile); virCommandSetErrorFD(cmd, &logfile); @@ -4505,9 +4496,8 @@ int qemuProcessStart(virConnectPtr conn, } 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) { @@ -4556,9 +4546,8 @@ int qemuProcessStart(virConnectPtr conn, } 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) @@ -4923,9 +4912,8 @@ void qemuProcessStop(virQEMUDriverPtr driver, /* 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); } -- 2.1.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list