]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
4 years agocmdSnapshotList: Fix memory leak
Tim Wiederhake [Mon, 19 Apr 2021 11:54:14 +0000 (13:54 +0200)]
cmdSnapshotList: Fix memory leak

Fixes: 3caa28dc50df7ec215713075d669b20bef6473a2
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agocmdCheckpointList: Fix memory leak
Tim Wiederhake [Mon, 19 Apr 2021 11:54:13 +0000 (13:54 +0200)]
cmdCheckpointList: Fix memory leak

Fixes: 3caa28dc50df7ec215713075d669b20bef6473a2
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agovirDomainFeaturesDefParse: Fix memory leak
Tim Wiederhake [Mon, 19 Apr 2021 11:54:12 +0000 (13:54 +0200)]
virDomainFeaturesDefParse: Fix memory leak

Fixes: 94013ee04e3945307a71f5c4897d78729e7eaff4
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoxenParseHypervisorFeatures: Fix memory leak
Tim Wiederhake [Mon, 19 Apr 2021 11:54:11 +0000 (13:54 +0200)]
xenParseHypervisorFeatures: Fix memory leak

Fixes:b523e22521afe733165869c9e1ae18e88536acd6
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agotests: nodedev: remove unnecessary cleanup label
Jonathon Jongsma [Tue, 13 Apr 2021 20:29:15 +0000 (15:29 -0500)]
tests: nodedev: remove unnecessary cleanup label

Now that the last cleanup task was removed in the previous commit, just
remove the label and return early on error rather than goto cleanup.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agotests: nodedev: remove unused variable
Jonathon Jongsma [Fri, 9 Apr 2021 20:32:04 +0000 (15:32 -0500)]
tests: nodedev: remove unused variable

This variable was leftover from previous changes but is no longer used.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agotests: nodedev: remove virt type from test macros
Jonathon Jongsma [Fri, 9 Apr 2021 20:30:01 +0000 (15:30 -0500)]
tests: nodedev: remove virt type from test macros

We only use the virt_type "QEMU" in this tests, so simply hard-code it
in the test function rather than specifying it in the test macro.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agotests: nodedev: remove 'create' from test macros
Jonathon Jongsma [Fri, 9 Apr 2021 20:30:01 +0000 (15:30 -0500)]
tests: nodedev: remove 'create' from test macros

We can figure out the appropriate value for 'create' from the command
type, so push that into the test function rather than specifying it in
the test macro.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agotests: nodedev: Make the mdevctl test function and helper generic
Erik Skultety [Wed, 31 Mar 2021 13:40:36 +0000 (15:40 +0200)]
tests: nodedev: Make the mdevctl test function and helper generic

Now that we have a generic mdevctl command generator, we can unify the
test infrastructure as well.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agonodedev: Remove GetMdevctl*Command() wrappers
Jonathon Jongsma [Wed, 31 Mar 2021 22:03:08 +0000 (17:03 -0500)]
nodedev: Remove GetMdevctl*Command() wrappers

These per-command generator functions were only exposed in the header to
allow the commandline generation to be tested. Now that we have a
generic mdevctl command generator, we can get rid of the per-command
wrappers and reduce the noise in the header.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agonodedev: driver: Create a generic mdevctl command translator
Erik Skultety [Wed, 31 Mar 2021 13:24:47 +0000 (15:24 +0200)]
nodedev: driver: Create a generic mdevctl command translator

Currently there are dedicated wrappers to construct mdevctl command.
These are mostly fine except for the one that translates both "start"
and "define" commands, only because mdevctl takes the same set of
arguments. Instead, keep the wrappers, but let them call a single
global translator that handles all the mdevctl command differences and
commonalities.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agonodedev: driver: Introduce internal mdevctl commands enum
Erik Skultety [Wed, 31 Mar 2021 13:20:50 +0000 (15:20 +0200)]
nodedev: driver: Introduce internal mdevctl commands enum

This is not a 1:1 mapping to mdevctl commands because mdevctl doesn't
support a separate 'create' command. mdevctl uses 'start' for both
starting a pre-defined device as well as for creating and starting a new
transient device. The libvirt code will be more readable if we treat
these as separate commands. When we need to actually execute mdevctl,
the 'create' command will be translated into the appropriate 'mdevctl
start' command.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
4 years agonodedev: Switch to using long options for mdevctl
Jonathon Jongsma [Thu, 8 Apr 2021 21:53:27 +0000 (16:53 -0500)]
nodedev: Switch to using long options for mdevctl

