Commit Graph

7420 Commits

Author SHA1 Message Date
Michal Privoznik
ac35a9fca2 qemuagenttest: Don't leak virTypedParameter on failure
There are two functions (testQemuAgentOSInfo() and
testQemuAgentTimezone()) which call virTypedParamsFree() only in
successful paths. If an error is met then those parameters would
be leaked. Fix this by placing the virTypedParamsFree() calls on
better place.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2021-11-11 16:16:02 +01:00
Pavel Hrdina
d73265af6e qemu_command: do not use host-nodes for system memory
Commit 88957116c9 switched to use
memory-backend-* for regular VM memory as well. That change indirectly
started using 'host-nodes' for system memory which results in QEMU
calling mbind() to bind the system memory to specific NUMA node if the
VM XML contains the configuration similar to this:

  ...
  <numatune>
    <memory mode='strict' nodeset='0'/>
  </numatune>
  ...

Once the VM was started with that configuration it was no longer
possible to change the memory NUMA nodeset.

Fixes: 677c90cc1d
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-11-10 11:17:44 +01:00
Tim Wiederhake
f976f90465 testVshTableHeader: Cleanup
Remove unnecessary label and goto. This also fixes a bug where a
failure to create the table would result in the test passing.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-11-08 14:32:32 +01:00
Tim Wiederhake
1fc3f05293 testLXCCapsInit: Cleanup
Remove unnecessary label and goto. Cleanup line breaks.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-11-08 14:32:32 +01:00
Tim Wiederhake
086f44a0fe fillXenCaps: Cleanup
Rework to remove unnecessary label and goto.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-11-08 14:32:32 +01:00
Tim Wiederhake
3bc6f46d30 qemu: Invalidate capabilities cache on host cpuid mismatch
See https://bugzilla.redhat.com/show_bug.cgi?id=1953389.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-11-05 17:12:25 +01:00
zhanglei
85e4f3db7c qemu: refactor 'qemuAgentGetInterfaces'
Add report_unsupported parameter to qemuAgentGetInterfaces

Signed-off-by: zhanglei <zhanglei@smartx.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-11-05 13:38:40 +01:00
Stefan Berger
a5bbe1a8b6 qemu: tpm: Extend TPM domain XML with PCR banks to activate
Extend the TPM backend XML with a node 'active_pcr_banks' that allows a
user to specify the PCR banks to activate before starting a VM. Valid
choices for PCR banks are sha1, sha256, sha384 and sha512. When the XML
node is provided, the set of active PCR banks is 'enforced' by running
swtpm_setup before every start of the VM. The activation requires that
swtpm_setup v0.7 or later is installed and may not have any effect
otherwise.

<tpm model='tpm-tis'>
  <backend type='emulator' version='2.0'>
    <active_pcr_banks>
      <sha256/>
      <sha384/>
    </active_pcr_banks>
  </backend>
</tpm>

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2016599

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-11-05 09:22:50 +01:00
Ján Tomko
da0a5ef598 qemu: retire QEMU_CAPS_SPICE_UNIX
It is now unused.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-11-04 14:37:15 +01:00
Ján Tomko
d7c814f7f7 tests: convert name-escape to use real caps
For later QEMUs than 2.11 we do FD passing for character devices,
so lock the capabilites to this exact version.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-11-04 14:37:15 +01:00
Ján Tomko
65b0b746b5 tests: qemuxml2argv: use latest caps for spice tests
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-11-04 14:37:15 +01:00
Ján Tomko
966e08ebef tests: qemuxml2xml: use latest caps for spice tests
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-11-04 14:37:15 +01:00
Ján Tomko
ee7a03bd55 tests: qemuxml2xmltest: move graphics-spice-timeout
Move the test closer to other graphics-spice tests.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-11-04 14:37:15 +01:00
Ján Tomko
5a766de16a tests: remove disks from spice tests
Reduce the churn in following patches.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-11-04 14:37:13 +01:00
Peter Krempa
6448470eca qemustatusxml2xmldata: backup-pull: Add private data for scratch image
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-04 10:55:28 +01:00
Peter Krempa
1e4aff444c virDomainBackupDefFormat: Propagate private data callbacks
The formatter for the backup job data didn't pass the virDomainXMLOption
struct to the disk formatter which meant that the private data of the
disk source were not formatted.

This didn't pose a problem for now as the blockjob list remembered the
nodenames for the jobs, but the backup source lost them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-04 10:55:28 +01:00
Michal Privoznik
196e6faabd lib: Use G_N_ELEMENTS instead of sizeof()/sizeof()
For statically declared arrays one can use G_N_ELEMENTS() instead
of explicit sizeof(array) / sizeof(item). I've noticed couple of
places where the latter was used.

