]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
5 years agodocs: kbase: Fix the libvirt-host--validate typo
Boris Fiuczynski [Wed, 8 Jul 2020 13:53:41 +0000 (15:53 +0200)] 
docs: kbase: Fix the libvirt-host--validate typo

In f0d0cd61797 I introduced this typo.

Suggested-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agoqemu_security: Complete renaming of virSecurityManagerSetAllLabel() argument
Michal Privoznik [Tue, 30 Jun 2020 20:02:19 +0000 (22:02 +0200)] 
qemu_security: Complete renaming of virSecurityManagerSetAllLabel() argument

Just like in the previous commit, the stdin_path argument of
virSecurityManagerSetAllLabel() is renamed to incomingPath.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agosecdrivers: Rename @stdin_path argument of virSecurityDomainSetAllLabel()
Michal Privoznik [Wed, 1 Jul 2020 09:50:00 +0000 (11:50 +0200)] 
secdrivers: Rename @stdin_path argument of virSecurityDomainSetAllLabel()

The argument (if not NULL) points to the file the domain is
restoring from. On QEMU command line this used to be '-incoming
$path', but we've switched to passing FD ages ago and thus this
argument is used only in AppArmor (which loads the profile on
domain start). Anyway, the argument does not refer to stdin,
rename it to 'incomingPath' then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agoRevert "qemuSecurityDomainRestorePathLabel: Introduce @ignoreNS argument"
Michal Privoznik [Tue, 30 Jun 2020 17:49:12 +0000 (19:49 +0200)] 
Revert "qemuSecurityDomainRestorePathLabel: Introduce @ignoreNS argument"

The only consumer was removed in the previous commit.

This reverts commit f03a38bd1d28eaa95402742da6ff64f3f633a979.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agoqemu: Use qemuSecuritySetSavedStateLabel() to label restore path
Michal Privoznik [Sat, 27 Jun 2020 04:28:17 +0000 (06:28 +0200)] 
qemu: Use qemuSecuritySetSavedStateLabel() to label restore path

Currently, when restoring from a domain the path that the domain
restores from is labelled under qemuSecuritySetAllLabel() (and after
v6.3.0-rc1~108 even outside transactions). While this grants QEMU
the access, it has a flaw, because once the domain is restored, up
and running then qemuSecurityDomainRestorePathLabel() is called,
which is not real counterpart. In case of DAC driver the
SetAllLabel() does nothing with the restore path but
RestorePathLabel() does - it chown()-s the file back and since there
is no original label remembered, the file is chown()-ed to
root:root. While the apparent solution is to have DAC driver set the
label (and thus remember the original one) in SetAllLabel(), we can
do better.

Turns out, we are opening the file ourselves (because it may live on
a root squashed NFS) and then are just passing the FD to QEMU. But
this means, that we don't have to chown() the file at all, we need
to set SELinux labels and/or add the path to AppArmor profile.

And since we want to restore labels right after QEMU is done loading
the migration stream (we don't want to wait until
qemuSecurityRestoreAllLabel()), the best way to approach this is to
have separate APIs for labelling and restoring label on the restore
file.

I will investigate whether AppArmor can use the SavedStateLabel()
API instead of passing the restore path to SetAllLabel().

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agosecurity_selinux: Implement virSecurityManager{Set,Restore}SavedStateLabel
Michal Privoznik [Tue, 30 Jun 2020 06:26:04 +0000 (08:26 +0200)] 
security_selinux: Implement virSecurityManager{Set,Restore}SavedStateLabel

These APIs are are basically
virSecuritySELinuxDomainSetPathLabelRO() and
virSecuritySELinuxDomainRestorePathLabel().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agoqemu_security: Implement virSecurityManager{Set,Restore}SavedStateLabel
Michal Privoznik [Sat, 27 Jun 2020 04:14:58 +0000 (06:14 +0200)] 
qemu_security: Implement virSecurityManager{Set,Restore}SavedStateLabel

These APIs don't use namespaces because the
virSecurityManagerSetSavedStateLabel() runs
when the namespace doesn't exist yet and thus
the virSecurityManagerRestoreSavedStateLabel()
has to run without namespace too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agosecurity: Reintroduce virSecurityManager{Set,Restore}SavedStateLabel
Michal Privoznik [Fri, 26 Jun 2020 15:05:39 +0000 (17:05 +0200)] 
security: Reintroduce virSecurityManager{Set,Restore}SavedStateLabel

These APIs were removed/renamed in v6.5.0-rc1~142 and v6.5.0-rc1~141
because they deemed unused. And if it wasn't for the RFE [1] things
would stay that way.

The RFE asks for us to not change DAC ownership on the file a domain is
restoring from. We have been doing that for ages (if not forever),
nevertheless it's annoying because if the restore file is on an NFS
remembering owner won't help - NFS doesn't support XATTRs yet. But more
importantly, there is no need for us to chown() the file because when
restoring the domain the file is opened and the FD is then passed to
QEMU. Therefore, we really need only to set SELinux and AppArmor.

