Commit Graph

41714 Commits

Author SHA1 Message Date
Peter Krempa
35efc9b535 conf: domain: Convert virDomainDiskDef's 'removable' to virTristateSwitch
Use the appropriate type for the variable and refactor the XML parser to
parse it correctly using virXMLPropEnum.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-19 14:43:59 +02:00
Peter Krempa
61fd7174c2 conf: domain: Move checks from virDomainDiskDefParseXML to virDomainDiskDefValidate
Move the rest of the validations to the vaidation code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-19 14:43:59 +02:00
Peter Krempa
73fbf346dc conf: domain: Move default setting from virDomainDiskDefParseXML to virDomainDiskDefPostParse
Move the setting of read-only state, the default disk bus and setting of
'snapshot' state for read-only disks to the post parse callback to clean
up the disk parser.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-19 14:43:59 +02:00
Peter Krempa
b528fffc6f vmx: Mark CDROM disk elements as read-only
Mark it explicitly as read only in accordance with the comment outlining
configuration.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-19 14:43:59 +02:00
Peter Krempa
7516ae5287 conf: domain: Introduce VIR_DOMAIN_DISK_BUS_NONE
Add a disk bus value represending no selected bus. This will help split
up the XML parser.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-19 14:43:59 +02:00
Peter Krempa
fb89cce883 conf: Move disk target 'ioemu:' stripping to virDomainDiskDefPostParse
Modifications of the data such as this one don't belong into the parser.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-19 14:43:59 +02:00
Peter Krempa
1645fc6aa7 conf: Move checks from virDomainDiskDefPostParse to virDomainDiskDefValidate
The moved code contains only checks and does not modify the parsed
document so it doesn't belong into the PostParse code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-19 14:43:59 +02:00
Peter Krempa
fc2e60fda7 conf: Move disk vendor and product pritability check to domain_validate
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-19 14:43:59 +02:00
Peter Krempa
e2a69d7641 conf: Move code from virDomainDiskDefParseValidate to virDomainDiskDefValidate
Unify the two distinct disk definition validators.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-19 14:43:59 +02:00
Peter Krempa
ceca89d43d virDomainDiskDefValidate: Consolidate conditions
Consolidate the checks for '<reservations/>' and viritio queues under
already existing blocks which have the same condition.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-19 14:43:59 +02:00
Peter Krempa
91d9ff75e6 conf: domain: Remove VIR_DOMAIN_DEF_PARSE_DISK_SOURCE parser flag
There's no code which would assert it at this point. Remove the flag.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-19 14:43:59 +02:00
Peter Krempa
62a4023d8a conf: domain: Split out parsing of source data from <disk> XML parser
Extract all code related to parsing data which ends up in the 'src'
member of a virDomainDiskDef.

This allows to use the new function directly in
virDomainDiskDefParseSource and removes the use of the
VIR_DOMAIN_DEF_PARSE_DISK_SOURCE parser flag.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-19 14:43:59 +02:00
Peter Krempa
c4dfe41c31 conf: domain: Split out source validation part from virDomainDiskDefParseValidate
Separate the validation of the source so that it can be reused once we
split up the XML parser too.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-19 14:43:59 +02:00
Peter Krempa
dbfb5aa7c0 conf: domain: Introduce an internal variant of virDomainDiskDefNew
The <disk> XML element parser is going to be modified so that the
virStorageSource bits are pre-parsed. Add virDomainDiskDefNewSource,
which uses an existing 'src' pointer.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-19 14:43:59 +02:00
Peter Krempa
0202467c4b qemu: driver: Use virDomainDiskDefParseSource in qemuDomainBlockCopy
qemuDomainBlockCopy needs just the source portion of the disk but uses
the disk parser for it. Since we have a specific function now, refactor
the code to avoid having to deal with the unused virDomainDiskDef.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-19 14:43:58 +02:00
Peter Krempa
fb0238414e conf: domain: Introduce virDomainDiskDefParseSource
Add a helper function which will parse the source portion of a <disk>.

