]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
3 years agoUpdate translation files
Weblate [Sat, 27 Nov 2021 15:16:14 +0000 (16:16 +0100)] 
Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

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

Co-authored-by: Weblate <noreply@weblate.org>
Signed-off-by: Fedora Weblate Translation <i18n@lists.fedoraproject.org>
3 years agoqemu: Fix validation of PCI option rom settings on hotplug
Peter Krempa [Thu, 25 Nov 2021 15:17:16 +0000 (16:17 +0100)] 
qemu: Fix validation of PCI option rom settings on hotplug

Commit 24be92b8e moved the option rom settings validation code to the
validation callbacks, but that doesn't work properly with device hotplug
as we assign addresses only after parsing the whole XML. The check is
too strict for that and caused failures when hotplugging devices such
as:

 <interface type='network'>
   <source network='default'/>
   <model type='virtio'/>
   <rom enabled='no'/>
 </interface>

This patch relaxes the check in the validation callback to accept also
_NONE and _UNASSIGNED address types and returns the check to
'qemuBuildRomProps' so that we preserve the full validation as we've
used to.

Fixes: 24be92b8e38762e9ba13e
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2021437
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: monitor: Fix usage of 'query-blockstats'
Peter Krempa [Wed, 24 Nov 2021 16:22:29 +0000 (17:22 +0100)] 
qemu: monitor: Fix usage of 'query-blockstats'

Commit bc24810c2cab modified code querying blockstats to use the
'query-nodes' parameter so that we can fetch stats also for images which
are not attached to a frontend such as block copy and backup scratch
images.

Unfortunately that broke the old blockstats because if 'query-nodes' is
enabled qemu doesn't output the 'qdev' parameter which our code used for
matching to the disk and also qemu neglects to populate the frontend
stats at all so we can't even switch to using nodename for matching.

To fix this we need to do two calls, one with 'query-nodes' disabled
using the old logic to populate everything and then an additional one
which populates all the remaining images.

Closes: https://gitlab.com/libvirt/libvirt/-/issues/246
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Tested-by: Erik Skultety <eskultet@redhat.com>
3 years agoNEWS: document tcp_min_ssf
Ján Tomko [Fri, 5 Nov 2021 13:02:25 +0000 (14:02 +0100)] 
NEWS: document tcp_min_ssf

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agopo: Refresh potfile for v7.10.0 v7.10.0-rc1
Jiri Denemark [Thu, 25 Nov 2021 09:19:23 +0000 (10:19 +0100)] 
po: Refresh potfile for v7.10.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3 years agoTranslated using Weblate (Swedish)
Göran Uddeborg [Wed, 24 Nov 2021 06:44:02 +0000 (07:44 +0100)] 
Translated using Weblate (Swedish)

Currently translated at 29.0% (3037 of 10441 strings)

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

Translated using Weblate (Swedish)

Currently translated at 29.0% (3036 of 10441 strings)

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

Translated using Weblate (Swedish)

Currently translated at 29.0% (3030 of 10441 strings)

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

Translated using Weblate (Swedish)