This reverts bd22eec903976c5c51b1d00e335c315699e5acd6.
This partially reverts 4ccbd207f213066c000f43eb544eb00ec745023b.

The difference to the original code is that secdrivers are now
not required to provide dummy implementation to avoid
virReportUnsupportedError(). The callback is run if it exists, if
it doesn't zero is returned without any error.

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
5 years agovirSecurityManagerMetadataLock: Ignore RO filesystem
Michal Privoznik [Fri, 10 Jul 2020 08:48:01 +0000 (10:48 +0200)] 
virSecurityManagerMetadataLock: Ignore RO filesystem

When locking files for metadata change, we open() them for R/W
access. The write access is needed because we want to acquire
exclusive (write) lock (to mutually exclude with other daemons
trying to modify XATTRs on the same file). Anyway, the open()
might fail if the file lives on a RO filesystem. Well, if that's
the case, ignore the error and continue with the next file on the
list. We won't change any seclabel on the file anyway - there is
nothing to remember then.

Reported-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirSecurityManagerMetadataLock: Clarify directory locking comment
Michal Privoznik [Fri, 10 Jul 2020 08:42:01 +0000 (10:42 +0200)] 
virSecurityManagerMetadataLock: Clarify directory locking comment

In the light of recent commit of 9d83281382 fix the comment that
says directories can't be locked. Well, in general they can, but
not in our case.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: use WITH_NSS instead of NSS
Pavel Hrdina [Tue, 2 Jun 2020 15:26:54 +0000 (17:26 +0200)] 
tests: use WITH_NSS instead of NSS

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: commandhelper: change how we detect if running as daemon
Pavel Hrdina [Wed, 27 May 2020 11:37:54 +0000 (13:37 +0200)] 
tests: commandhelper: change how we detect if running as daemon

The old code works correctly with make and running directly from shell
but it failed with Meson test suite where session ID and process group
are the same in both cases.

What changes in both cases is parent process ID so use that instead of
session ID.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agosrc: remote: Makefile: properly format sysconfdir in virtproxyd.conf
Pavel Hrdina [Wed, 6 May 2020 13:21:45 +0000 (15:21 +0200)] 
src: remote: Makefile: properly format sysconfdir in virtproxyd.conf

Commit <5b816e16968ba02def56f067774ecd9a8c8d44d7> removed hard-coded
sysconfdir path from *.conf files but missed virtproxyd.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agosrc: util: Makefile: drop undefined OPENPTY_LIBS
Pavel Hrdina [Wed, 24 Jun 2020 09:25:58 +0000 (11:25 +0200)] 
src: util: Makefile: drop undefined OPENPTY_LIBS

Commit <f650e86703847af544762d02f79c70131ff7fbab> added check for
openpty function from util library using AC_CHECK_LIB(). However, that
macro doesn't define OPENPTY_LIBS, it only defines WITH_LIBUTIL and
prepends -lutil into LIBS for the whole project.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agosrc: util: Makefile: drop undefined LDEXP_LIBM
Pavel Hrdina [Wed, 24 Jun 2020 09:10:20 +0000 (11:10 +0200)] 
src: util: Makefile: drop undefined LDEXP_LIBM

It was introduced by commit <c606671aaad10a9bc87f226bc473a091e00a9629>
as a gnulib ldexp module and later removed by commit
<09fe607b4de8eb883c966e90aaf5563299a22738>.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agosrc: util: rename some program macros
Pavel Hrdina [Thu, 23 Jan 2020 11:35:26 +0000 (12:35 +0100)] 
src: util: rename some program macros

Fixes inconsistency with macro names for external programs.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agosrc: logging: Makefile: drop undefined LOG_DRIVER
Pavel Hrdina [Thu, 7 May 2020 00:19:51 +0000 (02:19 +0200)] 
src: logging: Makefile: drop undefined LOG_DRIVER

Commit <0985a9597bb0348d46c0d18dc548a676bf0ad8e2> added unused variable
so remove it.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agosrc: remote: Makefile: drop CFLAGS and LDFLAGS duplication
Pavel Hrdina [Mon, 4 May 2020 16:23:05 +0000 (18:23 +0200)] 
src: remote: Makefile: drop CFLAGS and LDFLAGS duplication

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agosrc: remove unnecessary -I$(srcdir)/secret include
Pavel Hrdina [Mon, 4 May 2020 15:28:54 +0000 (17:28 +0200)] 
src: remove unnecessary -I$(srcdir)/secret include

Commit <894556ca813ad3c4ebb01083b7971d73b4f53c8b> moved function
virSecretGetSecretString out of secret directory but forgot to update
CFLAGS in places where the include is no longer needed.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agosrc: Makefile: remove LOCK_CHECKING_CFLAGS leftover
Pavel Hrdina [Mon, 4 May 2020 15:09:57 +0000 (17:09 +0200)] 
src: Makefile: remove LOCK_CHECKING_CFLAGS leftover