rather than using short opentions (e.g. "-p 0000:00:02.0"), use long
options everywhere (e.g. "--parent=0000:00:02.0")

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agonodedev: driver: Swap virMdevctlStart and virMdevctlCreate
Erik Skultety [Wed, 31 Mar 2021 13:32:44 +0000 (15:32 +0200)]
nodedev: driver: Swap virMdevctlStart and virMdevctlCreate

"start" in libvirt means - "take this object and create an
instance out of it"

"create" in libvirt most of the time means - "take and XML description,
make an object out of it and use it to create an instance"

This gets confusing with mdevctl which uses "start" for both. So, this
patch proposes to use virMdevctlStart in cases where from libvirt's POV
we're starting a defined device (unlike mdevctl). Similarly, use
virMdevctlCreate in scenarios where XML description is passed to
libvirt and a transient device is supposed to be created.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agotests: nodedev: switch all test macros to accept a filename
Jonathon Jongsma [Thu, 8 Apr 2021 15:25:48 +0000 (10:25 -0500)]
tests: nodedev: switch all test macros to accept a filename

Rather than specifying a UUID string to some test macros, just pass a
filename to an xml definition. This helps work toward unifying the test
macros and making it more maintainable.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agonodedev: avoid use of VIR_ERR_NO_* errors internally
Jonathon Jongsma [Tue, 30 Mar 2021 15:12:07 +0000 (10:12 -0500)]
nodedev: avoid use of VIR_ERR_NO_* errors internally

These errors are demoted to debug statements[1] since they're only
intended to be used as return values for public APIs.  This makes it
difficult to debug the problem when something goes wrong since no error
message is logged. Switch instead to VIR_ERR_INTERNAL_ERROR so that the
error is logged as expected.

[1] See the implementation of daemonErrorLogFilter() for details:
https://gitlab.com/libvirt/libvirt/-/blob/e2f82a3704f680fbb37a733476d870c19232c23e/src/remote/remote_daemon.c#L89

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agonodedev: don't log error in nodeDeviceFindAddressByName()
Jonathon Jongsma [Fri, 9 Apr 2021 19:29:43 +0000 (14:29 -0500)]
nodedev: don't log error in nodeDeviceFindAddressByName()

The calling function will log the error. Just return NULL if a device
cannot be found.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoconf: domain: Refactor virDomainDiskDefParseXML
Peter Krempa [Fri, 16 Apr 2021 07:10:55 +0000 (09:10 +0200)]
conf: domain: Refactor virDomainDiskDefParseXML

Use the new virXMLProp helpers and XPath queries to get rid of the old
style of iteration through element children.

Note that in case of def->blockio.logical_block_size,
def->blockio.physical_block_size and def->rotation_rate the wraparound
behaviour of 'virStrToLong_ui' was _not_ forward ported to the new code
as it makes no sense with the attributes.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoconf: domain: Convert virDomainDiskDef's 'device' to virDomainDiskDevice
Peter Krempa [Fri, 16 Apr 2021 08:46:00 +0000 (10:46 +0200)]
conf: domain: Convert virDomainDiskDef's 'device' to virDomainDiskDevice

Use the appropriate type for the variable and refactor the XML parser to
parse it correctly using virXMLPropEnum.

Changes to other places using switch statements were required.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoconf: domain: Convert virDomainDiskDef's 'bus' to virDomainDiskBus
Peter Krempa [Fri, 16 Apr 2021 08:46:00 +0000 (10:46 +0200)]
conf: domain: Convert virDomainDiskDef's 'bus' to virDomainDiskBus

Use the appropriate type for the variable and refactor the XML parser to
parse it correctly using virXMLPropEnum.

Changes to other places using switch statements were required.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoconf: domain: Convert virDomainDiskDef's 'snapshot' to unsigned int
Peter Krempa [Fri, 16 Apr 2021 08:46:00 +0000 (10:46 +0200)]
conf: domain: Convert virDomainDiskDef's 'snapshot' to unsigned int

Unfortunately virDomainSnapshotLocation is declared in snapshot_conf.h
which includes domain_conf.h. To avoid a circular dependency use
'unsigned int' for now.

