]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
4 years agodocs: html.in: Convert 'compiling' to rst
Erik Skultety [Fri, 12 Mar 2021 07:34:15 +0000 (08:34 +0100)] 
docs: html.in: Convert 'compiling' to rst

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agodocs: html.in: Convert bindings to rst
Erik Skultety [Fri, 12 Mar 2021 11:09:01 +0000 (12:09 +0100)] 
docs: html.in: Convert bindings to rst

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agodocs: html.in: Convert auditlog to rst
Erik Skultety [Fri, 12 Mar 2021 11:04:40 +0000 (12:04 +0100)] 
docs: html.in: Convert auditlog to rst

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agodocs: html.in: Convert apps to rst
Erik Skultety [Fri, 12 Mar 2021 11:14:57 +0000 (12:14 +0100)] 
docs: html.in: Convert apps to rst

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agodocs: html.in: Convert api to rst
Erik Skultety [Fri, 12 Mar 2021 10:53:13 +0000 (11:53 +0100)] 
docs: html.in: Convert api to rst

There were a number of occurrences where we used nested inline markup
(verbatim + refs) which is currently not possible with RST syntax [1].
There is a possible workaround involving substitution definitions like

  .. |virConnectPtr| replace:: ``virConnectPtr``
  .. _virConnectPtr: /html/libvirt-libvirt-host.html#virConnectPtr

Substitutions cannot be made generic, hence we cannot create a template
for substitution and use a single template everywhere, so we'd end up
with a lot of clutter and convolution. Therefore, we can make an
exception and just link the data type without further style markup.

[1] https://docutils.sourceforge.io/FAQ.html#is-nested-inline-markup-possible

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agodocs: html.in: Convert api_extension to rst
Erik Skultety [Fri, 12 Mar 2021 10:30:33 +0000 (11:30 +0100)] 
docs: html.in: Convert api_extension to rst

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agodocs: html.in: Convert aclpolkit to rst
Erik Skultety [Fri, 12 Mar 2021 10:12:47 +0000 (11:12 +0100)] 
docs: html.in: Convert aclpolkit to rst

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu_driver: fix setting vcpu_quota if not all vCPUs are online
Pavel Hrdina [Mon, 15 Mar 2021 13:10:45 +0000 (14:10 +0100)] 
qemu_driver: fix setting vcpu_quota if not all vCPUs are online

When switching to g_autoptr this was incorrectly changed from
'continue;' into 'return -1;' resulting into an error when user tries
to set vcpu_quota of running VM:

    error: An error occurred, but the cause is unknown

Fixes: e4a8bbfaf2b4cdd741bb441873bb730f9134b714
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agolib: Put some variable declarations on individual lines
Michal Privoznik [Thu, 11 Mar 2021 14:37:07 +0000 (15:37 +0100)] 
lib: Put some variable declarations on individual lines

In short, virXXXPtr type is going away. With big bang. And to
help us rewrite the code with a sed script, it's better if each
variable is declared on its own line.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirconftypes: Fix name of virCapsGuestArchPtr
Michal Privoznik [Thu, 11 Mar 2021 16:40:15 +0000 (17:40 +0100)] 
virconftypes: Fix name of virCapsGuestArchPtr

The name is supposed to be virCapsGuestArchPtr not ..ptr.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agosyntax-check: Fix and rename virSecurity rule
Michal Privoznik [Thu, 11 Mar 2021 07:29:42 +0000 (08:29 +0100)] 
syntax-check: Fix and rename virSecurity rule

The aim of virSecurity rule is to discourage from using plain
virSecurityManager*() APIs within QEMU driver in favor of their
qemuSecurity*() counterparts. The reason is simple: namespaces;
virSecurityManager*() needs additional
virSecurityManagerTransactionCommit() call to enter given
namespace and do its work from there. And that's exactly what
those qemuSecurity*() wrappers do.

To help us ensure correctness (from this POV), we have a
syntax-check rule that forbids any occurrence of
"virSecurityManager" string under src/qemu/ (except for
qemu_security of course).

But with if we want to remove virSecurityManagerPtr type, then we
have to allow "virSecurityManager *". Therefore, change the rule
so that no call of a function with "virSecurityManager" prefix is
allowed. And also change the name to better reflect what is going
on.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agogendispatch: Don't use virXXXPtr for internal types
Michal Privoznik [Wed, 10 Mar 2021 18:20:52 +0000 (19:20 +0100)] 
gendispatch: Don't use virXXXPtr for internal types

The use of virXXXPtr is going away soon, therefore use 'virXXX *'
instead.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirsysinfo: Define and use auto cleanup func for virSysinfoDef properly
Michal Privoznik [Thu, 11 Mar 2021 05:17:07 +0000 (06:17 +0100)] 
virsysinfo: Define and use auto cleanup func for virSysinfoDef properly

What we are using really is heap allocated structure rather than
stack allocated. And for that it's better to use g_autoptr() +
G_DEFINE_AUTOPTR_CLEANUP_FUNC() combo, as Glib documentation for
g_auto() reads:

  This is meant to be used with stack-allocated structures and
  non-pointer types. For the (more commonly used) pointer
  version, see g_autoptr().

This will be even more visible, when virSysinfoDefPtr type is
gone. Stay tuned.

Fixes: cee3a900a0d6a8fc79554db22dc262632fe487a6
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu_shim: Don't hang if failed to start domain
Michal Privoznik [Thu, 25 Feb 2021 14:01:27 +0000 (15:01 +0100)] 
qemu_shim: Don't hang if failed to start domain