Commit <fd3b8fe7ad491c77c0b3f57110adaf64f743855e> removed objectlocking
test but forgot to remove all of the usages of LOCK_CHECKING_CFLAGS.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoscripts: check-remote-protocol: remove unused OBJEXT argument
Pavel Hrdina [Tue, 19 May 2020 08:27:57 +0000 (10:27 +0200)] 
scripts: check-remote-protocol: remove unused OBJEXT argument

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agopo: change the format of POTFILES.in
Pavel Hrdina [Mon, 29 Jun 2020 15:36:45 +0000 (17:36 +0200)] 
po: change the format of POTFILES.in

There is no need to provide relative paths to the current directory if
we provide search paths using --directory option for xgettext.

In addition it will make libvirt.pot file look cleaner as it will not
contain relative paths to current directory. It improves the situation
for developers which are using different build path as that would
change the relative path in libvirt.pot as well. After this patch
it will not happen anymore.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agom4: virt-selinux: drop check for selabel_open signature change
Pavel Hrdina [Tue, 23 Jun 2020 22:28:55 +0000 (00:28 +0200)] 
m4: virt-selinux: drop check for selabel_open signature change

All supported OSes have at least libselinux version 2.5 so it's safe
to drop this check.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agom4: virt-sanlock: drop check for sanlock_write_lockspace()
Pavel Hrdina [Tue, 23 Jun 2020 22:20:08 +0000 (00:20 +0200)] 
m4: virt-sanlock: drop check for sanlock_write_lockspace()

Function sanlock_write_lockspace() was introduced in 2.7 version which
is available in all supported OSes.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agom4: virt-sanlock: drop check for sanlock_killpath()
Pavel Hrdina [Tue, 23 Jun 2020 22:15:15 +0000 (00:15 +0200)] 
m4: virt-sanlock: drop check for sanlock_killpath()

Function sanlock_killpath() was introduced in 2.4 version and had
modified one of the arguments from `char *` into `const char *` in
version 2.7. All of this is available in all supported OSes.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agom4: virt-sanlock: drop check for SANLK_INQ_WAIT
Pavel Hrdina [Tue, 23 Jun 2020 22:10:54 +0000 (00:10 +0200)] 
m4: virt-sanlock: drop check for SANLK_INQ_WAIT

SANLK_INQ_WAIT was introduced in sanlock 2.4 which is available in all
supported OSes.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agom4: virt-sanlock: use pkg-config to find libsanlock_client
Pavel Hrdina [Tue, 23 Jun 2020 22:05:57 +0000 (00:05 +0200)] 
m4: virt-sanlock: use pkg-config to find libsanlock_client

The last distribution supported by libvirt and lacking pkg-config file
for libsanlock_client was Ubuntu 16.04. It is no longer supported so
switch to pkg-config.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agom4: virt-sanlock: drop check for sanlock_inq_lockspace
Pavel Hrdina [Thu, 26 Mar 2020 15:26:21 +0000 (16:26 +0100)] 
m4: virt-sanlock: drop check for sanlock_inq_lockspace

This check was introduced by commit
<96a02703daad4dc6663165adbc0feade9900cebd> to guard calling
sanlock_inq_lockspace() function but it used SANLK_INQ_WAIT as a
parameter which was introduced later.  This was eventually fixed by
commit <238dba0f9c925359cb3b8beddd8c8ae739cb4e06>.

We can safely replace check for sanlock_inq_lockspace as that function
was introduced in sanlock-1.9.  The oldest used version, sanlock-2.2,
is by Ubuntu 16.04.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodocs: remove unused wrapstring.xsl file
Pavel Hrdina [Fri, 5 Jun 2020 20:36:39 +0000 (22:36 +0200)] 
docs: remove unused wrapstring.xsl file

Commit <d672551816e106f2ce8a6a04658691db96435fb5> removed last usage of
this file so drop it as well.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodocs: remove incorrect generated files by apibuild.py
Pavel Hrdina [Fri, 5 Jun 2020 14:47:02 +0000 (16:47 +0200)] 
docs: remove incorrect generated files by apibuild.py

These files are generated by xsltproc as part of html/index.html and
html/index-%.html rules.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoMakefile: drop undefined LIB_CLOCK_GETTIME
Pavel Hrdina [Wed, 24 Jun 2020 09:43:21 +0000 (11:43 +0200)] 
Makefile: drop undefined LIB_CLOCK_GETTIME

This was introduced together with clock-time gnulib module by commit
<d74e5a4dfc434d3a1d01856d013a7f50d910fa95> and removed from libvirt
by commit <86d223a762990c9d529065a2d3b30b6a00ea63dd>.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconfigure: remove usage of AC_HEADER_MAJOR
Pavel Hrdina [Mon, 29 Jun 2020 19:07:34 +0000 (21:07 +0200)] 
configure: remove usage of AC_HEADER_MAJOR

