[libvirt PATCH v4 0/3] Ignore EPERM on implicit clearing of VF VLAN ID
by Dmitrii Shcherbakov
SmartNIC DPUs may not expose some privileged eswitch operations
to the hypervisor hosts. For example, this happens with Bluefield
devices running in the ECPF (default) mode [1] for security reasons. While
VF MAC address programming is possible via an RTM_SETLINK operation,
trying to set a VLAN ID in the same operation will fail with EPERM.
In the kernel a relevant call chain may look like
do_setlink -> do_setvfinfo -> dev->netdev_ops->set_vf_vlan
which calls a driver-specific function like [2] eventually.
The equivalent ip link commands below provide an illustration:
1. This works:
sudo ip link set enp130s0f0 vf 2 mac de:ad:be:ef:ca:fe
2. Setting (or clearing) a VLAN fails with EPERM:
sudo ip link set enp130s0f0 vf 2 vlan 0
RTNETLINK answers: Operation not permitted
3. This is what Libvirt attempts to do today (when trying to clear a
VF VLAN at the same time as programming a VF MAC).
sudo ip link set enp130s0f0 vf 2 vlan 0 mac de:ad:be:ef:ca:fe
RTNETLINK answers: Operation not permitted
If setting an explicit VLAN ID results in an EPERM, clearing a VLAN
(setting a VLAN ID to 0) can be handled gracefully by ignoring the
EPERM error with the rationale being that if we cannot set this state
in the first place, we cannot clear it either.
Thus, virNetDevSetVfConfig is split into two distinct functions. If
clearing a VLAN ID fails with EPERM when clearing is implicit, the
error is simply ignored. For explicit clearing EPERM is still a
fatal error.
Both new functions rely virNetDevSendVfSetLinkRequest that implements
common functionality related to formatting a request, sending it and
handling error conditions and returns 0 or an error since in both cases
the payload is either NLMSG_DONE (no error) or NLMSG_ERROR where an
error message is needed by the caller to handle known cases
appropriately. This function allows the conditional code to be unit tested.
An alternative to this could be providing a higher level control plane
mechanism that would provide metadata about a device being remotely
managed in which case Libvirt would avoid trying to set or clear a
VLAN ID. This would be more complicated since other software (like Nova
in the OpenStack case) would have to annotate every guest device with an
attribute indicating whether a device is remotely managed or not based
on operator provided configuration so that Libvirt can act on this and
avoid VLAN programming.
https://gitlab.com/dmitriis/libvirt/-/pipelines/411044099
v4 changes:
* Split the change into several patches;
* Added a missing test case;
* Reworked error handling;
* Added a way to pass a NULL vlan id to preserve the old behavior
when needed.
[1] https://docs.mellanox.com/display/BlueFieldSWv35111601/Modes+of+Operation...
[2] https://github.com/torvalds/linux/blob/v5.15/drivers/net/ethernet/mellano...
Dmitrii Shcherbakov (3):
Set VF MAC and VLAN ID in two different operations
Allow VF vlanid to be passed as a pointer
Ignore EPERM on implicit clearing of VF VLAN ID
src/hypervisor/virhostdev.c | 4 +-
src/libvirt_private.syms | 7 ++
src/util/virnetdev.c | 218 ++++++++++++++++++++------------
src/util/virnetdevpriv.h | 44 +++++++
tests/virnetdevtest.c | 241 +++++++++++++++++++++++++++++++++++-
5 files changed, 436 insertions(+), 78 deletions(-)
create mode 100644 src/util/virnetdevpriv.h
--
2.32.0
3 years
[libvirt PATCH v3 0/1] Ignore EPERM on attempts to clear a VF VLAN ID
by Dmitrii Shcherbakov
SmartNIC DPUs may not expose some privileged eswitch operations
to the hypervisor hosts. For example, this happens with Bluefield
devices running in the ECPF (default) mode [1] for security reasons. While
VF MAC address programming is possible via an RTM_SETLINK operation,
trying to set a VLAN ID in the same operation will fail with EPERM.
In the kernel a relevant call chain may look like
do_setlink -> do_setvfinfo -> dev->netdev_ops->set_vf_vlan
which calls a driver-specific function like [2] eventually.
The equivalent ip link commands below provide an illustration:
1. This works:
sudo ip link set enp130s0f0 vf 2 mac de:ad:be:ef:ca:fe
2. Setting (or clearing) a VLAN fails with EPERM:
sudo ip link set enp130s0f0 vf 2 vlan 0
RTNETLINK answers: Operation not permitted
3. This is what Libvirt attempts to do today (when trying to clear a
VF VLAN at the same time as programming a VF MAC).
sudo ip link set enp130s0f0 vf 2 vlan 0 mac de:ad:be:ef:ca:fe
RTNETLINK answers: Operation not permitted
If setting an explicit VLAN ID results in an EPERM, clearing a VLAN
(setting a VLAN ID to 0) can be handled gracefully by ignoring the
EPERM error with the rationale being that if we cannot set this state
in the first place, we cannot clear it either.
Thus, virNetDevSetVfConfig is split into two distinct functions. If
clearing a VLAN ID fails with EPERM, the error is simply ignored.
Both new functions rely virNetDevSendVfSetLinkRequest that implements
common functionality related to formatting a request, sending it and
handling error conditions and returns 0 or an error since in both cases
the payload is either NLMSG_DONE (no error) or NLMSG_ERROR where an
error message is needed by the caller to handle known cases
appropriately. This function allows the conditional code to be unit tested.
An alternative to this could be providing a higher level control plane
mechanism that would provide metadata about a device being remotely
managed in which case Libvirt would avoid trying to set or clear a
VLAN ID. This would be more complicated since other software (like Nova
in the OpenStack case) would have to annotate every guest device with an
attribute indicating whether a device is remotely managed or not based
on operator provided configuration so that Libvirt can act on this and
avoid VLAN programming.
https://gitlab.com/dmitriis/libvirt/-/pipelines/409312792
v2 -> v3 changes:
* Fixed a bug caught during functional testing;
* Added a news file entry.
[1] https://docs.mellanox.com/display/BlueFieldSWv35111601/Modes+of+Operation...
[2] https://github.com/torvalds/linux/blob/v5.15/drivers/net/ethernet/mellano...
Dmitrii Shcherbakov (1):
Ignore EPERM on attempts to clear VF VLAN ID
NEWS.rst | 9 ++
src/libvirt_private.syms | 7 ++
src/util/virnetdev.c | 196 +++++++++++++++++++++-------------
src/util/virnetdevpriv.h | 44 ++++++++
tests/virnetdevtest.c | 222 ++++++++++++++++++++++++++++++++++++++-
5 files changed, 405 insertions(+), 73 deletions(-)
create mode 100644 src/util/virnetdevpriv.h
--
2.32.0
3 years
[RFC PATCH] tests/qemuxml2*/graphics-spice-timeout: skip CPU model check
by Daniel Henrique Barboza
Commit 65b0b746b516 changed spice tests to use latest caps. Before this
change, "FLAG_REAL_CAPS" wasn't being set in testQemuInfoInitArgs(). The
absence of this flag triggered the code path inside
testCompareXMLToArgv() that executed testUpdateQEMUCaps(). This function
will update the host CPU via virQEMUCapsUpdateHostCPUModel() into
virQEMUCapsInitHostCPUModel(). In this function,
virQEMUCapsInitCPUModel() would end up updating the hostCPU inside the
qemuCaps (via virQEMUCapsProbeHostCPU()). Before the forementioned
commit, the host CPU was being defaulted to x86_64, vendor Intel, for
the 'graphics-spice-timeout' test that is using the 'pc' machine type
and 'accel=kvm'.
Today, "FLAG_REAL_CAPS" is being set because we're using the latest caps
from x86_64. This means that the whole code path mentioned above is
skipped. qemuCaps are now being loaded via virQEMUCapsLoadCache()
directly. Without the handling being done by testUpdateQEMUCaps(), the
host CPU is being retrieved later on, down below
qemuProcessCreatePretendCmdPrepare() into qemuProcessUpdateGuestCPU().
The latter will attempt to update the domain cpu and executing a
virCPUCompare with the hostCPU and def->cpu.
All this logic ended up causing a failure of the
'graphics-spice-timeout' test in ppc64 and s390x hosts. This test is
being run with KVM acceleration, and the KVM driver for ppc64 and s390x
will return a default x86_64 CPU with vendor "AMD", making
virCPUCompare() fail with the following message:
"QEMU XML-2-ARGV graphics-spice-timeout.x86_64-latest ... libvirt: CPU
Driver error : the CPU is incompatible with host CPU: host CPU vendor does
not match required CPU vendor Intel"
Fix this test by setting cpu check='none' and avoid the virCPUCompare()
that causes the problem for ppc64 and s390x hosts.
Reported-by: Boris Fiuczynski <fiuczy(a)linux.ibm.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
Sending as a RFC because I'm not sure if this patch fixes the
problem for s390x. Boris, can you please test and see if this
fix works for you?
tests/qemuxml2argvdata/graphics-spice-timeout.xml | 2 +-
.../qemuxml2xmloutdata/graphics-spice-timeout.x86_64-latest.xml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/qemuxml2argvdata/graphics-spice-timeout.xml b/tests/qemuxml2argvdata/graphics-spice-timeout.xml
index 065318651f..33dae5c4bf 100644
--- a/tests/qemuxml2argvdata/graphics-spice-timeout.xml
+++ b/tests/qemuxml2argvdata/graphics-spice-timeout.xml
@@ -15,7 +15,7 @@
<apic/>
<pae/>
</features>
- <cpu match='exact'>
+ <cpu match='exact' check='none'>
<model>core2duo</model>
<vendor>Intel</vendor>
<topology sockets='1' dies='1' cores='2' threads='1'/>
diff --git a/tests/qemuxml2xmloutdata/graphics-spice-timeout.x86_64-latest.xml b/tests/qemuxml2xmloutdata/graphics-spice-timeout.x86_64-latest.xml
index fd34a6caf5..9e6782d00b 100644
--- a/tests/qemuxml2xmloutdata/graphics-spice-timeout.x86_64-latest.xml
+++ b/tests/qemuxml2xmloutdata/graphics-spice-timeout.x86_64-latest.xml
@@ -15,7 +15,7 @@
<apic/>
<pae/>
</features>
- <cpu mode='custom' match='exact' check='partial'>
+ <cpu mode='custom' match='exact' check='none'>
<model fallback='allow'>core2duo</model>
<vendor>Intel</vendor>
<topology sockets='1' dies='1' cores='2' threads='1'/>
--
2.31.1
3 years
[libvirt PATCH] conf: device: compare drive address fields separately
by Ján Tomko
Commit 3210c8b04 introduced a separate field 'diskbus' for
internal use by the commandline formatter.
Adjust the check for address equality to compare the relevant
fields separately instead of the whole struct.
This means that the changes of the 'diskbus' field added
in commit 03ed14d2d4 no longer affect the outcome of the address
equality check.
https://bugzilla.redhat.com/show_bug.cgi?id=2023605
Fixes: 3210c8b047534f7e1d3ccde7ea3bcf11e7c92ad9
Fixes: 03ed14d2d4a4e51568b1ee5a6e6c9c3371bb4d34
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
src/conf/device_conf.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c
index e587d90c59..cb523d3a0d 100644
--- a/src/conf/device_conf.c
+++ b/src/conf/device_conf.c
@@ -119,7 +119,10 @@ virDomainDeviceInfoAddressIsEqual(const virDomainDeviceInfo *a,
break;
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE:
- if (memcmp(&a->addr.drive, &b->addr.drive, sizeof(a->addr.drive)))
+ if (a->addr.drive.controller != b->addr.drive.controller ||
+ a->addr.drive.unit != b->addr.drive.unit ||
+ a->addr.drive.bus != b->addr.drive.bus ||
+ a->addr.drive.target != b->addr.drive.target)
return false;
break;
--
2.31.1
3 years
[PATCH] virt-aa-helper: fix bool initialization
by christian.ehrhardt@canonical.com
From: Christian Ehrhardt <christian.ehrhardt(a)canonical.com>
Since purged is a bool variable it should be initialized by false
instead of 0.
Suggested-by: Sergio Durigan Junior <sergio.durigan(a)canonical.com>
Signed-off-by: Christian Ehrhardt <christian.ehrhardt(a)canonical.com>
---
src/security/virt-aa-helper.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index 218e07bfb0..898f9f1a16 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -1438,7 +1438,7 @@ main(int argc, char **argv)
char *profile = NULL;
char *include_file = NULL;
off_t size;
- bool purged = 0;
+ bool purged = false;
if (virGettextInitialize() < 0 ||
virErrorInitialize() < 0) {
--
2.33.1
3 years
[PATCH 00/18] qemu: command: Convert '-compat' and '-audiodev' to use JSON
by Peter Krempa
In line of the previous work to use the long-term stable versions of the
commandline interface.
Peter Krempa (18):
virJSONValueObjectAdd: Convert @obj argument to double pointer
virJSONValueObjectAddVArgs: Take double pointer
virJSONValueObjectAddVArgs: Allocate new object if passed pointer is
NULL
qemu: block: Replace virJSONValueObjectCreate by virJSONValueObjectAdd
qemu: agent: Replace virJSONValueObjectCreate by virJSONValueObjectAdd
qemu: monitor_json: Replace virJSONValueObjectCreate by
virJSONValueObjectAdd
qemu: monitor: Replace virJSONValueObjectCreate by
virJSONValueObjectAdd
qemu: migration_cookie: Replace virJSONValueObjectCreate by
virJSONValueObjectAdd
qemuDiskSourceGetProps: Initialize 'ret'
qemu: command: Replace virJSONValueObjectCreate by
virJSONValueObjectAdd
qemublocktest: Replace virJSONValueObjectCreate by
virJSONValueObjectAdd
virjsontest: Replace virJSONValueObjectCreate by virJSONValueObjectAdd
qemu: migration_params: Replace virJSONValueObjectCreate by
virJSONValueObjectAdd
virsh: domain: Replace virJSONValueObjectCreate by
virJSONValueObjectAdd
Replace virJSONValueObjectCreateVArgs with virJSONValueObjectAddVArgs
util: json: Remove virJSONValueObjectCreate(VArgs)
qemu: command: Use JSON for parameters of -compat
qemu: command: Use JSON for parameters of -audiodev
src/libvirt_private.syms | 2 -
src/qemu/qemu_agent.c | 10 +-
src/qemu/qemu_block.c | 378 ++++----
src/qemu/qemu_command.c | 890 +++++++++---------
src/qemu/qemu_migration_cookie.c | 25 +-
src/qemu/qemu_migration_params.c | 8 +-
src/qemu/qemu_monitor.c | 20 +-
src/qemu/qemu_monitor_json.c | 51 +-
src/util/virjson.c | 50 +-
src/util/virjson.h | 8 +-
tests/qemublocktest.c | 2 +-
...fault-cpu-kvm-virt-4.2.aarch64-latest.args | 2 +-
...fault-cpu-tcg-virt-4.2.aarch64-latest.args | 2 +-
.../aarch64-features-sve.aarch64-latest.args | 2 +-
...arch64-os-firmware-efi.aarch64-latest.args | 2 +-
.../aarch64-tpm.aarch64-latest.args | 2 +-
.../aarch64-virt-graphics.aarch64-latest.args | 2 +-
.../aarch64-virt-headless.aarch64-latest.args | 2 +-
.../audio-alsa-best.x86_64-latest.args | 2 +-
.../audio-alsa-full.x86_64-latest.args | 2 +-
.../audio-alsa-minimal.x86_64-latest.args | 2 +-
.../audio-coreaudio-best.x86_64-latest.args | 2 +-
.../audio-coreaudio-full.x86_64-latest.args | 2 +-
...audio-coreaudio-minimal.x86_64-latest.args | 2 +-
...udio-default-nographics.x86_64-latest.args | 2 +-
.../audio-default-sdl.x86_64-latest.args | 2 +-
.../audio-default-spice.x86_64-latest.args | 2 +-
.../audio-default-vnc.x86_64-latest.args | 2 +-
.../audio-file-best.x86_64-latest.args | 2 +-
.../audio-file-full.x86_64-latest.args | 2 +-
.../audio-file-minimal.x86_64-latest.args | 2 +-
.../audio-jack-full.x86_64-latest.args | 2 +-
.../audio-jack-minimal.x86_64-latest.args | 2 +-
.../audio-many-backends.x86_64-latest.args | 6 +-
.../audio-none-best.x86_64-latest.args | 2 +-
.../audio-none-full.x86_64-latest.args | 2 +-
.../audio-none-minimal.x86_64-latest.args | 2 +-
.../audio-oss-best.x86_64-latest.args | 2 +-
.../audio-oss-full.x86_64-latest.args | 2 +-
.../audio-oss-minimal.x86_64-latest.args | 2 +-
.../audio-pulseaudio-best.x86_64-latest.args | 2 +-
.../audio-pulseaudio-full.x86_64-latest.args | 2 +-
...udio-pulseaudio-minimal.x86_64-latest.args | 2 +-
.../audio-sdl-best.x86_64-latest.args | 2 +-
.../audio-sdl-full.x86_64-latest.args | 2 +-
.../audio-sdl-minimal.x86_64-latest.args | 2 +-
.../audio-spice-best.x86_64-latest.args | 2 +-
.../audio-spice-full.x86_64-latest.args | 2 +-
.../audio-spice-minimal.x86_64-latest.args | 2 +-
.../blkdeviotune-group-num.x86_64-latest.args | 2 +-
...blkdeviotune-max-length.x86_64-latest.args | 2 +-
.../blkdeviotune-max.x86_64-latest.args | 2 +-
.../channel-unix-guestfwd.x86_64-latest.args | 2 +-
.../clock-timer-armvtimer.aarch64-latest.args | 2 +-
.../console-sclp.s390x-latest.args | 2 +-
.../console-virtio-unix.x86_64-latest.args | 2 +-
.../controller-virtio-scsi.x86_64-latest.args | 2 +-
...-Icelake-Server-pconfig.x86_64-latest.args | 2 +-
.../cpu-host-model.x86_64-4.2.0.args | 2 +-
.../cpu-host-model.x86_64-5.0.0.args | 2 +-
.../cpu-host-model.x86_64-5.1.0.args | 2 +-
.../cpu-host-model.x86_64-5.2.0.args | 2 +-
.../cpu-host-model.x86_64-6.0.0.args | 2 +-
.../cpu-host-model.x86_64-6.1.0.args | 2 +-
.../cpu-host-model.x86_64-latest.args | 2 +-
.../cpu-translation.x86_64-latest.args | 2 +-
.../cputune-cpuset-big-id.x86_64-latest.args | 2 +-
...ult-video-type-aarch64.aarch64-latest.args | 2 +-
...default-video-type-ppc64.ppc64-latest.args | 2 +-
...ult-video-type-riscv64.riscv64-latest.args | 2 +-
...default-video-type-s390x.s390x-latest.args | 2 +-
.../devices-acpi-index.x86_64-latest.args | 2 +-
.../disk-aio-io_uring.x86_64-latest.args | 2 +-
.../disk-aio.x86_64-latest.args | 2 +-
.../disk-arm-virtio-sd.aarch64-latest.args | 2 +-
...-backing-chains-noindex.x86_64-latest.args | 2 +-
.../disk-blockio.x86_64-latest.args | 2 +-
.../disk-boot-cdrom.x86_64-latest.args | 2 +-
.../disk-boot-disk.x86_64-latest.args | 2 +-
.../disk-cache.x86_64-latest.args | 2 +-
.../disk-cdrom-bus-other.x86_64-latest.args | 2 +-
...m-empty-network-invalid.x86_64-latest.args | 2 +-
.../disk-cdrom-network.x86_64-latest.args | 2 +-
.../disk-cdrom-tray.x86_64-latest.args | 2 +-
.../disk-cdrom.x86_64-latest.args | 2 +-
.../disk-copy_on_read.x86_64-latest.args | 2 +-
.../disk-detect-zeroes.x86_64-latest.args | 2 +-
.../disk-discard.x86_64-latest.args | 2 +-
.../disk-error-policy-s390x.s390x-latest.args | 2 +-
.../disk-error-policy.x86_64-latest.args | 2 +-
.../disk-floppy-q35-2_11.x86_64-latest.args | 2 +-
.../disk-floppy-q35-2_9.x86_64-latest.args | 2 +-
.../disk-floppy-tray.x86_64-latest.args | 2 +-
.../disk-floppy.x86_64-latest.args | 2 +-
.../disk-fmt-qcow.x86_64-latest.args | 2 +-
.../disk-geometry.x86_64-latest.args | 2 +-
.../disk-ide-split.x86_64-latest.args | 2 +-
.../disk-ide-wwn.x86_64-latest.args | 2 +-
.../disk-ioeventfd.x86_64-latest.args | 2 +-
.../disk-metadata-cache.x86_64-latest.args | 2 +-
.../disk-network-gluster.x86_64-latest.args | 2 +-
.../disk-network-http.x86_64-latest.args | 2 +-
.../disk-network-iscsi.x86_64-latest.args | 2 +-
.../disk-network-nbd.x86_64-latest.args | 2 +-
.../disk-network-nfs.x86_64-latest.args | 2 +-
...-network-rbd-encryption.x86_64-latest.args | 2 +-
...sk-network-rbd-no-colon.x86_64-latest.args | 2 +-
.../disk-network-rbd.x86_64-latest.args | 2 +-
.../disk-network-sheepdog.x86_64-6.0.0.args | 2 +-
...isk-network-source-auth.x86_64-latest.args | 2 +-
...disk-network-tlsx509-nbd.x86_64-5.2.0.args | 2 +-
...isk-network-tlsx509-nbd.x86_64-latest.args | 2 +-
...isk-network-tlsx509-vxhs.x86_64-5.0.0.args | 2 +-
.../disk-no-boot.x86_64-latest.args | 2 +-
.../disk-nvme.x86_64-latest.args | 2 +-
.../disk-order.x86_64-latest.args | 2 +-
.../disk-readonly-disk.x86_64-latest.args | 2 +-
.../disk-rotation.x86_64-latest.args | 2 +-
.../disk-sata-device.x86_64-latest.args | 2 +-
.../disk-scsi-device-auto.x86_64-latest.args | 2 +-
.../disk-scsi-disk-split.x86_64-latest.args | 2 +-
.../disk-scsi-disk-vpd.x86_64-latest.args | 2 +-
.../disk-scsi-disk-wwn.x86_64-latest.args | 2 +-
...sk-scsi-lun-passthrough.x86_64-latest.args | 2 +-
.../disk-scsi.x86_64-latest.args | 2 +-
.../disk-serial.x86_64-latest.args | 2 +-
.../disk-shared.x86_64-latest.args | 2 +-
.../disk-slices.x86_64-latest.args | 2 +-
.../disk-snapshot.x86_64-latest.args | 2 +-
.../disk-source-pool-mode.x86_64-latest.args | 2 +-
.../disk-source-pool.x86_64-latest.args | 2 +-
.../disk-transient.x86_64-latest.args | 2 +-
...sk-usb-device-removable.x86_64-latest.args | 2 +-
.../disk-usb-device.x86_64-latest.args | 2 +-
.../disk-vhostuser.x86_64-latest.args | 2 +-
.../disk-virtio-ccw-many.s390x-latest.args | 2 +-
.../disk-virtio-ccw.s390x-latest.args | 2 +-
.../disk-virtio-queues.x86_64-latest.args | 2 +-
.../disk-virtio-s390-zpci.s390x-latest.args | 2 +-
...virtio-scsi-reservations.x86_64-5.2.0.args | 2 +-
...irtio-scsi-reservations.x86_64-latest.args | 2 +-
.../disk-virtio.x86_64-latest.args | 2 +-
.../encrypted-disk-usage.x86_64-latest.args | 2 +-
.../encrypted-disk.x86_64-latest.args | 2 +-
.../eoi-disabled.x86_64-latest.args | 2 +-
.../eoi-enabled.x86_64-latest.args | 2 +-
.../event_idx.x86_64-latest.args | 2 +-
.../fips-enabled.x86_64-5.1.0.args | 2 +-
.../fips-enabled.x86_64-latest.args | 2 +-
.../floppy-drive-fat.x86_64-latest.args | 2 +-
.../fs9p-ccw.s390x-latest.args | 2 +-
.../qemuxml2argvdata/fs9p.x86_64-latest.args | 2 +-
.../genid-auto.x86_64-latest.args | 2 +-
.../qemuxml2argvdata/genid.x86_64-latest.args | 2 +-
...s-spice-agent-file-xfer.x86_64-latest.args | 2 +-
...aphics-spice-agentmouse.x86_64-latest.args | 2 +-
...s-spice-auto-socket-cfg.x86_64-latest.args | 2 +-
...phics-spice-auto-socket.x86_64-latest.args | 2 +-
...phics-spice-compression.x86_64-latest.args | 2 +-
...hics-spice-egl-headless.x86_64-latest.args | 2 +-
...pice-gl-auto-rendernode.x86_64-latest.args | 2 +-
.../graphics-spice-no-args.x86_64-latest.args | 2 +-
.../graphics-spice-qxl-vga.x86_64-latest.args | 2 +-
.../graphics-spice-sasl.x86_64-latest.args | 2 +-
.../graphics-spice-socket.x86_64-latest.args | 2 +-
.../graphics-spice-timeout.x86_64-latest.args | 2 +-
...raphics-spice-usb-redir.x86_64-latest.args | 2 +-
.../graphics-spice.x86_64-latest.args | 2 +-
...ics-vnc-auto-socket-cfg.x86_64-latest.args | 2 +-
...raphics-vnc-auto-socket.x86_64-latest.args | 2 +-
...aphics-vnc-egl-headless.x86_64-latest.args | 2 +-
...hics-vnc-no-listen-attr.x86_64-latest.args | 2 +-
.../graphics-vnc-none.x86_64-latest.args | 2 +-
.../graphics-vnc-policy.x86_64-latest.args | 2 +-
.../graphics-vnc-power.x86_64-latest.args | 2 +-
...remove-generated-socket.x86_64-latest.args | 2 +-
.../graphics-vnc-sasl.x86_64-latest.args | 2 +-
...-vnc-socket-new-cmdline.x86_64-latest.args | 2 +-
.../graphics-vnc-socket.x86_64-latest.args | 2 +-
.../graphics-vnc-tls-secret.x86_64-5.2.0.args | 2 +-
...graphics-vnc-tls-secret.x86_64-latest.args | 2 +-
.../graphics-vnc-tls.x86_64-latest.args | 2 +-
.../graphics-vnc-websocket.x86_64-latest.args | 2 +-
.../graphics-vnc.x86_64-latest.args | 2 +-
...tdev-mdev-display-ramfb.x86_64-latest.args | 2 +-
...play-spice-egl-headless.x86_64-latest.args | 2 +-
...ev-display-spice-opengl.x86_64-latest.args | 2 +-
...isplay-vnc-egl-headless.x86_64-latest.args | 2 +-
...ostdev-mdev-display-vnc.x86_64-latest.args | 2 +-
.../hostdev-scsi-lsi.x86_64-latest.args | 2 +-
...ostdev-scsi-virtio-scsi.x86_64-latest.args | 2 +-
...tdev-subsys-mdev-vfio-ap.s390x-latest.args | 2 +-
...ubsys-mdev-vfio-ccw-boot.s390x-latest.args | 2 +-
.../hugepages-memaccess3.x86_64-latest.args | 2 +-
.../hugepages-nvdimm.x86_64-latest.args | 2 +-
.../hyperv-off.x86_64-latest.args | 2 +-
.../hyperv-panic.x86_64-latest.args | 2 +-
.../hyperv-stimer-direct.x86_64-latest.args | 2 +-
.../hyperv.x86_64-latest.args | 2 +-
.../input-linux.x86_64-latest.args | 2 +-
.../intel-iommu-aw-bits.x86_64-latest.args | 2 +-
...ntel-iommu-caching-mode.x86_64-latest.args | 2 +-
...ntel-iommu-device-iotlb.x86_64-latest.args | 2 +-
.../intel-iommu-eim.x86_64-latest.args | 2 +-
.../intel-iommu.x86_64-latest.args | 2 +-
.../iommu-smmuv3.aarch64-latest.args | 2 +-
...othreads-virtio-scsi-ccw.s390x-latest.args | 2 +-
...othreads-virtio-scsi-pci.x86_64-5.2.0.args | 2 +-
...threads-virtio-scsi-pci.x86_64-latest.args | 2 +-
.../kvmclock+eoi-disabled.x86_64-latest.args | 2 +-
.../launch-security-s390-pv.s390x-latest.args | 2 +-
.../launch-security-sev.x86_64-6.0.0.args | 2 +-
.../luks-disks-source-qcow2.x86_64-5.2.0.args | 2 +-
...luks-disks-source-qcow2.x86_64-latest.args | 2 +-
.../luks-disks-source.x86_64-latest.args | 2 +-
.../luks-disks.x86_64-latest.args | 2 +-
...memory-default-hugepage.x86_64-latest.args | 2 +-
.../memfd-memory-numa.x86_64-latest.args | 2 +-
...y-hotplug-nvdimm-access.x86_64-latest.args | 2 +-
...ory-hotplug-nvdimm-align.x86_64-5.2.0.args | 2 +-
...ry-hotplug-nvdimm-align.x86_64-latest.args | 2 +-
...ory-hotplug-nvdimm-label.x86_64-5.2.0.args | 2 +-
...ry-hotplug-nvdimm-label.x86_64-latest.args | 2 +-
...mory-hotplug-nvdimm-pmem.x86_64-5.2.0.args | 2 +-
...ory-hotplug-nvdimm-pmem.x86_64-latest.args | 2 +-
...-hotplug-nvdimm-readonly.x86_64-5.2.0.args | 2 +-
...hotplug-nvdimm-readonly.x86_64-latest.args | 2 +-
.../memory-hotplug-nvdimm.x86_64-latest.args | 2 +-
...mory-hotplug-virtio-mem.x86_64-latest.args | 2 +-
...mory-hotplug-virtio-pmem.x86_64-5.2.0.args | 2 +-
...ory-hotplug-virtio-pmem.x86_64-latest.args | 2 +-
.../misc-no-reboot.x86_64-5.2.0.args | 2 +-
.../misc-no-reboot.x86_64-latest.args | 2 +-
.../mlock-off.x86_64-latest.args | 2 +-
.../mlock-on.x86_64-latest.args | 2 +-
.../net-vdpa.x86_64-latest.args | 2 +-
.../net-vhostuser.x86_64-latest.args | 2 +-
.../numatune-hmat.x86_64-latest.args | 2 +-
...emnode-restrictive-mode.x86_64-latest.args | 2 +-
.../numatune-memnode.x86_64-5.2.0.args | 2 +-
.../numatune-memnode.x86_64-latest.args | 2 +-
.../numatune-system-memory.x86_64-latest.args | 2 +-
.../os-firmware-bios.x86_64-latest.args | 2 +-
...re-efi-no-enrolled-keys.x86_64-latest.args | 2 +-
...os-firmware-efi-secboot.x86_64-latest.args | 2 +-
.../os-firmware-efi.x86_64-latest.args | 2 +-
.../panic-double.x86_64-latest.args | 2 +-
.../panic-no-address.x86_64-latest.args | 2 +-
.../qemuxml2argvdata/panic.x86_64-latest.args | 2 +-
.../parallel-unix-chardev.x86_64-latest.args | 2 +-
...pi-root-hotplug-disable.x86_64-latest.args | 2 +-
...cpi-root-hotplug-enable.x86_64-latest.args | 2 +-
...e-expander-bus-aarch64.aarch64-latest.args | 2 +-
...cie-root-port-nohotplug.x86_64-latest.args | 2 +-
...ault-cpu-kvm-pseries-2.7.ppc64-latest.args | 2 +-
...ault-cpu-kvm-pseries-3.1.ppc64-latest.args | 2 +-
...ault-cpu-kvm-pseries-4.2.ppc64-latest.args | 2 +-
...ault-cpu-tcg-pseries-2.7.ppc64-latest.args | 2 +-
...ault-cpu-tcg-pseries-3.1.ppc64-latest.args | 2 +-
...ault-cpu-tcg-pseries-4.2.ppc64-latest.args | 2 +-
.../ppc64-pseries-graphics.ppc64-latest.args | 2 +-
.../ppc64-pseries-headless.ppc64-latest.args | 2 +-
.../ppc64-tpmproxy-single.ppc64-latest.args | 2 +-
.../ppc64-tpmproxy-with-tpm.ppc64-latest.args | 2 +-
.../pv-spinlock-disabled.x86_64-latest.args | 2 +-
.../pv-spinlock-enabled.x86_64-latest.args | 2 +-
.../qemu-ns.x86_64-latest.args | 4 +-
.../riscv64-virt-graphics.riscv64-latest.args | 2 +-
.../riscv64-virt-headless.riscv64-latest.args | 2 +-
...low-bogus-usb-controller.s390x-latest.args | 2 +-
...390-allow-bogus-usb-none.s390x-latest.args | 2 +-
...t-cpu-kvm-ccw-virtio-2.7.s390x-latest.args | 2 +-
...t-cpu-kvm-ccw-virtio-4.2.s390x-latest.args | 2 +-
...t-cpu-tcg-ccw-virtio-2.7.s390x-latest.args | 2 +-
...t-cpu-tcg-ccw-virtio-4.2.s390x-latest.args | 2 +-
.../s390x-ccw-graphics.s390x-latest.args | 2 +-
.../s390x-ccw-headless.s390x-latest.args | 2 +-
.../serial-unix-chardev.x86_64-latest.args | 2 +-
...rtcard-passthrough-unix.x86_64-latest.args | 2 +-
.../tpm-emulator-spapr.ppc64-latest.args | 2 +-
.../tpm-emulator-tpm2-enc.x86_64-latest.args | 2 +-
...pm-emulator-tpm2-pstate.x86_64-latest.args | 2 +-
.../tpm-emulator-tpm2.x86_64-latest.args | 2 +-
.../tpm-emulator.x86_64-latest.args | 2 +-
.../tpm-passthrough-crb.x86_64-latest.args | 2 +-
.../tpm-passthrough.x86_64-latest.args | 2 +-
.../tseg-explicit-size.x86_64-latest.args | 2 +-
.../usb-redir-unix.x86_64-latest.args | 2 +-
...vhost-user-fs-fd-memory.x86_64-latest.args | 2 +-
...vhost-user-fs-hugepages.x86_64-latest.args | 2 +-
...host-user-gpu-secondary.x86_64-latest.args | 2 +-
.../vhost-user-vga.x86_64-latest.args | 2 +-
.../vhost-vsock-auto.x86_64-latest.args | 2 +-
.../vhost-vsock-ccw-auto.s390x-latest.args | 2 +-
.../vhost-vsock-ccw-iommu.s390x-latest.args | 2 +-
.../vhost-vsock-ccw.s390x-latest.args | 2 +-
.../vhost-vsock.x86_64-latest.args | 2 +-
...eo-bochs-display-device.x86_64-latest.args | 2 +-
...video-qxl-device-vram64.x86_64-latest.args | 2 +-
...o-qxl-sec-device-vram64.x86_64-latest.args | 2 +-
...eo-ramfb-display-device.x86_64-latest.args | 2 +-
...video-virtio-vga-gpu-gl.x86_64-latest.args | 2 +-
.../virtio-9p-createmode.x86_64-latest.args | 2 +-
.../virtio-9p-multidevs.x86_64-latest.args | 2 +-
.../virtio-lun.x86_64-latest.args | 2 +-
...virtio-non-transitional.x86_64-latest.args | 2 +-
...-options-controller-ats.x86_64-latest.args | 2 +-
...ptions-controller-iommu.x86_64-latest.args | 2 +-
...tions-controller-packed.x86_64-latest.args | 2 +-
...virtio-options-disk-ats.x86_64-latest.args | 2 +-
...rtio-options-disk-iommu.x86_64-latest.args | 2 +-
...tio-options-disk-packed.x86_64-latest.args | 2 +-
.../virtio-options-fs-ats.x86_64-latest.args | 2 +-
...virtio-options-fs-iommu.x86_64-latest.args | 2 +-
...irtio-options-fs-packed.x86_64-latest.args | 2 +-
...irtio-options-input-ats.x86_64-latest.args | 2 +-
...tio-options-input-iommu.x86_64-latest.args | 2 +-
...io-options-input-packed.x86_64-latest.args | 2 +-
...-options-memballoon-ats.x86_64-latest.args | 2 +-
...loon-freepage-reporting.x86_64-latest.args | 2 +-
...ptions-memballoon-iommu.x86_64-latest.args | 2 +-
...tions-memballoon-packed.x86_64-latest.args | 2 +-
.../virtio-options-net-ats.x86_64-latest.args | 2 +-
...irtio-options-net-iommu.x86_64-latest.args | 2 +-
...rtio-options-net-packed.x86_64-latest.args | 2 +-
.../virtio-options-rng-ats.x86_64-latest.args | 2 +-
...irtio-options-rng-iommu.x86_64-latest.args | 2 +-
...rtio-options-rng-packed.x86_64-latest.args | 2 +-
...irtio-options-video-ats.x86_64-latest.args | 2 +-
...tio-options-video-iommu.x86_64-latest.args | 2 +-
...io-options-video-packed.x86_64-latest.args | 2 +-
.../virtio-options.x86_64-latest.args | 2 +-
.../virtio-rng-builtin.x86_64-5.2.0.args | 2 +-
.../virtio-rng-builtin.x86_64-latest.args | 2 +-
.../virtio-rng-egd-unix.x86_64-5.2.0.args | 2 +-
.../virtio-rng-egd-unix.x86_64-latest.args | 2 +-
.../virtio-transitional.x86_64-latest.args | 2 +-
.../watchdog-device.x86_64-latest.args | 2 +-
.../watchdog-diag288.s390x-latest.args | 2 +-
.../watchdog-dump.x86_64-latest.args | 2 +-
.../watchdog-injectnmi.x86_64-latest.args | 2 +-
.../watchdog.x86_64-latest.args | 2 +-
...-default-cpu-kvm-pc-4.2.x86_64-latest.args | 2 +-
...default-cpu-kvm-q35-4.2.x86_64-latest.args | 2 +-
...-default-cpu-tcg-pc-4.2.x86_64-latest.args | 2 +-
...default-cpu-tcg-q35-4.2.x86_64-latest.args | 2 +-
.../x86_64-pc-graphics.x86_64-latest.args | 2 +-
.../x86_64-pc-headless.x86_64-latest.args | 2 +-
.../x86_64-q35-graphics.x86_64-latest.args | 2 +-
.../x86_64-q35-headless.x86_64-latest.args | 2 +-
tests/virjsontest.c | 18 +-
tools/virsh-domain.c | 8 +-
352 files changed, 1080 insertions(+), 1074 deletions(-)
--
2.31.1
3 years
[PATCH 0/2] qemu_command: Generate -mem-prealloc in one corner case more
by Michal Privoznik
This is a result of mu discussion with Jing:
https://listman.redhat.com/archives/libvir-list/2021-September/msg00407.html
Turns out, the problem has nothing to do with my virtio-mem patches so
I'm sending fix separately.
Michal Prívozník (2):
qemuxml2argvtest: Introduce another numa-topology test
qemu_command: Generate -mem-prealloc in one corner case more
src/qemu/qemu_command.c | 17 ++++-----
.../fd-memory-numa-topology.args | 3 +-
.../fd-memory-numa-topology2.args | 5 +--
.../fd-memory-numa-topology3.args | 7 ++--
...d-memory-numa-topology4.x86_64-latest.args | 34 +++++++++++++++++
.../fd-memory-numa-topology4.xml | 37 +++++++++++++++++++
tests/qemuxml2argvtest.c | 1 +
...fd-memory-numa-topology4.x86_64-latest.xml | 1 +
tests/qemuxml2xmltest.c | 1 +
9 files changed, 88 insertions(+), 18 deletions(-)
create mode 100644 tests/qemuxml2argvdata/fd-memory-numa-topology4.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/fd-memory-numa-topology4.xml
create mode 120000 tests/qemuxml2xmloutdata/fd-memory-numa-topology4.x86_64-latest.xml
--
2.32.0
3 years
[PATCH] lib: Drop needless one line labels
by Michal Privoznik
In some cases we have a label that contains nothing but a return
statement. The amount of such labels rises as we use automagic
cleanup. Anyway, such labels are pointless and can be dropped.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
examples/c/domain/dommigrate.c | 6 +-
src/conf/domain_conf.c | 70 +++++++++-----------
src/conf/netdev_vport_profile_conf.c | 33 +++++-----
src/conf/storage_conf.c | 12 ++--
src/conf/storage_source_conf.c | 15 ++---
src/conf/virsavecookie.c | 3 +-
src/hypervisor/virhostdev.c | 4 +-
src/libxl/libxl_migration.c | 5 +-
src/libxl/xen_xl.c | 9 +--
src/openvz/openvz_driver.c | 5 +-
src/qemu/qemu_capabilities.c | 5 +-
src/qemu/qemu_monitor_json.c | 16 ++---
src/qemu/qemu_snapshot.c | 21 +++---
src/qemu/qemu_virtiofs.c | 22 +++----
src/rpc/virnetlibsshsession.c | 10 +--
src/storage/storage_backend_iscsi.c | 13 ++--
src/test/test_driver.c | 5 +-
src/util/vircgroup.c | 4 +-
src/util/vircgroupv1.c | 24 +++----
src/util/virdnsmasq.c | 42 +++++-------
src/util/virhostcpu.c | 11 ++--
tests/domainconftest.c | 5 +-
tests/qemuxml2argvtest.c | 11 +---
tests/virpcitest.c | 15 ++---
tools/virsh-domain.c | 8 +--
tools/virsh-host.c | 6 +-
tools/virsh-nodedev.c | 45 +++++--------
tools/virsh-volume.c | 96 +++++++++++-----------------
28 files changed, 199 insertions(+), 322 deletions(-)
diff --git a/examples/c/domain/dommigrate.c b/examples/c/domain/dommigrate.c
index 3d32ada6d3..07a947e869 100644
--- a/examples/c/domain/dommigrate.c
+++ b/examples/c/domain/dommigrate.c
@@ -42,7 +42,7 @@ main(int argc, char *argv[])
if (argc < 4) {
usage(argv[0]);
- goto out;
+ return EXIT_FAILURE;
}
src_uri = argv[1];
@@ -54,7 +54,7 @@ main(int argc, char *argv[])
if (!conn) {
fprintf(stderr, "No connection to the source hypervisor: %s.\n",
virGetLastErrorMessage());
- goto out;
+ return EXIT_FAILURE;
}
printf("Attempting to retrieve domain %s...\n", domname);
@@ -79,7 +79,5 @@ main(int argc, char *argv[])
if (dom != NULL)
virDomainFree(dom);
virConnectClose(conn);
-
- out:
return ret;
}
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index da0c64b460..54218e76e7 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -18859,7 +18859,7 @@ virDomainDefParseIDs(virDomainDef *def,
/* Extract domain name */
if (!(def->name = virXPathString("string(./name[1])", ctxt))) {
virReportError(VIR_ERR_NO_NAME, NULL);
- goto error;
+ return -1;
}
/* Extract domain uuid. If both uuid and sysinfo/system/entry/uuid
@@ -18870,50 +18870,47 @@ virDomainDefParseIDs(virDomainDef *def,
if (virUUIDGenerate(def->uuid) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Failed to generate UUID"));
- goto error;
+ return -1;
}
*uuid_generated = true;
} else {
if (virUUIDParse(tmp, def->uuid) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("malformed uuid element"));
- goto error;
+ return -1;
}
VIR_FREE(tmp);
}
/* Extract domain genid - a genid can either be provided or generated */
if ((n = virXPathNodeSet("./genid", ctxt, &nodes)) < 0)
- goto error;
+ return -1;
if (n > 0) {
if (n != 1) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("element 'genid' can only appear once"));
- goto error;
+ return -1;
}
def->genidRequested = true;
if (!(tmp = virXPathString("string(./genid)", ctxt))) {
if (virUUIDGenerate(def->genid) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Failed to generate genid"));
- goto error;
+ return -1;
}
def->genidGenerated = true;
} else {
if (virUUIDParse(tmp, def->genid) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("malformed genid element"));
- goto error;
+ return -1;
}
VIR_FREE(tmp);
}
}
VIR_FREE(nodes);
return 0;
-
- error:
- return -1;
}
@@ -19002,20 +18999,20 @@ virDomainDefParseMemory(virDomainDef *def,
/* Extract domain memory */
if (virDomainParseMemory("./memory[1]", NULL, ctxt,
&def->mem.total_memory, false, true) < 0)
- goto error;
+ return -1;
if (virDomainParseMemory("./currentMemory[1]", NULL, ctxt,
&def->mem.cur_balloon, false, true) < 0)
- goto error;
+ return -1;
if (virDomainParseMemory("./maxMemory[1]", NULL, ctxt,
&def->mem.max_memory, false, false) < 0)
- goto error;
+ return -1;
if (virXPathUInt("string(./maxMemory[1]/@slots)", ctxt, &def->mem.memory_slots) == -2) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("Failed to parse memory slot count"));
- goto error;
+ return -1;
}
/* and info about it */
@@ -19023,7 +19020,7 @@ virDomainDefParseMemory(virDomainDef *def,
(def->mem.dump_core = virTristateSwitchTypeFromString(tmp)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Invalid memory core dump attribute value '%s'"), tmp);
- goto error;
+ return -1;
}
VIR_FREE(tmp);
@@ -19032,7 +19029,7 @@ virDomainDefParseMemory(virDomainDef *def,
if ((def->mem.source = virDomainMemorySourceTypeFromString(tmp)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown memoryBacking/source/type '%s'"), tmp);
- goto error;
+ return -1;
}
VIR_FREE(tmp);
}
@@ -19042,7 +19039,7 @@ virDomainDefParseMemory(virDomainDef *def,
if ((def->mem.access = virDomainMemoryAccessTypeFromString(tmp)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown memoryBacking/access/mode '%s'"), tmp);
- goto error;
+ return -1;
}
VIR_FREE(tmp);
}
@@ -19052,7 +19049,7 @@ virDomainDefParseMemory(virDomainDef *def,
if ((def->mem.allocation = virDomainMemoryAllocationTypeFromString(tmp)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown memoryBacking/allocation/mode '%s'"), tmp);
- goto error;
+ return -1;
}
VIR_FREE(tmp);
}
@@ -19062,7 +19059,7 @@ virDomainDefParseMemory(virDomainDef *def,
if ((n = virXPathNodeSet("./memoryBacking/hugepages/page", ctxt, &nodes)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot extract hugepages nodes"));
- goto error;
+ return -1;
}
if (n) {
@@ -19071,7 +19068,7 @@ virDomainDefParseMemory(virDomainDef *def,
for (i = 0; i < n; i++) {
if (virDomainHugepagesParseXML(nodes[i], ctxt,
&def->mem.hugepages[i]) < 0)
- goto error;
+ return -1;
def->mem.nhugepages++;
}
@@ -19093,9 +19090,6 @@ virDomainDefParseMemory(virDomainDef *def,
def->mem.discard = VIR_TRISTATE_BOOL_YES;
return 0;
-
- error:
- return -1;
}
@@ -19446,43 +19440,40 @@ virDomainDefLifecycleParse(virDomainDef *def,
&def->onReboot,
VIR_DOMAIN_LIFECYCLE_ACTION_RESTART,
virDomainLifecycleActionTypeFromString) < 0)
- goto error;
+ return -1;
if (virDomainEventActionParseXML(ctxt, "on_poweroff",
"string(./on_poweroff[1])",
&def->onPoweroff,
VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY,
virDomainLifecycleActionTypeFromString) < 0)
- goto error;
+ return -1;
if (virDomainEventActionParseXML(ctxt, "on_crash",
"string(./on_crash[1])",
&def->onCrash,
VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY,
virDomainLifecycleActionTypeFromString) < 0)
- goto error;
+ return -1;
if (virDomainEventActionParseXML(ctxt, "on_lockfailure",
"string(./on_lockfailure[1])",
&def->onLockFailure,
VIR_DOMAIN_LOCK_FAILURE_DEFAULT,
virDomainLockFailureTypeFromString) < 0)
- goto error;
+ return -1;
if (virDomainPMStateParseXML(ctxt,
"string(./pm/suspend-to-mem/@enabled)",
&def->pm.s3) < 0)
- goto error;
+ return -1;
if (virDomainPMStateParseXML(ctxt,
"string(./pm/suspend-to-disk/@enabled)",
&def->pm.s4) < 0)
- goto error;
+ return -1;
return 0;
-
- error:
- return -1;
}
@@ -19499,7 +19490,7 @@ virDomainDefClockParse(virDomainDef *def,
(def->clock.offset = virDomainClockOffsetTypeFromString(tmp)) < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown clock offset '%s'"), tmp);
- goto error;
+ return -1;
}
VIR_FREE(tmp);
@@ -19516,7 +19507,7 @@ virDomainDefClockParse(virDomainDef *def,
virReportError(VIR_ERR_XML_ERROR,
_("unknown clock adjustment '%s'"),
tmp);
- goto error;
+ return -1;
}
switch (def->clock.offset) {
case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME:
@@ -19546,7 +19537,7 @@ virDomainDefClockParse(virDomainDef *def,
if ((def->clock.data.variable.basis = virDomainClockBasisTypeFromString(tmp)) < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown clock basis '%s'"), tmp);
- goto error;
+ return -1;
}
VIR_FREE(tmp);
} else {
@@ -19559,13 +19550,13 @@ virDomainDefClockParse(virDomainDef *def,
if (!def->clock.data.timezone) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing 'timezone' attribute for clock with offset='timezone'"));
- goto error;
+ return -1;
}
break;
}
if ((n = virXPathNodeSet("./clock/timer", ctxt, &nodes)) < 0)
- goto error;
+ return -1;
if (n)
def->clock.timers = g_new0(virDomainTimerDef *, n);
@@ -19574,16 +19565,13 @@ virDomainDefClockParse(virDomainDef *def,
virDomainTimerDef *timer = virDomainTimerDefParseXML(nodes[i], ctxt);
if (!timer)
- goto error;
+ return -1;
def->clock.timers[def->clock.ntimers++] = timer;
}
VIR_FREE(nodes);
return 0;
-
- error:
- return -1;
}
static int
diff --git a/src/conf/netdev_vport_profile_conf.c b/src/conf/netdev_vport_profile_conf.c
index dfffc4dd70..d13833d7df 100644
--- a/src/conf/netdev_vport_profile_conf.c
+++ b/src/conf/netdev_vport_profile_conf.c
@@ -45,14 +45,14 @@ virNetDevVPortProfileParse(xmlNodePtr node, unsigned int flags)
(virtPort->virtPortType = virNetDevVPortTypeFromString(virtPortType)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown virtualport type %s"), virtPortType);
- goto error;
+ return NULL;
}
if ((virtPort->virtPortType == VIR_NETDEV_VPORT_PROFILE_NONE) &&
(flags & VIR_VPORT_XML_REQUIRE_TYPE)) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("missing required virtualport type"));
- goto error;
+ return NULL;
}
while (cur != NULL) {
@@ -74,12 +74,12 @@ virNetDevVPortProfileParse(xmlNodePtr node, unsigned int flags)
if (virStrToLong_ui(virtPortManagerID, NULL, 0, &val)) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("cannot parse value of managerid parameter"));
- goto error;
+ return NULL;
}
if (val > 0xff) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("value of managerid out of range"));
- goto error;
+ return NULL;
}
virtPort->managerID = (uint8_t)val;
virtPort->managerID_specified = true;
@@ -91,12 +91,12 @@ virNetDevVPortProfileParse(xmlNodePtr node, unsigned int flags)
if (virStrToLong_ui(virtPortTypeID, NULL, 0, &val)) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("cannot parse value of typeid parameter"));
- goto error;
+ return NULL;
}
if (val > 0xffffff) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("value for typeid out of range"));
- goto error;
+ return NULL;
}
virtPort->typeID = (uint32_t)val;
virtPort->typeID_specified = true;
@@ -108,12 +108,12 @@ virNetDevVPortProfileParse(xmlNodePtr node, unsigned int flags)
if (virStrToLong_ui(virtPortTypeIDVersion, NULL, 0, &val)) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("cannot parse value of typeidversion parameter"));
- goto error;
+ return NULL;
}
if (val > 0xff) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("value of typeidversion out of range"));
- goto error;
+ return NULL;
}
virtPort->typeIDVersion = (uint8_t)val;
virtPort->typeIDVersion_specified = true;
@@ -123,7 +123,7 @@ virNetDevVPortProfileParse(xmlNodePtr node, unsigned int flags)
if (virUUIDParse(virtPortInstanceID, virtPort->instanceID) < 0) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("cannot parse instanceid parameter as a uuid"));
- goto error;
+ return NULL;
}
virtPort->instanceID_specified = true;
}
@@ -132,14 +132,14 @@ virNetDevVPortProfileParse(xmlNodePtr node, unsigned int flags)
virStrcpyStatic(virtPort->profileID, virtPortProfileID) < 0) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("profileid parameter too long"));
- goto error;
+ return NULL;
}
if (virtPortInterfaceID) {
if (virUUIDParse(virtPortInterfaceID, virtPort->interfaceID) < 0) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("cannot parse interfaceid parameter as a uuid"));
- goto error;
+ return NULL;
}
virtPort->interfaceID_specified = true;
}
@@ -152,7 +152,7 @@ virNetDevVPortProfileParse(xmlNodePtr node, unsigned int flags)
if (virUUIDGenerate(virtPort->instanceID) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot generate a random uuid for instanceid"));
- goto error;
+ return NULL;
}
virtPort->instanceID_specified = true;
}
@@ -162,7 +162,7 @@ virNetDevVPortProfileParse(xmlNodePtr node, unsigned int flags)
if (virUUIDGenerate(virtPort->interfaceID) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot generate a random uuid for interfaceid"));
- goto error;
+ return NULL;
}
virtPort->interfaceID_specified = true;
}
@@ -172,16 +172,13 @@ virNetDevVPortProfileParse(xmlNodePtr node, unsigned int flags)
if ((flags & VIR_VPORT_XML_REQUIRE_ALL_ATTRIBUTES) &&
(virNetDevVPortProfileCheckComplete(virtPort, false) < 0)) {
- goto error;
+ return NULL;
}
if (virNetDevVPortProfileCheckNoExtras(virtPort) < 0)
- goto error;
+ return NULL;
return g_steal_pointer(&virtPort);
-
- error:
- return NULL;
}
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index c78456695c..6690d26ffd 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -692,7 +692,6 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt,
const char *permxpath)
{
long long val;
- int ret = -1;
VIR_XPATH_NODE_AUTORESTORE(ctxt)
xmlNodePtr node;
g_autofree char *mode = NULL;
@@ -715,7 +714,7 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt,
if (virStrToLong_i(mode, NULL, 8, &tmp) < 0 || (tmp & ~0777)) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("malformed octal mode"));
- goto error;
+ return -1;
}
perms->mode = tmp;
} else {
@@ -731,7 +730,7 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt,
val != -1)) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("malformed owner element"));
- goto error;
+ return -1;
}
perms->uid = val;
@@ -746,17 +745,14 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt,
val != -1)) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("malformed group element"));
- goto error;
+ return -1;
}
perms->gid = val;
}
/* NB, we're ignoring missing labels here - they'll simply inherit */
perms->label = virXPathString("string(./label)", ctxt);
-
- ret = 0;
- error:
- return ret;
+ return 0;
}
diff --git a/src/conf/storage_source_conf.c b/src/conf/storage_source_conf.c
index 5ca06fa30a..44944e1dbd 100644
--- a/src/conf/storage_source_conf.c
+++ b/src/conf/storage_source_conf.c
@@ -235,7 +235,6 @@ virStorageAuthDefParse(xmlNodePtr node,
xmlXPathContextPtr ctxt)
{
VIR_XPATH_NODE_AUTORESTORE(ctxt)
- virStorageAuthDef *ret = NULL;
xmlNodePtr secretnode = NULL;
g_autoptr(virStorageAuthDef) authdef = NULL;
g_autofree char *authtype = NULL;
@@ -247,7 +246,7 @@ virStorageAuthDefParse(xmlNodePtr node,
if (!(authdef->username = virXPathString("string(./@username)", ctxt))) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("missing username for auth"));
- goto cleanup;
+ return NULL;
}
authdef->authType = VIR_STORAGE_AUTH_TYPE_NONE;
@@ -259,14 +258,14 @@ virStorageAuthDefParse(xmlNodePtr node,
if ((authdef->authType = virStorageAuthTypeFromString(authtype)) < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown auth type '%s'"), authtype);
- goto cleanup;
+ return NULL;
}
}
if (!(secretnode = virXPathNode("./secret ", ctxt))) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("Missing <secret> element in auth"));
- goto cleanup;
+ return NULL;
}
/* Used by the domain disk xml parsing in order to ensure the
@@ -279,13 +278,9 @@ virStorageAuthDefParse(xmlNodePtr node,
authdef->secrettype = virXMLPropString(secretnode, "type");
if (virSecretLookupParseSecret(secretnode, &authdef->seclookupdef) < 0)
- goto cleanup;
+ return NULL;
- ret = g_steal_pointer(&authdef);
-
- cleanup:
-
- return ret;
+ return g_steal_pointer(&authdef);
}
diff --git a/src/conf/virsavecookie.c b/src/conf/virsavecookie.c
index c24a292355..5fc9ca06e1 100644
--- a/src/conf/virsavecookie.c
+++ b/src/conf/virsavecookie.c
@@ -61,9 +61,8 @@ virSaveCookieParse(xmlXPathContextPtr ctxt,
*obj = NULL;
- if (!(ctxt->node = virXPathNode("./cookie", ctxt))) {
+ if (!(ctxt->node = virXPathNode("./cookie", ctxt)))
return 0;
- }
return virSaveCookieParseNode(ctxt, obj, saveCookie);
}
diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c
index 14ea560309..e44eb7f1d3 100644
--- a/src/hypervisor/virhostdev.c
+++ b/src/hypervisor/virhostdev.c
@@ -92,7 +92,7 @@ static int virHostdevIsPCINodeDeviceUsed(virPCIDeviceAddress *devAddr, void *opa
if (helperData->usesVFIO &&
STREQ_NULLABLE(actual_drvname, helperData->driverName) &&
STREQ_NULLABLE(actual_domname, helperData->domainName))
- goto iommu_owner;
+ return 0;
if (actual_drvname && actual_domname)
virReportError(VIR_ERR_OPERATION_INVALID,
@@ -106,7 +106,7 @@ static int virHostdevIsPCINodeDeviceUsed(virPCIDeviceAddress *devAddr, void *opa
virPCIDeviceGetName(actual));
return -1;
}
- iommu_owner:
+
return 0;
}
diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c
index aa719a19d2..be5cc7e049 100644
--- a/src/libxl/libxl_migration.c
+++ b/src/libxl/libxl_migration.c
@@ -902,7 +902,7 @@ libxlMigrationSrcStartTunnel(libxlDriverPrivate *driver,
tc->dataFD[0] = -1;
tc->dataFD[1] = -1;
if (virPipe(tc->dataFD) < 0)
- goto out;
+ return -1;
arg = &tc->tmThread;
/* Read from pipe */
@@ -915,7 +915,7 @@ libxlMigrationSrcStartTunnel(libxlDriverPrivate *driver,
name, false, arg) < 0) {
virReportError(errno, "%s",
_("Unable to create tunnel migration thread"));
- goto out;
+ return -1;
}
virObjectUnlock(vm);
@@ -923,7 +923,6 @@ libxlMigrationSrcStartTunnel(libxlDriverPrivate *driver,
ret = libxlDoMigrateSrcSend(driver, vm, flags, tc->dataFD[1]);
virObjectLock(vm);
- out:
/* libxlMigrationSrcStopTunnel will be called in libxlDoMigrateSrcP2P
* to free all resources for us.
*/
diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c
index 05d4abbe81..17c5184b9b 100644
--- a/src/libxl/xen_xl.c
+++ b/src/libxl/xen_xl.c
@@ -1607,7 +1607,6 @@ xenFormatXLDisk(virConfValue *list, virDomainDiskDef *disk)
int format = virDomainDiskGetFormat(disk);
const char *driver = virDomainDiskGetDriver(disk);
g_autofree char *target = NULL;
- int ret = -1;
/* format */
virBufferAddLit(&buf, "format=");
@@ -1646,7 +1645,7 @@ xenFormatXLDisk(virConfValue *list, virDomainDiskDef *disk)
if (disk->transient) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("transient disks not supported yet"));
- goto cleanup;
+ return -1;
}
/* backendtype */
@@ -1673,7 +1672,7 @@ xenFormatXLDisk(virConfValue *list, virDomainDiskDef *disk)
* it must come last.
*/
if (xenFormatXLDiskSrc(disk->src, &target) < 0)
- goto cleanup;
+ return -1;
if (target)
virBufferAsprintf(&buf, ",target=%s", target);
@@ -1689,10 +1688,8 @@ xenFormatXLDisk(virConfValue *list, virDomainDiskDef *disk)
tmp->next = val;
else
list->list = val;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 93549e914a..681eb734ce 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -799,7 +799,7 @@ openvzDomainSetNetworkConfig(virConnectPtr conn,
if (openvzDomainSetNetwork(conn, def->name, def->nets[i], &buf) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not configure network"));
- goto exit;
+ return -1;
}
}
@@ -817,9 +817,6 @@ openvzDomainSetNetworkConfig(virConnectPtr conn,
}
return 0;
-
- exit:
- return -1;
}
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 67fae46a34..e87cda8c11 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -5580,14 +5580,11 @@ virQEMUCapsCacheNew(const char *libDir,
priv->kernelVersion = g_strdup_printf("%s %s", uts.release, uts.version);
priv->cpuData = virCPUDataGetHost();
-
- cleanup:
return cache;
error:
virObjectUnref(cache);
- cache = NULL;
- goto cleanup;
+ return NULL;
}
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 9186d59ca2..731227b158 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2058,16 +2058,16 @@ qemuMonitorJSONGetMemoryStats(qemuMonitor *mon,
}
if (!balloonpath)
- goto cleanup;
+ return ret;
if (!(cmd = qemuMonitorJSONMakeCommand("qom-get",
"s:path", balloonpath,
"s:property", "guest-stats",
NULL)))
- goto cleanup;
+ return ret;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return ret;
if ((data = virJSONValueObjectGetObject(reply, "error"))) {
const char *klass = virJSONValueObjectGetString(data, "class");
@@ -2077,18 +2077,18 @@ qemuMonitorJSONGetMemoryStats(qemuMonitor *mon,
STREQ_NULLABLE(desc, "guest hasn't updated any stats yet")) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("the guest hasn't updated any stats yet"));
- goto cleanup;
+ return ret;
}
}
if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0)
- goto cleanup;
+ return ret;
data = virJSONValueObjectGetObject(reply, "return");
if (!(statsdata = virJSONValueObjectGet(data, "stats"))) {
VIR_DEBUG("data does not include 'stats'");
- goto cleanup;
+ return ret;
}
GET_BALLOON_STATS(statsdata, "stat-swap-in",
@@ -2114,9 +2114,7 @@ qemuMonitorJSONGetMemoryStats(qemuMonitor *mon,
GET_BALLOON_STATS(statsdata, "stat-htlb-pgfail",
VIR_DOMAIN_MEMORY_STAT_HUGETLB_PGFAIL, 1);
- ret = got;
- cleanup:
- return ret;
+ return got;
}
#undef GET_BALLOON_STATS
diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
index d105eead27..bd58d500eb 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -1577,12 +1577,12 @@ qemuSnapshotCreateXML(virDomainPtr domain,
parse_flags |= VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE;
if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0)
- goto cleanup;
+ return NULL;
if (!vm->persistent && (flags & VIR_DOMAIN_SNAPSHOT_CREATE_HALT)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot halt after transient domain snapshot"));
- goto cleanup;
+ return NULL;
}
if ((flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY) ||
!virDomainObjIsActive(vm))
@@ -1593,7 +1593,7 @@ qemuSnapshotCreateXML(virDomainPtr domain,
if (!(def = virDomainSnapshotDefParseString(xmlDesc, driver->xmlopt,
priv->qemuCaps, NULL, parse_flags)))
- goto cleanup;
+ return NULL;
/* reject snapshot names containing slashes or starting with dot as
* snapshot definitions are saved in files named by the snapshot name */
@@ -1603,7 +1603,7 @@ qemuSnapshotCreateXML(virDomainPtr domain,
_("invalid snapshot name '%s': "
"name can't contain '/'"),
def->parent.name);
- goto cleanup;
+ return NULL;
}
if (def->parent.name[0] == '.') {
@@ -1611,7 +1611,7 @@ qemuSnapshotCreateXML(virDomainPtr domain,
_("invalid snapshot name '%s': "
"name can't start with '.'"),
def->parent.name);
- goto cleanup;
+ return NULL;
}
}
@@ -1622,7 +1622,7 @@ qemuSnapshotCreateXML(virDomainPtr domain,
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("live snapshot creation is supported only "
"during full system snapshots"));
- goto cleanup;
+ return NULL;
}
/* allow snapshots only in certain states */
@@ -1640,7 +1640,7 @@ qemuSnapshotCreateXML(virDomainPtr domain,
if (!redefine) {
virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid domain state %s"),
virDomainSnapshotStateTypeToString(state));
- goto cleanup;
+ return NULL;
}
break;
@@ -1648,7 +1648,7 @@ qemuSnapshotCreateXML(virDomainPtr domain,
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("qemu doesn't support taking snapshots of "
"PMSUSPENDED guests"));
- goto cleanup;
+ return NULL;
/* invalid states */
case VIR_DOMAIN_SNAPSHOT_NOSTATE:
@@ -1656,7 +1656,7 @@ qemuSnapshotCreateXML(virDomainPtr domain,
case VIR_DOMAIN_SNAPSHOT_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid domain state %s"),
virDomainSnapshotStateTypeToString(state));
- goto cleanup;
+ return NULL;
}
/* We are going to modify the domain below. Internal snapshots would use
@@ -1665,7 +1665,7 @@ qemuSnapshotCreateXML(virDomainPtr domain,
* job mask appropriately. */
if (qemuDomainObjBeginAsyncJob(driver, vm, QEMU_ASYNC_JOB_SNAPSHOT,
VIR_DOMAIN_JOB_OPERATION_SNAPSHOT, flags) < 0)
- goto cleanup;
+ return NULL;
qemuDomainObjSetAsyncJobMask(vm, QEMU_JOB_NONE);
@@ -1801,7 +1801,6 @@ qemuSnapshotCreateXML(virDomainPtr domain,
qemuDomainObjEndAsyncJob(driver, vm);
- cleanup:
return snapshot;
}
diff --git a/src/qemu/qemu_virtiofs.c b/src/qemu/qemu_virtiofs.c
index 0c12c5ea22..1b853a5a59 100644
--- a/src/qemu/qemu_virtiofs.c
+++ b/src/qemu/qemu_virtiofs.c
@@ -182,7 +182,6 @@ qemuVirtioFSStart(virQEMUDriver *driver,
pid_t pid = (pid_t) -1;
VIR_AUTOCLOSE fd = -1;
VIR_AUTOCLOSE logfd = -1;
- int ret = -1;
int rc;
if (!virFileExists(fs->src->path)) {
@@ -193,12 +192,12 @@ qemuVirtioFSStart(virQEMUDriver *driver,
}
if (!(pidfile = qemuVirtioFSCreatePidFilename(vm, fs->info.alias)))
- goto cleanup;
+ goto error;
socket_path = qemuDomainGetVHostUserFSSocketPath(vm->privateData, fs);
if ((fd = qemuVirtioFSOpenChardev(driver, vm, socket_path)) < 0)
- goto cleanup;
+ goto error;
logpath = qemuVirtioFSCreateLogFilename(cfg, vm->def, fs->info.alias);
@@ -206,7 +205,7 @@ qemuVirtioFSStart(virQEMUDriver *driver,
g_autoptr(virLogManager) logManager = virLogManagerNew(driver->privileged);
if (!logManager)
- goto cleanup;
+ goto error;
if ((logfd = virLogManagerDomainOpenLogFile(logManager,
"qemu",
@@ -215,12 +214,12 @@ qemuVirtioFSStart(virQEMUDriver *driver,
logpath,
0,
NULL, NULL)) < 0)
- goto cleanup;
+ goto error;
} else {
if ((logfd = open(logpath, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR)) < 0) {
virReportSystemError(errno, _("failed to create logfile %s"),
logpath);
- goto cleanup;
+ goto error;
}
if (virSetCloseExec(logfd) < 0) {
virReportSystemError(errno, _("failed to set close-on-exec flag on %s"),
@@ -230,7 +229,7 @@ qemuVirtioFSStart(virQEMUDriver *driver,
}
if (!(cmd = qemuVirtioFSBuildCommandLine(cfg, fs, &fd)))
- goto cleanup;
+ goto error;
/* so far only running as root is supported */
virCommandSetUID(cmd, 0);
@@ -243,7 +242,7 @@ qemuVirtioFSStart(virQEMUDriver *driver,
virCommandDaemonize(cmd);
if (qemuExtDeviceLogCommand(driver, vm, cmd, "virtiofsd") < 0)
- goto cleanup;
+ goto error;
rc = virCommandRun(cmd, NULL);
@@ -267,10 +266,7 @@ qemuVirtioFSStart(virQEMUDriver *driver,
goto error;
}
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
error:
if (pid != -1)
@@ -279,7 +275,7 @@ qemuVirtioFSStart(virQEMUDriver *driver,
unlink(pidfile);
if (socket_path)
unlink(socket_path);
- goto cleanup;
+ return -1;
}
diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c
index 22d54c99be..a3adc85728 100644
--- a/src/rpc/virnetlibsshsession.c
+++ b/src/rpc/virnetlibsshsession.c
@@ -453,7 +453,6 @@ virNetLibsshImportPrivkey(virNetLibsshSession *sess,
virNetLibsshAuthMethod *priv,
ssh_key *ret_key)
{
- int err;
int ret;
ssh_key key;
@@ -470,8 +469,7 @@ virNetLibsshImportPrivkey(virNetLibsshSession *sess,
virReportError(VIR_ERR_AUTH_FAILED,
_("error while reading private key '%s'"),
priv->filename);
- err = SSH_AUTH_ERROR;
- goto error;
+ return SSH_AUTH_ERROR;
} else if (ret == SSH_ERROR) {
if (virGetLastErrorCode() == VIR_ERR_OK) {
virReportError(VIR_ERR_AUTH_FAILED,
@@ -479,15 +477,11 @@ virNetLibsshImportPrivkey(virNetLibsshSession *sess,
"passphrase?"),
priv->filename);
}
- err = SSH_AUTH_ERROR;
- goto error;
+ return SSH_AUTH_ERROR;
}
*ret_key = key;
return SSH_AUTH_SUCCESS;
-
- error:
- return err;
}
diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_backend_iscsi.c
index ed17ed11a6..eef1d91062 100644
--- a/src/storage/storage_backend_iscsi.c
+++ b/src/storage/storage_backend_iscsi.c
@@ -91,7 +91,6 @@ static int
virStorageBackendISCSIGetHostNumber(const char *sysfs_path,
uint32_t *host)
{
- int ret = -1;
g_autoptr(DIR) sysdir = NULL;
struct dirent *dirent = NULL;
int direrr;
@@ -101,17 +100,16 @@ virStorageBackendISCSIGetHostNumber(const char *sysfs_path,
virWaitForDevices();
if (virDirOpen(&sysdir, sysfs_path) < 0)
- goto cleanup;
+ return -1;
while ((direrr = virDirRead(sysdir, &dirent, sysfs_path)) > 0) {
if (STRPREFIX(dirent->d_name, "target")) {
if (sscanf(dirent->d_name, "target%u:", host) == 1) {
- ret = 0;
- goto cleanup;
+ return 0;
} else {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to parse target '%s'"), dirent->d_name);
- goto cleanup;
+ return -1;
}
}
}
@@ -120,11 +118,10 @@ virStorageBackendISCSIGetHostNumber(const char *sysfs_path,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to get host number for iSCSI session "
"with path '%s'"), sysfs_path);
- goto cleanup;
+ return -1;
}
- cleanup:
- return ret;
+ return -1;
}
static int
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index ea474d55ac..d2577b2b16 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -858,13 +858,13 @@ testParseXMLDocFromFile(xmlNodePtr node, const char *file, const char *type)
absFile = testBuildFilename(file, relFile);
if (!(doc = virXMLParse(absFile, NULL, type, NULL, false)))
- goto error;
+ return NULL;
ret = xmlCopyNode(xmlDocGetRootElement(doc), 1);
if (!ret) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to copy XML node"));
- goto error;
+ return NULL;
}
xmlReplaceNode(node, ret);
xmlFreeNode(node);
@@ -872,7 +872,6 @@ testParseXMLDocFromFile(xmlNodePtr node, const char *file, const char *type)
ret = node;
}
- error:
return ret;
}
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 6234095827..51da6e6a2f 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -2764,8 +2764,7 @@ virCgroupKillRecursiveInternal(virCgroup *group,
if (rc == 0) {
VIR_DEBUG("Path %s does not exist, assuming done", keypath);
- killedAny = false;
- goto done;
+ return 0;
}
while ((direrr = virDirRead(dp, &ent, keypath)) > 0) {
@@ -2791,7 +2790,6 @@ virCgroupKillRecursiveInternal(virCgroup *group,
if (direrr < 0)
return -1;
- done:
return killedAny ? 1 : 0;
}
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
index 8a04bb2e4a..96f36c3b4d 100644
--- a/src/util/vircgroupv1.c
+++ b/src/util/vircgroupv1.c
@@ -926,7 +926,6 @@ virCgroupV1SetOwner(virCgroup *cgroup,
gid_t gid,
int controllers)
{
- int ret = -1;
size_t i;
int direrr;
@@ -945,7 +944,7 @@ virCgroupV1SetOwner(virCgroup *cgroup,
cgroup->legacy[i].placement);
if (virDirOpen(&dh, base) < 0)
- goto cleanup;
+ return -1;
while ((direrr = virDirRead(dh, &de, base)) > 0) {
g_autofree char *entry = NULL;
@@ -956,24 +955,21 @@ virCgroupV1SetOwner(virCgroup *cgroup,
virReportSystemError(errno,
_("cannot chown '%s' to (%u, %u)"),
entry, uid, gid);
- goto cleanup;
+ return -1;
}
}
if (direrr < 0)
- goto cleanup;
+ return -1;
if (chown(base, uid, gid) < 0) {
virReportSystemError(errno,
_("cannot chown '%s' to (%u, %u)"),
base, uid, gid);
- goto cleanup;
+ return -1;
}
}
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
@@ -1599,7 +1595,6 @@ virCgroupV1GetMemoryStat(virCgroup *group,
unsigned long long *inactiveFile,
unsigned long long *unevictable)
{
- int ret = -1;
g_autofree char *stat = NULL;
char *line = NULL;
unsigned long long cacheVal = 0;
@@ -1629,12 +1624,12 @@ virCgroupV1GetMemoryStat(virCgroup *group,
if (!valueStr) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Cannot parse 'memory.stat' cgroup file."));
- goto cleanup;
+ return -1;
}
*valueStr = '\0';
if (virStrToLong_ull(valueStr + 1, NULL, 10, &value) < 0)
- goto cleanup;
+ return -1;
if (STREQ(line, "cache"))
cacheVal = value >> 10;
@@ -1662,10 +1657,7 @@ virCgroupV1GetMemoryStat(virCgroup *group,
*inactiveFile = inactiveFileVal;
*unevictable = unevictableVal;
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c
index f2f606913f..2dd9a20377 100644
--- a/src/util/virdnsmasq.c
+++ b/src/util/virdnsmasq.c
@@ -172,10 +172,8 @@ addnhostsWrite(const char *path,
if (!(f = fopen(tmp, "w"))) {
istmp = false;
- if (!(f = fopen(path, "w"))) {
- rc = -errno;
- goto cleanup;
- }
+ if (!(f = fopen(path, "w")))
+ return -errno;
}
for (i = 0; i < nhosts; i++) {
@@ -186,7 +184,7 @@ addnhostsWrite(const char *path,
if (istmp)
unlink(tmp);
- goto cleanup;
+ return rc;
}
for (j = 0; j < hosts[i].nhostnames; j++) {
@@ -197,7 +195,7 @@ addnhostsWrite(const char *path,
if (istmp)
unlink(tmp);
- goto cleanup;
+ return rc;
}
}
@@ -208,23 +206,20 @@ addnhostsWrite(const char *path,
if (istmp)
unlink(tmp);
- goto cleanup;
+ return rc;
}
}
- if (VIR_FCLOSE(f) == EOF) {
- rc = -errno;
- goto cleanup;
- }
+ if (VIR_FCLOSE(f) == EOF)
+ return -errno;
if (istmp && rename(tmp, path) < 0) {
rc = -errno;
unlink(tmp);
- goto cleanup;
+ return rc;
}
- cleanup:
- return rc;
+ return 0;
}
static int
@@ -369,10 +364,8 @@ hostsfileWrite(const char *path,
if (!(f = fopen(tmp, "w"))) {
istmp = false;
- if (!(f = fopen(path, "w"))) {
- rc = -errno;
- goto cleanup;
- }
+ if (!(f = fopen(path, "w")))
+ return -errno;
}
for (i = 0; i < nhosts; i++) {
@@ -383,23 +376,20 @@ hostsfileWrite(const char *path,
if (istmp)
unlink(tmp);
- goto cleanup;
+ return rc;
}
}
- if (VIR_FCLOSE(f) == EOF) {
- rc = -errno;
- goto cleanup;
- }
+ if (VIR_FCLOSE(f) == EOF)
+ return -errno;
if (istmp && rename(tmp, path) < 0) {
rc = -errno;
unlink(tmp);
- goto cleanup;
+ return rc;
}
- cleanup:
- return rc;
+ return 0;
}
static int
diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c
index 3563a662d5..67b6910626 100644
--- a/src/util/virhostcpu.c
+++ b/src/util/virhostcpu.c
@@ -90,7 +90,7 @@ virHostCPUGetStatsFreeBSD(int cpuNum,
g_autofree long *cpu_times = NULL;
struct clockinfo clkinfo;
size_t i, j, cpu_times_size, clkinfo_size;
- int cpu_times_num, offset, hz, stathz, ret = -1;
+ int cpu_times_num, offset, hz, stathz;
struct field_cpu_map {
const char *field;
int idx[CPUSTATES];
@@ -151,7 +151,7 @@ virHostCPUGetStatsFreeBSD(int cpuNum,
virReportSystemError(errno,
_("sysctl failed for '%s'"),
sysctl_name);
- goto cleanup;
+ return -1;
}
for (i = 0; cpu_map[i].field != NULL; i++) {
@@ -161,7 +161,7 @@ virHostCPUGetStatsFreeBSD(int cpuNum,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Field '%s' too long for destination"),
cpu_map[i].field);
- goto cleanup;
+ return -1;
}
param->value = 0;
@@ -169,10 +169,7 @@ virHostCPUGetStatsFreeBSD(int cpuNum,
param->value += cpu_times[offset + cpu_map[i].idx[j]] * TICK_TO_NSEC;
}
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
#endif /* __FreeBSD__ */
diff --git a/tests/domainconftest.c b/tests/domainconftest.c
index 71fd1f7b73..14d84b0071 100644
--- a/tests/domainconftest.c
+++ b/tests/domainconftest.c
@@ -76,10 +76,10 @@ mymain(void)
int ret = 0;
if ((caps = virTestGenericCapsInit()) == NULL)
- goto cleanup;
+ return EXIT_FAILURE;
if (!(xmlopt = virTestGenericDomainXMLConfInit()))
- goto cleanup;
+ return EXIT_FAILURE;
#define DO_TEST_GET_FS(fspath, expect) \
do { \
@@ -100,7 +100,6 @@ mymain(void)
virObjectUnref(caps);
virObjectUnref(xmlopt);
- cleanup:
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 161e7efa62..58f16ef459 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -141,20 +141,15 @@ fakeStorageVolLookupByName(virStoragePoolPtr pool,
return NULL;
}
- if (!strchr(name, '+'))
- goto fallback;
-
if (!(volinfo = g_strsplit(name, "+", 2)))
return NULL;
- if (!volinfo[1])
- goto fallback;
+ if (!volinfo[1]) {
+ return virGetStorageVol(pool->conn, pool->name, name, "block", NULL, NULL);
+ }
return virGetStorageVol(pool->conn, pool->name, volinfo[1], volinfo[0],
NULL, NULL);
-
- fallback:
- return virGetStorageVol(pool->conn, pool->name, name, "block", NULL, NULL);
}
static int
diff --git a/tests/virpcitest.c b/tests/virpcitest.c
index 4c0f0b91c3..ad2fcc6751 100644
--- a/tests/virpcitest.c
+++ b/tests/virpcitest.c
@@ -81,7 +81,7 @@ testVirPCIDeviceNew(const void *opaque G_GNUC_UNUSED)
virReportError(VIR_ERR_INTERNAL_ERROR, \
"Unexpected count of items in " #list ": %d, " \
"expecting %zu", count, (size_t) cnt); \
- goto cleanup; \
+ return -1; \
}
static int
@@ -165,7 +165,6 @@ testVirPCIDeviceReset(const void *opaque G_GNUC_UNUSED)
static int
testVirPCIDeviceReattach(const void *opaque G_GNUC_UNUSED)
{
- int ret = -1;
virPCIDevice *dev[] = {NULL, NULL, NULL};
size_t i, nDev = G_N_ELEMENTS(dev);
g_autoptr(virPCIDeviceList) activeDevs = NULL;
@@ -174,17 +173,17 @@ testVirPCIDeviceReattach(const void *opaque G_GNUC_UNUSED)
if (!(activeDevs = virPCIDeviceListNew()) ||
!(inactiveDevs = virPCIDeviceListNew()))
- goto cleanup;
+ return -1;
for (i = 0; i < nDev; i++) {
virPCIDeviceAddress devAddr = {.domain = 0, .bus = 0,
.slot = i + 1, .function = 0};
if (!(dev[i] = virPCIDeviceNew(&devAddr)))
- goto cleanup;
+ return -1;
if (virPCIDeviceListAdd(inactiveDevs, dev[i]) < 0) {
virPCIDeviceFree(dev[i]);
- goto cleanup;
+ return -1;
}
CHECK_LIST_COUNT(activeDevs, 0);
@@ -198,15 +197,13 @@ testVirPCIDeviceReattach(const void *opaque G_GNUC_UNUSED)
for (i = 0; i < nDev; i++) {
if (virPCIDeviceReattach(dev[i], activeDevs, inactiveDevs) < 0)
- goto cleanup;
+ return -1;
CHECK_LIST_COUNT(activeDevs, 0);
CHECK_LIST_COUNT(inactiveDevs, nDev - i - 1);
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
struct testPCIDevData {
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 22f428f702..c592d0281a 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -4453,7 +4453,7 @@ cmdSave(vshControl *ctl, const vshCmd *cmd)
return false;
if (vshCommandOptStringReq(ctl, cmd, "file", &to) < 0)
- goto cleanup;
+ return false;
if (vshCommandOptBool(cmd, "verbose"))
verbose = true;
@@ -4462,7 +4462,7 @@ cmdSave(vshControl *ctl, const vshCmd *cmd)
true,
doSave,
&data) < 0)
- goto cleanup;
+ return false;
virshWatchJob(ctl, dom, verbose, eventLoop,
&data.ret, 0, NULL, NULL, _("Save"));
@@ -4472,7 +4472,6 @@ cmdSave(vshControl *ctl, const vshCmd *cmd)
if (!data.ret)
vshPrintExtra(ctl, _("\nDomain '%s' saved to %s\n"), name, to);
- cleanup:
return !data.ret;
}
@@ -4770,7 +4769,7 @@ cmdManagedSave(vshControl *ctl, const vshCmd *cmd)
true,
doManagedsave,
&data) < 0)
- goto cleanup;
+ return false;
virshWatchJob(ctl, dom, verbose, eventLoop,
&data.ret, 0, NULL, NULL, _("Managedsave"));
@@ -4780,7 +4779,6 @@ cmdManagedSave(vshControl *ctl, const vshCmd *cmd)
if (!data.ret)
vshPrintExtra(ctl, _("\nDomain '%s' state saved by libvirt\n"), name);
- cleanup:
return !data.ret;
}
diff --git a/tools/virsh-host.c b/tools/virsh-host.c
index fc84415e7b..5ae6657347 100644
--- a/tools/virsh-host.c
+++ b/tools/virsh-host.c
@@ -1122,11 +1122,11 @@ vshExtractCPUDefXMLs(vshControl *ctl,
}
}
- cleanup:
- return g_steal_pointer(&cpus);
+ return cpus;
error:
- goto cleanup;
+ g_strfreev(cpus);
+ return NULL;
}
diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c
index 424865962f..fe15d2d702 100644
--- a/tools/virsh-nodedev.c
+++ b/tools/virsh-nodedev.c
@@ -141,7 +141,6 @@ static bool
cmdNodeDeviceDestroy(vshControl *ctl, const vshCmd *cmd)
{
g_autoptr(virshNodeDevice) dev = NULL;
- bool ret = false;
const char *device_value = NULL;
if (vshCommandOptStringReq(ctl, cmd, "device", &device_value) < 0)
@@ -149,18 +148,16 @@ cmdNodeDeviceDestroy(vshControl *ctl, const vshCmd *cmd)
dev = vshFindNodeDevice(ctl, device_value);
if (!dev)
- goto cleanup;
+ return false;
if (virNodeDeviceDestroy(dev) == 0) {
vshPrintExtra(ctl, _("Destroyed node device '%s'\n"), device_value);
} else {
vshError(ctl, _("Failed to destroy node device '%s'"), device_value);
- goto cleanup;
+ return false;
}
- ret = true;
- cleanup:
- return ret;
+ return true;
}
struct virshNodeList {
@@ -578,7 +575,6 @@ cmdNodeDeviceDumpXML(vshControl *ctl, const vshCmd *cmd)
g_autoptr(virshNodeDevice) device = NULL;
g_autofree char *xml = NULL;
const char *device_value = NULL;
- bool ret = false;
if (vshCommandOptStringReq(ctl, cmd, "device", &device_value) < 0)
return false;
@@ -586,16 +582,13 @@ cmdNodeDeviceDumpXML(vshControl *ctl, const vshCmd *cmd)
device = vshFindNodeDevice(ctl, device_value);
if (!device)
- goto cleanup;
+ return false;
if (!(xml = virNodeDeviceGetXMLDesc(device, 0)))
- goto cleanup;
+ return false;
vshPrint(ctl, "%s\n", xml);
-
- ret = true;
- cleanup:
- return ret;
+ return true;
}
/*
@@ -1013,7 +1006,6 @@ static bool
cmdNodeDeviceUndefine(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
{
g_autoptr(virshNodeDevice) dev = NULL;
- bool ret = false;
const char *device_value = NULL;
if (vshCommandOptStringReq(ctl, cmd, "device", &device_value) < 0)
@@ -1022,17 +1014,15 @@ cmdNodeDeviceUndefine(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
dev = vshFindNodeDevice(ctl, device_value);
if (!dev)
- goto cleanup;
+ return false;
if (virNodeDeviceUndefine(dev, 0) < 0) {
vshError(ctl, _("Failed to undefine node device '%s'"), device_value);
- goto cleanup;
+ return false;
}
vshPrintExtra(ctl, _("Undefined node device '%s'\n"), device_value);
- ret = true;
- cleanup:
- return ret;
+ return true;
}
@@ -1163,7 +1153,6 @@ static bool
cmdNodeDeviceAutostart(vshControl *ctl, const vshCmd *cmd)
{
g_autoptr(virshNodeDevice) dev = NULL;
- bool ret = false;
const char *name = NULL;
int autostart;
@@ -1172,7 +1161,8 @@ cmdNodeDeviceAutostart(vshControl *ctl, const vshCmd *cmd)
dev = vshFindNodeDevice(ctl, name);
- if (!dev) goto cleanup;
+ if (!dev)
+ return false;
autostart = !vshCommandOptBool(cmd, "disable");
@@ -1181,7 +1171,7 @@ cmdNodeDeviceAutostart(vshControl *ctl, const vshCmd *cmd)
vshError(ctl, _("failed to mark device %s as autostarted"), name);
else
vshError(ctl, _("failed to unmark device %s as autostarted"), name);
- goto cleanup;
+ return false;
}
if (autostart)
@@ -1189,9 +1179,7 @@ cmdNodeDeviceAutostart(vshControl *ctl, const vshCmd *cmd)
else
vshPrintExtra(ctl, _("Device %s unmarked as autostarted\n"), name);
- ret = true;
- cleanup:
- return ret;
+ return true;
}
@@ -1224,7 +1212,6 @@ cmdNodeDeviceInfo(vshControl *ctl, const vshCmd *cmd)
{
g_autoptr(virshNodeDevice) device = NULL;
const char *device_value = NULL;
- bool ret = false;
int autostart;
const char *parent = NULL;
@@ -1234,7 +1221,7 @@ cmdNodeDeviceInfo(vshControl *ctl, const vshCmd *cmd)
device = vshFindNodeDevice(ctl, device_value);
if (!device)
- goto cleanup;
+ return false;
parent = virNodeDeviceGetParent(device);
vshPrint(ctl, "%-15s %s\n", _("Name:"), virNodeDeviceGetName(device));
@@ -1248,9 +1235,7 @@ cmdNodeDeviceInfo(vshControl *ctl, const vshCmd *cmd)
else
vshPrint(ctl, "%-15s %s\n", _("Autostart:"), autostart ? _("yes") : _("no"));
- ret = true;
- cleanup:
- return ret;
+ return true;
}
diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c
index 12773d900b..ca40fbcd72 100644
--- a/tools/virsh-volume.c
+++ b/tools/virsh-volume.c
@@ -238,7 +238,6 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
unsigned long flags = 0;
virshControl *priv = ctl->privData;
- bool ret = false;
if (vshCommandOptBool(cmd, "prealloc-metadata"))
flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;
@@ -247,27 +246,27 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
return false;
if (vshCommandOptStringReq(ctl, cmd, "name", &name) < 0)
- goto cleanup;
+ return false;
if (vshCommandOptStringReq(ctl, cmd, "capacity", &capacityStr) < 0)
- goto cleanup;
+ return false;
if (virshVolSize(capacityStr, &capacity) < 0) {
vshError(ctl, _("Malformed size %s"), capacityStr);
- goto cleanup;
+ return false;
}
if (vshCommandOptStringQuiet(ctl, cmd, "allocation", &allocationStr) > 0 &&
virshVolSize(allocationStr, &allocation) < 0) {
vshError(ctl, _("Malformed size %s"), allocationStr);
- goto cleanup;
+ return false;
}
if (vshCommandOptStringReq(ctl, cmd, "format", &format) < 0 ||
vshCommandOptStringReq(ctl, cmd, "backing-vol", &snapshotStrVol) < 0 ||
vshCommandOptStringReq(ctl, cmd, "backing-vol-format",
&snapshotStrFormat) < 0)
- goto cleanup;
+ return false;
virBufferAddLit(&buf, "<volume>\n");
virBufferAdjustIndent(&buf, 2);
@@ -325,11 +324,11 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
}
if (snapVol == NULL) {
vshError(ctl, _("failed to get vol '%s'"), snapshotStrVol);
- goto cleanup;
+ return false;
}
if ((snapshotStrVolPath = virStorageVolGetPath(snapVol)) == NULL) {
- goto cleanup;
+ return false;
}
/* Create XML for the backing store */
@@ -353,15 +352,12 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
} else {
if (!(vol = virStorageVolCreateXML(pool, xml, flags))) {
vshError(ctl, _("Failed to create vol %s"), name);
- goto cleanup;
+ return false;
}
vshPrintExtra(ctl, _("Vol %s created\n"), name);
}
- ret = true;
-
- cleanup:
- return ret;
+ return true;
}
/*
@@ -393,7 +389,6 @@ cmdVolCreate(vshControl *ctl, const vshCmd *cmd)
g_autoptr(virshStoragePool) pool = NULL;
g_autoptr(virshStorageVol) vol = NULL;
const char *from = NULL;
- bool ret = false;
unsigned int flags = 0;
g_autofree char *buffer = NULL;
@@ -404,23 +399,21 @@ cmdVolCreate(vshControl *ctl, const vshCmd *cmd)
return false;
if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
- goto cleanup;
+ return false;
if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) {
vshSaveLibvirtError();
- goto cleanup;
+ return false;
}
if (!(vol = virStorageVolCreateXML(pool, buffer, flags))) {
vshError(ctl, _("Failed to create vol from %s"), from);
- goto cleanup;
+ return false;
}
vshPrintExtra(ctl, _("Vol %s created from %s\n"),
virStorageVolGetName(vol), from);
- ret = true;
- cleanup:
- return ret;
+ return true;
}
/*
@@ -463,12 +456,11 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd)
g_autoptr(virshStorageVol) newvol = NULL;
g_autoptr(virshStorageVol) inputvol = NULL;
const char *from = NULL;
- bool ret = false;
g_autofree char *buffer = NULL;
unsigned int flags = 0;
if (!(pool = virshCommandOptPool(ctl, cmd, "pool", NULL)))
- goto cleanup;
+ return false;
if (vshCommandOptBool(cmd, "prealloc-metadata"))
flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;
@@ -477,28 +469,26 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd)
flags |= VIR_STORAGE_VOL_CREATE_REFLINK;
if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
- goto cleanup;
+ return false;
if (!(inputvol = virshCommandOptVol(ctl, cmd, "vol", "inputpool", NULL)))
- goto cleanup;
+ return false;
if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) {
vshReportError(ctl);
- goto cleanup;
+ return false;
}
newvol = virStorageVolCreateXMLFrom(pool, buffer, inputvol, flags);
if (!newvol) {
vshError(ctl, _("Failed to create vol from %s"), from);
- goto cleanup;
+ return false;
}
vshPrintExtra(ctl, _("Vol %s created from input vol %s\n"),
virStorageVolGetName(newvol), virStorageVolGetName(inputvol));
- ret = true;
- cleanup:
- return ret;
+ return true;
}
static xmlChar *
@@ -653,7 +643,6 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd)
{
const char *file = NULL;
g_autoptr(virshStorageVol) vol = NULL;
- bool ret = false;
VIR_AUTOCLOSE fd = -1;
g_autoptr(virshStream) st = NULL;
const char *name = NULL;
@@ -673,16 +662,16 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd)
return false;
if (vshCommandOptStringReq(ctl, cmd, "file", &file) < 0)
- goto cleanup;
+ return false;
if ((fd = open(file, O_RDONLY)) < 0) {
vshError(ctl, _("cannot read %s"), file);
- goto cleanup;
+ return false;
}
if (fstat(fd, &sb) < 0) {
vshError(ctl, _("unable to stat %s"), file);
- goto cleanup;
+ return false;
}
cbData.ctl = ctl;
@@ -694,12 +683,12 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd)
if (!(st = virStreamNew(priv->conn, 0))) {
vshError(ctl, _("cannot create a new stream"));
- goto cleanup;
+ return false;
}
if (virStorageVolUpload(vol, st, offset, length, flags) < 0) {
vshError(ctl, _("cannot upload to volume %s"), name);
- goto cleanup;
+ return false;
}
if (flags & VIR_STORAGE_VOL_UPLOAD_SPARSE_STREAM) {
@@ -707,30 +696,27 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd)
virshStreamInData,
virshStreamSourceSkip, &cbData) < 0) {
vshError(ctl, _("cannot send data to volume %s"), name);
- goto cleanup;
+ return false;
}
} else {
if (virStreamSendAll(st, virshStreamSource, &cbData) < 0) {
vshError(ctl, _("cannot send data to volume %s"), name);
- goto cleanup;
+ return false;
}
}
if (VIR_CLOSE(fd) < 0) {
vshError(ctl, _("cannot close file %s"), file);
virStreamAbort(st);
- goto cleanup;
+ return false;
}
if (virStreamFinish(st) < 0) {
vshError(ctl, _("cannot close volume %s"), name);
- goto cleanup;
+ return false;
}
- ret = true;
-
- cleanup:
- return ret;
+ return true;
}
/*
@@ -931,7 +917,6 @@ static bool
cmdVolWipe(vshControl *ctl, const vshCmd *cmd)
{
g_autoptr(virshStorageVol) vol = NULL;
- bool ret = false;
const char *name;
const char *algorithm_str = NULL;
int algorithm = VIR_STORAGE_VOL_WIPE_ALG_ZERO;
@@ -941,12 +926,12 @@ cmdVolWipe(vshControl *ctl, const vshCmd *cmd)
return false;
if (vshCommandOptStringReq(ctl, cmd, "algorithm", &algorithm_str) < 0)
- goto out;
+ return false;
if (algorithm_str &&
(algorithm = virshStorageVolWipeAlgorithmTypeFromString(algorithm_str)) < 0) {
vshError(ctl, _("Unsupported algorithm '%s'"), algorithm_str);
- goto out;
+ return false;
}
if ((funcRet = virStorageVolWipePattern(vol, algorithm, 0)) < 0) {
@@ -957,13 +942,11 @@ cmdVolWipe(vshControl *ctl, const vshCmd *cmd)
if (funcRet < 0) {
vshError(ctl, _("Failed to wipe vol %s"), name);
- goto out;
+ return false;
}
vshPrintExtra(ctl, _("Vol %s wiped\n"), name);
- ret = true;
- out:
- return ret;
+ return true;
}
@@ -1111,7 +1094,6 @@ cmdVolResize(vshControl *ctl, const vshCmd *cmd)
const char *capacityStr = NULL;
unsigned long long capacity = 0;
unsigned int flags = 0;
- bool ret = false;
bool delta = vshCommandOptBool(cmd, "delta");
if (vshCommandOptBool(cmd, "allocate"))
@@ -1123,7 +1105,7 @@ cmdVolResize(vshControl *ctl, const vshCmd *cmd)
return false;
if (vshCommandOptStringReq(ctl, cmd, "capacity", &capacityStr) < 0)
- goto cleanup;
+ return false;
virSkipSpaces(&capacityStr);
if (*capacityStr == '-') {
/* The API always requires a positive value; but we allow a
@@ -1134,7 +1116,7 @@ cmdVolResize(vshControl *ctl, const vshCmd *cmd)
} else {
vshError(ctl, "%s",
_("negative size requires --shrink"));
- goto cleanup;
+ return false;
}
}
@@ -1143,7 +1125,7 @@ cmdVolResize(vshControl *ctl, const vshCmd *cmd)
if (virshVolSize(capacityStr, &capacity) < 0) {
vshError(ctl, _("Malformed size %s"), capacityStr);
- goto cleanup;
+ return false;
}
if (virStorageVolResize(vol, capacity, flags) < 0) {
@@ -1151,16 +1133,14 @@ cmdVolResize(vshControl *ctl, const vshCmd *cmd)
delta ? _("Failed to change size of volume '%s' by %s")
: _("Failed to change size of volume '%s' to %s"),
virStorageVolGetName(vol), capacityStr);
- goto cleanup;
+ return false;
}
vshPrintExtra(ctl,
delta ? _("Size of volume '%s' successfully changed by %s\n")
: _("Size of volume '%s' successfully changed to %s\n"),
virStorageVolGetName(vol), capacityStr);
- ret = true;
- cleanup:
- return ret;
+ return true;
}
/*
--
2.32.0
3 years