Use XML parser can use virXMLPropEnum.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoconf: domain: Convert virDomainDiskDef's 'model' to virDomainDiskModel
Peter Krempa [Fri, 16 Apr 2021 08:46:00 +0000 (10:46 +0200)]
conf: domain: Convert virDomainDiskDef's 'model' to virDomainDiskModel

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>
4 years agoconf: domain: Convert virDomainDiskDef's 'sgio' to virDomainDeviceSGIO
Peter Krempa [Fri, 16 Apr 2021 08:46:00 +0000 (10:46 +0200)]
conf: domain: Convert virDomainDiskDef's 'sgio' to virDomainDeviceSGIO

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>
4 years agoconf: domain: Convert virDomainDiskDef's 'rawio' to virTristateBool
Peter Krempa [Fri, 16 Apr 2021 08:46:00 +0000 (10:46 +0200)]
conf: domain: Convert virDomainDiskDef's 'rawio' to virTristateBool

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>
4 years agoconf: domain: Convert virDomainDiskDef's 'removable' to virTristateSwitch
Peter Krempa [Fri, 16 Apr 2021 08:46:00 +0000 (10:46 +0200)]
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>
4 years agoconf: domain: Move checks from virDomainDiskDefParseXML to virDomainDiskDefValidate
Peter Krempa [Thu, 15 Apr 2021 15:27:01 +0000 (17:27 +0200)]
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>
4 years agoconf: domain: Move default setting from virDomainDiskDefParseXML to virDomainDiskDefP...
Peter Krempa [Thu, 15 Apr 2021 15:15:26 +0000 (17:15 +0200)]
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>
4 years agovmx: Mark CDROM disk elements as read-only
Peter Krempa [Thu, 15 Apr 2021 15:08:45 +0000 (17:08 +0200)]
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>
4 years agoconf: domain: Introduce VIR_DOMAIN_DISK_BUS_NONE
Peter Krempa [Thu, 15 Apr 2021 14:58:19 +0000 (16:58 +0200)]
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>
4 years agoconf: Move disk target 'ioemu:' stripping to virDomainDiskDefPostParse
Peter Krempa [Wed, 14 Apr 2021 07:59:22 +0000 (09:59 +0200)]
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>
4 years agoconf: Move checks from virDomainDiskDefPostParse to virDomainDiskDefValidate
Peter Krempa [Wed, 14 Apr 2021 07:36:57 +0000 (09:36 +0200)]
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>
4 years agoconf: Move disk vendor and product pritability check to domain_validate
Peter Krempa [Wed, 14 Apr 2021 07:31:05 +0000 (09:31 +0200)]
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>
4 years agoconf: Move code from virDomainDiskDefParseValidate to virDomainDiskDefValidate
Peter Krempa [Wed, 14 Apr 2021 07:21:36 +0000 (09:21 +0200)]
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>
4 years agovirDomainDiskDefValidate: Consolidate conditions
Peter Krempa [Tue, 13 Apr 2021 12:05:15 +0000 (14:05 +0200)]
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>
4 years agoconf: domain: Remove VIR_DOMAIN_DEF_PARSE_DISK_SOURCE parser flag
Peter Krempa [Wed, 14 Apr 2021 16:04:31 +0000 (18:04 +0200)]
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>
4 years agoconf: domain: Split out parsing of source data from <disk> XML parser
Peter Krempa [Wed, 14 Apr 2021 15:59:55 +0000 (17:59 +0200)]
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>
4 years agoconf: domain: Split out source validation part from virDomainDiskDefParseValidate
Peter Krempa [Thu, 15 Apr 2021 13:20:28 +0000 (15:20 +0200)]
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>
4 years agoconf: domain: Introduce an internal variant of virDomainDiskDefNew
Peter Krempa [Wed, 14 Apr 2021 14:48:53 +0000 (16:48 +0200)]
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>
4 years agoqemu: driver: Use virDomainDiskDefParseSource in qemuDomainBlockCopy
Peter Krempa [Wed, 14 Apr 2021 14:43:22 +0000 (16:43 +0200)]
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>
4 years agoconf: domain: Introduce virDomainDiskDefParseSource
Peter Krempa [Wed, 14 Apr 2021 14:35:52 +0000 (16:35 +0200)]
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>
4 years agoutil: xml: Introduce virXMLParseStringCtxtRoot
Peter Krempa [Wed, 14 Apr 2021 12:16:28 +0000 (14:16 +0200)]
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>
4 years agovirXMLParseHelper: Add root XML node name validation capability
Peter Krempa [Wed, 14 Apr 2021 11:12:12 +0000 (13:12 +0200)]
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>
4 years agoTranslated using Weblate (Swedish)
Göran Uddeborg [Mon, 19 Apr 2021 09:05:45 +0000 (11:05 +0200)]
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>
4 years agoTranslated using Weblate (Finnish)
Jan Kuparinen [Mon, 19 Apr 2021 09:05:45 +0000 (11:05 +0200)]
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>
4 years agoTranslated using Weblate (Korean)
simmon [Mon, 19 Apr 2021 09:05:44 +0000 (11:05 +0200)]
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>
4 years agoTranslated using Weblate (Korean)
SeongHyun Jo [Mon, 19 Apr 2021 09:05:43 +0000 (11:05 +0200)]
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>
4 years agoTranslated using Weblate (Korean)
simmon [Mon, 19 Apr 2021 09:05:42 +0000 (11:05 +0200)]
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>
4 years agoqemu_block: fix copy&paste typo in SSH protocol
Pavel Hrdina [Mon, 19 Apr 2021 10:28:17 +0000 (12:28 +0200)]
qemu_block: fix copy&paste typo in SSH protocol