Currently translated at 28.9% (3020 of 10441 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>
3 years agoTranslated using Weblate (Korean)
simmon [Wed, 24 Nov 2021 06:44:01 +0000 (07:44 +0100)] 
Translated using Weblate (Korean)

Currently translated at 100.0% (10441 of 10441 strings)

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

Translated using Weblate (Korean)

Currently translated at 100.0% (10441 of 10441 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>
3 years agoqemu_alias: change return type to void if possible
Kristina Hanicova [Wed, 24 Nov 2021 16:12:54 +0000 (17:12 +0100)] 
qemu_alias: change return type to void if possible

These functions always return success so it seems logical to not
return anything and remove unnecessary checks.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu_alias: Rewrite of code pattern
Kristina Hanicova [Wed, 24 Nov 2021 16:12:53 +0000 (17:12 +0100)] 
qemu_alias: Rewrite of code pattern

This patch rewrites the pattern using early return where it is
not needed and changes the return type of the functions to 'void'
if possible.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: Rewrite code to the pattern
Kristina Hanicova [Wed, 24 Nov 2021 11:25:35 +0000 (12:25 +0100)] 
qemu: Rewrite code to the pattern

I have seen this pattern a lot in the project, so I decided to
rewrite code I stumbled upon to the same pattern as well.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agolibxl: Don't derive libxlDomainObjPrivate from virObjectLockable
Jim Fehlig [Mon, 22 Nov 2021 17:54:04 +0000 (10:54 -0700)] 
libxl: Don't derive libxlDomainObjPrivate from virObjectLockable

The libxlDomainObjPrivate object is never locked and hence does not need to
be a virObjectLockable object.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agolibxl: Remove unused macros
Jim Fehlig [Mon, 22 Nov 2021 17:43:13 +0000 (10:43 -0700)] 
libxl: Remove unused macros

Remove unused JOB_MASK and DEFAULT_JOB_MASK macros.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: Remove 'else' branches after 'return' or 'goto'
Kristina Hanicova [Tue, 23 Nov 2021 17:20:10 +0000 (18:20 +0100)] 
qemu: Remove 'else' branches after 'return' or 'goto'

I think it makes no sense to have else branches after return or
goto as it will never reach them in cases it should not. This
patch makes the code more readable (at least to me).

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
3 years agovirDomainObjListAdd: Transfer definition ownership
Michal Privoznik [Tue, 2 Nov 2021 11:19:50 +0000 (12:19 +0100)] 
virDomainObjListAdd: Transfer definition ownership

Upon successful return from virDomainObjListAdd() the
virDomainObj is the owner of secret definition. To make this
ownership transfer even more visible, lets pass the definition as
a double pointer and use g_steal_pointer().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agovirStoragePoolObjListAdd: Transfer definition ownership
Michal Privoznik [Tue, 23 Nov 2021 16:09:59 +0000 (17:09 +0100)] 
virStoragePoolObjListAdd: Transfer definition ownership

Upon successful return from virStoragePoolObjListAdd() the
virStoragePoolObj is the owner of secret definition. To make this
ownership transfer even more visible, lets pass the definition as
a double pointer and use g_steal_pointer().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agovirSecretObjListAdd: Transfer definition ownership
Michal Privoznik [Tue, 23 Nov 2021 16:03:44 +0000 (17:03 +0100)] 
virSecretObjListAdd: Transfer definition ownership

Upon successful return from virSecretObjListAdd() the
virSecretObj is the owner of secret definition. To make this
ownership transfer even more visible, lets pass the definition as
a double pointer and use g_steal_pointer().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agovirInterfaceObjListAssignDef: Transfer definition ownership
Michal Privoznik [Tue, 2 Nov 2021 10:02:27 +0000 (11:02 +0100)] 
virInterfaceObjListAssignDef: Transfer definition ownership

Upon successful return from virInterfaceObjListAssignDef() the
virInterfaceObj is the owner of secret definition. To make this
ownership transfer even more visible, lets pass the definition as
a double pointer and use g_steal_pointer().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agoutil: fix cache invalidation of swtpm capabilities
Daniel P. Berrangé [Wed, 24 Nov 2021 10:56:02 +0000 (10:56 +0000)] 
util: fix cache invalidation of swtpm capabilities

The check for whether the swtpm binary was modified is checking pointers
to the mtime field in two distinct structs, so will always compare
different. This resulted in re-probing swtpm capabilities every time,
as many as 20 times for a single VM launch.

Fixes:

  commit 01cf7a1bb9f1da27ad8bcbaa82c4f7a948c6a793
  Author: Stefan Berger <stefanb@us.ibm.com>
  Date:   Thu Jul 25 14:22:04 2019 -0400

    tpm: Check whether previously found executables were updated

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoci: display installed packages at start of build
Daniel P. Berrangé [Tue, 23 Nov 2021 16:00:17 +0000 (16:00 +0000)] 
ci: display installed packages at start of build

When a build fails it is helpful to know what packages were installed,
because by the time we look at the build job output, the original
container image might have changed.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoutil: virExec may blocked by reading pipe if grandchild prematurely exit
Xu Chao [Wed, 24 Nov 2021 02:33:11 +0000 (10:33 +0800)] 
util: virExec may blocked by reading pipe if grandchild prematurely exit

When VIR_EXEC_DAEMON is set, if virPidFileAcquirePath/virSetInherit failed,
then pipesync[0] can not be closed when granchild process exit, because
pipesync[1] still opened in child process. and then saferead in child
process may blocked forever, and left grandchild process in defunct state.

Signed-off-by: Xu Chao <xu.chao6@zte.com.cn>
Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoutil: xml: Remove virXMLPropStringLimit and virXPathStringLimit
Peter Krempa [Mon, 22 Nov 2021 16:44:49 +0000 (17:44 +0100)] 
util: xml: Remove virXMLPropStringLimit and virXPathStringLimit

The functions have very difficult semantics where callers are not able
to tell whether the property is missing or failed the length check. Only
the latter produces errors.

Since usage of the functions was phased out, remove them completely to
avoid further broken code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirSecurityLabelDefParseXML: Don't use virXMLPropStringLimit
Peter Krempa [Mon, 22 Nov 2021 16:43:13 +0000 (17:43 +0100)] 
virSecurityLabelDefParseXML: Don't use virXMLPropStringLimit

The function produces an error which is ignored in this code path.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirSecurityDeviceLabelDefParseXML: Don't use 'virXPathStringLimit'
Peter Krempa [Mon, 22 Nov 2021 16:26:40 +0000 (17:26 +0100)] 
virSecurityDeviceLabelDefParseXML: Don't use 'virXPathStringLimit'

virXPathStringLimit doesn't give callers a way to differentiate between
the queried XPath being empty and the length limit being exceeded.

This means that the callers is completely ignoring the error.

Move the length check into the caller.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirSecurityDeviceLabelDefParseXML: Use automatic memory clearing for temp strings
Peter Krempa [Mon, 22 Nov 2021 16:34:36 +0000 (17:34 +0100)] 
virSecurityDeviceLabelDefParseXML: Use automatic memory clearing for temp strings

Apart from code simplification the refactor of 'model' fixes an unlikely
memory leak of the string if a duplicate model is found.

While the coversion of 'label' variable may seem unnecessary it will
come in handy in the next patch.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirSecurityLabelDefParseXML: Don't use 'virXPathStringLimit'
Peter Krempa [Mon, 22 Nov 2021 16:26:40 +0000 (17:26 +0100)] 
virSecurityLabelDefParseXML: Don't use 'virXPathStringLimit'

virXPathStringLimit doesn't give callers a way to differentiate between
the queried XPath being empty and the length limit being exceeded.

This means that callers are either overwriting the error message or
ignoring it altogether.

Move the length checks into the caller.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirNodeDeviceCapVPDParseCustomFields: Don't use 'virXPathStringLimit'
Peter Krempa [Mon, 22 Nov 2021 16:17:24 +0000 (17:17 +0100)] 
virNodeDeviceCapVPDParseCustomFields: Don't use 'virXPathStringLimit'

virXPathStringLimit doesn't give callers a way to differentiate between
the queried XPath being empty and the length limit being exceeded.

This means that callers are overwriting the error message.

Move the length checks into the caller.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirSecurityLabelDefParseXML: Remove pointless 'error' label
Peter Krempa [Mon, 22 Nov 2021 15:42:21 +0000 (16:42 +0100)] 
virSecurityLabelDefParseXML: Remove pointless 'error' label

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirSecurityLabelDefParseXML: Use automatic freeing for 'seclabel'
Peter Krempa [Mon, 22 Nov 2021 15:40:33 +0000 (16:40 +0100)] 
virSecurityLabelDefParseXML: Use automatic freeing for 'seclabel'

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirSecurityLabelDefParseXML: Don't reuse temporary string 'p'
Peter Krempa [Mon, 22 Nov 2021 15:37:10 +0000 (16:37 +0100)] 
virSecurityLabelDefParseXML: Don't reuse temporary string 'p'

Use separate variables for 'model' and 'relabel' properties.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirSecurityLabelDefParseXML: Directly assign strings into appropriate variables
Peter Krempa [Mon, 22 Nov 2021 15:33:37 +0000 (16:33 +0100)] 
virSecurityLabelDefParseXML: Directly assign strings into appropriate variables

'seclabel->label', 'seclabel->imagelabel' and 'seclabel->baselabel' are
populated by stealing the pointer from the 'p' temporary string. Remove
the extra step.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirSecurityLabelDef: Declare 'type' as 'virDomainSeclabelType'
Peter Krempa [Mon, 22 Nov 2021 15:31:44 +0000 (16:31 +0100)] 
virSecurityLabelDef: Declare 'type' as 'virDomainSeclabelType'

Use the appropriate enum type instead of an int and fix the XML parser
and one missing fully populated switch.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoutil: seclabel: Define autoptr cleanup func for virSecurityLabelDef and virSecurityDe...
Peter Krempa [Mon, 22 Nov 2021 15:17:24 +0000 (16:17 +0100)] 
util: seclabel: Define autoptr cleanup func for virSecurityLabelDef and virSecurityDeviceLabelDef

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agomeson: fix cpuset_getaffinity() detection
Roman Bogorodskiy [Tue, 23 Nov 2021 11:19:10 +0000 (15:19 +0400)] 
meson: fix cpuset_getaffinity() detection

The cpuset_getaffinity() function is checked in sys/cpuset.h to see if
BSD CPU affinity APIs are available. This check requires including
sys/param.h to work properly, otherwise the test program fails with
unrelated errors like:

/usr/include/sys/cpuset.h:155:1: error: unknown type name
'__BEGIN_DECLS'
__BEGIN_DECLS
^
/usr/include/sys/cpuset.h:156:12: error: unknown type name 'cpusetid_t';
did you mean 'cpuset_t'?
int     cpuset(cpusetid_t *);

and so forth.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: Remove unnecessary variables and labels
Kristina Hanicova [Tue, 23 Nov 2021 16:34:36 +0000 (17:34 +0100)] 
qemu: Remove unnecessary variables and labels

This patch removes variables such as 'ret', 'rc' and others which
are easily replaced. Therefore, making the code look cleaner and
easier to understand.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoci: run a mingw64 job on stable Fedora
Daniel P. Berrangé [Tue, 23 Nov 2021 12:12:25 +0000 (12:12 +0000)] 
ci: run a mingw64 job on stable Fedora

Both of the current mingw jobs are marked as 'allow_failure' because
they are running against Fedora rawhide which is an unstable distro.

We need at least one mingw job to be gating to more reliably detect
problems.

This introduces dockerfiles for both mingw variants on Fedora 35
and sets the mingw64 build to run on Fedora 34, and mingw32 on
Fedora rawhide.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoci: refresh variables/dockerfiles with latest content
Daniel P. Berrangé [Tue, 23 Nov 2021 12:09:37 +0000 (12:09 +0000)] 
ci: refresh variables/dockerfiles with latest content

  - The Cirrus CI variables are now sorted
  - The dockerfiles update commands changed for some distros
  - Meson in CentOS is now new enough to use

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoci: replace Fedora 33 with Fedora 35
Daniel P. Berrangé [Tue, 23 Nov 2021 12:09:00 +0000 (12:09 +0000)] 
ci: replace Fedora 33 with Fedora 35

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agotests: pcivpdtest: check return value of virCreateAnonymousFile
Ján Tomko [Tue, 23 Nov 2021 14:05:43 +0000 (15:05 +0100)] 
tests: pcivpdtest: check return value of virCreateAnonymousFile

Fixes: 59c1bc3a0e25e6d725db41990f11e0b53137115d
Fixes: 43820e4b8037680ec451761216750c6b139db67a
Fixes: 600f580d623ae4077ddeb6c7cb24f8a315a7c73b
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Kristína Hanicová <khanicov@redhat.com>
3 years agoch: fix logic in virCHMonitorBuildPtyJson
Ján Tomko [Tue, 23 Nov 2021 13:51:18 +0000 (14:51 +0100)] 
ch: fix logic in virCHMonitorBuildPtyJson

There is a leftover 'ptys' variable, which we only assign
to and one assignment to 'content', where we add an empty
'pty' object.

Remove 'ptys'.

Fixes: 93accefd9eca1bc3d7e923a979ab2d1b8a312ff7
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Kristína Hanicová <khanicov@redhat.com>
3 years agovbox: fix vboxCapsInit
Ján Tomko [Tue, 23 Nov 2021 13:17:00 +0000 (14:17 +0100)] 
vbox: fix vboxCapsInit

There is a stray mis-indented 'return NULL' left after a recent
refactor.

Fixes: c18d9e23fafabcfbb80481e0705931036b8e7331
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Kristína Hanicová <khanicov@redhat.com>
3 years agotools: virt-host-validate: fix memory leak
Ján Tomko [Tue, 23 Nov 2021 13:15:45 +0000 (14:15 +0100)] 
tools: virt-host-validate: fix memory leak

virHostValidateGetCPUFlags returns an allocated virBitmap and
it needs to be freed.

Fixes: a0ec7165e3bbc416478740f6d2e8fef2ece18602
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Kristína Hanicová <khanicov@redhat.com>
3 years agoUse virProcessGetStat
Martin Kletzander [Fri, 19 Nov 2021 15:03:55 +0000 (16:03 +0100)] 
Use virProcessGetStat

This eliminates one incorrect parsing implementation which relied on the
command field not having a closing bracket.  This possibility is already
tested against in the virProcessGetStat() tests.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoutil: Add virProcessGetStat
Martin Kletzander [Thu, 18 Nov 2021 15:13:52 +0000 (16:13 +0100)] 
util: Add virProcessGetStat

This reads and separates all fields from /proc/<pid>/stat or
/proc/<pid>/task/<tid>/stat as there are easy mistakes to be done in the
implementation.  Some tests are added to show it works correctly.  No number
parsing is done as it would be unused for most of the fields most, if not all,
of the time.  No struct is used for the result as the length can vary (new
fields can be added in the future).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsh: man: update snapshot-revert description
Pavel Hrdina [Tue, 23 Nov 2021 14:15:43 +0000 (15:15 +0100)] 
virsh: man: update snapshot-revert description

We've changed the behavior of this API that from now on it will always
restart the VM process and we are no longer able to revert to snapshots
created by libvirt older then 0.9.5.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu_monitor: remove unused load snapshot code
Pavel Hrdina [Tue, 23 Nov 2021 13:50:20 +0000 (14:50 +0100)] 
qemu_monitor: remove unused load snapshot code

Recent cleanup of snapshot revert code made these function unused.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agobash-completion: fix variable leaks of "IFS" and "word"
Koichi Murase [Sun, 14 Nov 2021 06:06:40 +0000 (15:06 +0900)] 
bash-completion: fix variable leaks of "IFS" and "word"

Signed-off-by: Koichi Murase <myoga.murase@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoutil: Check for pkttyagent availability properly
Martin Kletzander [Fri, 19 Nov 2021 16:12:54 +0000 (17:12 +0100)] 
util: Check for pkttyagent availability properly

It does not need a tty to work, it opens its controlling terminal for user
interaction and with this patch even crazy things like this work:

  echo 'list --name' | virsh -q >/dev/null

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoutil: Report errors in all code paths in virPolkitAgentCreate
Martin Kletzander [Fri, 19 Nov 2021 15:20:25 +0000 (16:20 +0100)] 
util: Report errors in all code paths in virPolkitAgentCreate

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsh: Do not try connecting first time without polkit agent
Martin Kletzander [Tue, 16 Nov 2021 14:00:19 +0000 (15:00 +0100)] 
virsh: Do not try connecting first time without polkit agent

Trying to connect once without a polkit agent will generate an error on the
server side which seems too rough given it only serves the purpose of the client
(virsh in this case) to figure out that an agent is needed.  Thankfully we can
just try running the agent.  It does not break anything as we are running it
with `--fallback`, which makes sure it does not replace an existing agent in
case there is one already registered.

The second piece of code trying to start the polkit text agent is kept in order
to _really_ try out starting the agent (and error out when failing to do so)
just in case the agent was not available the first time it was ran.  Even though
it should not happen it avoids a very rare race condition and really does not
add much complexity.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1945501
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoutil: Add virPolkitAgentAvailable
Martin Kletzander [Tue, 16 Nov 2021 13:37:52 +0000 (14:37 +0100)] 
util: Add virPolkitAgentAvailable

With this function we can decide whether to try running the polkit text agent
only if it is available, removing a potential needless error saying that the
agent binary does not exist, which is useful especially when running the agent
before knowing whether it is going to be needed.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoutil: Tiny reword fix in comment
Martin Kletzander [Tue, 16 Nov 2021 13:35:34 +0000 (14:35 +0100)] 
util: Tiny reword fix in comment

Automatic "Ptr " -> " *" also wreaked havoc in comments.  Fix it and while at it
reword the sentence so it is clear that the object is newly allocated.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirsh: Remove needless variable
Martin Kletzander [Tue, 16 Nov 2021 13:30:07 +0000 (14:30 +0100)] 
virsh: Remove needless variable

It only redundantly reflects whether pkagent != NULL.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agomeson: improve CPU affinity routines check
Roman Bogorodskiy [Sun, 21 Nov 2021 11:56:06 +0000 (15:56 +0400)] 
meson: improve CPU affinity routines check

Recently, FreeBSD has got sched_get/setaffinity(3) implementations and
the sched.h header as well [1]. To make these routines visible,
users have to define _WITH_CPU_SET_T.

This breaks current detection. Specifically, meson sees the
sched_getaffinity() symbol and defines WITH_SCHED_GETAFFINITY. This
define unlocks Linux implementation of virProcessSetAffinity() and other
functions, which fails to build on FreeBSD because cpu_set_t is not
visible as _WITH_CPU_SET_T is not defined.

For now, change detection to the following:

 - Instead of checking sched_getaffinity(), check if 'cpu_set_t' is
   available through sched.h
 - Explicitly check the sched.h header instead of assuming its presence
   if WITH_SCHED_SETSCHEDULER is defined

1:
https://cgit.freebsd.org/src/commit/?id=43736b71dd051212d5c55be9fa21c45993017fbb
https://cgit.freebsd.org/src/commit/?id=160b4b922b6021848b6b48afc894d16b879b7af2
https://cgit.freebsd.org/src/commit/?id=90fa9705d5cd29cf11c5dc7319299788dec2546a

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agodomain_snapshot: update virDomainRevertToSnapshot description
Pavel Hrdina [Mon, 15 Nov 2021 14:52:39 +0000 (15:52 +0100)] 
domain_snapshot: update virDomainRevertToSnapshot description

We've changed the behavior of this API that from now on it will always
restart the VM process and we are no longer able to revert to snapshots
created by libvirt older then 0.9.5.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agotest: snapshot revert: drop error the VM must be restarted
Pavel Hrdina [Mon, 15 Nov 2021 14:48:41 +0000 (15:48 +0100)] 
test: snapshot revert: drop error the VM must be restarted

This will always happen so there is no need to error out and require
usage of FORCE flag.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agotest: snapshot revert: fix emitting events
Pavel Hrdina [Tue, 23 Nov 2021 08:15:04 +0000 (09:15 +0100)] 
test: snapshot revert: fix emitting events

Now that we always emulate restarting the VM process events are emitted
differently so we need to update the code and the comment as well.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agotest: snapshot revert: drop unused code
Pavel Hrdina [Thu, 11 Nov 2021 16:39:54 +0000 (17:39 +0100)] 
test: snapshot revert: drop unused code

Now that we always emulate VM process stop we can drop the unused code
and simply the logic.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agotest: snapshot revert: always emulate VM process stop
Pavel Hrdina [Thu, 11 Nov 2021 16:36:06 +0000 (17:36 +0100)] 
test: snapshot revert: always emulate VM process stop

Reflect the same change in test driver as in QEMU driver because the
compatibility check code isn't perfect.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agotest: snapshot revert: properly emulate starting CPUs
Pavel Hrdina [Tue, 23 Nov 2021 08:03:10 +0000 (09:03 +0100)] 
test: snapshot revert: properly emulate starting CPUs

When active snapshot is reverted we stop CPUs in order to load the
snapshot but we never start the CPUs again.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agotest: snapshot revert: always error out if VM XML is missing
Pavel Hrdina [Thu, 11 Nov 2021 16:34:46 +0000 (17:34 +0100)] 
test: snapshot revert: always error out if VM XML is missing

We should have this check even if FORCE flag is used because later we
unconditionally copy the `snap->def->dom` and error out if there is no
copy created. The test driver will always save the VM XML when creating
new snapshot.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemu_snapshot: revert: drop error that QEMU process must be restarted
Pavel Hrdina [Mon, 15 Nov 2021 14:46:04 +0000 (15:46 +0100)] 
qemu_snapshot: revert: drop error that QEMU process must be restarted

This will always happen so there is no need to error out and require
usage of FORCE flag.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemu_snapshot: revert: fix emitting events
Pavel Hrdina [Mon, 15 Nov 2021 16:12:20 +0000 (17:12 +0100)] 
qemu_snapshot: revert: fix emitting events

Now that we always restart the QEMU process events are emitted
differently so we need to update the code and the comment as well.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemu_snapshot: revert: drop unused loadvm code
Pavel Hrdina [Wed, 10 Nov 2021 14:59:26 +0000 (15:59 +0100)] 
qemu_snapshot: revert: drop unused loadvm code

Now that we always restart QEMU process the loadvm code is unused and
can be dropped.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemu_snapshot: revert: always restart QEMU process for running VM
Pavel Hrdina [Wed, 10 Nov 2021 14:44:07 +0000 (15:44 +0100)] 
qemu_snapshot: revert: always restart QEMU process for running VM

Our compatibility check code isn't complete and there are cases where it
fails to detect incompatible configuration and the revert fails. In
addition future support for external snapshot will always require
restarting the QEMU process.

To unify the behavior drop the compatibility check code and always
restart the QEMU process.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemu_snapshot: revert: always error out if VM XML is missing
Pavel Hrdina [Wed, 10 Nov 2021 12:55:58 +0000 (13:55 +0100)] 
qemu_snapshot: revert: always error out if VM XML is missing

The support to revert snapshots was introduced in libvirt 0.8.0 but
saving the whole VM XML was implemented later in libvirt 0.9.5.

That is more then 10 years ago so we can safely assume that nobody will
try reverting to snapshot created by that old libvirt. In the unlikely
scenario where someone would actually did it we would simply error out.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoutil: fix various ATTRIBUTE_NONNULL calls
Pavel Hrdina [Fri, 19 Nov 2021 17:01:23 +0000 (18:01 +0100)] 
util: fix various ATTRIBUTE_NONNULL calls

Git bisect took me to commit where incorrect usage of ATTRIBUTE_NONNULL
was introduced and caused coverity scan to fail. This patch fixes the
issue where the index starts from 1 and not 0 and two other different
cases.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: Switch to -accel
Michal Privoznik [Fri, 5 Nov 2021 08:38:10 +0000 (09:38 +0100)] 
qemu: Switch to -accel

We currently use -machine accel=XXX which is just a syntax sugar
for -accel XXX. The former doesn't allow specifying arguments for
accelerator, because all arguments passed to -machine are
treated as arguments of machine itself.

The -accel argument was introduced in QEMU commit
v2.9.0-rc0~70^2~19 and since our minimum required version is
newer (2.11.0) we can safely assume its existence and use it
without any capability.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/233
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Kashyap Chamarthy <kchamart@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemu_command: Don't validate accelerator when building cmd line
Michal Privoznik [Fri, 5 Nov 2021 08:33:45 +0000 (09:33 +0100)] 
qemu_command: Don't validate accelerator when building cmd line

The domain accelerator was validated in qemuValidateDomainDef()
which calls virQEMUCapsIsVirtTypeSupported() which reports proper
error if QEMU is not capable of KVM/TCG. There is no point in
doing the validation again when building command line.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Tested-by: Kashyap Chamarthy <kchamart@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemuMonitorJSONAttachCharDevGetProps: Modernize construction of JSON objects
Peter Krempa [Thu, 14 Oct 2021 12:17:02 +0000 (14:17 +0200)] 
qemuMonitorJSONAttachCharDevGetProps: Modernize construction of JSON objects

Use 'virJSONValueObjectAdd' instead of the step-by-step manual JSON
object building.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuMonitorJSONBuildChrChardevReconnect: Unify with qemuBuildChrChardevReconnectStr
Peter Krempa [Fri, 19 Nov 2021 12:25:00 +0000 (13:25 +0100)] 
qemuMonitorJSONBuildChrChardevReconnect: Unify with qemuBuildChrChardevReconnectStr

When formatting the commandline we explicitly set the reconnect timeout
to 0 when it's disabled even when that's the default. Do the same in
the monitor/hotplug code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuMonitorJSONAttachCharDevGetProps: Rename 'backend_type' and 'data'
Peter Krempa [Fri, 19 Nov 2021 12:17:27 +0000 (13:17 +0100)] 
qemuMonitorJSONAttachCharDevGetProps: Rename 'backend_type' and 'data'

Rename 'data' to 'backendData' so that it's more clear what the object
represents and 'backend_type' to 'backendType' to go with the common
camel case notation.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agolib: Drop needless one line labels
Michal Privoznik [Thu, 4 Nov 2021 14:26:07 +0000 (15:26 +0100)] 
lib: Drop needless one line labels

In some cases we have a label that contains nothing but a return
statement. The amount of such labels rises as we use automagic
cleanup. Anyway, such labels are pointless and can be dropped.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
3 years agoqemu_command: Generate -mem-prealloc in one corner case more
Michal Privoznik [Wed, 15 Sep 2021 13:59:59 +0000 (15:59 +0200)] 
qemu_command: Generate -mem-prealloc in one corner case more

When guest has NUMA nodes and QEMU is new enough to report
default RAM ID then ideally we would use -numa memdev= combined
with memory-backend-* combo becasue -mem-path/-mem-prealloc/-numa
mem are deprecated. Well, there is one problem - the .memdev=
attribute is machine type dependent (just look at arguments of
virQEMUCapsGetMachineNumaMemSupported()) and to ensure backwards
compatibility we prefer -numa mem= over -numa memdev=.

But there was one corner case when -mem-prealloc was requested
but not generated on the cmd line. It all starts with
qemuBuildMemCommandLine() which generates just '-m XXX' and
because it sees defaultRAMid and guest NUMA nodes greater than
zero it does nothing more.

Then, qemuBuildNumaCommandLine() sees that -numa mem= is still
supported for given machine type and nothing else set
@needBackend thus qemuBuildMemPathStr() is called which output
-mem-prealloc only in a few cases assuming it was outputted
earlier.

Reported-by: Jing Qi <jinqi@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuxml2argvtest: Introduce another numa-topology test
Michal Privoznik [Wed, 15 Sep 2021 14:05:49 +0000 (16:05 +0200)] 
qemuxml2argvtest: Introduce another numa-topology test

This test shows a bug we have: even though the XML says:

  <allocation mode='immediate'/>

there is no -mem-prealloc nor .prealloc=yes anywhere on the cmd
line. This will be fixed in the next commit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu_capabilities.c: del 'cleanup' label in virQEMUCapsLoadHostCPUModelInfo()
Daniel Henrique Barboza [Thu, 18 Nov 2021 20:54:33 +0000 (17:54 -0300)] 
qemu_capabilities.c: del 'cleanup' label in virQEMUCapsLoadHostCPUModelInfo()

Create extra g_autofree strings and use them in an adequate scope to
eliminate the need for VIR_FREE() calls and the 'cleanup' label.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
3 years agocpu_ppc64.c: remove 'guest' param from ppc64Compute()
Daniel Henrique Barboza [Thu, 18 Nov 2021 14:20:20 +0000 (11:20 -0300)] 
cpu_ppc64.c: remove 'guest' param from ppc64Compute()

ppc64Compute() is used only once, by virCPUppc64Compare(), which
doesn't use the 'guest' parameter. It was last used by an API
called 'cpuGuestData' that was dropped by commit 03fa904c0c0cb2.

Removing the 'guest' parameter will not only remove unused code from
ppc64Compute() but also remove the ppc64MakeCPUData() entirely.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
3 years agoqemu_capabilities.c: remove cleanup label from virQEMUCapsLoadCache()
Daniel Henrique Barboza [Thu, 18 Nov 2021 18:47:15 +0000 (15:47 -0300)] 
qemu_capabilities.c: remove cleanup label from virQEMUCapsLoadCache()

'str' is no longer being used and the 'cleanup' label can be removed
together with the 'ret' variable.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
3 years agoqemu_capabilities.c: add virQEMUCapsValidateArch()
Daniel Henrique Barboza [Thu, 18 Nov 2021 18:41:19 +0000 (15:41 -0300)] 
qemu_capabilities.c: add virQEMUCapsValidateArch()

Create a new helper to remove the arch validation logic from the
body of virQEMUCapsLoadCache().

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
3 years agoqemu_capabilities.c: add virQEMUCapsValidateEmulator()
Daniel Henrique Barboza [Thu, 18 Nov 2021 18:37:06 +0000 (15:37 -0300)] 
qemu_capabilities.c: add virQEMUCapsValidateEmulator()

Create a new helper to remove the emulator validation logic from the
body of virQEMUCapsLoadCache().

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
3 years agoqemu_capabilities.c: del 'nodes' var from virQEMUCapsLoadCache()
Daniel Henrique Barboza [Thu, 18 Nov 2021 18:29:38 +0000 (15:29 -0300)] 
qemu_capabilities.c: del 'nodes' var from virQEMUCapsLoadCache()

The 'nodes' var is not being used.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
3 years agoqemu_capabilities.c: add virQEMUCapsParseGIC()
Daniel Henrique Barboza [Thu, 18 Nov 2021 18:27:54 +0000 (15:27 -0300)] 
qemu_capabilities.c: add virQEMUCapsParseGIC()

Create a new helper to remove the GIC parse logic from the body of
virQEMUCapsLoadCache().

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
3 years agoqemu_capabilities.c: add virQEMUCapsParseFlags()
Daniel Henrique Barboza [Thu, 18 Nov 2021 18:17:44 +0000 (15:17 -0300)] 
qemu_capabilities.c: add virQEMUCapsParseFlags()

Create a new helper to remove the parse capabilities flag logic from the
body of virQEMUCapsLoadCache().

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
3 years agoqemu: Fix the check of AMD secure guest support
Vasiliy Ulyanov [Fri, 19 Nov 2021 12:37:38 +0000 (13:37 +0100)] 
qemu: Fix the check of AMD secure guest support

The content of /sys/module/kvm_amd/parameters/sev may vary depending on
the kernel version. Check also for 'Y' and 'y' in addition to '1' to
cover several possible variants. The fix is similar to the one
introduced in commit 3f9c1a4bb841

Signed-off-by: Vasiliy Ulyanov <vulyanov@suse.de>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoconf: match by network alias only if aliases are assigned
Ján Tomko [Thu, 18 Nov 2021 15:21:27 +0000 (16:21 +0100)] 
conf: match by network alias only if aliases are assigned

Commit 114e3b423210d316b3326816fd2c33335b1167fe added matching by
aliases for interfaces with same MAC address.
( https://bugzilla.redhat.com/show_bug.cgi?id=1926190 )

However, unless the domain is using user aliases (prefixed ua-),
there are no aliases in the persistent definition.

Only match by MAC/PCI/other addresses in that case, to fix update-device
with --persistent flag (AFFECT_LIVE | AFFECT_CONFIG).

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

Fixes: 114e3b423210d316b3326816fd2c33335b1167fe
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
3 years agoqemuDomainPrepareStorageSourceBlockdev: Set default encryption engine also when prepa...
Peter Krempa [Tue, 16 Nov 2021 13:45:53 +0000 (14:45 +0100)] 
qemuDomainPrepareStorageSourceBlockdev: Set default encryption engine also when preparing virStorageSource

Originally the default encryption engine is populated in the disk
post-parse callback code. This works for disks but for any additional
images introduced either via the block copy API or via the backup API we
don't populate the default.

In case when the backup or block copy is requested on an encrypted image
this would then lead to an error:

 error: internal error: Unexpected enum value 0 for virStorageEncryptionEngine

This patch adds another point where we populate the default which is
when setting up a virStorageSource for actual usage.

We keep the original setting in the post-parse callback as that's the
only point that is recorded in the XML file after definition.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2023674
Fixes: ab1d46d6128
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuxml2argvtest: Add device with 'ramfb=off' to 'hostdev-mdev-display-ramfb'
Peter Krempa [Thu, 18 Nov 2021 08:25:29 +0000 (09:25 +0100)] 
qemuxml2argvtest: Add device with 'ramfb=off' to 'hostdev-mdev-display-ramfb'

Add a test case where 'ramfb' is explicitly disabled for a mediated
device to prevent regressing again.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildHostdevMediatedDevProps: Format 'ramfb' only when enabled
Peter Krempa [Thu, 18 Nov 2021 08:23:09 +0000 (09:23 +0100)] 
qemuBuildHostdevMediatedDevProps: Format 'ramfb' only when enabled

Before commit 73c352ab8c97d3 which converted the hostdev commandline
formatter to JSON the 'ramfb' property was formatted only if it was
enabled.

The main reason for that is that enabling 'ramfb' switches the device
model to 'vfio-pci-nohotplug' which actually has the property, while
'vfio-pci' (used when 'ramfb' is disabled or absent) doesn't have it.

Restore the logic to format 'ramfb' only when it's enabled and add a
comment that it's deliberate.

Fixes: 73c352ab8c97d3
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2024435
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuxml2argvtest: Fix type for faked chardev backing a TPM
Peter Krempa [Mon, 15 Nov 2021 15:52:52 +0000 (16:52 +0100)] 
qemuxml2argvtest: Fix type for faked chardev backing a TPM

The test filled the chardev type to VIR_DOMAIN_CHR_TYPE_FILE and thus
set the 'data.emulator.source->data.file.path' pointer, but the
commandline formatter is unconditionally expecting VIR_DOMAIN_CHR_TYPE_UNIX
and thus reading 'data.emulator.source->data.nix.path'. Since it's an
union it happened to land in the correct place. Fix the faked data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoconf: Properly instantiate virDomainChrSourceDef in virDomainTPMDef
Peter Krempa [Fri, 5 Nov 2021 15:51:22 +0000 (16:51 +0100)] 
conf: Properly instantiate virDomainChrSourceDef in virDomainTPMDef

'virDomainChrSourceDef' contains private data so 'virDomainChrSourceDefNew'
must be used to allocate it. 'virDomainTPMDef' was using it directly
which won't work with the chardev helper functions.

Convert it to a pointer to properly allocate private data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildStorageSourceAttachPrepare(Drive|Chardev): Unexport
Peter Krempa [Thu, 4 Nov 2021 15:50:58 +0000 (16:50 +0100)] 
qemuBuildStorageSourceAttachPrepare(Drive|Chardev): Unexport

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuDomainAttachChrDevice: Drop 'dev' variable
Peter Krempa [Thu, 18 Nov 2021 14:35:08 +0000 (15:35 +0100)] 
qemuDomainAttachChrDevice: Drop 'dev' variable

It's referenced only once and it's a shortcut to the chardev source thus
can be used directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuDomainAttachChrDeviceAssignAddr: Simplify return value handling
Peter Krempa [Thu, 18 Nov 2021 13:58:26 +0000 (14:58 +0100)] 
qemuDomainAttachChrDeviceAssignAddr: Simplify return value handling

Rather than returning a different error code if the device address needs
to be released pass in the 'need_release' flag via a pointer.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuDomainEnsurePCIAddress: Don't pass virQEMUDriver explicitly
Peter Krempa [Thu, 18 Nov 2021 13:50:28 +0000 (14:50 +0100)] 
qemuDomainEnsurePCIAddress: Don't pass virQEMUDriver explicitly

The function is already getting 'virDomainObj' which has already the
driver pointer present.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuDomainAddChardevTLSObjects: Refactor cleanup
Peter Krempa [Thu, 18 Nov 2021 13:28:25 +0000 (14:28 +0100)] 
qemuDomainAddChardevTLSObjects: Refactor cleanup

Switch to automatic memory clearing for the two virJSONValues and remove
the 'cleanup' label and 'ret' variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoconf: Convert 'chr' in virDomainShmemDef to proper pointer
Peter Krempa [Tue, 2 Nov 2021 15:01:57 +0000 (16:01 +0100)] 
conf: Convert 'chr' in virDomainShmemDef to proper pointer

The main reason is to ensure that the private data are properly
allocated for every instance.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildChrChardevStr: Use proper type for the switch statement
Peter Krempa [Thu, 14 Oct 2021 14:43:00 +0000 (16:43 +0200)] 
qemuBuildChrChardevStr: Use proper type for the switch statement

Add the missing cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: command: Rename qemuBuildHostNetStr -> qemuBuildHostNetProps
Peter Krempa [Thu, 14 Oct 2021 13:35:02 +0000 (15:35 +0200)] 
qemu: command: Rename qemuBuildHostNetStr -> qemuBuildHostNetProps

The function is already returning JSON properties, rename it
accordingly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuMonitorJSONAttachCharDevGetProps: Simplify handling of unsupported types
Peter Krempa [Tue, 16 Nov 2021 09:10:16 +0000 (10:10 +0100)] 
qemuMonitorJSONAttachCharDevGetProps: Simplify handling of unsupported types

Use 'virReportEnumRangeError' for the invalid cases and keep the
original error for known but unsupported chardevs.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuMonitorJSONAttachCharDevCommand: Format only the properties
Peter Krempa [Wed, 13 Oct 2021 15:18:50 +0000 (17:18 +0200)] 
qemuMonitorJSONAttachCharDevCommand: Format only the properties

Move the addition of the command wrapper to qemuMonitorJSONAttachCharDev
and rename the function to qemuMonitorJSONAttachCharDevGetProps.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuMonitorJSONAddDeviceProps: Simplify construction of the command
Peter Krempa [Wed, 13 Oct 2021 15:06:15 +0000 (17:06 +0200)] 
qemuMonitorJSONAddDeviceProps: Simplify construction of the command

Use 'qemuMonitorJSONMakeCommandInternal' instead of
'qemuMonitorJSONMakeCommand' + 'virJSONValueObjectAppend'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>