Commit <03c532cf9711dd6ad35380455a77141ef7d492ab> removed usage of
MAJOR_IN_MKDEV and MAJOR_IN_SYSMACROS from libvirt which makes the
AC_HEADER_MAJOR useless.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconfigure: introduce FLAT_NAMESPACE_FLAGS
Pavel Hrdina [Thu, 30 Apr 2020 12:34:33 +0000 (14:34 +0200)] 
configure: introduce FLAT_NAMESPACE_FLAGS

Set FLAT_NAMESPACE_FLAGS to -Wl,-flat_namespace in configure only for
macOS and use it unconditionally in Makefiles.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconfigure: drop check for unsupported FreeBSD
Pavel Hrdina [Fri, 24 Apr 2020 14:51:31 +0000 (16:51 +0200)] 
configure: drop check for unsupported FreeBSD

FreeBSD 10 is no longer supported by libvirt and the struct member
ifi_oqdrops is usable without any define on later FreeBSD versions.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agobuild: use DLOPEN_LIBS directly
Pavel Hrdina [Mon, 4 May 2020 16:00:47 +0000 (18:00 +0200)] 
build: use DLOPEN_LIBS directly

There is no need to have DRIVER_MODULES_LIBS as it's used only for
libvirt.so. The other places are using DLOPEN_LIBS directly and dlopen
is required if building with libvirtd.

It's mandatory since <5aec02dc37623bf739d1edd8f2be3e4ad9f94ff5>.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: fix accessibility check for hook directory
Ján Tomko [Tue, 7 Jul 2020 11:47:58 +0000 (13:47 +0200)] 
util: fix accessibility check for hook directory

virFileIsAccessible does not return true on accessible
directories. Check whether it set EISDIR and only
then assume the directory is inaccessible.

Return 0 (not found) instead of 1 (found),
since the bridge driver taints the network based on
this return value, not whether the hook actually ran.

Remove the bogus check from virHookCall, since it already
checks the virHooksFound bitmap that was filled before
by virHookCheck.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 7fa7f7eeb6e969e002845928e155914da2fc8cd0
Closes: https://gitlab.com/libvirt/libvirt/-/issues/47
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agocpu_arm: fix build on non-Linux
Roman Bogorodskiy [Wed, 8 Jul 2020 13:39:36 +0000 (17:39 +0400)] 
cpu_arm: fix build on non-Linux

 - Add a check for asm/hwcap.h header presence,
 - Add a check for getauxval() function that is used
   on Linux, and for elf_aux_info() which is a FreeBSD
   equivalent.

This is based on a patch submitted by Mikael Urankar in
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=247722.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoresctrl: Do not open directory for writing
Martin Kletzander [Thu, 9 Jul 2020 07:27:41 +0000 (09:27 +0200)] 
resctrl: Do not open directory for writing

When preparing for the removal of GNULIB commit 18dca21a32e9 removed the
unneeded O_DIRECTORY, but unfortunately started opening the directory for
writing which fails every time for a directory.  There is also no need for that
as flock() works on O_RDONLY file descriptor as well, even for LOCK_EX.

https://bugzilla.redhat.com/1852741

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agoAdd a changelog entry for the esx NIC limit changes
Bastien Orivel [Thu, 9 Jul 2020 10:30:39 +0000 (12:30 +0200)] 
Add a changelog entry for the esx NIC limit changes

This was forgotten in 4bd375b6ce3a4c134bab19cd7c9a7a83609547c8

Signed-off-by: Bastien Orivel <bastien.orivel@diateam.net>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agosrc: fix word spell typos
Fangge Jin [Thu, 9 Jul 2020 04:42:21 +0000 (12:42 +0800)] 
src: fix word spell typos

Signed-off-by: Fangge Jin <fjin@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agoReplace "OS-X" with "macOS" in index.html.in
Ryan Schmidt [Thu, 9 Jul 2020 00:45:03 +0000 (00:45 +0000)] 
Replace "OS-X" with "macOS" in index.html.in

Apple changed the operating system's name from "OS X" to "macOS" a few years ago.

Signed-off-by: Ryan Schmidt <git@ryandesign.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: use g_autofree for all pointers to virXMLPropString() in device_conf.c
Nicolas Brignone [Wed, 8 Jul 2020 20:19:44 +0000 (17:19 -0300)] 
conf: use g_autofree for all pointers to virXMLPropString() in device_conf.c

All modified functions are similar, in all cases "cleanup" label is removed,
along with all the "goto" calls.

Signed-off-by: Nicolas Brignone <nmbrignone@gmail.com>
Reviewed-by: Laine Stump <laine@redhat.com>
5 years agoeliminate unnecessary labels and ret variables
Laine Stump [Sat, 4 Jul 2020 20:38:37 +0000 (16:38 -0400)] 
eliminate unnecessary labels and ret variables