Fixes: caf71b64fe6989116316b966fda119cd3e47f485
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Add support for 'restrictive' mode in numatune
Luyao Zhong [Thu, 15 Apr 2021 13:55:04 +0000 (15:55 +0200)]
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>
4 years agoconf, docs, schema: Add support for 'restrictive' mode in numatune
Luyao Zhong [Tue, 13 Apr 2021 06:38:06 +0000 (14:38 +0800)]
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>
4 years agolxc: Format --handshakefd for controller cmd fully
Michal Privoznik [Sat, 17 Apr 2021 07:59:51 +0000 (09:59 +0200)]
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>
4 years agovircgroup: Fix virCgroupKillRecursive() wrt nested controllers
Michal Privoznik [Fri, 16 Apr 2021 14:39:14 +0000 (16:39 +0200)]
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>
4 years agovircgroupbackend: Extend error messages in VIR_CGROUP_BACKEND_CALL()
Michal Privoznik [Fri, 16 Apr 2021 14:14:33 +0000 (16:14 +0200)]
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>
4 years agovircgroup: Debug print all arguments of virCgroupKillRecursiveInternal()
Michal Privoznik [Fri, 16 Apr 2021 14:48:32 +0000 (16:48 +0200)]
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>
4 years agocmdDomBlkError: Fix crash when initial call to virDomainGetDiskErrors fails
Peter Krempa [Mon, 19 Apr 2021 06:11:55 +0000 (08:11 +0200)]
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>
4 years agoconf: domain: Convert virDomainDiskDef's 'startupPolicy' to virDomainStartupPolicy
Peter Krempa [Fri, 16 Apr 2021 08:46:00 +0000 (10:46 +0200)]
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>
4 years agoconf: domain: Convert virDomainDiskDef's 'tray_status' to virDomainDiskTray
Peter Krempa [Fri, 16 Apr 2021 08:46:00 +0000 (10:46 +0200)]
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>
4 years agovirsh: snapshot: Don't validate schema of XML generated by 'virsh snapshot-create-as'
Peter Krempa [Thu, 15 Apr 2021 11:26:37 +0000 (13:26 +0200)]
virsh: snapshot: Don't validate schema of XML generated by 'virsh snapshot-create-as'

