]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
5 years agoqemu_migration_cookie.h: register AUTOPTR_CLEANUP_FUNC for qemuMigrationCookiePtr
Daniel Henrique Barboza [Mon, 13 Jul 2020 09:49:46 +0000 (06:49 -0300)] 
qemu_migration_cookie.h: register AUTOPTR_CLEANUP_FUNC for qemuMigrationCookiePtr

Next patch will use g_autoptr() in a qemuMigrationCookiePtr pointer to
modernize qemuMigrationSrcBeginPhase().

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_migration.c: use g_auto* in qemuMigrationDstPrepareDirect()
Daniel Henrique Barboza [Mon, 13 Jul 2020 09:49:45 +0000 (06:49 -0300)] 
qemu_migration.c: use g_auto* in qemuMigrationDstPrepareDirect()

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_monitor_json.c: modernize qemuMonitorJSONMigrateIncoming()
Daniel Henrique Barboza [Mon, 13 Jul 2020 09:49:44 +0000 (06:49 -0300)] 
qemu_monitor_json.c: modernize qemuMonitorJSONMigrateIncoming()

Use g_autoptr() and remove the now obsolete 'cleanup' label.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_migration_params.c: use g_autofree in qemuMigrationParamsApply()
Daniel Henrique Barboza [Mon, 13 Jul 2020 09:49:43 +0000 (06:49 -0300)] 
qemu_migration_params.c: use g_autofree in qemuMigrationParamsApply()

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_migration_params.c: modernize qemuMigrationParamsEnableTLS()
Daniel Henrique Barboza [Mon, 13 Jul 2020 09:49:42 +0000 (06:49 -0300)] 
qemu_migration_params.c: modernize qemuMigrationParamsEnableTLS()

Use g_autoptr() and remove both 'cleanup' and 'error' labels.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_migration_params.c: modernize qemuMigrationParamsFetch()
Daniel Henrique Barboza [Mon, 13 Jul 2020 09:49:41 +0000 (06:49 -0300)] 
qemu_migration_params.c: modernize qemuMigrationParamsFetch()

Use g_autoptr() and remove the 'cleanup' label.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_migration.c: use g_auto* in qemuMigrationDstPrepareAny()
Daniel Henrique Barboza [Mon, 13 Jul 2020 09:49:40 +0000 (06:49 -0300)] 
qemu_migration.c: use g_auto* in qemuMigrationDstPrepareAny()

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_migration.c: modernize qemuMigrationDstPrepare()
Daniel Henrique Barboza [Mon, 13 Jul 2020 09:49:39 +0000 (06:49 -0300)] 
qemu_migration.c: modernize qemuMigrationDstPrepare()

Use g_autofree and remove the 'cleanup' label.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_driver.c: modernize qemuDomainMigratePrepare3Params()
Daniel Henrique Barboza [Mon, 13 Jul 2020 09:49:38 +0000 (06:49 -0300)] 
qemu_driver.c: modernize qemuDomainMigratePrepare3Params()

Use variable autocleanup and remove the now obsolete 'cleanup'
label.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_driver.c: modernize qemuDomainMigratePrepare3()
Daniel Henrique Barboza [Mon, 13 Jul 2020 09:49:37 +0000 (06:49 -0300)] 
qemu_driver.c: modernize qemuDomainMigratePrepare3()

Use g_autoptr() on pointers and remove the unneeded 'cleanup'
label.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_driver.c: modernize qemuDomainMigrateBegin3Params()
Daniel Henrique Barboza [Mon, 13 Jul 2020 09:49:36 +0000 (06:49 -0300)] 
qemu_driver.c: modernize qemuDomainMigrateBegin3Params()

Use g_autofree and remove the unneeded 'cleanup' label.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agolibvirt-domain.c: use g_autofree in virDomainMigrateVersion* functions
Daniel Henrique Barboza [Mon, 13 Jul 2020 09:49:35 +0000 (06:49 -0300)] 
libvirt-domain.c: use g_autofree in virDomainMigrateVersion* functions

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agolibvirt-domain.c: modernize virDomainMigrateVersion1
Daniel Henrique Barboza [Mon, 13 Jul 2020 09:49:34 +0000 (06:49 -0300)] 
libvirt-domain.c: modernize virDomainMigrateVersion1