The idea is to replace *virDomainDiskDefParse with
VIR_DOMAIN_DEF_PARSE_DISK_SOURCE with the new helper in the future.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-19 14:43:58 +02:00
Peter Krempa
5c56538937 util: xml: Introduce virXMLParseStringCtxtRoot
Use the new macro instead of virXMLParseStringCtxt in places where the
root node is being validated.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-19 14:43:58 +02:00
Peter Krempa
3362ab5e02 virXMLParseHelper: Add root XML node name validation capability
Some callers want to validate the root XML node name. Add the capability
to the parser helper to prevent open-coding.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-19 14:43:58 +02:00
Göran Uddeborg
b660a043e0 Translated using Weblate (Swedish)
Currently translated at 23.5% (2497 of 10581 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/sv/

Co-authored-by: Göran Uddeborg <goeran@uddeborg.se>
Signed-off-by: Göran Uddeborg <goeran@uddeborg.se>
2021-04-19 12:49:32 +02:00
Jan Kuparinen
e7ef01bb44 Translated using Weblate (Finnish)
Currently translated at 20.3% (2154 of 10581 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/fi/

Co-authored-by: Jan Kuparinen <copper_fin@hotmail.com>
Signed-off-by: Jan Kuparinen <copper_fin@hotmail.com>
2021-04-19 12:49:31 +02:00
simmon
285d3b3264 Translated using Weblate (Korean)
Currently translated at 37.6% (3981 of 10581 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/ko/

Translated using Weblate (Korean)

Currently translated at 37.2% (3944 of 10581 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/ko/

Translated using Weblate (Korean)

Currently translated at 36.0% (3819 of 10581 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/ko/

Translated using Weblate (Korean)

Currently translated at 34.2% (3629 of 10581 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/ko/

Co-authored-by: simmon <simmon@nplob.com>
Signed-off-by: simmon <simmon@nplob.com>
2021-04-19 12:49:31 +02:00
SeongHyun Jo
9b6f0f2d50 Translated using Weblate (Korean)
Currently translated at 33.8% (3577 of 10581 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/ko/

Co-authored-by: SeongHyun Jo <caelus9536@gmail.com>
Signed-off-by: SeongHyun Jo <caelus9536@gmail.com>
2021-04-19 12:49:31 +02:00
simmon
96bc80fe78 Translated using Weblate (Korean)
Currently translated at 33.8% (3577 of 10581 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/ko/

Translated using Weblate (Korean)

Currently translated at 33.0% (3501 of 10581 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/ko/

Co-authored-by: simmon <simmon@nplob.com>
Signed-off-by: simmon <simmon@nplob.com>
2021-04-19 12:49:31 +02:00
Pavel Hrdina
48472a3a3d qemu_block: fix copy&paste typo in SSH protocol
Fixes: caf71b64fe
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-04-19 12:48:24 +02:00
Luyao Zhong
2d37d8dbc9 qemu: Add support for 'restrictive' mode in numatune
Signed-off-by: Luyao Zhong <luyao.zhong@intel.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-19 11:39:21 +02:00
Luyao Zhong
6213d52384 conf, docs, schema: Add support for 'restrictive' mode in numatune
This allows users to restrict memory nodes without setting any specific
memory policy, then 'restrictive' mode is useful.

Signed-off-by: Luyao Zhong <luyao.zhong@intel.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-04-19 11:39:13 +02:00
Michal Privoznik
69a4cd9249 lxc: Format --handshakefd for controller cmd fully
The command line argument is called --hanshakefd (check out
lxc_controller.c:main()). But the command line builder puts only
--handshake. This works, because there is no other argument
sharing the prefix.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-04-19 11:21:40 +02:00
Michal Privoznik
ea7d0ca37c vircgroup: Fix virCgroupKillRecursive() wrt nested controllers
I've encountered the following bug, but only on Gentoo with
systemd and CGroupsV2. I've started an LXC container successfully
but destroying it reported the following error:

  error: Failed to destroy domain 'amd64'
  error: internal error: failed to get cgroup backend for 'pathOfController'

Debugging showed, that CGroup hierarchy is full of surprises:

/sys/fs/cgroup/machine.slice/machine-lxc\x2d861\x2damd64.scope/
└── libvirt
    ├── dev-hugepages.mount
    ├── dev-mqueue.mount
    ├── init.scope
    ├── sys-fs-fuse-connections.mount
    ├── sys-kernel-config.mount
    ├── sys-kernel-debug.mount
    ├── sys-kernel-tracing.mount
    ├── system.slice
    │   ├── console-getty.service
    │   ├── dbus.service
    │   ├── system-getty.slice
    │   ├── system-modprobe.slice
    │   ├── systemd-journald.service
    │   ├── systemd-logind.service
    │   └── tmp.mount
    └── user.slice

For comparison, here's the same container on recent Rawhide:

/sys/fs/cgroup/machine.slice/machine-lxc\x2d13550\x2damd64.scope/
└── libvirt

Anyway, those nested directories should not be a problem, because
virCgroupKillRecursiveInternal() removes them recursively, right?
Sort of. The function really does remove nested directories, but
it assumes that every directory has the same controller as the
rest. Just take a look at virCgroupV2KillRecursive() - it gets
'Any' controller (the first one it found in ".scope") and then
passes it to virCgroupKillRecursiveInternal().

This assumption is not true though. The controllers found in
".scope" are the following:

  cpuset cpu io memory pids

while "libvirt" has fewer:

  cpuset cpu io memory

Up until now it's not problem, because of how we order
controllers internally - "cpu" is the first and thus picking
"Any" controller returns just that. But the rest of directories
has no controllers, their "cgroup.controllers" is just empty.

What fixes the bug is dropping @controller argument from
virCgroupKillRecursiveInternal() and letting each iteration work
pick its own controller.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-19 11:21:40 +02:00
Michal Privoznik
a0815484b1 vircgroupbackend: Extend error messages in VIR_CGROUP_BACKEND_CALL()
The VIR_CGROUP_BACKEND_CALL() macro gets a backend for controller
and calls corresponding callback in it. If either is NULL then an
error message is printed out. However, the error message contains
only the intended callback func and not controller or backend
found.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-19 11:21:40 +02:00
Michal Privoznik
edce157f11 vircgroup: Debug print all arguments of virCgroupKillRecursiveInternal()
Currently, only a subset of virCgroupKillRecursiveInternal()
arguments is printed into debug logs. Print all of them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-19 11:21:40 +02:00
Peter Krempa
c2558e78d4 cmdDomBlkError: Fix crash when initial call to virDomainGetDiskErrors fails
virDomainGetDiskErrors uses the weird semantics where we make the
caller query for the number of elements and then pass pre-allocated
structure.

The cleanup section errorneously used the 'count' variable to free the
allocated elements for the API but 'count' can be '-1' in cases when the
API returns failure, thus attempting to free beyond the end of the
array.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/155
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-04-19 11:04:53 +02:00
Peter Krempa
ac87f612ba conf: domain: Convert virDomainDiskDef's 'startupPolicy' to virDomainStartupPolicy
Use the appropriate type for the variable and refactor the XML parser to
parse it correctly using virXMLPropEnum.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2021-04-16 17:28:06 +02:00
Peter Krempa
56be92b473 conf: domain: Convert virDomainDiskDef's 'tray_status' to virDomainDiskTray
Use the appropriate type for the variable and refactor the XML parser to
parse it correctly using virXMLPropEnum.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2021-04-16 17:28:06 +02:00
Peter Krempa
f1c9fed2ca virsh: snapshot: Don't validate schema of XML generated by 'virsh snapshot-create-as'
Commit 95f8e3237e which introduced XML schema validation
for snapshot XMLs always asserted the validation for the XML generated
by 'virsh snapshot-create-as' on the basis that it's libvirt-generated,
thus valid.

This unfortunately isn't true as users can influence certain bits of the
XML such as the disk image path which must be a full path. Thus if a
user tries to invoke virsh as:

 $ virsh snapshot-create-as upstream --diskspec vda,file=relative.qcow2
 error: XML document failed to validate against schema: Unable to validate doc against /path/to/domainsnapshot.rng
 Extra element disks in interleave
 Element domainsnapshot failed to validate content

They get a rather useless error from the libxml2 RNG validator.

With this fix applied, we get to the XML parser in libvirtd which has a
more reasonable error:

 $ virsh snapshot-create-as upstream --diskspec vda,file=relative.qcow2
 error: XML error: disk snapshot image path 'relative.qcow2' must be absolute

Instead users can force validation of the XML generated by 'virsh
snapshot-create-as' by passing the '--validate' flag.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-04-16 17:27:39 +02:00
Tim Wiederhake
f0379bdd14 virCPUDefParseXML: Use virXMLProp*
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-04-16 13:22:35 +02:00
Tim Wiederhake
324f6f5826 virDomainIOThreadIDDefParseXML: Use virXMLProp*
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-04-16 13:22:35 +02:00
Tim Wiederhake
593140dabd virNetworkForwardNatDefParseXML: Use virXMLProp*
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-04-16 13:22:35 +02:00
Tim Wiederhake
ab5d2776c9 virxml: Add virXMLPropEnum
Convenience function to return the value of an enum XML attribute.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-04-16 13:22:32 +02:00
Tim Wiederhake
68cda45b57 virxml: Add virXMLPropUInt
Convenience function to return the value of an unsigned integer XML attribute.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-04-16 13:22:11 +02:00
Tim Wiederhake
de17e0d30d virxml: Add virXMLPropInt
Convenience function to return the value of an integer XML attribute.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-04-16 13:21:55 +02:00
Tim Wiederhake
8861d96c88 virxml: Add virXMLPropTristateSwitch
Convenience function to return the value of an on / off XML attribute.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-04-16 13:21:27 +02:00
Tim Wiederhake
c8726ede83 virxml: Add virXMLPropTristateBool
Convenience function to return the value of a yes / no XML attribute.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-04-16 13:21:07 +02:00
Peter Krempa
638007f916 virXMLParseHelper: Refactor cleanup
Switch @xml and @pctxt to g_autofree and get rid of the "error" and
"cleanup" labels.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2021-04-16 13:17:35 +02:00
Peter Krempa
e87eeefb3e virXMLParseHelper: Rework error reporting
Move the reporting of parsing error on the error path of the parser as
other code paths report their own errors already.

Additionally prefer printing the 'url' as document name if provided
instead of "[inline data]" as that usually gives a better hint at least
which kind of XML is being parsed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2021-04-16 13:17:35 +02:00
Peter Krempa
5339ecf6b9 util: xml: Register autoptr cleanup function for 'xmlParserCtxt'
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2021-04-16 13:17:35 +02:00
Peter Krempa
7a77556e60 virXMLParseHelper: Sync argument names between declaration and definition
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2021-04-16 13:17:35 +02:00
Peter Krempa
6f29230a46 util: virxml: Fix formatting of virxml.h
Remove the "block" formatting of function declarations and use uniform
spacing.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
2021-04-16 13:17:35 +02:00
Tim Wiederhake
876f994db1 conf: Use virTristateXXX in virPCIDeviceAddress
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-04-16 09:48:42 +02:00
Tim Wiederhake
975e2cb39d conf: Use virTristateXXX in virStoragePoolSourceDevice
Note that the comment for virStoragePoolSourceDevice::part_separator was wrong.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-04-16 09:48:42 +02:00
Tim Wiederhake
62f06ffe8a conf: Use virTristateXXX in virStorageAdapterFCHost
Note that the comment for virStorageAdapterFCHost::managed was wrong.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-04-16 09:48:42 +02:00