The qemu shim spawns a separate thread in which the event loop is
ran. The virEventRunDefaultImpl() call is wrapped in a while()
loop, just like it should. There are few lines of code around
which try to ensure that domain is destroyed (when quitting) and
that the last round of event loop is ran after the
virDomainDestroy() call. Only after that the loop is quit from
and the thread quits.

However, if domain creation fails, there is no @dom to call
destroy over, the @quit flag is never set and while() never
exits. Set the flag regardless of @dom pointer.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1920337
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agoqemu: command: Generate commandline of iothread objects JSON
Peter Krempa [Thu, 26 Nov 2020 18:07:03 +0000 (19:07 +0100)] 
qemu: command: Generate commandline of iothread objects JSON

The commandline generator for 'iothread' objects has a private
implementation of the properties. Convert it to JSON so that it can be
later validated.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: command: Generate commandline of 'sev0' sev-guest object via JSON
Peter Krempa [Thu, 26 Nov 2020 18:07:03 +0000 (19:07 +0100)] 
qemu: command: Generate commandline of 'sev0' sev-guest object via JSON

While the 'sev0' sev-guest object will never be hotplugged, but we want
to generate it through JSON so that we'll be able to validate all
parameters of '-object' against the QAPI schema once 'object-add' is
qapified in qemu.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: command: Generate commandline of 'masterKey0' secret via JSON
Peter Krempa [Thu, 26 Nov 2020 18:07:03 +0000 (19:07 +0100)] 
qemu: command: Generate commandline of 'masterKey0' secret via JSON

While the 'masterKey0' secret object will never be hotplugged we want to
generate it through JSON so that we'll be able to validate all
parameters of '-object' against the QAPI schema once 'object-add' is
qapified in qemu.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirtlo(g|ck)d: Fix exec-restart
Peter Krempa [Wed, 10 Mar 2021 16:14:18 +0000 (17:14 +0100)] 
virtlo(g|ck)d: Fix exec-restart

Commit 94e45d1042e broke exec-restart of virtlogd and virtlockd as the
code waiting for the daemon shutdown closed the daemons before
exec-restarting.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1912243
Fixes: 94e45d1042e
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirnetdaemon: Introduce virNetDaemonQuitExecRestart
Peter Krempa [Wed, 10 Mar 2021 16:01:23 +0000 (17:01 +0100)] 
virnetdaemon: Introduce virNetDaemonQuitExecRestart

Recent changes which meant to fix daemon shutdown broke the exec-restart
capability of virtlogd and virtlockd, since the code actually closed all
the sockets and shut down all the internals.

Add virNetDaemonQuitExecRestart, which requests a shutdown of the
process, but keeps all the services open and registered since they are
preserved across the restart.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu_shim: Always pre-create root dir
Michal Privoznik [Thu, 25 Feb 2021 17:20:51 +0000 (18:20 +0100)] 
qemu_shim: Always pre-create root dir

This problem is reproducible only with secret driver. When
starting a domain via virt-qemu-run and both secret and
(nonexistent) root directory specified this is what happens:

1) virt-qemu-run opens "secret:///embed?root=$rootdir"
   connection, which results in the secret driver initialization
   (done in secretStateInitialize()). During this process, the
   driver creates its own configDir (derived from $rootdir)
   including those parents which don't exists yet. This is all
   done with the mode S_IRWXU and thus results in the $rootdir
   being created with very restrictive mode (specifically, +x is
   missing for group and others).

2) now, virt-qemu-run opens "qemu:///embed?root=$rootdir" and
   calls virDomainCreateXML(). This results in the master-key.aes
   being written somewhere under the $rootdir and telling qemu
   where to find it.

But because the secret driver created $rootdir with too
restrictive mode, qemu can't access the file (even though it
knows the full path) and fails to start.

It looks like the best solution is to pre-create the root
directory before opening any connection (letting any driver
initialize itself) and set its mode to something less
restrictive.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1859873
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agovirConnectOpen: Require root dir to be absolute path
Michal Privoznik [Thu, 25 Feb 2021 15:29:22 +0000 (16:29 +0100)] 
virConnectOpen: Require root dir to be absolute path

In theory, users might want to use a relative path as a root
directory for embed drivers. But in practice, nothing in driver
initialization (specifically QEMU driver since it's the only one
that supports embedding now), is prepared for that. Document and
enforce absolute paths.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1883725
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agodocs: Lift restriction on running API from the event loop thread
Michal Privoznik [Thu, 25 Feb 2021 14:29:16 +0000 (15:29 +0100)] 
docs: Lift restriction on running API from the event loop thread

Since v6.2.0-rc1~238 (and friends) QMP processing was moved to a
per-domain thread. Therefore, it is now safe to call APIs from
the event loop thread (e.g. just like qemu shim is doing in
qemuShimEventLoop(). However, it is still important to let the
event loop run after each API call (obviously).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agovirLockSpaceNewPostExecRestart: Fix out-of-bounds array access
Peter Krempa [Fri, 12 Mar 2021 09:16:11 +0000 (10:16 +0100)] 
virLockSpaceNewPostExecRestart: Fix out-of-bounds array access

'res->owners' is allocated to 'res->nOwners' elements, but unfortunately
'res->nOwners' doesn't contain the proper value until after the
allocation so 0 elements are allocated. The following loop which assumes
that the array has the right number of elements then accesses the
pointer out of bounds. The bug was also faithfully converted from
VIR_ALLOC_N to g_new0.

Fixes: 4a3d6ed5ee0
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirLockSpacePreExecRestart: Avoid use-after-free
Peter Krempa [Fri, 12 Mar 2021 09:12:51 +0000 (10:12 +0100)] 
virLockSpacePreExecRestart: Avoid use-after-free

Recent refactor marked 'object' which is returned from the function as
autofree but forgot to use g_steal_pointer in the return statement to
prevent freeing it.

Fixes: 9a1651f64d7
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuBackupJobTerminate: Fix job termination for inactive VMs
Peter Krempa [Thu, 11 Mar 2021 15:18:50 +0000 (16:18 +0100)] 
qemuBackupJobTerminate: Fix job termination for inactive VMs

Commit cb29e4e801d didn't take into account that the VM can be inactive
when it's destroyed. This means that the job would remain active also
when the VM became inactive.

To fix this properly:

1) Remove the bogus VM liveness check and early return
    (reverts the aforementioned commit)