after making all virFirewall objects use g_autoptr().

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agouse g_autoptr() for all usages of virFirewallNew/Free
Laine Stump [Sat, 4 Jul 2020 20:35:10 +0000 (16:35 -0400)] 
use g_autoptr() for all usages of virFirewallNew/Free

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agostorage: eliminate unnecessary labels
Laine Stump [Fri, 3 Jul 2020 03:24:51 +0000 (23:24 -0400)] 
storage: eliminate unnecessary labels

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agonwfilter: eliminate unnecessary labels
Laine Stump [Fri, 3 Jul 2020 03:24:30 +0000 (23:24 -0400)] 
nwfilter: eliminate unnecessary labels

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoesx: eliminate unnecessary labels
Laine Stump [Fri, 3 Jul 2020 03:24:16 +0000 (23:24 -0400)] 
esx: eliminate unnecessary labels

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agolxc: eliminate unnecessary labels
Laine Stump [Fri, 3 Jul 2020 03:21:25 +0000 (23:21 -0400)] 
lxc: eliminate unnecessary labels

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agonetwork: eliminate unnecessary labels
Laine Stump [Fri, 3 Jul 2020 03:21:05 +0000 (23:21 -0400)] 
network: eliminate unnecessary labels

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotools: eliminate unnecessary labels
Laine Stump [Fri, 3 Jul 2020 03:20:27 +0000 (23:20 -0400)] 
tools: eliminate unnecessary labels

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: eliminate unnecessary labels
Laine Stump [Fri, 3 Jul 2020 03:20:17 +0000 (23:20 -0400)] 
tests: eliminate unnecessary labels

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: eliminate unnecessary labels
Laine Stump [Fri, 3 Jul 2020 03:20:00 +0000 (23:20 -0400)] 
util: eliminate unnecessary labels

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agolibxl: eliminate unnecessary labels
Laine Stump [Fri, 3 Jul 2020 03:19:45 +0000 (23:19 -0400)] 
libxl: eliminate unnecessary labels

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: eliminate unnecessary labels
Laine Stump [Fri, 3 Jul 2020 03:19:26 +0000 (23:19 -0400)] 
conf: eliminate unnecessary labels

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agobhyve: eliminate unnecessary labels
Laine Stump [Fri, 3 Jul 2020 03:19:10 +0000 (23:19 -0400)] 
bhyve: eliminate unnecessary labels

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agolibxl: eliminate extra copy of string
Laine Stump [Sun, 5 Jul 2020 03:43:52 +0000 (23:43 -0400)] 
libxl: eliminate extra copy of string

libxlMakeNic was calling g_strdup(virBufferCurrentContent(&buf)) to
make a copy of the buffer contents, and then later freeing the buffer
without ever using it again. Instead of this extra strdup, just
transfer ownership of the virBuffer's string with
virBufferContentAndReset(), and be done with it.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoremove redundant calls to virBufferFreeAndReset()
Laine Stump [Sat, 4 Jul 2020 22:09:21 +0000 (18:09 -0400)] 
remove redundant calls to virBufferFreeAndReset()

There are several calls to virBufferFreeAndReset() when functions
encounter an error, but the caller never uses the virBuffer once an
error has been encountered (all callers detect error by looking at the
function return value, not the contents of the virBuffer being
operated on), and now that all virBuffers are auto-freed there is no
reason for the lower level functions like these to spend time freeing
a buffer that is guaranteed to be freed momentarily anyway.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: consistently check for error when calling virSysinfoFormat()
Laine Stump [Sat, 4 Jul 2020 21:55:59 +0000 (17:55 -0400)] 
conf: consistently check for error when calling virSysinfoFormat()

Every other caller of this function checks for an error return and
ends their formatting early if there is an error. This function
happily continues on its way.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: remove unnecessary virBufferFreeAndReset() after virCommandAddArgBuffer()
Laine Stump [Sat, 4 Jul 2020 21:45:57 +0000 (17:45 -0400)] 
qemu: remove unnecessary virBufferFreeAndReset() after virCommandAddArgBuffer()

