Commit Graph

43161 Commits

Author SHA1 Message Date
Ján Tomko
849c06596e tests: cputest: use g_auto for virCPUDef
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-23 14:43:57 +02:00
Ján Tomko
12185e5a3a tests: cputest: use g_auto for virCPUData
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-23 14:43:57 +02:00
Ján Tomko
a32c2b2360 tests: cputest: use g_auto for virQEMUCaps
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-23 14:43:57 +02:00
Ján Tomko
e2b5fc9a8b tests: use g_auto in cpuTestMakeQEMUCaps
Refactor to use automatic cleanup and remove the goto's.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-23 14:43:57 +02:00
Ján Tomko
55031c09e6 qemu: monitor: define cleanup function for qemuMonitorCPUModelInfo
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-23 14:43:57 +02:00
Michal Privoznik
c71a986e9a rpm: Enable numactl on s390x
While s390x doesn't have NUMA nodes it has libnuma which is still
helpful as it parses sysfs for us and kernel emulates NUMA#0.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-23 14:00:24 +02:00
Michal Privoznik
78d4c12b8c virhostmem: Handle numactl-less build in hugepages allocation/reporting
When using 'virsh freepages' or 'virsh allocpages' then
virHostMemGetFreePages() or virHostMemAllocPages() is called,
respectively. But the following may happen: libvirt was built
without numactl support and thus a fake NUMA node was constructed
for capabilities, which means that startCell is going to be 0.
But we can't blindly pass startCell = 0 to virNumaGetPageInfo()
nor virNumaSetPagePoolSize() because they would operate over node
specific path (/sys/devices/system/node/nodeX) rather than NUMA
agnostic path (/sys/kernel/mm/hugepages/) and we are not
guaranteed that the former exists (kernel might have been built
without NUMA support).

Resolves:https://bugzilla.redhat.com/show_bug.cgi?id=1978574

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-23 14:00:20 +02:00
Michal Privoznik
ebec3de97d virhostmem: Let caller pass max NUMA node to virHostMemAllocPages
In all three cases (LXC, QEMU and VBox drivers) the caller has
access to host capabilities and thus know the maximum NUMA node.
This means, that virHostMemAllocPages() doesn't have to query
it. Querying may fail if libvirt was compiled without numactl
support.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-23 14:00:15 +02:00
Michal Privoznik
59e3584f71 virhostmem: Let caller pass max NUMA node to virHostMemGetFreePages
In all three cases (LXC, QEMU and VBox drivers) the caller has
access to host capabilities and thus know the maximum NUMA node.
This means, that virHostMemGetFreePages() doesn't have to query
it. Querying may fail if libvirt was compiled without numactl
support.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-23 14:00:10 +02:00
Michal Privoznik
20816cbda5 conf: Introduce virCapabilitiesHostNUMAGetMaxNode()
This is just a small helper that will be used later.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-23 13:59:28 +02:00
Ján Tomko
406a6c20a8 tests: virnetdev*: remove unnecessary labels
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-20 16:43:20 +02:00
Ján Tomko
0846343861 tests: introduce testVirNetDevBandwidthParse
The 'PARSE' macro does not use '#' or '##' directives,
or anything from outside of the macro other than the
cleanup label.

Turn it into a function.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-20 16:43:20 +02:00
Ján Tomko
3e74bb8321 tests: virnetdevbandwidthtest: use g_auto
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-20 16:43:20 +02:00
Ján Tomko
780b5ab62a tests: virnetdevopenvswitch: use g_auto
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-20 16:43:20 +02:00
Ján Tomko
4a0c0d85d2 build: only build virnetdevopenvswitchtest on Linux
Now that it uses virnetdevbandwidthmock which we only
build on Linux.

Fixes: eb55e8a897
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-20 16:43:19 +02:00
Peter Krempa
ca444a2eb2 qemublocktest: Add test for creating a qcow2 on top of an luks-encrypted qcow2
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-20 15:43:17 +02:00
Peter Krempa
15ab655835 qemu: block: Use correct format name when formatting overlay of qcow2+luks
A logic bug in the code creating overlays on existing images resulted
into wrongly using "luks" instead of "qcow2" for the backing format if
the backing image is an luks-encrypted qcow2. The special format munging
is needed only for raw luks images.