2) Conditionalize the stats assignment only when the stats object is
   present
    (properly fix the crash when VM dies when reconnecting)

3) end the asyncjob only when it was already set
   (prevent corruption of priv->jobs_queued)

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1937598
Fixes: cb29e4e801d
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agobackup: Store 'apiFlags' in private section of virDomainBackupDef
Peter Krempa [Thu, 11 Mar 2021 15:14:17 +0000 (16:14 +0100)] 
backup: Store 'apiFlags' in private section of virDomainBackupDef

'qemuBackupJobTerminate' needs the API flags to see whether
VIR_DOMAIN_BACKUP_BEGIN_REUSE_EXTERNAL. Unfortunately when called via
qemuProcessReconnect()->qemuProcessStop() early (e.g. if the qemu
process died while we were reconnecting) the job is cleared temporarily
so that other APIs can be called. This would mean that we couldn't clean
up the files in some cases.

Save the 'apiFlags' inside the backup object and set it from the
'qemuDomainJobObj' 'apiFlags' member when reconnecting to a VM.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirsystemdtest: Call at least one virSystemdCreateMachine with 'maxthreads' > 0
Peter Krempa [Wed, 10 Mar 2021 13:37:56 +0000 (14:37 +0100)] 
virsystemdtest: Call at least one virSystemdCreateMachine with 'maxthreads' > 0

There was a bug in the code adding TasksMax property. It remained
undetected because all tests used '0' for @maxthreads.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agovirSystemdCreateMachine: Use proper format string for uint64_t when constructing...
Peter Krempa [Wed, 10 Mar 2021 13:33:06 +0000 (14:33 +0100)] 
virSystemdCreateMachine: Use proper format string for uint64_t when constructing gvariant

g_variant_new_parsed uses '%t' for a uint64_t rather than printf-like
%llu. Additionally ensure that the passed value is a uint64_t since the
argument used is a 'unsigned int'.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1937287
Fixes: bf5f2ed09c2
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoutil: virstring: Remove virStrncpy
Peter Krempa [Tue, 2 Mar 2021 13:26:24 +0000 (14:26 +0100)] 
util: virstring: Remove virStrncpy

The function is now unused and motivated users to write crazy parsers
which were hard to understand, had pointless error paths just to avoid
few memory allocations.

Remove the function as we're fine with g_strndup and virStrcpy.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoxenParseVif: Refactor parser
Peter Krempa [Tue, 2 Mar 2021 10:49:34 +0000 (11:49 +0100)] 
xenParseVif: Refactor parser

Use g_strsplit to split the string and avoid use of stack'd strings.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodocs: Document libxl.conf location
Michal Privoznik [Mon, 8 Mar 2021 17:02:08 +0000 (18:02 +0100)] 
docs: Document libxl.conf location

This is similar to my earlier commit which documented lxc.conf
location. Just like LXC, the libxl driver has only the system
connection and thus only few places need changing.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agomanpages: Remove reference to a session daemon for libxl
Michal Privoznik [Mon, 8 Mar 2021 16:55:00 +0000 (17:55 +0100)] 
manpages: Remove reference to a session daemon for libxl

The libxl driver has no session daemon therefore its split daemon
(virtxend) has to be ran as root. Any attempt to start it with
euid != 0 fails. This is why the daemon does not look under any
of XDG_* paths either.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agodocs: Document lxc.conf location
Michal Privoznik [Mon, 8 Mar 2021 16:13:38 +0000 (17:13 +0100)] 
docs: Document lxc.conf location

This is similar to my earlier commit which documented qemu.conf
locations. Luckily, the LXC driver has only the system connection
and not session or embed one.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agomanpages: Remove reference to a session daemon for LXC
Michal Privoznik [Mon, 8 Mar 2021 16:22:59 +0000 (17:22 +0100)] 
manpages: Remove reference to a session daemon for LXC

The LXC driver has no session daemon therefore its split daemon
(virtlxcd) has to be ran as root. Any attempt to start it with
euid != 0 fails. This is why the daemon does not look under any
of XDG_* paths either.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agodocs: Capitalize QEMU driver reference
Michal Privoznik [Mon, 8 Mar 2021 16:14:47 +0000 (17:14 +0100)] 
docs: Capitalize QEMU driver reference

In official docs we refer to it as "QEMU driver", not "qemu
driver".

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agospec: Drop BuildDepends on make
Andrea Bolognani [Thu, 11 Mar 2021 14:32:57 +0000 (15:32 +0100)] 
spec: Drop BuildDepends on make

make is only used for the syntax-check tests, which we are
explicitly skipping when building RPMs.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agosyntax-check: Update list of gethostname exceptions
Michal Privoznik [Tue, 9 Mar 2021 14:20:57 +0000 (15:20 +0100)] 
syntax-check: Update list of gethostname exceptions