Commit 95f8e3237e5486f487324c6 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>
4 years agovirCPUDefParseXML: Use virXMLProp*
Tim Wiederhake [Fri, 16 Apr 2021 09:41:52 +0000 (11:41 +0200)]
virCPUDefParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirDomainIOThreadIDDefParseXML: Use virXMLProp*
Tim Wiederhake [Fri, 16 Apr 2021 09:41:51 +0000 (11:41 +0200)]
virDomainIOThreadIDDefParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirNetworkForwardNatDefParseXML: Use virXMLProp*
Tim Wiederhake [Fri, 16 Apr 2021 09:41:50 +0000 (11:41 +0200)]
virNetworkForwardNatDefParseXML: Use virXMLProp*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovirxml: Add virXMLPropEnum
Tim Wiederhake [Fri, 16 Apr 2021 09:41:49 +0000 (11:41 +0200)]
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>
4 years agovirxml: Add virXMLPropUInt
Tim Wiederhake [Fri, 16 Apr 2021 09:41:48 +0000 (11:41 +0200)]
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>
4 years agovirxml: Add virXMLPropInt
Tim Wiederhake [Fri, 16 Apr 2021 09:41:47 +0000 (11:41 +0200)]
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>
4 years agovirxml: Add virXMLPropTristateSwitch
Tim Wiederhake [Fri, 16 Apr 2021 09:41:46 +0000 (11:41 +0200)]
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>
4 years agovirxml: Add virXMLPropTristateBool
Tim Wiederhake [Fri, 16 Apr 2021 09:41:45 +0000 (11:41 +0200)]
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>
4 years agovirXMLParseHelper: Refactor cleanup
Peter Krempa [Wed, 14 Apr 2021 11:06:51 +0000 (13:06 +0200)]
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>
4 years agovirXMLParseHelper: Rework error reporting
Peter Krempa [Wed, 14 Apr 2021 11:03:58 +0000 (13:03 +0200)]
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>
4 years agoutil: xml: Register autoptr cleanup function for 'xmlParserCtxt'
Peter Krempa [Wed, 14 Apr 2021 10:54:41 +0000 (12:54 +0200)]
util: xml: Register autoptr cleanup function for 'xmlParserCtxt'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
4 years agovirXMLParseHelper: Sync argument names between declaration and definition
Peter Krempa [Wed, 14 Apr 2021 10:52:35 +0000 (12:52 +0200)]
virXMLParseHelper: Sync argument names between declaration and definition

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
4 years agoutil: virxml: Fix formatting of virxml.h
Peter Krempa [Wed, 14 Apr 2021 11:32:12 +0000 (13:32 +0200)]
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>
4 years agoconf: Use virTristateXXX in virPCIDeviceAddress
Tim Wiederhake [Wed, 7 Apr 2021 11:48:41 +0000 (13:48 +0200)]
conf: Use virTristateXXX in virPCIDeviceAddress

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: Use virTristateXXX in virStoragePoolSourceDevice
Tim Wiederhake [Wed, 7 Apr 2021 11:48:40 +0000 (13:48 +0200)]
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>
4 years agoconf: Use virTristateXXX in virStorageAdapterFCHost
Tim Wiederhake [Wed, 7 Apr 2021 11:48:39 +0000 (13:48 +0200)]
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>
4 years agoconf: Use virTristateXXX in virDomainDef
Tim Wiederhake [Wed, 7 Apr 2021 11:48:38 +0000 (13:48 +0200)]
conf: Use virTristateXXX in virDomainDef

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: Use virTristateXXX in virDomainLoaderDef
Tim Wiederhake [Wed, 7 Apr 2021 11:48:37 +0000 (13:48 +0200)]
conf: Use virTristateXXX in virDomainLoaderDef

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: Use virTristateXXX in virDomainMemballoonDef
Tim Wiederhake [Wed, 7 Apr 2021 11:48:36 +0000 (13:48 +0200)]
conf: Use virTristateXXX in virDomainMemballoonDef

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: Use virTristateXXX in virDomainGraphicsDef
Tim Wiederhake [Wed, 7 Apr 2021 11:48:35 +0000 (13:48 +0200)]
conf: Use virTristateXXX in virDomainGraphicsDef

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: Use virTristateXXX in virDomainChrSourceDef
Tim Wiederhake [Wed, 7 Apr 2021 11:48:34 +0000 (13:48 +0200)]
conf: Use virTristateXXX in virDomainChrSourceDef

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: Use virTristateXXX in virDomainNetDef
Tim Wiederhake [Wed, 7 Apr 2021 11:48:33 +0000 (13:48 +0200)]
conf: Use virTristateXXX in virDomainNetDef

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: Use virTristateXXX in virDomainActualNetDef
Tim Wiederhake [Wed, 7 Apr 2021 11:48:32 +0000 (13:48 +0200)]
conf: Use virTristateXXX in virDomainActualNetDef

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: Use virTristateXXX in virDomainDiskDef
Tim Wiederhake [Wed, 7 Apr 2021 11:48:31 +0000 (13:48 +0200)]
conf: Use virTristateXXX in virDomainDiskDef

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: Use virTristateXXX in virDomainDeviceInfo
Tim Wiederhake [Wed, 7 Apr 2021 11:48:30 +0000 (13:48 +0200)]
conf: Use virTristateXXX in virDomainDeviceInfo