I am not fixing every occurrence because we have some places
which do not use glib (examples and NSS module).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2021-11-03 14:46:54 +01:00
Michal Privoznik
4f607caba0 virpcivpdtest: Declare variables at multiple lines
In testPCIVPDResourceCustomCompareIndex() there are two variables
declared at one line. They are both g_autoptr() decorated which
makes it worse, because coccinelle fails to parse that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2021-11-03 14:46:54 +01:00
Ján Tomko
20ccc19a3c tests: qemuxml2argv: remove validation warning
This warning is emitted for pretty much every test case,
making it hard to see what the actual error is.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-11-03 10:14:12 +01:00
Dmitrii Shcherbakov
935fbcf9da PCI VPD: Fix a wrong return code in a test case
The test case should return -1, not 0 in case a valid resource could
not be parsed successfully but the ret value is initialized to 0.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Dmitrii Shcherbakov <dmitrii.shcherbakov@canonical.com>
2021-11-02 13:43:23 +00:00
Dmitrii Shcherbakov
600f580d62 PCI VPD: Skip fields with invalid values
While invalid values need to be ignored when presenting VPD data to the
user, it would be good to attempt to parse a valid portion of the VPD
instead of marking it invalid as a whole.

Based on a mailing list discussion, the set of accepted characters is
extended to the set of printable ASCII characters.

https://listman.redhat.com/archives/libvir-list/2021-October/msg01043.html

The particular example encountered on real hardware was multi-faceted:

* "N/A" strings present in read-only fields. This would not be a useful
  valid value for a field (especially if a unique serial number is
  expected), however, it was decided to delegate handling of those kinds
  of values to higher-level software;
* "4W/1W PCIeG2x4" - looks like some vendors use even more printable
  characters in the ASCII range than we currently allow. Since the
  PCI/PCIe VPD specs mention alphanumeric characters without specifying
  the full character set, it looks like this is ambiguous for vendors
  and they tend to use printable ASCII characters;
* 0xFF bytes present in VPD-W field values. Those bytes do not map to
  printable ASCII code points and were probably used by the vendor as
  placeholders. Ignoring the whole VPD because of that would be too
  strict.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Dmitrii Shcherbakov <dmitrii.shcherbakov@canonical.com>
2021-11-02 13:43:23 +00:00
Dmitrii Shcherbakov
43820e4b80 PCI VPD: handle additional edge cases
* RV and RW fields must be at the last position in their respective
  section (per the conditions in the spec). Therefore, the parser now
  stops iterating over fields as soon as it encounters one of those
  fields and checks whether the end of the resource has been reached;
* The lack of the RW field is not treated as a parsing error since we
  can still extract valid data even though this is a PCI/PCIe VPD spec
  violation;
* Individual fields must have a valid length - the parser needs to check
  for invalid length values that violate boundary conditions of the
  resource.
* A zero-length field may be the last one in the resource, however, the
  boundary check is currently too strict to allow that.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Dmitrii Shcherbakov <dmitrii.shcherbakov@canonical.com>
2021-11-02 13:43:23 +00:00
Michal Privoznik
b72419f387 lib: Introduce and use g_autoptr() for virInterfaceDef
There are a lot of places where we call virInterfaceDefFree()
explicitly. We can define autoptr cleanup macro and annotate
declarations with g_autoptr() and remove plenty of those explicit
free calls.

This also fixes a memory leak in udevInterfaceGetXMLDesc() which
called virInterfaceDefFree() only in successful path.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2021-11-02 10:52:18 +01:00
zhenwei pi
74447e404d tests: qemu: add kvm-pv-ipi off test
Since b2757b697e
(qemu: support kvm-pv-ipi off), libvirt supports xml definition like:

      <features>
        <kvm>
          <pv-ipi state='off'/>
        </kvm>
      </features>