The only place where gethostname() is acceptable is in
virGetHostnameImpl() which lives in src/util/virutil.c.
Reflect this in the list of exceptions for the syntax-check rule.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirutil: Do not use g_get_host_name() to obtain hostname
Michal Privoznik [Tue, 9 Mar 2021 14:11:23 +0000 (15:11 +0100)] 
virutil: Do not use g_get_host_name() to obtain hostname

The problem is that g_get_host_name() caches the hostname in a
thread local variable. Therefore, it doesn't reflect any
subsequent hostname changes. While this might be acceptable for
logs where the hostname is printed exactly once when the libvirtd
starts up, it is not optimal for virGetHostnameImpl() which is
what our public virConnectGetHostname() API calls. If the
hostname at the moment of the first API invocation happens to
start with "localhost" or contains a dot, then no further
hostname changes will ever be reflected.

This reverts 26d9748ff11, partially.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirNetLibsshAuthenticatePrivkeyCb: Use virStrcpy instead of virStrncpy
Peter Krempa [Tue, 2 Mar 2021 13:24:27 +0000 (14:24 +0100)] 
virNetLibsshAuthenticatePrivkeyCb: Use virStrcpy instead of virStrncpy

We already assume that 'retr_passphrase.result' is a string, thus we can
use virStrcpy instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirNetLibsshAuthenticatePrivkeyCb: Use g_autofree for 'actual_prompt'
Peter Krempa [Tue, 2 Mar 2021 13:18:05 +0000 (14:18 +0100)] 
virNetLibsshAuthenticatePrivkeyCb: Use g_autofree for 'actual_prompt'

So that the 'error' label can be removed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoxenParseXLUSB: Rewrite to avoid virStrncpy
Peter Krempa [Tue, 2 Mar 2021 13:10:00 +0000 (14:10 +0100)] 
xenParseXLUSB: Rewrite to avoid virStrncpy

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoxenParseXLUSBController: Avoid use of virStrncpy
Peter Krempa [Tue, 2 Mar 2021 13:04:42 +0000 (14:04 +0100)] 
xenParseXLUSBController: Avoid use of virStrncpy

Use g_strndup with a freed buffer instead of the more complex approach
using virStrncpy.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoxenParseXLChannel: Use g_strndup instead of virStrncpy
Peter Krempa [Tue, 2 Mar 2021 12:41:22 +0000 (13:41 +0100)] 
xenParseXLChannel: Use g_strndup instead of virStrncpy

Make the temporary string an autofree-ing pointer and copy the contents.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoopenvzReadNetworkConf: Rework parser
Peter Krempa [Tue, 2 Mar 2021 12:33:07 +0000 (13:33 +0100)] 
openvzReadNetworkConf: Rework parser

Rewrite so that the parser doesn't use virStrncpy by employing
g_strsplit.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoxenParseSxprSound: Refactor parsing of model list
Peter Krempa [Tue, 2 Mar 2021 11:04:41 +0000 (12:04 +0100)] 
xenParseSxprSound: Refactor parsing of model list

Copy the input string so that we don't have to use a static buffer and
virStrncpy.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoAdd 'interleave' to the sub-element for video device in rng file
Kristina Hanicova [Thu, 11 Mar 2021 13:04:03 +0000 (14:04 +0100)] 
Add 'interleave' to the sub-element for video device in rng file

Previously, validation of XML failed if sub-elements of video
device were in different order.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1825769
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoXML validate that 'ramfb' has no address
Kristina Hanicova [Fri, 5 Mar 2021 12:01:21 +0000 (13:01 +0100)] 
XML validate that 'ramfb' has no address

With this, XML fails if config video type 'ramfb' contains
address, since address is not supported for 'ramfb' video
devices. Previously it didn't raise error.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1891416
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agovirQEMUCapsInitQMPArch: Refactor cleanup
Yi Li [Wed, 10 Mar 2021 07:46:29 +0000 (15:46 +0800)] 
virQEMUCapsInitQMPArch: Refactor cleanup

Switch to using the 'g_auto*' helpers.

Signed-off-by: Yi Li <yili@winhong.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: wire up support for backend specific audio settings
Daniel P. Berrangé [Tue, 2 Mar 2021 17:44:04 +0000 (17:44 +0000)] 
qemu: wire up support for backend specific audio settings

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoconf: add support for audio backend specific settings
Daniel P. Berrangé [Tue, 2 Mar 2021 17:34:21 +0000 (17:34 +0000)] 
conf: add support for audio backend specific settings

This pulls in the remaining QEMU audio backend specific settings to the
XML schema.

    <audio id="1" type="alsa">
      <input dev="/dev/dsp0"/>
      <output dev="/dev/dsp1"/>
    </audio>

    <audio id="1" type="coreaudio">
      <input bufferCount="50"/>
      <output bufferCount="42"/>
    </audio>

    <audio id="1" type="file" path="audio.wav"/>

    <audio id="1" type="jack">
      <input serverName="fish" clientName="food" connectPorts="yum"/>
      <output serverName="fish" clientName="food" connectPorts="yum"/>
    </audio>

    <audio id="1" type="oss" tryMMap="yes" exclusive="yes" dspPolicy="3">
      <input dev="/dev/dsp0" bufferCount="50" tryPoll="yes"/>
      <output dev="/dev/dsp1" bufferCount="30" tryPoll="no"/>
    </audio>

    <audio id="1" type="pulseaudio" serverName="acme.example.org">
      <input name="fish" streamName="food" latency="100"/>
      <output name="fish" streamName="food" latency="200"/>
    </audio>

    <audio type='sdl' id='1' driver='pulseaudio'>
      <input bufferCount='40'/>
      <output bufferCount='40'/>
    </audio>

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: wire up support for common audio backend settings
Daniel P. Berrangé [Tue, 2 Mar 2021 17:22:47 +0000 (17:22 +0000)] 
qemu: wire up support for common audio backend settings

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoconf: introduce support for common audio settings
Daniel P. Berrangé [Tue, 2 Mar 2021 16:04:54 +0000 (16:04 +0000)] 
conf: introduce support for common audio settings