Use g_autofree on strings and remove the 'done' label since it's
now unneeded.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agolibvirt-domain.c: modernize virDomainMigrateCheckNotLocal()
Daniel Henrique Barboza [Mon, 13 Jul 2020 09:49:33 +0000 (06:49 -0300)] 
libvirt-domain.c: modernize virDomainMigrateCheckNotLocal()

Use g_autoptr() and remove the 'cleanup' label.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agostorage: fix vstorage backend build
Nikolay Shirokovskiy [Tue, 7 Jul 2020 11:58:17 +0000 (14:58 +0300)] 
storage: fix vstorage backend build

Add headers with declarations of  geteuid/getegid
and virGetUserName/virGetGroupName.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agodocs: point out that locals should be defined at the top of a block of code
Laine Stump [Thu, 9 Jul 2020 22:36:48 +0000 (18:36 -0400)] 
docs: point out that locals should be defined at the top of a block of code

Although we have nothing in make syntax-check to enforce this, and
apparently there are places where it isn't the case (according to
Dan), we should discourage the practice of defining new variables in
the middle of a block of code.

https://www.redhat.com/archives/libvir-list/2020-July/msg00433.html

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
5 years agodocs: rename fig to svg in Makefile.am
Pavel Hrdina [Fri, 10 Jul 2020 15:39:29 +0000 (17:39 +0200)] 
docs: rename fig to svg in Makefile.am

Commit <9ad637c9651ff29955dd6aa8fe31f639b42b7315> converted all fig
files into svg files but did not change the Makefile.am.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
5 years agoqemu_domain: moved qemuDomainNamespace to `qemu_domain`
Prathamesh Chavan [Fri, 10 Jul 2020 07:11:37 +0000 (12:41 +0530)] 
qemu_domain: moved qemuDomainNamespace to `qemu_domain`

While moving the code, qemuDomainNamespace also was moved
to `qemu_domainjob`. Hence it is moved back to `qemu_domain`
where it will be more appropriate.

Signed-off-by: Prathamesh Chavan <pc44800@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agowireshark: fix compilation errors
Pavel Hrdina [Wed, 20 May 2020 20:52:05 +0000 (22:52 +0200)] 
wireshark: fix compilation errors

With meson introduction which is using the same CFLAGS for the whole
project some compilation errors were discovered. The wireshark plugin
library is the only one in tools directory that is not using AM_CFLAGS.

With the AM_CFLAGS we get these errors:

../../tools/wireshark/src/packet-libvirt.c: In function 'dissect_libvirt_fds':
../../tools/wireshark/src/packet-libvirt.c:348:31: error: unused parameter 'tvb' [-Werror=unused-parameter]
  348 | dissect_libvirt_fds(tvbuff_t *tvb, gint start, gint32 nfds)
      |                     ~~~~~~~~~~^~~
../../tools/wireshark/src/packet-libvirt.c:348:41: error: unused parameter 'start' [-Werror=unused-parameter]
  348 | dissect_libvirt_fds(tvbuff_t *tvb, gint start, gint32 nfds)
      |                                    ~~~~~^~~~~
../../tools/wireshark/src/packet-libvirt.c:348:55: error: unused parameter 'nfds' [-Werror=unused-parameter]
  348 | dissect_libvirt_fds(tvbuff_t *tvb, gint start, gint32 nfds)
      |                                                ~~~~~~~^~~~
At top level:
../../tools/wireshark/src/packet-libvirt.c:64:5: error: 'dissect_xdr_bool' defined but not used [-Werror=unused-function]
   64 |     dissect_xdr_##xtype(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf) \
      |     ^~~~~~~~~~~~
../../tools/wireshark/src/packet-libvirt.c:88:1: note: in expansion of macro 'XDR_PRIMITIVE_DISSECTOR'
   88 | XDR_PRIMITIVE_DISSECTOR(bool,    bool_t,  boolean)
      | ^~~~~~~~~~~~~~~~~~~~~~~