Note that the wrong "VIR_TRISTATE_*_ABSENT" was used in qemuDomainChangeNet.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: Use virTristateXXX in virStorageSourceNVMeDef
Tim Wiederhake [Wed, 7 Apr 2021 11:48:29 +0000 (13:48 +0200)]
conf: Use virTristateXXX in virStorageSourceNVMeDef

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: Use virTristateXXX in virStorageSource
Tim Wiederhake [Wed, 7 Apr 2021 11:48:28 +0000 (13:48 +0200)]
conf: Use virTristateXXX in virStorageSource

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoci: Refresh contents
Andrea Bolognani [Thu, 15 Apr 2021 17:07:16 +0000 (19:07 +0200)]
ci: Refresh contents

Notable changes:

  * cross-building container images are smaller because they
    no longer include the native compilers;

  * ccache is enabled for clang builds.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
4 years agonodedev: handle null return from GetIOMMUGroupDev()
Jonathon Jongsma [Tue, 13 Apr 2021 19:27:04 +0000 (14:27 -0500)]
nodedev: handle null return from GetIOMMUGroupDev()

Coverity reported that this function can return NULL, so it should be
handled properly.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agonodedev: refactor virMediatedDeviceGetIOMMUGroupNum()
Jonathon Jongsma [Tue, 13 Apr 2021 19:09:19 +0000 (14:09 -0500)]
nodedev: refactor virMediatedDeviceGetIOMMUGroupNum()

Currently virMediatedDeviceGetIOMMUGroupDev() looks up the iommu group
number and uses that to construct a path to the iommu group device.
virMediatedDeviceGetIOMMUGroupNum() then uses that device path and takes
the basename to get the group number. That's unnecessary extra string
manipulation for *GroupNum(). Reverse the implementations and make
*GroupDev() call *GroupNum().

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agoqemu: remove unnecessary null check
Jonathon Jongsma [Tue, 13 Apr 2021 16:19:00 +0000 (11:19 -0500)]
qemu: remove unnecessary null check

virMediatedDeviceGetSysfsPath() (via g_strdup_printf()) is guaranteed to
return a non-NULL value, so remove the unnecessary checks for NULL.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agovirlog: Remove stray "todo" in comment
Tim Wiederhake [Thu, 15 Apr 2021 08:12:13 +0000 (10:12 +0200)]
virlog: Remove stray "todo" in comment

Fixes: 8fe30b2167b5b56461b11dbf02aca83030070caf
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoFix spelling
Tim Wiederhake [Thu, 15 Apr 2021 08:12:12 +0000 (10:12 +0200)]
Fix spelling

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agolibxl: Add debug statements
Jim Fehlig [Tue, 13 Apr 2021 23:29:19 +0000 (17:29 -0600)]
libxl: Add debug statements

Over several years of debugging reports related to VM shutdown, destruction,
and cleanup, I've found that logging of all events received from libxl and
logging the entry of libxlDomainCleanup has proven useful. Add the these
debug messages upstream to aid in future debugging.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: Expose disk serial in virDomainGetGuestInfo()
Michal Privoznik [Wed, 14 Apr 2021 08:09:35 +0000 (10:09 +0200)]
qemu: Expose disk serial in virDomainGetGuestInfo()

When querying guest info via virDomainGetGuestInfo() the
'guest-get-disks' agent command is called. It may report disk
serial number which we parse, but never report nor use for
anything else.

As it turns out, it may help management application find matching
disk in their internals.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-By: Tomáš Golembiovský <tgolembi@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agovircgroupv2devices: refactor virCgroupV2DevicesRemoveProg
Pavel Hrdina [Wed, 14 Apr 2021 10:01:23 +0000 (12:01 +0200)]
vircgroupv2devices: refactor virCgroupV2DevicesRemoveProg

When running on systemd host the cgroup itself is removed by machined
so when we reach this code the directory no longer exist. If libvirtd
was running the whole time between starting and destroying VM the
detection is skipped because we still have both FD in memory. But if
libvirtd was restarted and no operation requiring cgroup devices
executed the FDs would be 0 and libvirt would try to detect them using
the cgroup directory. This results in reporting following errors:

    libvirtd[955]: unable to open '/sys/fs/cgroup/machine.slice/machine-qemu\x2d1\x2dguest.scope/': No such file or directory
    libvirtd[955]: Failed to remove cgroup for guest