The latter function is guaranteed to always clear out the virBuffer
anyway, so this is redundant and could add to extra cargo-cult code if
used as an example.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agouse g_auto() for all remaining non-g_auto() virBuffers
Laine Stump [Fri, 3 Jul 2020 02:42:16 +0000 (22:42 -0400)] 
use g_auto() for all remaining non-g_auto() virBuffers

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agonetwork: use g_auto() for all virBuffers
Laine Stump [Fri, 3 Jul 2020 02:41:26 +0000 (22:41 -0400)] 
network: use g_auto() for all virBuffers

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agonwfilter: use g_auto() for all virBuffers
Laine Stump [Fri, 3 Jul 2020 02:39:38 +0000 (22:39 -0400)] 
nwfilter: use g_auto() for all virBuffers

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agorpc: use g_auto() for all virBuffers
Laine Stump [Fri, 3 Jul 2020 02:39:19 +0000 (22:39 -0400)] 
rpc: use g_auto() for all virBuffers

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agocpu: use g_auto() for all virBuffers
Laine Stump [Fri, 3 Jul 2020 02:36:24 +0000 (22:36 -0400)] 
cpu: use g_auto() for all virBuffers

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoutil: use g_auto() for all virBuffers
Laine Stump [Fri, 3 Jul 2020 02:30:20 +0000 (22:30 -0400)] 
util: use g_auto() for all virBuffers

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: use g_auto() for all virBuffers
Laine Stump [Fri, 3 Jul 2020 02:19:01 +0000 (22:19 -0400)] 
conf: use g_auto() for all virBuffers

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotools: use g_auto() for all virBuffers
Laine Stump [Thu, 2 Jul 2020 23:40:16 +0000 (19:40 -0400)] 
tools: use g_auto() for all virBuffers

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: use g_auto for all virBuffers
Laine Stump [Thu, 2 Jul 2020 23:35:41 +0000 (19:35 -0400)] 
tests: use g_auto for all virBuffers

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: use g_auto() for all virBuffers
Laine Stump [Thu, 2 Jul 2020 22:26:41 +0000 (18:26 -0400)] 
qemu: use g_auto() for all virBuffers

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agolxc: use g_auto() for all virBuffers
Laine Stump [Thu, 2 Jul 2020 22:23:25 +0000 (18:23 -0400)] 
lxc: use g_auto() for all virBuffers

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agolibxl: use g_auto() for all virBuffers
Laine Stump [Thu, 2 Jul 2020 22:21:30 +0000 (18:21 -0400)] 
libxl: use g_auto() for all virBuffers

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agohyperv: use g_auto() for all virBuffers
Laine Stump [Thu, 2 Jul 2020 22:16:08 +0000 (18:16 -0400)] 
hyperv: use g_auto() for all virBuffers

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoesx: use g_auto() for all virBuffers
Laine Stump [Thu, 2 Jul 2020 22:14:00 +0000 (18:14 -0400)] 
esx: use g_auto() for all virBuffers

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agobhyve: use g_auto() for all virBuffers
Laine Stump [Thu, 2 Jul 2020 22:03:45 +0000 (18:03 -0400)] 
bhyve: use g_auto() for all virBuffers

In most cases this eliminates one or more calls to
virBufferClearAndReset(), but even when it doesn't it's better because:

1) it makes the code more consistent, making it more likely that new
   contributors who are "learning by example" will to the right thing.

2) it protects against future modifications that might have otherwise
   needed to add a virBufferClearAndReset()

3) Currently some functions don't call virBufferClearAndReset() only
   because they're relying on some subordinate function to call it for
   them (e.g. bhyveConnectGetSysinfo() in this patch relies on
   virSysinfoFormat() to clear out the buffer when there is an
   error). I think this is sloppy behavior, and that the toplevel
   function that defines and initializes the buffer should be the
   function clearing it at the end.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf, qemu: consider available CPUs in vcpupin/emulatorpin output
Daniel Henrique Barboza [Fri, 26 Jun 2020 22:10:44 +0000 (19:10 -0300)] 
conf, qemu: consider available CPUs in vcpupin/emulatorpin output

The output of vcpupin and emulatorpin for a domain with vcpu
placement='static' is based on a default bitmap that contains
all possible CPUs in the host, regardless of the CPUs being offline
or not. E.g. for a Linux host with this CPU setup (from lscpu):

On-line CPU(s) list:   0,8,16,24,32,40,(...),184
Off-line CPU(s) list: 1-7,9-15,17-23,25-31,(...),185-191

And a domain with this configuration:

  <vcpu placement='static'>1</vcpu>

'virsh vcpupin' will return the following:

$ sudo ./run tools/virsh vcpupin vcpupin_test
 VCPU   CPU Affinity
----------------------
 0      0-191

This is benign by its own, but can make the user believe that all
CPUs from the 0-191 range are eligible for pinning. Which can lead
to situations like this:

$ sudo ./run tools/virsh vcpupin vcpupin_test 0 1
error: Invalid value '1' for 'cpuset.cpus': Invalid argument

This is exarcebated by the fact that 'virsh vcpuinfo' considers only
available host CPUs in the 'CPU Affinity' field:

$ sudo ./run tools/virsh vcpuinfo vcpupin_test
(...)
CPU Affinity:   y-------y-------y-------(...)

This patch changes the default bitmap of vcpupin and emulatorpin, in
the case of domains with static vcpu placement, to all available CPUs
instead of all possible CPUs. Aside from making it consistent with
the behavior of 'vcpuinfo', users will now have one less incentive to
try to pin a vcpu in an offline CPU.

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

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovirhostcpu.c: introduce virHostCPUGetAvailableCPUsBitmap()
Daniel Henrique Barboza [Fri, 26 Jun 2020 22:10:43 +0000 (19:10 -0300)] 
virhostcpu.c: introduce virHostCPUGetAvailableCPUsBitmap()

The idea is to have a function that calls virHostCPUGetOnlineBitmap()
but, instead of returning NULL if the host does not have CPU
offlining capabilities,  fall back to a bitmap containing all
present CPUs.