This introduces support for the QEMU audio settings that are common to
all audio backends. These are expressed in the QAPI schema as settings
common to all backends, but in reality some backends ignore some of
them. For example, some backends are output only. The parser isn't
attempting to apply restrictions that QEMU itself doesn't apply.

    <audio id='1' type='pulseaudio'>
      <input mixingEngine='yes' fixedSettings='yes' voices='1' bufferLength='100'>
        <settings frequency='44100' channels='2' format='s16'/>
      </input>
      <output mixingEngine='yes' fixedSettings='yes' voices='2' bufferLength='100'>
        <settings frequency='22050' channels='4' format='f32'/>
      </output>
    </audio>

The <settings> child is only valid if fixedSettings='yes'

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: add support for generating -audiodev arguments
Daniel P. Berrangé [Wed, 24 Feb 2021 14:40:19 +0000 (14:40 +0000)] 
qemu: add support for generating -audiodev arguments

The -audiodev argument is replacing the QEMU_AUDIO_DRV env variable (and
its relations).

Sadly we still have to use the SDL_AUDIODRIVER env variable because that
wasn't mapped into QAPI schema.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: probe for -vnc audiodev property
Daniel P. Berrangé [Tue, 23 Feb 2021 16:16:28 +0000 (16:16 +0000)] 
qemu: probe for -vnc audiodev property

The -audiodev arg is a new way to configure audio devices in QEMU to
replace the QEMU_AUDIO_DRV env variable. This arg is not visible in
the "query-command-line-options" output since it is entirely QAPI
driven, not QemuOpts. It also isn't in "query-qmp-schema" though
since there's no QMP command that uses the Audiodev type yet.

So probe for the existance of this feature by looking for the
-vnc "audiodev" property. This won't let us determine which
precise audio backends QEMU has been built with, but for now
that's no worse than with env variables today.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: populate <audio> element with default config
Daniel P. Berrangé [Wed, 24 Feb 2021 14:24:10 +0000 (14:24 +0000)] 
qemu: populate <audio> element with default config

Currently the QEMU driver secretly sets the QEMU_AUDIO_DRV env variable

 - VNC - set to "none", unless passthrough of host env variable is set
 - SPICE - always set to "spice"
 - SDL - always passthrough host env
 - No graphics - set to "none", unless passthrough of host env variable is set

The setting of the QEMU_AUDIO_DRV env variable is done in the code which
configures graphics.

If no <audio> element is present, we now auto-populate <audio> elements
to reflect this historical default config. This avoids need to set audio
env when processing graphics.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: support use of <audio> elements
Daniel P. Berrangé [Tue, 23 Feb 2021 18:32:25 +0000 (18:32 +0000)] 
qemu: support use of <audio> elements

Currently the QEMU driver secretly sets the QEMU_AUDIO_DRV env variable
depending on how <graphics> are configured.

This introduces support for configuring audio backends from the <audio>
elements in the XML config.

The existing default behaviour is now only used if no <audio> element is
present.

All except the 'jack' audio driver are supported via QEMU's old env
variable config.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoconf: rename and improve virDomainDefFindAudioForSound
Daniel P. Berrangé [Wed, 3 Mar 2021 18:06:17 +0000 (18:06 +0000)] 
conf: rename and improve virDomainDefFindAudioForSound

The virDomainDefFindAudioForSound only takes a virDomainSoundDefPtr as
its arg, but we want to use the same functionality for VNC graphics.
In addition if audio ID is zero, then we want to return the first
available audio backend.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoconf: add validation of audio backend IDs
Daniel P. Berrangé [Wed, 24 Feb 2021 17:20:53 +0000 (17:20 +0000)] 
conf: add validation of audio backend IDs

Validate that if a non-zero audio ID is given for <sound> or <graphics>
elements, it must map to an <audio> backend that exists.

Validate that audio IDs given in <audio> are unique.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoconf: add support for audio backend for the VNC server
Daniel P. Berrangé [Wed, 24 Feb 2021 17:19:55 +0000 (17:19 +0000)] 
conf: add support for audio backend for the VNC server

When there are multiple <audio> backends specified, it is possible to
assign a specific one to the VNC server using

  <graphics type='vnc'...>
    <audio id='1'/>
  </graphics>

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoconf: add coverage for all QEMU audio backend types
Daniel P. Berrangé [Tue, 23 Feb 2021 17:50:21 +0000 (17:50 +0000)] 
conf: add coverage for all QEMU audio backend types

The current <audio> element only allows an "OSS" audio backend, as this
is all that BHyve needed. This is now extended to cover most QEMU audio
backends. These backends all have a variety of attributes they support,
but this initial impl does the bare minimum, relying on built-in
defaults for everything. The only QEMU backend omitted is "dsound" since
the libvirt QEMU driver is not built on Windows platforms.