../../tools/wireshark/src/packet-libvirt.c:64:5: error: 'dissect_xdr_float' defined but not used [-Werror=unused-function]
   64 |     dissect_xdr_##xtype(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf) \
      |     ^~~~~~~~~~~~
../../tools/wireshark/src/packet-libvirt.c:86:1: note: in expansion of macro 'XDR_PRIMITIVE_DISSECTOR'
   86 | XDR_PRIMITIVE_DISSECTOR(float,   gfloat,  float)
      | ^~~~~~~~~~~~~~~~~~~~~~~
../../tools/wireshark/src/packet-libvirt.c:64:5: error: 'dissect_xdr_short' defined but not used [-Werror=unused-function]
   64 |     dissect_xdr_##xtype(tvbuff_t *tvb, proto_tree *tree, XDR *xdrs, int hf) \
      |     ^~~~~~~~~~~~
../../tools/wireshark/src/packet-libvirt.c:80:1: note: in expansion of macro 'XDR_PRIMITIVE_DISSECTOR'
   80 | XDR_PRIMITIVE_DISSECTOR(short,   gint16,  int)
      | ^~~~~~~~~~~~~~~~~~~~~~~
../../tools/wireshark/src/packet-libvirt.c: In function 'dissect_libvirt_message':
../../tools/wireshark/src/packet-libvirt.c:423:34: error: null pointer dereference [-Werror=null-dereference]
  423 |         vir_xdr_dissector_t xd = find_payload_dissector(proc, type, get_program_data(prog, VIR_PROGRAM_DISSECTORS),
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  424 |                                                         *(gsize *)get_program_data(prog, VIR_PROGRAM_DISSECTORS_LEN));
      |                                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agom4: virt-xdr: rewrite XDR check
Pavel Hrdina [Thu, 18 Jun 2020 22:44:07 +0000 (00:44 +0200)] 
m4: virt-xdr: rewrite XDR check

The current code to check XDR support was obsolete and way to
complicated.

On linux we can use pkg-config to check for libtirpc and have
the CFLAGS and LIBS configured by it as well.

On MinGW there is portablexdr library which installs header files
directly into system include directory.

On FreeBSD and macOS XDR functions are part of libc so there is
no library needed, we just need to call AM_CONDITIONAL to silence
configure which otherwise complains about missing WITH_XDR.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agom4: virt-secdriver-selinux: drop obsolete function checks
Pavel Hrdina [Wed, 24 Jun 2020 08:57:22 +0000 (10:57 +0200)] 
m4: virt-secdriver-selinux: drop obsolete function checks

All of the listed functions are available in libselinux version 2.2.
Our supported OSes start with version 2.5 so there is no need to check
it.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agodocs: convert FIG files into SVG format
Pavel Hrdina [Fri, 10 Jul 2020 08:35:10 +0000 (10:35 +0200)] 
docs: convert FIG files into SVG format

Converted by using:

    fig2dev -L svg <infile> <outfile>

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agodocs: drop %.png: %.fig rule
Pavel Hrdina [Thu, 25 Jun 2020 12:10:57 +0000 (14:10 +0200)] 
docs: drop %.png: %.fig rule

convert bin is part of ImageMagick package and uses uniconvertor to
create png file from fig files.

Unfortunately uniconvertor is python2 only and not available in most
recent distributions which makes the convert command fail with:

sh: uniconvertor: command not found
/usr/bin/mv: cannot stat '/tmp/magick-1397138DRT8Pzx4Qmoc.svg': No such file or directory
convert: delegate failed `'uniconvertor' '%i' '%o.svg'; /usr/bin/mv '%o.svg' '%o'' @ error/delegate.c/InvokeDelegate/1958.
convert: unable to open file `/tmp/magick-1397138S8ARueJXLXkc': No such file or directory @ error/constitute.c/ReadImage/605.
convert: no images defined `docs/migration-managed-direct.png' @ error/convert.c/ConvertImageCommand/3226.

It looks like that there are plans to somehow port uniconvertor into
python3 but as part of different project color-picker but the job is
far from complete.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
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>