]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
3 years agorpm: List more directories
Andrea Bolognani [Mon, 24 Jan 2022 18:05:44 +0000 (19:05 +0100)]
rpm: List more directories

This has two advantages: it makes it possible for the admin to
ask rpm what package they belong to, and results in them ending
up with stricter permissions than they would have if we let
libvirt create them at runtime.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agorpm: Move /var/lib/libvirt from -libs to -daemon
Andrea Bolognani [Mon, 24 Jan 2022 15:54:43 +0000 (16:54 +0100)]
rpm: Move /var/lib/libvirt from -libs to -daemon

The server, not the client, uses local storage.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agorpm: Move /etc/libvirt from -daemon to -libs
Andrea Bolognani [Mon, 24 Jan 2022 15:54:01 +0000 (16:54 +0100)]
rpm: Move /etc/libvirt from -daemon to -libs

Files like libvirt.conf influence the behavior of the library
itself. The daemon depends on the library, so the directory is
guaranteed to be present both on the client side and on the
server side.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: add PCI root to MIPS Malta machine
Lubomir Rintel [Tue, 1 Feb 2022 14:33:55 +0000 (15:33 +0100)]
qemu: add PCI root to MIPS Malta machine

MIPS Malta (and no other supported MIPS machine) has a PCI bus.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: add qemuDomainIsMipsMalta()
Lubomir Rintel [Tue, 1 Feb 2022 14:33:54 +0000 (15:33 +0100)]
qemu: add qemuDomainIsMipsMalta()

This identifies various MIPS Malta machines, be it 32-bit or 64-bit,
little-endian or big-endian.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoutil: add ARCH_IS_MIPS helper macro
Lubomir Rintel [Tue, 1 Feb 2022 14:33:53 +0000 (15:33 +0100)]
util: add ARCH_IS_MIPS helper macro

Identifies all of various MIPS sub-architectures: 32-bit or 64-bit,
little-endian or big-endian.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agosrc: Use g_steal_pointer() more
Michal Privoznik [Fri, 28 Jan 2022 17:06:32 +0000 (18:06 +0100)]
src: Use g_steal_pointer() more

There are few places where the g_steal_pointer() is open coded.
Switch them to calling the g_steal_pointer() function instead.
Generated by the following spatch:

  @ rule1 @
  expression a, b;
  @@
    <...
  - b = a;
    ... when != b
  - a = NULL;
  + b = g_steal_pointer(&a);
    ...>

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
3 years agovirpcivpdtest: Fix potential double-free()
Michal Privoznik [Fri, 28 Jan 2022 19:37:42 +0000 (20:37 +0100)]
virpcivpdtest: Fix potential double-free()

Inside the testPCIVPDResourceCustomCompareIndex() function we
have two variables @a and @b, both marked as g_autoptr(). Then,
towards the end of the function b->value is freed and set to
a->value. This is to make sure
virPCIVPDResourceCustomCompareIndex() works correctly even if
->value member is the same for both arguments.

Nevertheless, if the function returns anything else than 0 then
the control executes subsequent return statement and since
b->value points to the very same string as a->value a double free
will occur. Avoid this by setting b->value to NULL explicitly,
just like we are already doing for the successful path.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
3 years agolib: Don't set variable to NULL after VIR_FREE()
Michal Privoznik [Fri, 28 Jan 2022 17:22:06 +0000 (18:22 +0100)]
lib: Don't set variable to NULL after VIR_FREE()

There are a few places where a variable is VIR_FREE()-d and then
explicitly set to NULL. This is not necessary since VIR_FREE()
does that for us.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
3 years agotest_driver: Don't leak @group_name
Michal Privoznik [Mon, 31 Jan 2022 12:52:25 +0000 (13:52 +0100)]
test_driver: Don't leak @group_name

In testDomainSetBlockIoTune() the info.group_name is strdup()-ed
and just after the whole @info structure is passed to
virDomainDiskSetBlockIOTune() the @group_name member is set to
NULL. This creates a memleak, because
virDomainDiskSetBlockIOTune() creates its own copy of the string.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
3 years agoci: containers: Add CentOS Stream 9 target
Erik Skultety [Thu, 27 Jan 2022 11:46:32 +0000 (12:46 +0100)]
ci: containers: Add CentOS Stream 9 target

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoci: manifest: Allow RPM builds on CentOS Stream 8
Erik Skultety [Wed, 5 Jan 2022 14:23:51 +0000 (15:23 +0100)]
ci: manifest: Allow RPM builds on CentOS Stream 8