The SDL audio driver names are based on the SDL 2.0 drivers. It is not
intended to support SDL 1.2 drivers.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoconf: refactor OSS audio backend specific options
Daniel P. Berrangé [Tue, 2 Mar 2021 14:59:28 +0000 (14:59 +0000)] 
conf: refactor OSS audio backend specific options

To prepare for the introduction for more backend specific audio options,
move the OSS options into a dedicated struct and introduce separate
helper methods for parse/format/free.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoconf: add missing iteration over audio backends
Daniel P. Berrangé [Tue, 2 Mar 2021 13:48:42 +0000 (13:48 +0000)] 
conf: add missing iteration over audio backends

Fixes 9375bc7373caddd31f1ac5c14a69eac5096ea416
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoconf: add helper to test for sound device codec support
Daniel P. Berrangé [Tue, 2 Mar 2021 13:46:28 +0000 (13:46 +0000)] 
conf: add helper to test for sound device codec support

The check for ICH6 || ICH9 is repeated in many places in the code. The
new virDomainSoundModelSupportsCodecs() method provides a helper to
standardize this check.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoconf: don't force existance of audio child elements
Daniel P. Berrangé [Wed, 24 Feb 2021 13:05:01 +0000 (13:05 +0000)] 
conf: don't force existance of audio child elements

The attributes on the elements are optional, so we should not force the
elements themselves to be present, especially since we omit them when
formating the XML thus breaking round-tripping.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoconf: stronger error reporting when parsing audio related params
Daniel P. Berrangé [Tue, 23 Feb 2021 18:54:53 +0000 (18:54 +0000)] 
conf: stronger error reporting when parsing audio related params

Check for varuous mandatory elements and improve error message
clarity

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoconfig: cleanup some typos / baggage wrt compiler checks
Daniel P. Berrangé [Tue, 23 Feb 2021 16:15:43 +0000 (16:15 +0000)] 
config: cleanup some typos / baggage wrt compiler checks

We had a copy and paste mistake from code we mirrored from QEMU, as well
as failing to remove an earlier redundant check.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: add per-vcpu delay stats
Aleksei Zakharov [Fri, 19 Feb 2021 20:08:34 +0000 (23:08 +0300)] 
qemu: add per-vcpu delay stats

This patch adds delay time (steal time inside guest) to libvirt
domain per-vcpu stats. Delay time is an important performance metric.
It is a consequence of the overloaded CPU. Knowledge of the delay
time of a virtual machine helps to understand if it is affected and
estimate the impact.

As a result, it is possible to react exactly when needed and
rebalance the load between hosts. This is used by cloud providers
to provide quality of service, especially when the CPU is
oversubscribed.

It's more convenient to work with this metric in a context of a
libvirt domain. Any monitoring software may use this information.

Signed-off-by: Aleksei Zakharov <zaharov@selectel.ru>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoutil: Fix error reporting in virnetlink
Andrea Bolognani [Tue, 9 Mar 2021 10:18:53 +0000 (11:18 +0100)] 
util: Fix error reporting in virnetlink

The preprocessor macro we use to check whether we're on Linux
has not been spelled properly, and so we will always report the
error message intended for other platforms.

Fixes: 879bcee08ce0f91f556fddfe452c3fbed5318468
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuMigrationSrcRun: Don't jump to 'exit_monitor' from outside of the monitor
Peter Krempa [Mon, 1 Mar 2021 13:52:03 +0000 (14:52 +0100)] 
qemuMigrationSrcRun: Don't jump to 'exit_monitor' from outside of the monitor

Failure of 'qemuMigrationSetDBusVMState' would jump to 'exit_monitor'
but the function isn't called inside of the monitor context.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agodomaincapstest: Return EXIT_SUCCESS / EXIT_FAILURE instead of -1
Peter Krempa [Tue, 9 Mar 2021 11:51:48 +0000 (12:51 +0100)] 
domaincapstest: Return EXIT_SUCCESS / EXIT_FAILURE instead of -1

The value is used as return value for the process itself.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agomeson: Add documentation installation directory option
Chris Mayo [Fri, 26 Feb 2021 19:11:06 +0000 (19:11 +0000)] 
meson: Add documentation installation directory option

Allow the directory to be chosen at installation time, to support local
conventions e.g. versioning.

Signed-off-by: Chris Mayo <aklhfex@gmail.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirnetdevbandwidth: Don't generate burst outside of boundaries
Michal Privoznik [Fri, 5 Mar 2021 09:13:36 +0000 (10:13 +0100)] 
virnetdevbandwidth: Don't generate burst outside of boundaries

When generating TC rules for domain's outbound traffic, Libvirt
will use the 'average' as the default for 'burst' - it's been
this way since the feature introduction in v0.9.4-rc1~22. The
reason is that 'average' considers 'burst' for policing. However,
when parsing its command line TC uses an unsigned int (with
overflow detection) to store the 'burst' size. This means, that
the upper limit for the value is UINT_MAX, well UINT_MAX / 1024
because we are putting the value in KiB onto the command line.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1912210
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agotests: Mock virProcessGetMaxMemLock()
Andrea Bolognani [Fri, 5 Mar 2021 16:55:39 +0000 (17:55 +0100)] 
tests: Mock virProcessGetMaxMemLock()

Up until now we've implicitly relied on the fact that failures
reported from this function were simply ignored, but that's
about to change and so we need a proper mock.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoconf: Rename original_memlock -> originalMemlock
Andrea Bolognani [Fri, 5 Mar 2021 15:08:19 +0000 (16:08 +0100)] 
conf: Rename original_memlock -> originalMemlock

