Commit Graph

43134 Commits

Author SHA1 Message Date
Ján Tomko
c7f3a1f787 qemu: simplify machine-type check for implicit floppy controller
Q35 machine types 2.3 and older had an integrated floppy controller.

Support for these machine types was removed by QEMU commit

  commit 86165b499edf8b03bb2d0e926d116c2f12a95bfe
      q35: Remove old machine versions
  git describe: v2.5.0-1530-g86165b499e contains: v2.6.0-rc0~76^2~4

In libvirt, we have bumped the minimum QEMU version to 2.11:

  commit b4cbdbe90b
    qemu: Formally deprecate support for qemu < 2.11
  git describe: v7.3.0-13-gb4cbdbe90b contains: v7.4.0-rc1~300

Since this QEMU version only supports Q35 machine versions 2.4+,
remove the code dealing with older ones.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-24 16:26:55 +02:00
Simon Rowe
e72fe141f8 qemu: check unlink hint from virQEMUFileOpenAs()
Signed-off-by: Simon Rowe <simon.rowe@nutanix.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-24 16:02:41 +02:00
Simon Rowe
5646b7c5e1 iohelper: skip lseek() and ftruncate() on block devices
Signed-off-by: Simon Rowe <simon.rowe@nutanix.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-24 16:02:38 +02:00
Kristina Hanicova
7e7747cc2d virsh: add support for '--validate' option in define network
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-24 15:47:03 +02:00
Kristina Hanicova
cc195a2da6 network: allow VIR_NETWORK_DEFINE_VALIDATE flag
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-24 15:46:59 +02:00
Kristina Hanicova
8555dee6ba src & network_conf: add validation against schema in define
This patch also includes propagation of flags into the
virNetworkDefParse().

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-24 15:46:54 +02:00
Kristina Hanicova
0faf5c6aa4 api: add virNetworkDefineFlags
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-24 15:46:38 +02:00
Kristina Hanicova
a4d8bd34a5 src: add driver support for networkDefineXMLFlags()
I have added new driver functions which define network with given
flags. I have also replaced definitions of the functions without
flags with function calls to the new ones.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-24 15:46:35 +02:00
Kristina Hanicova
652eac2437 vbox_network: add flags to vboxNetworkDefineCreateXML()
I need to propagate flags for the next commit.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-24 15:46:31 +02:00
Kristina Hanicova
8105fbe8e6 api: add public virNetworkDefineXMLFlags() and remote protocol
This new API allows to define network with given flags.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-24 15:46:28 +02:00
Ján Tomko
59281d9dc7 qemu: capabilities: remove pointless labels
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2021-08-23 17:35:06 +02:00
Ján Tomko
eb69535efc qemu: capabilities: use g_auto
Where easily possible, declare variables with g_auto to reduce
the amount of calls in cleanup sections.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2021-08-23 17:35:06 +02:00
Ján Tomko
d45af4ea45 qemu: refactor virQEMUCapsNewCopy
Use g_auto and remove pointless labels.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2021-08-23 17:35:06 +02:00
Ján Tomko
37574d5f17 qemu: refactor virQEMUCapsInit
Use g_auto and remove pointless labels.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2021-08-23 17:35:06 +02:00
Ján Tomko
c9d6ffacd1 qemu: refactor virQEMUCapsLoadFile
Use g_auto and remove pointless labels.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2021-08-23 17:35:06 +02:00
Ján Tomko
a41b23d718 qemu: refactor virQEMUCapsNewForBinaryInternal
Use g_auto and remove pointless labels.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
2021-08-23 17:35:06 +02:00
Peter Krempa
fa8f99bbee conf: snapshot/checkpoint: Rewrite 'AlignDisk' logic to appease clang
New clang has a false-positive about value of 'olddisks' being unused
after being set. This is clearly wrong because we want to use
'g_autofree' to clear it later.

While I'm against modifying good code for the sake of bad static
analysis in this case it's not obvious that we depend on the lifetime of
'olddisks' being needed until the end of the function as we store
pointers into it into the hash table and later copy them out.

Rewrite the code by assigning to 'olddisks' earlier and then using
'olddisks' in the loop, so it's clear where the lifetime of the objects
ends, and this should also silence the warning.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-23 16:59:23 +02:00
Kristina Hanicova
ef83940524 vbox_network: fix possible memory leak in vboxNetworkDefineCreateXML()
virNetworkDef was not freed if the function failed in the first
two ifs, causing a possible memory leak.

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-23 16:48:50 +02:00
Michal Privoznik
6d7a16361b virsh-snapshot: Don't leak @then in cmdSnapshotList()
The variable is used inside a loop in which it's allocated in
each iteration. Bring it inside the loop so that g_autoptr()
kicks in each iteration.

Fixes: 3caa28dc50
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-23 14:52:15 +02:00
Ján Tomko
e431293d74 tests: qemuxml2*test: switch to virTestRunLog
This essentially reverts:
commit ca5c8e1dc7
    qemuxml2argvtest: Avoid conditions in test macro

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
8628cbe6ad tests: cputests: introduce and use virTestRunLog
A helper that resets the log before each test and prints
it on failure.

It also takes the return variable as an argument,
so it can be used to eliminate number of branches
the compiler has to consider in the main function.

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
0ee2cc3ad8 tests: cputest: remove unnecessary labels
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
32f1323cba tests: cputest: use g_autofree
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
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