In practice the impact is not as critical as to use encrypted images in
the backing chain the user must fully describe the backing chain
including backing images to provide encryption keys, which overrides the
metadata recorded in the qcow2 header.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-20 15:43:17 +02:00
Kristina Hanicova
ec5561c0bb virsh: add support for '--validate' option in define secret
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-08-20 15:41:22 +02:00
Kristina Hanicova
5cb3d4ed6d secret_driver: allow VIR_SECRET_DEFINE_VALIDATE flag
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-08-20 15:41:22 +02:00
Kristina Hanicova
9d482a415b secret_conf: add validation against schema in define
We need to validate the XML against schema if option '--validate'
was passed to the virsh command. This patch also includes
propagation of flags into the virSecretDefParse() function.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-08-20 15:41:22 +02:00
Kristina Hanicova
6589794a1f api: add virSecretDefineFlags
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-08-20 15:41:22 +02:00
Kristina Hanicova
d46a0b0e96 virsh: add support for '--validate' option in define interface
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-08-20 15:41:22 +02:00
Kristina Hanicova
4b4bd278a4 src: allow validation flag in interface define
We need to validate the XML against schema if option 'validate'
was passed to the 'iface-define' virsh command. For that we need
to allow validation flag and propagate flags to parse function.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-08-20 15:41:22 +02:00
Kristina Hanicova
5e71d3ad57 conf: add validation and propagate flags into virInterfaceDefParse()
We need to know if validation flag is present in order to
validate given XML against schema in virXMLParse().

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-08-20 15:41:21 +02:00
Kristina Hanicova
609dfaf43e api: add virInterfaceDefineFlags
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-08-20 15:41:21 +02:00
Kristina Hanicova
a3d88c9d4c virsh: add support for '--validate' option in define nwfilter
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-20 15:38:53 +02:00
Kristina Hanicova
a59d196b5d nwfilter_driver: allow VIR_NWFILTER_DEFINE_VALIDATE flag
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-20 15:38:53 +02:00
Kristina Hanicova
1b0caedb72 nwfilter_conf: add validation against schema in define
This patch also includes propagation of flags into the
virNWFilterDefParse().

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-20 15:38:53 +02:00
Kristina Hanicova
499c0e4ecf api: add virNWFilterDefineFlags
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-20 15:38:53 +02:00
Kristina Hanicova
fa53b26026 nwfilter: add nwfilterDefineXMLFlags()
I have added a new driver function which allows to define
nwfilter with given flags. I have also replaced definition of
nwfilterDefineXML() with function call to the new function.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-20 15:38:53 +02:00
Kristina Hanicova
c839014dd2 api: add public virNWFilterDefineXMLFlags() and remote protocol
This new API function allows to define nwfilter with given flags.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-20 15:38:53 +02:00
Ján Tomko
0447e6243b tests: use g_auto in qemuTestParseCapabilitiesArch
Refactor qemuTestParseCapabilitiesArch to use g_auto for cleanup.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-20 15:19:35 +02:00
Ján Tomko
693831a58d tests: use g_auto in testQemuGetCaps
Refactor testQemuGetCaps to use g_auto for cleanup,
remove the error label and use g_steal_pointer for
the successful return path.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-20 15:19:35 +02:00
Michal Privoznik
9f33a6dcb4 virsocket: Don't preserve errno in virSocketRecvFD()
When setting O_CLOEXEC flag on received FD fails the FD is closed
using VIR_FORCE_CLOSE(). But the call is wrapped in errno save
which is not necessary because VIR_FORCE_CLOSE() preserves  errno
value.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-20 15:00:53 +02:00
Ján Tomko
247e8fcc6a ch: monitor: unref mon->vm before vm
Do not access 'mon' after unref'ing it.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-20 13:29:07 +02:00
Ján Tomko
005e70e9a7 syntax-check: remove _test_script_regex
Commit abab5c47f8 incorrectly
assumed we do not have any files that could be affected by

  sc_prohibit_reversed_compare_failure

due to the conditional assignment:

  _test_script_regex ?= \<init\.sh\>

so it removed the check.

Also remove the leftover assignment of test-lib.sh,
since any new code attempting to use the compare function
with reversed arguments should be rejected by review
for using shell instead of C or Python.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-20 13:28:08 +02:00
Ján Tomko
0af0b7d87d syntax-check: drop useless useless-if-before-free
With most of new code using g_auto for cleanup, contributors
are used to most of the free fucntions handling NULL gracefully.

Also, despite finding some occurrences in current codebase:
  avoid_if_before_free
  ~/libvirt/src/ch/ch_monitor.c: if (mon->vm)
        virObjectUnref(mon->vm);
  ~/libvirt/src/util/virresctrl.c: if (a_type->masks[cache])
        virBitmapFree(a_type->masks[cache]);