That's more consistent with our usual naming convention.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoutil: Don't special-case setting a limit to zero
Andrea Bolognani [Tue, 2 Mar 2021 17:44:00 +0000 (18:44 +0100)] 
util: Don't special-case setting a limit to zero

This behavior reflects the needs of the QEMU driver and has no
place in a generic module such as virProcess.

Thanks to the changes made with the previous commit, it is now
safe to remove these checks and make all virProcessSetMax*()
functions finally behave the same way.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: Set limits only when explicitly asked to do so
Andrea Bolognani [Tue, 2 Mar 2021 17:20:47 +0000 (18:20 +0100)] 
qemu: Set limits only when explicitly asked to do so

The current code is written under the assumption that, for all
limits except the core size, asking for the limit to be set to
zero is a no-op, and so the operation is performed
unconditionally.

While this is the behavior we want for the QEMU driver, the
virCommand and virProcess facilities are generic, and should not
implement this kind of policy: asking for a limit to be set to
zero should result in that limit being set to zero every single
time.

Add some checks in the QEMU driver, effectively moving the
policy where it belongs.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoutil: Have virCommand remember whether limits are set
Andrea Bolognani [Tue, 2 Mar 2021 17:18:34 +0000 (18:18 +0100)] 
util: Have virCommand remember whether limits are set

Currently this only happens for the core size, but we want the
behavior to be consistent for other limits as well.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: Set all limits at the same time
Andrea Bolognani [Tue, 2 Mar 2021 17:57:51 +0000 (18:57 +0100)] 
qemu: Set all limits at the same time

qemuProcessLaunch() is the correct place to set process limits,
and in fact is where we were dealing with almost all of them,
but the memory locking limit was handled in
qemuBuildCommandLine() instead for some reason.

The code is rewritten so that the desired limit is calculated
and applied in separated steps, which will help with further
changes, but this doesn't alter the behavior.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: Make some minor tweaks
Andrea Bolognani [Tue, 2 Mar 2021 17:56:06 +0000 (18:56 +0100)] 
qemu: Make some minor tweaks

Doing this now will make the next changes nicer.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoutil: Introduce virProcess{Get,Set}Limit()
Andrea Bolognani [Tue, 23 Feb 2021 17:52:26 +0000 (18:52 +0100)] 
util: Introduce virProcess{Get,Set}Limit()

These functions abstract part of the existing logic, which is
the same in all virProcessSetMax*() functions, and changes it
so that which underlying syscall is used depends on their
availability rather than on the context in which they are
called: since prlimit() and {g,s}etrlimit() have slightly
different requirements, using the same one every single time
should make for a more consistent experience.

As part of the change, we also remove the special case for
passing zero to virProcessSetMax*() functions: we have removed
all callers that depended on that functionality in the previous
commit, so this is now safe to do and makes the semantics
simpler.

This commit is better viewed with 'git show -w'.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoutil: Always pass a pid to virProcessSetMax*()
Andrea Bolognani [Mon, 1 Mar 2021 11:03:18 +0000 (12:03 +0100)] 
util: Always pass a pid to virProcessSetMax*()

Currently, the functions accept either an explicit pid or zero,
in which case the current process should be modified: the latter
might sound like a convenient little feature, but in reality
obtaining the pid of the current process is a single additional
function call away, so it hardly makes a difference.

Removing the few cases in which we're passing zero will allow us
to simplify and improve the functions later.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: wire up support for VNC power control options
Daniel P. Berrangé [Tue, 16 Feb 2021 13:38:06 +0000 (13:38 +0000)] 
qemu: wire up support for VNC power control options

This allows the VNC client user to perform a shutdown, reboot and reset
of the VM from the host side.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: probe for -vnc power-control option support
Daniel P. Berrangé [Tue, 16 Feb 2021 13:34:26 +0000 (13:34 +0000)] 
qemu: probe for -vnc power-control option support

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoconf: add support for VNC power control setting
Daniel P. Berrangé [Tue, 16 Feb 2021 10:37:46 +0000 (10:37 +0000)] 
conf: add support for VNC power control setting

The <graphics type="vnc" .... powerControl="yes"/> option instructs the
VNC server to enable an extension that lets the client perform a
graceful shutdown, reboot and hard reset.

This is enabled by default since it cannot be assumed that the VNC
client user has administrator rights over the guest OS. In the case
where the VNC user is a guest administrator though, it is reasonable
to allow direct power control host side too.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoutil: Simplify stubs
Andrea Bolognani [Tue, 23 Feb 2021 16:54:56 +0000 (17:54 +0100)] 
util: Simplify stubs

Calling a stub should always result in ENOSYS being raised,
regardless of what arguments are passed to it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoutil: Document limit-related functions
Andrea Bolognani [Tue, 23 Feb 2021 18:28:17 +0000 (19:28 +0100)] 
util: Document limit-related functions

We're going to change their behavior, so it's good to have the
current one documented to serve as baseline.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoTranslated using Weblate (Finnish)
Ricky Tigg [Sun, 7 Mar 2021 17:01:49 +0000 (18:01 +0100)] 
Translated using Weblate (Finnish)

Currently translated at 17.1% (1811 of 10545 strings)

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

Translated using Weblate (Finnish)

Currently translated at 17.1% (1810 of 10545 strings)

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

Co-authored-by: Ricky Tigg <ricky.tigg@gmail.com>
Signed-off-by: Ricky Tigg <ricky.tigg@gmail.com>
4 years agoAdded translation using Weblate (Sinhala)
Hela Basa [Sun, 7 Mar 2021 17:01:48 +0000 (18:01 +0100)] 
Added translation using Weblate (Sinhala)