Next patch will use this helper in two other places.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovirhostcpu.c: refactor virHostCPUParseCountLinux()
Daniel Henrique Barboza [Fri, 26 Jun 2020 22:10:42 +0000 (19:10 -0300)] 
virhostcpu.c: refactor virHostCPUParseCountLinux()

This function reads the string in sysfspath/cpu/present and
parses it manually to retrieve the number of present CPUs.

virHostCPUGetPresentBitmap() reads and parses the same file,
using a more robust parser via virBitmapParseUnlimited(),
but returns a bitmap. Let's drop all the manual parsing done
here and simply return the size of the resulting bitmap
from virHostCPUGetPresentBitmap().

Given that no more parsing is being done manually in the function,
rename it to virHostCPUCountLinux().

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovirsh-domain.c: modernize cmdVcpuinfo()
Daniel Henrique Barboza [Fri, 26 Jun 2020 22:10:41 +0000 (19:10 -0300)] 
virsh-domain.c: modernize cmdVcpuinfo()

Use g_auto* pointers to avoid the need for the cleanup label. The
type of the pointer 'virDomainPtr dom' was changed to its alias
'virshDomainPtr' to allow the use of g_autoptr().

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovirsh-domain.c: modernize virshVcpuinfoInactive()
Daniel Henrique Barboza [Fri, 26 Jun 2020 22:10:40 +0000 (19:10 -0300)] 
virsh-domain.c: modernize virshVcpuinfoInactive()

Use g_auto* in the string and in the bitmap. Remove the
cleanup label since it's now unneeded.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovirhostcpu.c: use g_autoptr in virHostCPUGetMap()
Daniel Henrique Barboza [Fri, 26 Jun 2020 22:10:39 +0000 (19:10 -0300)] 
virhostcpu.c: use g_autoptr in virHostCPUGetMap()

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_driver.c: use g_autoptr in qemuDomainGetEmulatorPinInfo()
Daniel Henrique Barboza [Fri, 26 Jun 2020 22:10:38 +0000 (19:10 -0300)] 
qemu_driver.c: use g_autoptr in qemuDomainGetEmulatorPinInfo()

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoChange the virtual NICs limit for the ESX driver
Bastien Orivel [Tue, 7 Jul 2020 14:04:33 +0000 (16:04 +0200)] 
Change the virtual NICs limit for the ESX driver

Since the ESX virtual hardware version 4.0, virtual machines support up
to 10 virtual NICs instead of 4 previously. This changes the limit
accordingly based on the provided `virtualHW.version`.

Signed-off-by: Bastien Orivel <bastien.orivel@diateam.net>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodomain_conf: Replace the name string with 'vcpu' if it is 'vcpus'
Liao Pingfang [Wed, 1 Jul 2020 23:39:40 +0000 (07:39 +0800)] 
domain_conf: Replace the name string with 'vcpu' if it is 'vcpus'

If the name is 'vcpus', we will get 'vcpussched' instead of 'vcpusched'
in the error message as following:

... 19155 : vcpussched attributes 'vcpus' must not overlap

So we use 'vcpu' to replace 'vcpus'.

Signed-off-by: Liao Pingfang <liao.pingfang@zte.com.cn>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemuBuildNumaCommandLine: Fix @masterInitiator check
Michal Privoznik [Wed, 8 Jul 2020 13:35:08 +0000 (15:35 +0200)] 
qemuBuildNumaCommandLine: Fix @masterInitiator check

A few commits ago, in aeecbc87b73, I've implemented command line
generation for ACPI HMAT. For this, we need to know if at least
one guest NUMA node has vCPUs. This is tracked in
@masterInitiator variable, which is initialized to -1, then we
iterate through guest NUMA nodes and break the loop if we find a
node with a vCPU. After the loop, if masterInitiator is still
negative then no NUMA node has a vCPU and we error out. But this
exact check was missing comparison for negativeness.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodocs: kbase: Fix the libvirt-host-validate typo
Erik Skultety [Wed, 8 Jul 2020 10:57:39 +0000 (12:57 +0200)] 
docs: kbase: Fix the libvirt-host-validate typo

I overlooked this typo during review of 2c3ffa37.

Reported-by: Yalan Zhang <yalzhang@redhat.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
5 years agonews: Document HMAT addition
Michal Privoznik [Wed, 24 Jun 2020 13:44:48 +0000 (15:44 +0200)] 
news: Document HMAT addition

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemu: Build HMAT command line
Michal Privoznik [Wed, 8 Jul 2020 09:28:37 +0000 (11:28 +0200)] 
qemu: Build HMAT command line

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemu: Introduce QEMU_CAPS_NUMA_HMAT capability
Michal Privoznik [Wed, 27 May 2020 09:00:07 +0000 (11:00 +0200)] 
qemu: Introduce QEMU_CAPS_NUMA_HMAT capability

This capability tracks whether QEMU is capable of defining HMAT
ACPI table for the guest.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agonuma: expose HMAT APIs
Michal Privoznik [Fri, 29 May 2020 12:55:57 +0000 (14:55 +0200)] 
numa: expose HMAT APIs