The meson version provided by the package managing system satisfies our
minimum requirement.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agolxcDomainDetachDeviceHostdevUSBLive: Use VIR_WITH_OBJECT_LOCK_GUARD
Tim Wiederhake [Tue, 31 Aug 2021 13:09:51 +0000 (15:09 +0200)]
lxcDomainDetachDeviceHostdevUSBLive: Use VIR_WITH_OBJECT_LOCK_GUARD

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agobhyveAutostartDomain: Use virObjectLockGuard
Tim Wiederhake [Tue, 24 Aug 2021 15:20:43 +0000 (17:20 +0200)]
bhyveAutostartDomain: Use virObjectLockGuard

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agovirChrdevFree: Use VIR_WITH_MUTEX_LOCK
Tim Wiederhake [Wed, 25 Aug 2021 08:25:32 +0000 (10:25 +0200)]
virChrdevFree: Use VIR_WITH_MUTEX_LOCK

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agovirChrdevFDStreamCloseCb: Use virLockGuardLock
Tim Wiederhake [Wed, 25 Aug 2021 08:25:32 +0000 (10:25 +0200)]
virChrdevFDStreamCloseCb: Use virLockGuardLock

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agovirobject: Introduce VIR_WITH_OBJECT_LOCK_GUARD
Tim Wiederhake [Mon, 23 Aug 2021 12:47:25 +0000 (14:47 +0200)]
virobject: Introduce VIR_WITH_OBJECT_LOCK_GUARD