When running on non-systemd host where we handle cgroups manually this
would not happen.

When destroying VM it is not necessary to detect the BPF prog and map
because the following code only closes the FDs without doing anything
else. We could run code that would try to detach the BPF prog from the
cgroup but that is not necessary as well. If the cgroup is removed and
there is no other FD open to the prog kernel will cleanup the prog and
map eventually.

Reported-by: Eric Farman <farman@linux.ibm.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Tested-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroupv2: properly free BPF prog and map FDs
Pavel Hrdina [Fri, 9 Apr 2021 16:28:09 +0000 (18:28 +0200)]
vircgroupv2: properly free BPF prog and map FDs

When nested cgroup was introduced it did not properly free file
descriptors for BPF prog and map. With nested cgroups we create the BPF
bits in the nested cgroup instead of the VM root cgroup.

This would leak the FDs which would be the last reference to the prog
and map so kernel would not remove the resources as well. It would only
happen once libvirtd process exits.

Fixes: 184245f53b94fc84f727eb6e8a2aa52df02d69c0
Reported-by: Eric Farman <farman@linux.ibm.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Tested-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agonodedev: Don't fail device enumeration if MDEVCTL is missing
Michal Privoznik [Tue, 13 Apr 2021 09:50:11 +0000 (11:50 +0200)]
nodedev: Don't fail device enumeration if MDEVCTL is missing

After all devices were enumerated, the enumeration thread call
nodeDeviceUpdateMediatedDevices() to refresh the state of
mediated devices. This means that 'mdevctl' will be executed. But
it may be missing on some systems (e.g. mine) in which case we
should just skip the update of mdevs instead of failing whole
device enumeration.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agonodedev: Mark device initialization complete even in case of an error
Michal Privoznik [Tue, 13 Apr 2021 08:45:24 +0000 (10:45 +0200)]
nodedev: Mark device initialization complete even in case of an error

To speed up nodedev driver initialization, the device enumeration
is done in a separate thread. Once finished, the thread sets a
boolean variable that allows public APIs to be called (instead of
waiting for the thread to finish).

However, if there's an error in the device enumeration thread
then the control jumps over at the 'error' label and the boolean
is never set. This means, that any virNodeDev*() API is stuck
forever. Mark the initialization as complete (the thread is
quitting anyway) and let the APIs proceed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agonodedev: Wait for device initialization in all public API callbacks
Michal Privoznik [Tue, 13 Apr 2021 09:18:23 +0000 (11:18 +0200)]
nodedev: Wait for device initialization in all public API callbacks

Although I have not experienced this in real life, there is a
possible race condition when creating new device, getting its XML
or parent or listing its capabilities.  If the nodedev driver is
still enumerating devices (in a separate thread) and one of
virNodeDeviceGetXMLDesc(), virNodeDeviceGetParent(),
virNodeDeviceNumOfCaps(), virNodeDeviceListCaps() or
virNodeDeviceCreate() is called then it can lead to spurious
results because the device enumeration thread is removing devices
from or adding them to the internal list of devices (among with
their states).

Therefore, wait for things to settle down before proceeding with
any of the APIs.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agonodedev: Signal initCond with driver locked
Michal Privoznik [Tue, 13 Apr 2021 08:52:07 +0000 (10:52 +0200)]
nodedev: Signal initCond with driver locked

This is more academic dispute than a real bug, but this is taken
from pthread_cond_broadcast(3p) man:

  The pthread_cond_broadcast() or pthread_cond_signal() functions
  may be called by a thread whether or not it currently owns the
  mutex that threads calling pthread_cond_wait() or
  pthread_cond_timedwait() have associated with the condition
  variable during their waits; however, if predictable scheduling
  behavior is required, then that mutex shall be locked by the
  thread calling pthread_cond_broadcast() or
  pthread_cond_signal().

Therefore, broadcast the initCond while the nodedev driver is
still locked.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agonodedev: Rename nodeDeviceWaitInit()
Michal Privoznik [Tue, 13 Apr 2021 09:14:15 +0000 (11:14 +0200)]
nodedev: Rename nodeDeviceWaitInit()

The consensus is to put the verb last. Therefore, the new name is
nodeDeviceInitWait(). This allows us to introduce new function
(done later in a separate commit) that will "complete" the device
initialization.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>