Add test case for this feature.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-11-02 09:23:53 +01:00
zhenwei pi
4c54af1c93 tests: qemu: use domain type 'kvm' for kvm-features-off
KVM features off test cases should be tested for a KVM domain, so
keep align kvm-features-off test with kvm-features except KVM
features on/off.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-11-02 09:23:53 +01:00
Peter Krempa
cc54647fb0 testQEMUSchemaValidateEnum: Validate deprecated members
Starting from QEMU-6.2 enum members can be deprecated. Add support to
the validator.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-01 17:37:15 +01:00
Peter Krempa
43e2c6544e testQEMUSchemaValidateDeprecated: Move to the top
Move the function to the top of the file so other functions placed
towards the top will be able to reuse it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-01 17:37:15 +01:00
Peter Krempa
cf68184e74 testQEMUSchemaValidateEnum: Use new 'members' for 'enum' meta type
Switch to the new more featured way to report enum members which will
also allow us to detect use of deprecated members.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-01 17:37:15 +01:00
Peter Krempa
91453650f3 testQEMUSchemaValidateEnum: Refactor logic to simplify switching to new QMP schema format
QEMU-6.2 is reporting enum values in the new 'members' array which we'll
be switching to. Rewrite the logic so that adding the new checker is
more straightforward.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-01 17:37:15 +01:00
Peter Krempa
5f5e490c93 qemucapabilitiestest: Update capability probe for qemu-6.2 on x86_64
Update to v6.1.0-1735-gc52d69e7db which has Markus' patches for
improvements of enum probing.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-01 17:37:15 +01:00
Peter Krempa
ac9f3a4444 qemu: monitor: Remove unused qemuMonitorSetCPU
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-01 16:14:53 +01:00
Peter Krempa
4b1199a5c4 qemuhotplugtest: Remove tests for legacy cpu hotplug on x86
Modern cpu hotplug was introduced in qemu-2.7, thus all qemu versions
actually support it. Remove the tests for the legacy hotplug.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-01 16:14:53 +01:00
Michal Privoznik
2996a94dd0 lib: Don't check for virCapabilitiesAddGuestDomain() retval
The virCapabilitiesAddGuestDomain() function can't fail. It
aborts on OOM. Therefore, there's no need to check for its
return value.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-01 16:08:26 +01:00
Michal Privoznik
c18d9e23fa lib: Don't check for virCapabilitiesAddGuest() retval
The virCapabilitiesAddGuest() function can't fail. It aborts on
OOM. Therefore, there's no need to check for its return value.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-01 16:05:52 +01:00
zhangjl02
f3ac931d36 virnetdevopenvswitch: unify calculation of ovs and tc
For other interface type, values in tc rules are calculated by
multiply by 8*1000 instead of 8*1024.

Signed-off-by: zhangjl02 <zhangjl02@inspur.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-11-01 15:56:47 +01:00
Ani Sinha
d89fd6d93d qemu: Fix hotplug error message format to conform to spec
Error messages must conform to spec as specified here:
https://www.libvirt.org/coding-style.html#error-message-format

This change makes some error messages conform to the spec above.

Fixes: 8eadf82fb5 ("conf: introduce option to enable/disable pci hotplug on pci-root controller")

Signed-off-by: Ani Sinha <ani@anisinha.ca>
Reviewed-by: Laine Stump <laine@redhat.com>
2021-10-25 23:42:01 -04:00
Laine Stump
97475487f8 Revert "qemu: capablities: detect acpi-pci-hotplug-with-bridge-support"
This reverts commit 58ba0f6a3d.

Conflict:
  * src/qemu/qemu_capabilities.[ch]

    Because other new cap flags had been added since the original
    commit, reformatting was necessary to follow the "groups of
    five" pattern.

  * tests.qemucapabilitiesdata/caps_6.2.0.x86_64.xml

    This file was added after the original commit that we
    are reverting, so had to be manually edited to remove
    the two capabilities.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ani Sinha <ani@anisinha.ca>
2021-10-25 23:18:41 -04:00
Laine Stump
dba9893831 Revert "conf: introduce support for acpi-bridge-hotplug feature"
This reverts commit 7300ccc9b3.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ani Sinha <ani@anisinha.ca>
2021-10-25 23:18:41 -04:00
Laine Stump
26e8eda46e Revert "qemu: command: add support for acpi-bridge-hotplug feature"
This reverts commit bef0f0d8be.

Conflicts:
 tests/qemuxml2argvdata/q35-acpi-hotplug-bridge-disable.args

  * this file had been renamed from its original, then renamed back,
    which understandably confused git. It's being completely removed
    here anyway, so the contents don't matter.

 tests/qemuxml2argvtest.c

  * change in context around removed chunk

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ani Sinha <ani@anisinha.ca>
2021-10-25 23:18:41 -04:00
Laine Stump
1a786fda0e Revert "qemuxml2argvtest: Use real-caps testing for 'acpi-hotplug-bridge-disable'"
This reverts commit 2d20f0bb05.