Modeled after "WITH_QEMU_LOCK_GUARD" (see qemu's include/qemu/lockable.h).

See comment for typical usage.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agovirobject: Introduce virObjectLockGuard
Tim Wiederhake [Mon, 23 Aug 2021 14:03:54 +0000 (16:03 +0200)]
virobject: Introduce virObjectLockGuard

Typical usage:
    void foobar(virObjectLockable *obj)
    {
        VIR_LOCK_GUARD lock = virObjectLockGuard(obj);
        /* `obj` is locked, and released automatically on scope exit */

        ...
    }

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agovirthread: Introduce VIR_WITH_MUTEX_LOCK_GUARD
Tim Wiederhake [Wed, 25 Aug 2021 08:25:32 +0000 (10:25 +0200)]
virthread: Introduce VIR_WITH_MUTEX_LOCK_GUARD

Modeled after "WITH_QEMU_LOCK_GUARD" (see qemu's include/qemu/lockable.h).

See comment for typical usage.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agovirthread: Introduce virLockGuard
Tim Wiederhake [Wed, 25 Aug 2021 08:25:32 +0000 (10:25 +0200)]
virthread: Introduce virLockGuard

Locks a virMutex on creation and unlocks it in its destructor.

The VIR_LOCK_GUARD macro is used instead of "g_auto(virLockGuard)" to
work around a clang issue (see https://bugs.llvm.org/show_bug.cgi?id=3888
and https://bugs.llvm.org/show_bug.cgi?id=43482).

Typical usage:

    void function(virMutex *m)
    {
        VIR_LOCK_GUARD lock = virLockGuardLock(m);
        /* `m` is locked, and released automatically on scope exit */

        ...
        while (expression) {
            VIR_LOCK_GUARD lock2 = virLockGuardLock(...);
            /* similar */
        }
    }

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agointernal: Add CONCAT macro
Tim Wiederhake [Wed, 25 Aug 2021 08:25:32 +0000 (10:25 +0200)]
internal: Add CONCAT macro

Using the two-step idiom to force resolution of other macros, e.g.:

  #define bar BAR
  CONCAT_(foo, bar)     // foobar
  CONCAT(foo, bar)      // fooBAR

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agosystemd: Use correct man page name in modular daemon service files
Peter Krempa [Tue, 1 Feb 2022 12:13:05 +0000 (13:13 +0100)]
systemd: Use correct man page name in modular daemon service files

The service files were copied out of the service file for libvirtd and
the name of the corresponding manpage was not fixed.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2045959
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agokbase: debuglogs: Add note about sensitive information in the logs
Peter Krempa [Mon, 31 Jan 2022 12:26:21 +0000 (13:26 +0100)]
kbase: debuglogs: Add note about sensitive information in the logs

Outline information commonly logged which users could consider
sensitive.

Add a note that VNC/SPICE passwords are logged in plaintext.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agovirnwfilterbindingobj: Fix virNWFilterBindingObjNew()
Michal Privoznik [Tue, 1 Feb 2022 09:21:02 +0000 (10:21 +0100)]
virnwfilterbindingobj: Fix virNWFilterBindingObjNew()

The idea behind virNWFilterBindingObjNew() is to create and
return an object of virNWFilterBindingObjClass class. The class
is virObjectLockable (and the corresponding
_virNWFilterBindingObj structure has virObjectLockable parent).
But for some reason plain virObjectNew() is called. This is wrong
because the mutex in the parent is left uninitialized.

Next, the returned object is not locked. This is wrong because in
some cases the returned object is added onto a list of bindings
and then passed to virNWFilterBindingObjEndAPI() which unlocks it
right away. This is potentially dangerous because we might just
have unlocked the object for another thread.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoTranslated using Weblate (Swedish)
Göran Uddeborg [Sun, 30 Jan 2022 17:16:37 +0000 (18:16 +0100)]
Translated using Weblate (Swedish)

Currently translated at 32.0% (3354 of 10455 strings)

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

Co-authored-by: Göran Uddeborg <goeran@uddeborg.se>
Signed-off-by: Göran Uddeborg <goeran@uddeborg.se>
3 years agoTranslated using Weblate (Spanish)
Emilio Herrera [Sun, 30 Jan 2022 17:16:36 +0000 (18:16 +0100)]
Translated using Weblate (Spanish)

Currently translated at 48.7% (5097 of 10455 strings)

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

Co-authored-by: Emilio Herrera <ehespinosa57@gmail.com>
Signed-off-by: Emilio Herrera <ehespinosa57@gmail.com>
3 years agolibxl: assume LIBXL_HAVE_PVUSB
Ján Tomko [Fri, 28 Jan 2022 19:11:19 +0000 (20:11 +0100)]
libxl: assume LIBXL_HAVE_PVUSB

Introduced in Xen 4.7 by commit:
  commit bf7628f087b212052a0e9f024044b2790c33f820
    libxl: add pvusb API

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agolibxl: assume LIBXL_HAVE_SRM_V2
Ján Tomko [Fri, 28 Jan 2022 18:54:05 +0000 (19:54 +0100)]
libxl: assume LIBXL_HAVE_SRM_V2

Introduced in Xen 4.6.0 by:
  commit 3a9ace0147d48af49ffd34628f9510f248f2f588
    tools/libxc+libxl+xl: Restore v2 streams

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agolibxl: remove LIBXL_ATTR_UNUSED
Ján Tomko [Fri, 28 Jan 2022 19:01:27 +0000 (20:01 +0100)]
libxl: remove LIBXL_ATTR_UNUSED

Unused as of:
  commit 446d09149802677546449fa2dd253f3ebce377ac
    libxl: pass driver config to libxlMakeDomBuildInfo

All other usage of LIBXL_HAVE_DEVICE_CHANNEL was removed by:
  commit e58004d70aceb560fba64803e566b8be3ef93940
    Xen: Remove unneeded LIBXL_HAVE_* ifdefs

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agolibxl: assume LIBXL_HAVE_DEVICE_BACKEND_DOMNAME
Ján Tomko [Thu, 13 Jan 2022 18:54:34 +0000 (19:54 +0100)]
libxl: assume LIBXL_HAVE_DEVICE_BACKEND_DOMNAME

Introduced in 4.3.0 by xen commit:

  commit ef496b81f0336f09968a318e7f81151dd4f5a0cc
    libxl: postpone backend name resolution

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agotests: refactor testSELinuxLoadDef
Ján Tomko [Sat, 4 Sep 2021 19:10:17 +0000 (21:10 +0200)]
tests: refactor testSELinuxLoadDef

Since its introduction in
commit 907a39e735d256b8428ed4c77009d1f713aea19b
    Add a test suite for validating SELinux labelling

this function did not return NULL on OOM.

Since we abort on OOM now, switch testSELinuxMungePath to void,
return NULL explicitly on XML parsing failure and remove
the (now pointless) cleanup label.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agosyntax-check: https: list the HTTP-only sites
Ján Tomko [Tue, 25 Aug 2020 21:58:22 +0000 (23:58 +0200)]
syntax-check: https: list the HTTP-only sites

Instead of listing the sites that surely support HTTPS,
list the ones that don't.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu: qemuDomainSetLaunchSecurityState: do not lookup qemuCaps in cache
Ján Tomko [Fri, 28 Jan 2022 16:44:32 +0000 (17:44 +0100)]
qemu: qemuDomainSetLaunchSecurityState: do not lookup qemuCaps in cache

Any active domain has a copy in the privateData, filled in
qemuProcessInit.

Move the qemu capability check below the activeness check and remove
the extra lookup.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agolib: Drop '&*' from '&*variable'
Michal Privoznik [Mon, 31 Jan 2022 08:28:16 +0000 (09:28 +0100)]
lib: Drop '&*' from '&*variable'

Apparently, some of '&*variable' slipped in. Drop '&*' and access
the variable directly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ani Sinha <ani@anisinha.ca>
3 years agoqemu: qemuDomainSetLaunchSecurityState: check for params presence
Ján Tomko [Thu, 27 Jan 2022 18:41:24 +0000 (19:41 +0100)]
qemu: qemuDomainSetLaunchSecurityState: check for params presence

We require the header and the secret to be present.

Use a different approach to virParams to report an error if they
are not present, instead of trying to pass empty arguments to QEMU
via QMP.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agovirsh: domsetlaunchsecstate: report error if no options are passed
Ján Tomko [Wed, 26 Jan 2022 12:25:44 +0000 (13:25 +0100)]
virsh: domsetlaunchsecstate: report error if no options are passed

We already exit if they are not present.

Report an error, but do not mark them as required in case a future
version of this command will want to accept a different set of
parameters.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoutil: refactor virNetDevBandwidthUnplug
Ján Tomko [Mon, 17 Jan 2022 17:02:33 +0000 (18:02 +0100)]
util: refactor virNetDevBandwidthUnplug

Remove pointless 'ret', cmd variable reuse and use g_auto.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoutil: refactor virNetDevBandwidthPlug
Ján Tomko [Mon, 17 Jan 2022 17:02:32 +0000 (18:02 +0100)]
util: refactor virNetDevBandwidthPlug

Use g_auto, split the double use of 'cmd' variable and remove useless
ret variable.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoutil: virNetDevBandwidthClear: use g_auto
Ján Tomko [Mon, 17 Jan 2022 17:02:31 +0000 (18:02 +0100)]
util: virNetDevBandwidthClear: use g_auto

Separate the two uses of 'cmd' to avoid mixing manual and automatic
cleanup.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoutil: virNetDevBandwidthManipulateFilter: use g_auto
Ján Tomko [Mon, 17 Jan 2022 17:02:30 +0000 (18:02 +0100)]
util: virNetDevBandwidthManipulateFilter: use g_auto

Reduce the scope of the variable to avoid renaming it.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoutil: virNetDevBandwidthUpdateRate: refactor
Ján Tomko [Mon, 17 Jan 2022 17:02:29 +0000 (18:02 +0100)]
util: virNetDevBandwidthUpdateRate: refactor

Use automatic cleanup and remove the 'ret' variable in favor of
direct returns.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoutil: midonet: use g_auto for virCommand
Ján Tomko [Mon, 17 Jan 2022 17:02:28 +0000 (18:02 +0100)]
util: midonet: use g_auto for virCommand

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agodomain_cgroup: Don't put semicolon at the end of VIR_GET_LIMIT_PARAMETER macro
Michal Privoznik [Fri, 28 Jan 2022 11:15:01 +0000 (12:15 +0100)]
domain_cgroup: Don't put semicolon at the end of VIR_GET_LIMIT_PARAMETER macro

In domain_cgroup.c there's VIR_GET_LIMIT_PARAMETER macro which
has a semicolon at the end of its declaration. Well, remove it so
that the places where macro is used have to put the semicolon
explicitly. This helps with automatic reformatting (at least in
vim).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
3 years agoch_driver: emulator threadinfo & pinning callbacks
Praveen K Paladugu [Tue, 25 Jan 2022 16:19:59 +0000 (16:19 +0000)]
ch_driver: emulator threadinfo & pinning callbacks

Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoch_process: Setup emulator and iothread settings
Praveen K Paladugu [Tue, 25 Jan 2022 16:19:58 +0000 (16:19 +0000)]
ch_process: Setup emulator and iothread settings

using virCHProcessSetupPid

Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoch_driver: add numatune callbacks for CH driver
Vineeth Pillai [Tue, 25 Jan 2022 16:19:57 +0000 (16:19 +0000)]
ch_driver: add numatune callbacks for CH driver

Signed-off-by: Vineeth Pillai <viremana@linux.microsoft.com>
Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoch_driver: enable typed param string for numatune
Vineeth Pillai [Tue, 25 Jan 2022 16:19:56 +0000 (16:19 +0000)]
ch_driver: enable typed param string for numatune

Enable support of VIR_DRV_FEATURE_TYPED_PARAM_STRING to enable numatune

Signed-off-by: Vineeth Pillai <viremana@linux.microsoft.com>
Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoch_driver, ch_domain: vcpupin callback in ch driver
Vineeth Pillai [Tue, 25 Jan 2022 16:19:55 +0000 (16:19 +0000)]
ch_driver, ch_domain: vcpupin callback in ch driver

Signed-off-by: Vineeth Pillai <viremana@linux.microsoft.com>
Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoch: Move and rename chDomObjFromDomain()
Vineeth Pillai [Fri, 28 Jan 2022 11:51:33 +0000 (12:51 +0100)]
ch: Move and rename chDomObjFromDomain()

The chDomObjFromDomain() function which currently lives as a
static one in ch_driver.c is going to be needed in other parts
of the driver. Move it into ch_domain.c, rename to
virCHDomainObjFromDomain() and expose in corresponding header
file for the rest of the driver to use.

Signed-off-by: Vineeth Pillai <viremana@linux.microsoft.com>
Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoch: methods for cgroup mgmt in ch driver
Vineeth Pillai [Tue, 25 Jan 2022 16:19:54 +0000 (16:19 +0000)]
ch: methods for cgroup mgmt in ch driver

Signed-off-by: Vineeth Pillai <viremana@linux.microsoft.com>
Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoqemu, hypervisor: refactor some cgroup mgmt methods
Praveen K Paladugu [Tue, 25 Jan 2022 16:19:53 +0000 (16:19 +0000)]
qemu, hypervisor: refactor some cgroup mgmt methods

Refactor some cgroup management methods from qemu into hypervisor.
These methods will be shared with ch driver for cgroup management.

Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agocpu-data.py: Query hyperv enlightenments
Tim Wiederhake [Tue, 25 Jan 2022 11:18:23 +0000 (12:18 +0100)]
cpu-data.py: Query hyperv enlightenments

Reporting hv-* properties properly requires hv to be enabled,
see qemu commit 071ce4b03b.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
3 years agoinclude: Fix documentation for various VIR_*_LAST values
Andrea Bolognani [Thu, 27 Jan 2022 14:26:57 +0000 (15:26 +0100)]
include: Fix documentation for various VIR_*_LAST values

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuDomainDetachDeviceLive: Handle hostevs with unassigned type of address
Michal Privoznik [Tue, 25 Jan 2022 10:05:21 +0000 (11:05 +0100)]
qemuDomainDetachDeviceLive: Handle hostevs with unassigned type of address

A <hostdev/> can have <address type='unassigned'/> which means
libvirt manages the device detach from/reattach to the host but
the device is never exposed to the guest. This means that we have
to take a shortcut during hotunplug (e.g. never ask QEMU on the
monitor to detach the device, or never wait for DEVICE_DELETED
event).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuDomainAttachHostPCIDevice: Handle hostevs with unassigned type of address
Michal Privoznik [Tue, 25 Jan 2022 07:51:26 +0000 (08:51 +0100)]
qemuDomainAttachHostPCIDevice: Handle hostevs with unassigned type of address

A <hostdev/> can have <address type='unassigned'/> which means
libvirt manages the device detach from/reattach to the host but
the device is never exposed to the guest. This means that we have
to take a shortcut during hotplug, similar to the one we are
taking when constructing the command line (see
qemuBuildHostdevCommandLine()).

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2040548
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agodomain_validate: Refuse VIR_DOMAIN_DEVICE_ADDRESS_TYPE_UNASSIGNED
Michal Privoznik [Tue, 25 Jan 2022 09:47:28 +0000 (10:47 +0100)]
domain_validate: Refuse VIR_DOMAIN_DEVICE_ADDRESS_TYPE_UNASSIGNED

We document that <address type='unassigned'/> can be used only
for <hostdev/>-s. However, corresponding validation rule is
missing. Let's put the rule into hypervisor agnostic part of
validation process so that all drivers can benefit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agomeson: Optimize handling of qemu_user and qemu_group
Andrea Bolognani [Wed, 26 Jan 2022 14:21:20 +0000 (15:21 +0100)]
meson: Optimize handling of qemu_user and qemu_group

If the user has already provided us with the configuration they
want, there's no point in trying to come up with a reasonable
OS-specific default.

Suggested-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
3 years agomeson: Require that both qemu_user and qemu_group are provided
Andrea Bolognani [Wed, 26 Jan 2022 14:14:13 +0000 (15:14 +0100)]
meson: Require that both qemu_user and qemu_group are provided

Or that neither is. The current implementation, where if only
one of the two is provided the other one will be based on
OS-specific defaults is more likely to cause confusion than it
is to be helpful.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
3 years agomeson: Don't check whether qemu_user and qemu_group exist
Andrea Bolognani [Wed, 26 Jan 2022 14:11:17 +0000 (15:11 +0100)]
meson: Don't check whether qemu_user and qemu_group exist

QEMU might not be installed on the build system, in which case
the user and group will not be present. We should avoid falling
back to root:root in that case, and assume the user and group
are going to be present in the target system instead.

Suggested-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
3 years agomeson: Don't require /etc/os-release to be present
Andrea Bolognani [Wed, 26 Jan 2022 14:01:40 +0000 (15:01 +0100)]
meson: Don't require /etc/os-release to be present

It might be part of some non-mandatory package on certain
distros, and our logic deals just fine with its contents not
being available.

Fixes: 4c69d64efa3731d074d198f871fd42e74c4a39f6
Reported-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
3 years agonode_device: Treat NVMe disks as regular disks
Michal Privoznik [Wed, 26 Jan 2022 12:47:33 +0000 (13:47 +0100)]
node_device: Treat NVMe disks as regular disks

Unfortunately, udev doesn't set ID_TYPE attribute for NVMe disks,
therefore we have to add another case into udevKludgeStorageType()
to treat /dev/nvme* devlinks as any other disk.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2045953
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agonode_device: Rework udevKludgeStorageType()
Michal Privoznik [Wed, 26 Jan 2022 13:00:13 +0000 (14:00 +0100)]
node_device: Rework udevKludgeStorageType()

The udevKludgeStorageType() function looks at devlink name
(/dev/XXX) and guesses the type of the (storage) device using a
series of STRPREFIX() calls. Well those can be turn into an array
and a for() loop, especially if we are about to add a new case
(in the next commit).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
3 years agoqemu: Allow prealloc for virtio-mem-pci
Michal Privoznik [Tue, 30 Nov 2021 17:16:00 +0000 (18:16 +0100)]
qemu: Allow prealloc for virtio-mem-pci

There are a some scenarios in which we want to prealloc guest
memory (e.g. when requested in domain XML, when using hugepages,
etc.). With 'regular' <memory/> models (like 'dimm', 'nvdimm' or
'virtio-pmem') or regular guest memory it is corresponding
memory-backend-* object that ends up with .prealloc attribute
set. And that's desired because neither of those devices can
change its size on the fly. However, with virtio-mem model things
are a bit different. While one can set .prealloc attribute on
corresponding memory-backend-* object it doesn't make much sense,
because virtio-mem can inflate/deflate on the fly, i.e. change
how big of a portion of the memory-backend-* object is exposed to
the guest. For instance, from a say 4GiB module only a half can
be exposed to the guest. Therefore, it doesn't make much sense to
preallocate whole 4GiB and keep them allocated. But we still want
the part exposed to the guest preallocated (when conditions
described at the beginning are met).

Having said that, with new enough QEMU the virtio-mem-pci device
gained new attribute ".prealloc" which instructs the device to
talk to the memory backend object and allocate only the requested
portion of memory.

Now, that our algorithm for setting .prealloc was isolated in a
single function, the function can be called when constructing cmd
line for virtio-mem-pci device.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu_capabilities: Introduce QEMU_CAPS_DEVICE_VIRTIO_MEM_PCI_PREALLOC
Michal Privoznik [Tue, 30 Nov 2021 16:52:28 +0000 (17:52 +0100)]
qemu_capabilities: Introduce QEMU_CAPS_DEVICE_VIRTIO_MEM_PCI_PREALLOC

This new capability tracks whether virtio-mem device is capable
of memory preallocation, which is detected by the device having
.prealloc attribute.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: Move @prealloc into qemuBuildMemoryGetPagesize()
Michal Privoznik [Wed, 1 Dec 2021 11:34:09 +0000 (12:34 +0100)]
qemu: Move @prealloc into qemuBuildMemoryGetPagesize()

The qemuBuildMemoryGetPagesize() function has everything is needs
to decide whether preallocation is needed or not. Move the logic
from qemuBuildMemoryBackendProps() into
qemuBuildMemoryGetPagesize().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemu: Separate out hugepages handling from qemuBuildMemoryBackendProps()
Michal Privoznik [Wed, 1 Dec 2021 09:44:32 +0000 (10:44 +0100)]
qemu: Separate out hugepages handling from qemuBuildMemoryBackendProps()

The qemuBuildMemoryBackendProps() function is already long
enough. Move code that decides what hugepages to use into a
separate function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuBuildMemoryDeviceProps: Fix const correctness
Michal Privoznik [Wed, 1 Dec 2021 12:23:04 +0000 (13:23 +0100)]
qemuBuildMemoryDeviceProps: Fix const correctness

The @mem agrument of qemuBuildMemoryDeviceProps() function is
only read from. Make this fact obvious from the function
declaration too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agospec: Don't clean up *.la and *.a files
Andrea Bolognani [Mon, 24 Jan 2022 16:10:57 +0000 (17:10 +0100)]
spec: Don't clean up *.la and *.a files

autotools used to produce those, but meson doesn't.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoconf: Separate out virDomainClockDef formatting
Michal Privoznik [Mon, 24 Jan 2022 06:15:04 +0000 (07:15 +0100)]
conf: Separate out virDomainClockDef formatting

Currently, virDomainClockDef is formatted inside
virDomainDefFormatInternalSetRootName() which is already long
enough. Move the code into a new function
(virDomainClockDefFormat()) and make the code use
virXMLFormatElement() while at it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirDomainTimerDefFormat: return void
Michal Privoznik [Mon, 24 Jan 2022 06:04:48 +0000 (07:04 +0100)]
virDomainTimerDefFormat: return void

This function never returns an error, make it void then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoconf: Rework virDomainTimerDefFormat()
Michal Privoznik [Mon, 24 Jan 2022 05:41:09 +0000 (06:41 +0100)]
conf: Rework virDomainTimerDefFormat()

Use virXMLFormatElement() to simplify virDomainTimerDefFormat().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoconf: Fix @mode member of _virDomainTimerDef struct
Michal Privoznik [Sun, 23 Jan 2022 21:08:03 +0000 (22:08 +0100)]
conf: Fix @mode member of _virDomainTimerDef struct

The @mode member of the _virDomainTimerDef struct stores
values of the virDomainTimerModeType enum, or -1 for the
default value (when user provided no value in XML).

This is needlessly complicated. Introduce new value to the enum
which reflects the default state.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoconf: Fix @track member of _virDomainTimerDef struct
Michal Privoznik [Sun, 23 Jan 2022 20:56:54 +0000 (21:56 +0100)]
conf: Fix @track member of _virDomainTimerDef struct

The @track member of the _virDomainTimerDef struct stores
values of the virDomainTimerTrackType enum, or -1 for the
default value (when user provided no value in XML).

This is needlessly complicated. Introduce new value to the enum
which reflects the default state.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoconf: Fix @tickpolicy member of _virDomainTimerDef struct
Michal Privoznik [Sun, 23 Jan 2022 20:34:29 +0000 (21:34 +0100)]
conf: Fix @tickpolicy member of _virDomainTimerDef struct

The @tickpolicy member of the _virDomainTimerDef struct stores
values of the virDomainTimerTickpolicyType enum, or -1 for the
default value (when user provided no value in XML).

This is needlessly complicated. Introduce new value to the enum
which reflects the default state.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoconf: Fix type of @present in _virDomainTimerDef struct
Michal Privoznik [Sun, 23 Jan 2022 20:15:10 +0000 (21:15 +0100)]
conf: Fix type of @present in _virDomainTimerDef struct

In the _virDomainTimerDef structure we have @present member which
is like virTristateBool, except it's an integer and has values
shifted by one. This is harder to read. Retype the member to
virTristateBool which we are familiar with.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirDomainChrSourceDefCopy: return void
Michal Privoznik [Mon, 24 Jan 2022 07:58:00 +0000 (08:58 +0100)]
virDomainChrSourceDefCopy: return void

This function never returns an error, make it void then. And
while at it, make the @src argument const to make it obvious it's
never changed inside the function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirDomainChrSourceDefCopy: Don't check arguments against NULL
Michal Privoznik [Mon, 24 Jan 2022 07:55:52 +0000 (08:55 +0100)]
virDomainChrSourceDefCopy: Don't check arguments against NULL

The only caller of this function
(qemuProcessFindCharDevicePTYsMonitor()) doesn't pass NULL.
Remove corresponding check from virDomainChrSourceDefCopy().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirDomainChrSourceDefCopy: Copy more struct members
Michal Privoznik [Sun, 23 Jan 2022 13:58:36 +0000 (14:58 +0100)]
virDomainChrSourceDefCopy: Copy more struct members

The aim of virDomainChrSourceDefCopy() is to make a deep copy of
given virDomainChrSourceDef. However, some types were not copied
at all (VIR_DOMAIN_CHR_TYPE_SPICEVMC and
VIR_DOMAIN_CHR_TYPE_SPICEPORT) and some members weren't copied
either (@logfile, @logappend).

After this, there are still some members that are not copied
(seclabels and private data), but the sole caller
qemuProcessFindCharDevicePTYsMonitor() doesn't seem to care.
Therefore, just document this behavior so that future user is
aware.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agovirDomainInputDefParseXML: Move validation into validator
Michal Privoznik [Sun, 23 Jan 2022 11:54:27 +0000 (12:54 +0100)]
virDomainInputDefParseXML: Move validation into validator

There is some code that validates whether parsed @bus <input/>
makes sense (e.g. some hypervisors have their own type of bus).
But this code should not live in the parser, but validator
rather. That way, we can also validate that the value we compute
(if user didn't provide any) is valid.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
3 years agoqemuDomainSetupDisk: Initialize 'targetPaths'
Peter Krempa [Tue, 25 Jan 2022 16:49:00 +0000 (17:49 +0100)]
qemuDomainSetupDisk: Initialize 'targetPaths'

Compiler isn't able to see that 'virDevMapperGetTargets' in cases e.g.
when the devmapper isn't available may not initialize the value in the
pointer passed as the second argument.

The usage 'qemuDomainSetupDisk' lead to an accidental infinite loop as
previous calls apparently doctored the stack to a point where
'g_slist_concat' would end up in an infinite loop trying to find the end
of the list.

Fixes: 6c49c2ee9fcb88de02cdc333f666a8e95d60a3b0
Closes: https://gitlab.com/libvirt/libvirt/-/issues/268
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agomeson: recognize sles when guessing default_qemu_user
Olaf Hering [Tue, 25 Jan 2022 13:17:23 +0000 (14:17 +0100)]
meson: recognize sles when guessing default_qemu_user

NAME="SLES"
VERSION="15-SP3"
VERSION_ID="15.3"
PRETTY_NAME="SUSE Linux Enterprise Server 15 SP3"
ID="sles"
ID_LIKE="suse"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:suse:sles:15:sp3"
DOCUMENTATION_URL="https://documentation.suse.com/"

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
3 years agonews: Mention hvf domain type
Roman Bolshakov [Sun, 18 Nov 2018 12:47:37 +0000 (15:47 +0300)]
news: Mention hvf domain type

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agodocs: Add support page for libvirt on macOS
Roman Bolshakov [Tue, 20 Nov 2018 00:12:17 +0000 (03:12 +0300)]
docs: Add support page for libvirt on macOS

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agodocs: Note hvf support for domain elements
Roman Bolshakov [Mon, 19 Nov 2018 11:13:53 +0000 (14:13 +0300)]
docs: Note hvf support for domain elements

Many domain elements have "QEMU and KVM only" or "QEMU/KVM since x.y.z"
remarks. Most of the elements work for HVF domain, so it makes sense to
add respective notices for HVF domain.

All the elements have been manually tested.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agodocs: Add hvf on QEMU driver page
Roman Bolshakov [Sun, 18 Nov 2018 21:27:07 +0000 (00:27 +0300)]
docs: Add hvf on QEMU driver page

It's worth to make the domain type a little bit more visible than a row
in news. An example of hvf domain is available on QEMU driver page.

While at it, mention Hypervisor.framework on index page.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agotests: Add HVF test cases
Andrea Bolognani [Tue, 4 Jan 2022 16:27:01 +0000 (17:27 +0100)]
tests: Add HVF test cases

We need to use a hardcoded list of capabilities because we don't
yet have proper replies files obtained from QEMU running on actual
macOS machines.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agotests: Add macOS support to qemuxml2*test
Andrea Bolognani [Thu, 6 Jan 2022 11:32:33 +0000 (12:32 +0100)]
tests: Add macOS support to qemuxml2*test

The new DO_TEST_MACOS() macro makes it possible to create test
cases that verify the behavior of libvirt on a macOS machine
with HVF support available.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agotests: Add macOS support to testutilsqemu
Andrea Bolognani [Thu, 6 Jan 2022 10:45:25 +0000 (11:45 +0100)]
tests: Add macOS support to testutilsqemu

This exposes a couple of macOS-specific variants of existing
APIs, which can be used when implementing test programs and
result in HVF support being advertised.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agotests: Introduce testQemuHostOS
Andrea Bolognani [Thu, 6 Jan 2022 11:32:25 +0000 (12:32 +0100)]
tests: Introduce testQemuHostOS

This new enumeration provides a way to specify the host OS
that a specific test case expects. The default is Linux, which
has been the implicit host OS until now; when Linux is selected
as the host OS, KVM support is advertised in capabilies data
exposed to test cases.

This commit doesn't result in any functional change, and simply
sets the stage for introducing macOS host OS support later.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoqemu: Correct CPU capabilities probing for hvf
Roman Bolshakov [Fri, 19 Oct 2018 18:32:03 +0000 (21:32 +0300)]
qemu: Correct CPU capabilities probing for hvf

With this change virsh domcapabilites shows:

  <mode name='host-passthrough' supported='yes'/>

https://gitlab.com/libvirt/libvirt/-/issues/147

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoqemu: Introduce virQEMUCapsHaveAccel
Roman Bolshakov [Fri, 19 Oct 2018 15:10:05 +0000 (18:10 +0300)]
qemu: Introduce virQEMUCapsHaveAccel

The function should be used to check if qemu capabilities include a
hardware acceleration, i.e. accel is not TCG.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoqemu: Introduce virQEMUCapsTypeIsAccelerated
Roman Bolshakov [Fri, 19 Oct 2018 14:30:26 +0000 (17:30 +0300)]
qemu: Introduce virQEMUCapsTypeIsAccelerated

It replaces hardcoded checks for KVM. It'll be cleaner to use
the function once multiple accelerators are supported in the
QEMU driver.

Explicit KVM domain checks should be done only when a feature is
available only for KVM.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoqemu: Introduce virQEMUCapsAccelStr
Roman Bolshakov [Fri, 19 Oct 2018 16:38:33 +0000 (19:38 +0300)]
qemu: Introduce virQEMUCapsAccelStr

This makes possible to add more accelerators by touching less code and
reduces code duplication.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoqemu: Expose hvf domain type if hvf is supported
Roman Bolshakov [Fri, 19 Oct 2018 13:08:17 +0000 (16:08 +0300)]
qemu: Expose hvf domain type if hvf is supported

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoqemu: Query hvf capability on macOS
Roman Bolshakov [Fri, 19 Oct 2018 12:07:53 +0000 (15:07 +0300)]
qemu: Query hvf capability on macOS

There's no QMP command for querying if hvf is supported, therefore we
use sysctl interface that tells if Hypervisor.framework works/available
on the host.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoqemu: Define hvf capability
Roman Bolshakov [Fri, 19 Oct 2018 12:06:26 +0000 (15:06 +0300)]
qemu: Define hvf capability

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoconf: Add hvf domain type
Roman Bolshakov [Thu, 18 Oct 2018 22:14:01 +0000 (01:14 +0300)]
conf: Add hvf domain type

QEMU supports Hypervisor.framework since 2.12 as hvf accel.
Hypervisor.framework provides a lightweight interface to run a virtual
cpu on macOS without the need to install third-party kernel
extensions (KEXTs).

It's supported since macOS 10.10 on machines with Intel VT-x feature
set that includes Extended Page Tables (EPT) and Unrestricted Mode.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoqemu: Add KVM CPUs into cache only if KVM is present
Roman Bolshakov [Wed, 21 Nov 2018 18:45:02 +0000 (21:45 +0300)]
qemu: Add KVM CPUs into cache only if KVM is present

virQEMUCapsFormatCache/virQEMUCapsLoadCache adds/reads KVM CPUs to/from
capabilities cache regardless of QEMU_CAPS_KVM. That can cause undesired
side-effects when KVM CPUs are present in the cache on a platform that
doesn't support it, e.g. macOS or Linux without KVM support.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agoqemu: Only probe KVM on Linux
Andrea Bolognani [Wed, 5 Jan 2022 15:37:51 +0000 (16:37 +0100)]
qemu: Only probe KVM on Linux

We already know it's not going to be available on other
platforms.

Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Tested-by: Brad Laue <brad@brad-x.com>
Tested-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Ani Sinha <ani@anisinha.ca>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
3 years agolibxl: Add lock process indicator to saved VM state
Jim Fehlig [Mon, 24 Jan 2022 19:03:20 +0000 (12:03 -0700)]
libxl: Add lock process indicator to saved VM state

Commit fa58f571ee added a lock processes indicator to the
libxlDomainObjPrivate struct to note that a lock process was
successfully started for the VM. However, the commit neglected to
add the indicator to the VM's saved state file. As a result, the
indicator is lost on libvirtd restart, along with the knowledge of
whether a lock process was started for the VM.

This change adds support for the indicator in the domainObjPrivate
data parse and format callbacks, ensuring its value survives libvirtd
restarts.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>