mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
maint: use consistent if-else braces in qemu
I'm about to add a syntax check that enforces our documented HACKING style of always using matching {} on if-else statements. This commit focuses on the qemu driver. * src/qemu/qemu_command.c (qemuParseISCSIString) (qemuParseCommandLineDisk, qemuParseCommandLine) (qemuBuildSmpArgStr, qemuBuildCommandLine) (qemuParseCommandLineDisk, qemuParseCommandLineSmp): Correct use of {}. * src/qemu/qemu_capabilities.c (virQEMUCapsProbeCPUModels): Likewise. * src/qemu/qemu_driver.c (qemuDomainCoreDumpWithFormat) (qemuDomainRestoreFlags, qemuDomainGetInfo) (qemuDomainMergeBlkioDevice): Likewise. * src/qemu/qemu_hotplug.c (qemuDomainAttachNetDevice): Likewise. * src/qemu/qemu_monitor_text.c (qemuMonitorTextCreateSnapshot) (qemuMonitorTextLoadSnapshot, qemuMonitorTextDeleteSnapshot): Likewise. * src/qemu/qemu_process.c (qemuProcessStop): Likewise. Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
ff78ff7c93
commit
44e30277d8
@ -629,11 +629,11 @@ virQEMUCapsProbeCPUModels(virQEMUCapsPtr qemuCaps, uid_t runUid, gid_t runGid)
|
||||
virCommandPtr cmd;
|
||||
|
||||
if (qemuCaps->arch == VIR_ARCH_I686 ||
|
||||
qemuCaps->arch == VIR_ARCH_X86_64)
|
||||
qemuCaps->arch == VIR_ARCH_X86_64) {
|
||||
parse = virQEMUCapsParseX86Models;
|
||||
else if (qemuCaps->arch == VIR_ARCH_PPC64)
|
||||
} else if (qemuCaps->arch == VIR_ARCH_PPC64) {
|
||||
parse = virQEMUCapsParsePPCModels;
|
||||
else {
|
||||
} else {
|
||||
VIR_DEBUG("don't know how to parse %s CPU models",
|
||||
virArchToString(qemuCaps->arch));
|
||||
return 0;
|
||||
|
@ -2791,9 +2791,9 @@ qemuParseISCSIString(virDomainDiskDefPtr def)
|
||||
if (uri->path &&
|
||||
(slash = strchr(uri->path + 1, '/')) != NULL) {
|
||||
|
||||
if (slash[1] == '\0')
|
||||
if (slash[1] == '\0') {
|
||||
*slash = '\0';
|
||||
else if (virStrToLong_ui(slash + 1, NULL, 10, &lun) == -1) {
|
||||
} else if (virStrToLong_ui(slash + 1, NULL, 10, &lun) == -1) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("invalid name '%s' for iSCSI disk"),
|
||||
def->src->path);
|
||||
@ -6491,8 +6491,7 @@ qemuBuildSmpArgStr(const virDomainDef *def,
|
||||
virBufferAsprintf(&buf, ",sockets=%u", def->cpu->sockets);
|
||||
virBufferAsprintf(&buf, ",cores=%u", def->cpu->cores);
|
||||
virBufferAsprintf(&buf, ",threads=%u", def->cpu->threads);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
virBufferAsprintf(&buf, ",sockets=%u", def->maxvcpus);
|
||||
virBufferAsprintf(&buf, ",cores=%u", 1);
|
||||
virBufferAsprintf(&buf, ",threads=%u", 1);
|
||||
@ -7807,10 +7806,10 @@ qemuBuildCommandLine(virConnectPtr conn,
|
||||
virDomainTimerTickpolicyTypeToString(def->clock.timers[i]->tickpolicy));
|
||||
goto error;
|
||||
}
|
||||
} else if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_RTC)
|
||||
&& (def->clock.timers[i]->tickpolicy
|
||||
!= VIR_DOMAIN_TIMER_TICKPOLICY_DELAY)
|
||||
&& (def->clock.timers[i]->tickpolicy != -1)) {
|
||||
} else if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_RTC) &&
|
||||
(def->clock.timers[i]->tickpolicy
|
||||
!= VIR_DOMAIN_TIMER_TICKPOLICY_DELAY) &&
|
||||
(def->clock.timers[i]->tickpolicy != -1)) {
|
||||
/* a non-default rtc policy was given, but there is no
|
||||
way to implement it in this version of qemu */
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
@ -9986,8 +9985,9 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
|
||||
if (VIR_STRDUP(def->src->path, vdi) < 0)
|
||||
goto error;
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
def->src->type = VIR_STORAGE_TYPE_FILE;
|
||||
}
|
||||
} else {
|
||||
def->src->type = VIR_STORAGE_TYPE_FILE;
|
||||
}
|
||||
@ -10000,20 +10000,22 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
|
||||
_("pseries systems do not support ide devices '%s'"), val);
|
||||
goto error;
|
||||
}
|
||||
} else if (STREQ(values[i], "scsi"))
|
||||
} else if (STREQ(values[i], "scsi")) {
|
||||
def->bus = VIR_DOMAIN_DISK_BUS_SCSI;
|
||||
else if (STREQ(values[i], "virtio"))
|
||||
} else if (STREQ(values[i], "virtio")) {
|
||||
def->bus = VIR_DOMAIN_DISK_BUS_VIRTIO;
|
||||
else if (STREQ(values[i], "xen"))
|
||||
} else if (STREQ(values[i], "xen")) {
|
||||
def->bus = VIR_DOMAIN_DISK_BUS_XEN;
|
||||
else if (STREQ(values[i], "sd"))
|
||||
} else if (STREQ(values[i], "sd")) {
|
||||
def->bus = VIR_DOMAIN_DISK_BUS_SD;
|
||||
}
|
||||
} else if (STREQ(keywords[i], "media")) {
|
||||
if (STREQ(values[i], "cdrom")) {
|
||||
def->device = VIR_DOMAIN_DISK_DEVICE_CDROM;
|
||||
def->src->readonly = true;
|
||||
} else if (STREQ(values[i], "floppy"))
|
||||
} else if (STREQ(values[i], "floppy")) {
|
||||
def->device = VIR_DOMAIN_DISK_DEVICE_FLOPPY;
|
||||
}
|
||||
} else if (STREQ(keywords[i], "format")) {
|
||||
if (VIR_STRDUP(def->src->driverName, "qemu") < 0)
|
||||
goto error;
|
||||
@ -10888,8 +10890,9 @@ qemuParseCommandLineSmp(virDomainDefPtr dom,
|
||||
cpu->sockets = sockets;
|
||||
cpu->cores = cores;
|
||||
cpu->threads = threads;
|
||||
} else if (sockets || cores || threads)
|
||||
} else if (sockets || cores || threads) {
|
||||
goto syntax;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
@ -11215,9 +11218,9 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
|
||||
if (!(disk = virDomainDiskDefNew()))
|
||||
goto error;
|
||||
|
||||
if (STRPREFIX(val, "/dev/"))
|
||||
if (STRPREFIX(val, "/dev/")) {
|
||||
disk->src->type = VIR_STORAGE_TYPE_BLOCK;
|
||||
else if (STRPREFIX(val, "nbd:")) {
|
||||
} else if (STRPREFIX(val, "nbd:")) {
|
||||
disk->src->type = VIR_STORAGE_TYPE_NETWORK;
|
||||
disk->src->protocol = VIR_STORAGE_NET_PROTOCOL_NBD;
|
||||
} else if (STRPREFIX(val, "rbd:")) {
|
||||
@ -11231,8 +11234,9 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
|
||||
disk->src->type = VIR_STORAGE_TYPE_NETWORK;
|
||||
disk->src->protocol = VIR_STORAGE_NET_PROTOCOL_SHEEPDOG;
|
||||
val += strlen("sheepdog:");
|
||||
} else
|
||||
} else {
|
||||
disk->src->type = VIR_STORAGE_TYPE_FILE;
|
||||
}
|
||||
if (STREQ(arg, "-cdrom")) {
|
||||
disk->device = VIR_DOMAIN_DISK_DEVICE_CDROM;
|
||||
if (((def->os.arch == VIR_ARCH_PPC64) &&
|
||||
@ -11367,9 +11371,9 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
|
||||
const char *token = NULL;
|
||||
WANT_VALUE();
|
||||
|
||||
if (!strchr(val, ','))
|
||||
if (!strchr(val, ',')) {
|
||||
qemuParseCommandLineBootDevs(def, val);
|
||||
else {
|
||||
} else {
|
||||
token = val;
|
||||
while (token && *token) {
|
||||
if (STRPREFIX(token, "order=")) {
|
||||
@ -11683,11 +11687,11 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
|
||||
WANT_VALUE();
|
||||
|
||||
val += strlen("PIIX4_PM.disable_s3=");
|
||||
if (STREQ(val, "0"))
|
||||
if (STREQ(val, "0")) {
|
||||
def->pm.s3 = VIR_TRISTATE_BOOL_YES;
|
||||
else if (STREQ(val, "1"))
|
||||
} else if (STREQ(val, "1")) {
|
||||
def->pm.s3 = VIR_TRISTATE_BOOL_NO;
|
||||
else {
|
||||
} else {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("invalid value for disable_s3 parameter: "
|
||||
"'%s'"), val);
|
||||
@ -11700,11 +11704,11 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
|
||||
WANT_VALUE();
|
||||
|
||||
val += strlen("PIIX4_PM.disable_s4=");
|
||||
if (STREQ(val, "0"))
|
||||
if (STREQ(val, "0")) {
|
||||
def->pm.s4 = VIR_TRISTATE_BOOL_YES;
|
||||
else if (STREQ(val, "1"))
|
||||
} else if (STREQ(val, "1")) {
|
||||
def->pm.s4 = VIR_TRISTATE_BOOL_NO;
|
||||
else {
|
||||
} else {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("invalid value for disable_s4 parameter: "
|
||||
"'%s'"), val);
|
||||
|
@ -2559,9 +2559,9 @@ static int qemuDomainGetInfo(virDomainPtr dom,
|
||||
} else if (qemuDomainJobAllowed(priv, QEMU_JOB_QUERY)) {
|
||||
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0)
|
||||
goto cleanup;
|
||||
if (!virDomainObjIsActive(vm))
|
||||
if (!virDomainObjIsActive(vm)) {
|
||||
err = 0;
|
||||
else {
|
||||
} else {
|
||||
qemuDomainObjEnterMonitor(driver, vm);
|
||||
err = qemuMonitorGetBalloonInfo(priv->mon, &balloon);
|
||||
qemuDomainObjExitMonitor(driver, vm);
|
||||
@ -3698,9 +3698,9 @@ static int qemuDomainCoreDumpWithFormat(virDomainPtr dom,
|
||||
}
|
||||
}
|
||||
|
||||
if (qemuDomainObjEndAsyncJob(driver, vm) == 0)
|
||||
if (qemuDomainObjEndAsyncJob(driver, vm) == 0) {
|
||||
vm = NULL;
|
||||
else if ((ret == 0) && (flags & VIR_DUMP_CRASH) && !vm->persistent) {
|
||||
} else if ((ret == 0) && (flags & VIR_DUMP_CRASH) && !vm->persistent) {
|
||||
qemuDomainRemoveInactive(driver, vm);
|
||||
vm = NULL;
|
||||
}
|
||||
@ -5647,9 +5647,9 @@ qemuDomainRestoreFlags(virConnectPtr conn,
|
||||
if (virFileWrapperFdClose(wrapperFd) < 0)
|
||||
VIR_WARN("Failed to close %s", path);
|
||||
|
||||
if (!qemuDomainObjEndJob(driver, vm))
|
||||
if (!qemuDomainObjEndJob(driver, vm)) {
|
||||
vm = NULL;
|
||||
else if (ret < 0 && !vm->persistent) {
|
||||
} else if (ret < 0 && !vm->persistent) {
|
||||
qemuDomainRemoveInactive(driver, vm);
|
||||
vm = NULL;
|
||||
}
|
||||
@ -7708,17 +7708,17 @@ qemuDomainMergeBlkioDevice(virBlkioDevicePtr *dest_array,
|
||||
if (STREQ(src->path, dest->path)) {
|
||||
found = true;
|
||||
|
||||
if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT))
|
||||
if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT)) {
|
||||
dest->weight = src->weight;
|
||||
else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS))
|
||||
} else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS)) {
|
||||
dest->riops = src->riops;
|
||||
else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS))
|
||||
} else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS)) {
|
||||
dest->wiops = src->wiops;
|
||||
else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS))
|
||||
} else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS)) {
|
||||
dest->rbps = src->rbps;
|
||||
else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS))
|
||||
} else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS)) {
|
||||
dest->wbps = src->wbps;
|
||||
else {
|
||||
} else {
|
||||
virReportError(VIR_ERR_INVALID_ARG, _("Unknown parameter %s"),
|
||||
type);
|
||||
return -1;
|
||||
@ -7733,17 +7733,17 @@ qemuDomainMergeBlkioDevice(virBlkioDevicePtr *dest_array,
|
||||
return -1;
|
||||
dest = &(*dest_array)[*dest_size - 1];
|
||||
|
||||
if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT))
|
||||
if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT)) {
|
||||
dest->weight = src->weight;
|
||||
else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS))
|
||||
} else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS)) {
|
||||
dest->riops = src->riops;
|
||||
else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS))
|
||||
} else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS)) {
|
||||
dest->wiops = src->wiops;
|
||||
else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS))
|
||||
} else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS)) {
|
||||
dest->rbps = src->rbps;
|
||||
else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS))
|
||||
} else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS)) {
|
||||
dest->wbps = src->wbps;
|
||||
else {
|
||||
} else {
|
||||
*dest_size = *dest_size - 1;
|
||||
return -1;
|
||||
}
|
||||
|
@ -966,12 +966,13 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
|
||||
if (virDomainCCWAddressAssign(&net->info, priv->ccwaddrs,
|
||||
!net->info.addr.ccw.assigned) < 0)
|
||||
goto cleanup;
|
||||
} else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390))
|
||||
} else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) {
|
||||
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)
|
||||
goto cleanup;
|
||||
} else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE) &&
|
||||
virDomainPCIAddressEnsureAddr(priv->pciaddrs, &net->info) < 0) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
releaseaddr = true;
|
||||
|
||||
|
@ -2726,17 +2726,14 @@ int qemuMonitorTextCreateSnapshot(qemuMonitorPtr mon, const char *name)
|
||||
virReportError(VIR_ERR_OPERATION_FAILED,
|
||||
_("Failed to take snapshot: %s"), reply);
|
||||
goto cleanup;
|
||||
}
|
||||
else if (strstr(reply, "No block device can accept snapshots") != NULL) {
|
||||
} else if (strstr(reply, "No block device can accept snapshots") != NULL) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("this domain does not have a device to take snapshots"));
|
||||
goto cleanup;
|
||||
}
|
||||
else if (strstr(reply, "Could not open VM state file") != NULL) {
|
||||
} else if (strstr(reply, "Could not open VM state file") != NULL) {
|
||||
virReportError(VIR_ERR_OPERATION_FAILED, "%s", reply);
|
||||
goto cleanup;
|
||||
}
|
||||
else if (strstr(reply, "Error") != NULL
|
||||
} else if (strstr(reply, "Error") != NULL
|
||||
&& strstr(reply, "while writing VM") != NULL) {
|
||||
virReportError(VIR_ERR_OPERATION_FAILED, "%s", reply);
|
||||
goto cleanup;
|
||||
@ -2769,27 +2766,22 @@ int qemuMonitorTextLoadSnapshot(qemuMonitorPtr mon, const char *name)
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("this domain does not have a device to load snapshots"));
|
||||
goto cleanup;
|
||||
}
|
||||
else if (strstr(reply, "Could not find snapshot") != NULL) {
|
||||
} else if (strstr(reply, "Could not find snapshot") != NULL) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||
_("the snapshot '%s' does not exist, and was not loaded"),
|
||||
name);
|
||||
goto cleanup;
|
||||
}
|
||||
else if (strstr(reply, "Snapshots not supported on device") != NULL) {
|
||||
} else if (strstr(reply, "Snapshots not supported on device") != NULL) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s", reply);
|
||||
goto cleanup;
|
||||
}
|
||||
else if (strstr(reply, "Could not open VM state file") != NULL) {
|
||||
} else if (strstr(reply, "Could not open VM state file") != NULL) {
|
||||
virReportError(VIR_ERR_OPERATION_FAILED, "%s", reply);
|
||||
goto cleanup;
|
||||
}
|
||||
else if (strstr(reply, "Error") != NULL
|
||||
} else if (strstr(reply, "Error") != NULL
|
||||
&& strstr(reply, "while loading VM state") != NULL) {
|
||||
virReportError(VIR_ERR_OPERATION_FAILED, "%s", reply);
|
||||
goto cleanup;
|
||||
}
|
||||
else if (strstr(reply, "Error") != NULL
|
||||
} else if (strstr(reply, "Error") != NULL
|
||||
&& strstr(reply, "while activating snapshot on") != NULL) {
|
||||
virReportError(VIR_ERR_OPERATION_FAILED, "%s", reply);
|
||||
goto cleanup;
|
||||
@ -2821,12 +2813,10 @@ int qemuMonitorTextDeleteSnapshot(qemuMonitorPtr mon, const char *name)
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("this domain does not have a device to delete snapshots"));
|
||||
goto cleanup;
|
||||
}
|
||||
else if (strstr(reply, "Snapshots not supported on device") != NULL) {
|
||||
} else if (strstr(reply, "Snapshots not supported on device") != NULL) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s", reply);
|
||||
goto cleanup;
|
||||
}
|
||||
else if (strstr(reply, "Error") != NULL
|
||||
} else if (strstr(reply, "Error") != NULL
|
||||
&& strstr(reply, "while deleting snapshot") != NULL) {
|
||||
virReportError(VIR_ERR_OPERATION_FAILED, "%s", reply);
|
||||
goto cleanup;
|
||||
|
@ -4659,8 +4659,7 @@ void qemuProcessStop(virQEMUDriverPtr driver,
|
||||
if (graphics->data.vnc.autoport) {
|
||||
virPortAllocatorRelease(driver->remotePorts,
|
||||
graphics->data.vnc.port);
|
||||
}
|
||||
else if (graphics->data.vnc.portReserved) {
|
||||
} else if (graphics->data.vnc.portReserved) {
|
||||
virPortAllocatorSetUsed(driver->remotePorts,
|
||||
graphics->data.spice.port,
|
||||
false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user