These APIs will be used by QEMU driver when building the command
line.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoconf: Validate NUMA HMAT configuration
Michal Privoznik [Thu, 28 May 2020 15:23:00 +0000 (17:23 +0200)] 
conf: Validate NUMA HMAT configuration

There are several restrictions, for instance @initiator and
@target have to refer to existing NUMA nodes (daa), @cache has to
refer to a defined cache level and so on.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoconf: Parse and format HMAT
Michal Privoznik [Wed, 27 May 2020 09:46:33 +0000 (11:46 +0200)] 
conf: Parse and format HMAT

To cite ACPI specification:

  Heterogeneous Memory Attribute Table describes the memory
  attributes, such as memory side cache attributes and bandwidth
  and latency details, related to the System Physical Address
  (SPA) Memory Ranges. The software is expected to use this
  information as hint for optimization.

According to our upstream discussion [1] this is exposed under
<numa/> as <cache/> under NUMA <cell/> and <latency> or
<bandwidth/> under numa/latencies.

1: https://www.redhat.com/archives/libvir-list/2020-January/msg00422.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoAllow NUMA nodes without vCPUs
Michal Privoznik [Wed, 27 May 2020 11:42:22 +0000 (13:42 +0200)] 
Allow NUMA nodes without vCPUs

QEMU allows creating NUMA nodes that have memory only.
These are somehow important for HMAT.

With check done in qemuValidateDomainDef() for QEMU 2.7 or newer
(checked via QEMU_CAPS_NUMA), we can be sure that the vCPUs are
fully assigned to NUMA nodes in domain XML.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agonuma_conf: Make virDomainNumaSetNodeCpumask() return void
Michal Privoznik [Wed, 27 May 2020 09:49:51 +0000 (11:49 +0200)] 
numa_conf: Make virDomainNumaSetNodeCpumask() return void

There is only one caller of virDomainNumaSetNodeCpumask() which
checks for the return value but because the function will return
NULL iff the @cpumask was NULL in the first place. But in that
place @cpumask can't be NULL because it was just allocated by
virBitmapParse().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemuBuildMachineCommandLine: Drop needless check
Michal Privoznik [Fri, 29 May 2020 12:56:16 +0000 (14:56 +0200)] 
qemuBuildMachineCommandLine: Drop needless check

The machine can not be NULL at this point -
qemuDomainDefPostParse() makes sure it isn't.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemu_command: Rename qemuBuildNumaArgStr()
Michal Privoznik [Fri, 29 May 2020 12:57:20 +0000 (14:57 +0200)] 
qemu_command: Rename qemuBuildNumaArgStr()

The function doesn't just build the argument for -numa. Since the
-numa can be repeated multiple times, it also puts -numa onto the
cmd line. Also, the rest of the functions has 'Command' infix.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agonuma_conf: Drop CPU from name of two functions
Michal Privoznik [Thu, 28 May 2020 14:52:22 +0000 (16:52 +0200)] 
numa_conf: Drop CPU from name of two functions

There are two functions virDomainNumaDefCPUFormatXML() and
virDomainNumaDefCPUParseXML() which format and parse domain's
<numa/>. There is nothing CPU specific about them. Drop the
infix.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoconf: Move and rename virDomainParseScaledValue()
Michal Privoznik [Thu, 28 May 2020 10:38:43 +0000 (12:38 +0200)] 
conf: Move and rename virDomainParseScaledValue()

There is nothing domain specific about the function, thus it
should not have virDomain prefix. Also, the fact that it is a
static function makes it impossible to use from other files.
Move the function to virxml.c and drop the 'Domain' infix.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemuxml2xmltest: Add "numatune-distance" test case
Michal Privoznik [Wed, 27 May 2020 12:24:56 +0000 (14:24 +0200)] 
qemuxml2xmltest: Add "numatune-distance" test case

This test case checks that expanding NUMA distance works. On
input we accept if only distance from A to B is specified. On the
output we format the B to A distance too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemuBuildMemoryBackendProps: Use boolean type for 'pmem' property
Peter Krempa [Wed, 8 Jul 2020 07:13:42 +0000 (09:13 +0200)] 
qemuBuildMemoryBackendProps: Use boolean type for 'pmem' property

Commit 82576d8f35e used a string "on" to enable the 'pmem' property.
This is okay for the command line visitor, but the property is declared
as boolean in qemu and thus it will not work when using QMP.

Modify the type to boolean. This changes the command line, but
fortunately the command line visitor in qemu parses both 'yes' and 'on'
as true for the property.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: capabilities: Drop the virQEMUCapsCacheLookupByArch function
Erik Skultety [Wed, 8 Jul 2020 07:58:51 +0000 (09:58 +0200)] 
qemu: capabilities: Drop the virQEMUCapsCacheLookupByArch function

Previous commit removed the last usage of the function. Drop
virQEMUCapsCompareArch as well since virQEMUCapsCacheLookupByArch was
its only caller.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>