the check passes succesfully, because the script's logic:

  Exit status:
    0   one or more matches
    1   no match
    2   an error

does not play nicely with xargs:

  xargs exits with the following status:
       0      if it succeeds
     123      if any invocation of the command exited with status 1-125

The list of functions is also out of date - e.g. qemuCapsFree has
been renamed since.

This also helps eliminate one more Perl script per our programming
languages strategy: https://libvirt.org/programming-languages.html

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-20 13:28:08 +02:00
Ján Tomko
2ff7a2d5d6 syntax-check: replace vc-list-files
Directly invoke git ls-tree instead of the wrapper file which also:
* checks for other versioning systems
* prepends the source directory to all output lines

Since there is no srcdir prefix in the output anymore, also drop
the extra 'sed' invocation that removes it.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-20 13:28:08 +02:00
Ján Tomko
a7fee0a4c6 syntax-check: use VC_LIST_EXCEPT instead of VC_LIST
Three callers were using VC_LIST directly.

This is not wrong, because they exclude the always-excluded
files by only looking for C and/or header files.

But using VC_LIST here prevents switching it to outputting
relative paths.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-20 13:28:08 +02:00
Ján Tomko
f2dda804a6 syntax-check: assume we're using git
Meson already checks whether we're using git before running
syntax check. This only affects direct invocation through make.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-20 13:28:08 +02:00
Zhenyu Ye
94ac9d55fd fix error in printf format string
Use %s to print NULLSTR(duri).

Reported-by: Peng Liang <liangpeng10@huawei.com>
Signed-off-by: Zhenyu Ye <yezhenyu2@huawei.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-19 17:03:22 +02:00
Jinsheng Zhang
eb55e8a897 tests: add test on virNetDevOpenvswitchInterfaceSetQos and virNetDevOpenvswitchInterfaceClearQos
Test virNetDevOpenvswitchInterfaceSetQos and
virNetDevOpenvswitchInterfaceClearQos with dryrun method.

Signed-off-by: zhangjl02 <zhangjl02@inspur.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-19 16:47:40 +02:00
Jinsheng Zhang
47437bbe3a virnetdevopenvswitch: Fix qos cleaning residual on multi interfaces
Warn these error instead of return when removing qos or queues. This will
avoid residual qos clearance on multiple interfaces.

Signed-off-by: zhangjl02 <zhangjl02@inspur.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-19 16:47:40 +02:00
Jinsheng Zhang
56723f8846 virnetdevopenvswitch: Introduce virNetDevOpenvswitchInterfaceClearTxQos and virNetDevOpenvswitchInterfaceClearRxQos
Separate virNetDevOpenvswitchInterfaceClearQos into two steps. When setting
qos, we can set only rx or tx and the other one should be cleared.

Signed-off-by: zhangjl02 <zhangjl02@inspur.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-19 16:47:38 +02:00
Jinsheng Zhang
a6986fb2cf virnetdevopenvswitch: Extract common code block to a single function
Signed-off-by: zhangjl02 <zhangjl02@inspur.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-19 16:46:52 +02:00
Jinsheng Zhang
d05aa66db3 virnetdevopenvswitch: Extract conversion parameters between virNetDevBandwidth and ovs
Signed-off-by: zhangjl02 <zhangjl02@inspur.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-19 16:46:45 +02:00
Jinsheng Zhang
c40421f702 virnetdevopenvswitch: Add vmuuid notes on virNetDevOpenvswitchInterfaceSetQos
Add vmuuid notes on virNetDevOpenvswitchInterfaceSetQos,
and change vmid to vmuuid.

Signed-off-by: Jinsheng Zhang <zhangjl02@inspur.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-19 16:46:36 +02:00
Martin Kletzander
2b6bc910b7 tests: Add missing test cases to vmx2xmltest
Commit 42b2f35d36 was meant to test all four combinations of
serial-pipe-{server,client}-{app,vm} files, but did only add the files and by
mistake duplicated the tests.  Those were later removed as duplicates, so add
them back in.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-19 13:32:10 +02:00
Luke Yue
ba32bf03b2 tests: Test BlkioParameters related functions for test driver
Signed-off-by: Luke Yue <lukedyue@gmail.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-19 13:31:57 +02:00
Luke Yue
2dfc2ab48a test_driver: Implement virDomainSetBlkioParameters
Signed-off-by: Luke Yue <lukedyue@gmail.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-19 13:31:57 +02:00