Conflicts:
 tests/qemuxml2argvdata/pc-i440fx-acpi-hotplug-bridge-disable.args
 tests/qemuxml2argvdata/q35-acpi-hotplug-bridge-disable.args

  the test output of these files was regenerated because the tests
  were changed upstream to use JSON on the commandline at a later
  commit than the commit being reverted here (where they were changed
  to use latest caps, but the patches to use JSON on the commandline
  hadn't been committed yet).

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ani Sinha <ani@anisinha.ca>
2021-10-25 23:18:40 -04:00
Laine Stump
85094a4d60 Revert "qemuxml2argvtest: Add '-enable' variants for ACPI-hotplug related cases"
This reverts commit 6414603105.

Conflicts:
 tests/qemuxml2argvdata/pc-i440fx-acpi-hotplug-bridge-enable.x86_64-latest.args
 tests/qemuxml2argvdata/pc-i440fx-acpi-root-hotplug-enable.x86_64-latest.args
 tests/qemuxml2argvdata/q35-acpi-hotplug-bridge-enable.x86_64-latest.args

These files are unrelated to the functionality we need to remove, so
they weren't removed, and the associated test cases weren't removed
from qemuxml2argvtest.c

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ani Sinha <ani@anisinha.ca>
2021-10-25 23:18:40 -04:00
Laine Stump
ea373d6c07 Revert "qemuxml2xmltest: Convert all acpi-hotplug control related tests to DO_TEST_CAPS_LATEST"
This reverts commit da896d440c.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ani Sinha <ani@anisinha.ca>
2021-10-25 23:18:40 -04:00
Laine Stump
d65eb5dd8d Revert "qemu: capabilities: Remove QEMU_CAPS_PIIX4_ACPI_HOTPLUG_BRIDGE"
This reverts commit 618e8665db.

This is the first in a series of 10 commits that revert (in reverse
order) the changes to add the <acpi-hotplug-bridge state='on|off'/>
switch to libvirt domain XML, which unfortunately needs to be removed
due to QEMU developers discovering a flaw with the design of the QEMU
commandline switch used to implement the libvirt switch that will
likely result in a new and different method of selecting hotplug
modes. Because the libvirt switch has not been in any official
releases of libvirt, we are still able to remove it completely, rather
than deprecating it.

The original commits began with commit
58ba0f6a3d. The other original commit
IDs are documented in each revert commit.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ani Sinha <ani@anisinha.ca>
2021-10-25 23:18:40 -04:00
Peter Krempa
8e3a7c6db9 qemublocktest: Don't leak 'disk' in testQemuImageCreateLoadDiskXML
The function returns only the source portion but forgot to free the disk
wrapper.

Fixes: 9696427ad6
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2021-10-25 16:11:49 +02:00
Or Ozeri
060f344c80 conf: add luks2 encryption format
This commit extends libvirt XML configuration to support luks2 encryption format.
This means that <encryption format="luks2" engine="librbd"> becomes valid.
Currently librbd is the only engine that supports this new format.

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-10-25 14:06:15 +02:00
Or Ozeri
59090adf63 qemu: add librbd encryption engine
rbd encryption is new in qemu 6.1.0.
This commit adds a new encryption engine property which
allows the user to use this new encryption engine.

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-10-25 14:06:15 +02:00
Or Ozeri
ab1d46d612 conf: add encryption engine property
This commit extends libvirt XML configuration to support a custom encryption engine.
This means that <encryption format="luks" engine="qemu">  becomes valid.
The only engine for now is qemu. However, a new engine (librbd) will be added in an upcoming commit.
If no engine is specified, qemu will be used (assuming qemu driver is used).

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-10-25 14:06:15 +02:00
Or Ozeri
0398be5da6 qemu: capablities: Detect presence of 'rbd-encryption' as QEMU_CAPS_RBD_ENCRYPTION
rbd encryption is new in qemu 6.1.0.
This commit adds capability probing for it.

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-10-25 14:06:15 +02:00
Or Ozeri
9696427ad6 qemu: add disk post parse to qemublocktest
The post parse callback is part of the real (non-test) processing flow.
This commit adds it (for disks) to the qemublocktest flow as well.
Specifically, this will be needed for tests that use luks encryption,
so that the default encryption engine (which is added in an upcoming commit)
will be overridden by qemu.

Signed-off-by: Or Ozeri <oro@il.ibm.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-10-25 14:06:15 +02:00
Michal Privoznik
857df2fe50 lib: Drop intermediary return variables
In a few places we declare a variable (which is optionally
followed by a code not touching it) then set the variable to a
value and return the variable immediately. It's obvious that the
variable is needless and the value can be returned directly
instead.

This patch was generated using this semantic patch:

  @@
  type T;
  identifier ret;
  expression E;
  @@
  - T ret;
  ... when != ret
      when strict
  - ret = E;
  - return ret;
  + return E;

After that I fixed couple of formatting issues because coccinelle
formatted some lines differently than our coding style.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-10-25 12:48:46 +02:00