Co-authored-by: Hela Basa <r45xveza@pm.me>
Signed-off-by: Hela Basa <r45xveza@pm.me>
4 years agovirDevMapperGetTargetsImpl: Use correct length when copying into dm.name
Michal Privoznik [Sat, 6 Mar 2021 10:47:59 +0000 (11:47 +0100)] 
virDevMapperGetTargetsImpl: Use correct length when copying into dm.name

For reasons unknown, when rewriting this code and dropping
libdevmapper I've mistakenly used incorrect length of dm.name. In
linux/dm-ioctl.h the dm_ioctl struct is defined as follows:

  #define DM_NAME_LEN 128

  struct dm_ioctl {
    ...
    char name[DM_NAME_LEN];     /* device name */
    ...
  };

However, when copying string into this member, DM_TABLE_DEPS was
used, which is defined as follows:

  #define DM_TABLE_DEPS    _IOWR(DM_IOCTL, DM_TABLE_DEPS_CMD, struct dm_ioctl)

After decryption, this results in the following size: 3241737483.

Fixes: 22494556542c676d1b9e7f1c1f2ea13ac17e1e3e
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agomeson: tools: depend on keycode generated sources
Roman Bogorodskiy [Wed, 3 Mar 2021 02:40:01 +0000 (06:40 +0400)] 
meson: tools: depend on keycode generated sources

Tools depend on keycode generated sources, so declare that as an
explicit dependency, otherwise it might fail with:

../tools/virsh-completer-domain.c:35:10: fatal error: 'virkeynametable_linux.h' file not found
         ^~~~~~~~~~~~~~~~~~~~~~~~~

Fixes: b0f4cf25a6c17907d16523e0fa3c10e253f81f8b
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirFirewallApply: Fix possible NULL dereference on error
Peter Krempa [Fri, 5 Mar 2021 09:38:49 +0000 (10:38 +0100)] 
virFirewallApply: Fix possible NULL dereference on error

Commit bbc25f0d03d443efd35381463efc81b01cb6ae96 juggled around some
error reporting. Unfortunately virFirewallApply tries to report the
errno stored in the firewall object and we'd try to do that when the
firewall object is NULL too. Report EINVAL if 'firewall' is NULL.

Found by Coverity.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agovirBufferAdd: Ensure that the buffer is initialized also when len == 0
Peter Krempa [Thu, 4 Mar 2021 17:09:42 +0000 (18:09 +0100)] 
virBufferAdd: Ensure that the buffer is initialized also when len == 0

There's an optimization in virBufferAdd which returns early when the
length of the added string is 0 (given that auto-indent is disabled).

The optimization causes inconsistent behaviour between these two cases:

 virBufferAdd(buf, "", 0);  // this doesn't initialize the buffer

and

 virBufferAdd(buf, "", -1); //this initializes the buffer

Since using an empty string is used to prime the buffer to an empty
string it can be confusing. Remove the optimization.

This fixes such a wrong initialization done in x86FeatureNames.

Note that our code in many places expects that if no virBuffer APIs are
used on a buffer object, then NULL should be retured, so we can't always
prime the buffer to an empty string.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agotests: Don't return -1 as program return value
Peter Krempa [Thu, 4 Mar 2021 17:52:32 +0000 (18:52 +0100)] 
tests: Don't return -1 as program return value

In cases we use -1 for failure internally we still must return
EXIT_FAILURE.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoconf: Rewrite network virtio driver formatting using virXMLFormatElement
Peter Krempa [Thu, 4 Mar 2021 17:33:44 +0000 (18:33 +0100)] 
conf: Rewrite network virtio driver formatting using virXMLFormatElement

Simplify the logic picking which element form to format by using
virBuffers for the partial properties and virXMLFormatElement for
combining them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agocommandhelper: printCwd: Print result directly instead of copying it
Peter Krempa [Wed, 3 Mar 2021 10:36:22 +0000 (11:36 +0100)] 
commandhelper: printCwd: Print result directly instead of copying it

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirHostCPUGetStatsLinux: Avoid 'strcpy'
Peter Krempa [Wed, 3 Mar 2021 10:14:33 +0000 (11:14 +0100)] 
virHostCPUGetStatsLinux: Avoid 'strcpy'

Use an allocated buffer for 'cpu_header' so that g_strdup(_printf) can
be used to fill it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoremote_daemon_dispatch: Replace g_new + strcpy with g_strdup
Peter Krempa [Wed, 3 Mar 2021 10:06:31 +0000 (11:06 +0100)] 
remote_daemon_dispatch: Replace g_new + strcpy with g_strdup

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirIndexToDiskName: Use g_string_prepend(_c) to improve readability
Peter Krempa [Wed, 3 Mar 2021 09:52:51 +0000 (10:52 +0100)] 
virIndexToDiskName: Use g_string_prepend(_c) to improve readability

Use a dynamic string helper so that we don't have to calculate the
string lengths and then iterate from the rear.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirIndexToDiskName: Make 'idx' unsigned and remove check
Peter Krempa [Wed, 3 Mar 2021 09:20:00 +0000 (10:20 +0100)] 
virIndexToDiskName: Make 'idx' unsigned and remove check

We can remove the check that 'idx' is negative by forcing callers to
pass unsigned numbers, which they do already or have a check that 'idx'
is positive.

This in turn allows us to remove most return value NULL checks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocommandtest: test27: Remove pointless 'cleanup' label
Peter Krempa [Mon, 1 Mar 2021 10:09:02 +0000 (11:09 +0100)] 
commandtest: test27: Remove pointless 'cleanup' label

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