]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
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>
4 years agovirCommandSetSendBuffer: Provide saner semantics
Peter Krempa [Mon, 1 Mar 2021 10:04:54 +0000 (11:04 +0100)] 
virCommandSetSendBuffer: Provide saner semantics

The function is used to automatically feed a buffer into a pipe which
can be used by the command to read contents of the buffer.

Rather than passing in a pipe, let's create the pipe inside
virCommandSetSendBuffer and directly associate the reader end with the
command. This way the ownership of both ends of the pipe will end up
with the virCommand right away reducing the need of cleanup in callers.

The returned value then can be used just to format the appropriate
arguments without worrying about cleanup or failure.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirCommandFDSet: Remove return value
Peter Krempa [Tue, 23 Feb 2021 15:18:57 +0000 (16:18 +0100)] 
virCommandFDSet: Remove return value

The function can't fail nowadays. Remove the return value and adjust the
only caller which ensures that @cmd is non-NULL and @fd is positive.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirCommandAddEnvBuffer: Remove unused function
Peter Krempa [Tue, 23 Feb 2021 09:20:13 +0000 (10:20 +0100)] 
virCommandAddEnvBuffer: Remove unused function

Last usage was removed by 5745dc123a4798db36dd

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: vircommand: Add wrappers for virCommand error checking
Peter Krempa [Tue, 23 Feb 2021 09:52:14 +0000 (10:52 +0100)] 
util: vircommand: Add wrappers for virCommand error checking

Extract the check and reporting of error from the individual virCommand
APIs into a separate helper. This will aid future refactors.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirPipeImpl: Don't overwrite error
Peter Krempa [Mon, 1 Mar 2021 09:25:18 +0000 (10:25 +0100)] 
virPipeImpl: Don't overwrite error

If WITH_PIPE2 is not defined we attempt to set the pipe to nonblocking
operation after they are created. We errorneously rewrote the existing
error message on failure to do so or even reported an error if quiet
mode was requested.

Fixes: ab36f729470c313b9d5b7debdbeac441f7780dec
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: virerror: Remove VIR_ERROR_MAX_LENGTH macro
Peter Krempa [Tue, 23 Feb 2021 14:45:12 +0000 (15:45 +0100)] 
util: virerror: Remove VIR_ERROR_MAX_LENGTH macro

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuProcessReportLogError: Don't mark "%s: %s" as translatable
Peter Krempa [Thu, 25 Feb 2021 16:52:47 +0000 (17:52 +0100)] 
qemuProcessReportLogError: Don't mark "%s: %s" as translatable

The function is constructing an error message from a prefix and the
contents of the qemu log file. Marking just two string modifiers as
translatable is pointless and will certainly confuse translators.

Remove the marking and add a comment which bypasses the
sc_libvirt_unmarked_diagnostics check.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemuProcessReportLogError: Remove unnecessary math for max error message
Peter Krempa [Tue, 23 Feb 2021 14:27:07 +0000 (15:27 +0100)] 
qemuProcessReportLogError: Remove unnecessary math for max error message

Now that error message formatting doesn't use fixed size buffers we can
drop the math for calculating the maximum chunk of log to report in the
error message and use a round number. This also makes it obvious that
the chosen number is arbitrary.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: virprocess: Use local maximum error message size
Peter Krempa [Tue, 23 Feb 2021 14:21:13 +0000 (15:21 +0100)] 
util: virprocess: Use local maximum error message size

Use of VIR_ERROR_MAX_LENGTH is actually misleading to the readers
because it implies that the strings in virError are 1024 bytes at most.

That isn't true at least for the 'message' field as it's constructed
from concatenating the detail string which (was) max 1024 bytes with
the string variant of the error code without limiting to 1024.

Use a local copy for declaring the struct for error transport with a
comment so that's obvious that it's a local decision to use 1k buffers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: virerror: Avoid a copy of the error messages
Peter Krempa [Thu, 25 Feb 2021 16:20:12 +0000 (17:20 +0100)] 
util: virerror: Avoid a copy of the error messages

Some error message reporting functions already have allocated buffers
which were used to format the error message, so copying the strings is
redundant.

Extract the internals from 'virRaiseErrorFull' to
'virRaiseErrorInternal' which takes allocated strings as arguments and
steals them, so that callers can reuse the buffers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: virerror: Don't use stack'd buffers in error report helpers
Peter Krempa [Tue, 23 Feb 2021 14:38:02 +0000 (15:38 +0100)] 
util: virerror: Don't use stack'd buffers in error report helpers

This was (probably) a relict from times when we cared about OOM
conditions and the possibility to report the error. Nowadays it doesn't
make sense as virRaiseErrorFull will do an allocated copy of the strings
and also concatenate the error message prefix with the detail which
doesn't guarantee that the result will be less than 1024 chars.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agotest_driver: Rewrite testBuildFilename
Peter Krempa [Tue, 2 Mar 2021 12:13:50 +0000 (13:13 +0100)] 
test_driver: Rewrite testBuildFilename

Use glib functions to do the relative name lookup instead of manual
assembly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoxenParseXMDisk: Replace g_new + virStrncpy by g_strndup
Peter Krempa [Tue, 2 Mar 2021 11:08:28 +0000 (12:08 +0100)] 
xenParseXMDisk: Replace g_new + virStrncpy by g_strndup

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirFileLoopDeviceAssociate: Use virStrcpy instead of virStrncpy
Peter Krempa [Tue, 2 Mar 2021 11:50:36 +0000 (12:50 +0100)] 
virFileLoopDeviceAssociate: Use virStrcpy instead of virStrncpy

Passing 'strlen(src)' for length makes it equivalent to virStrcpy.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirDevMapperGetTargetsImpl: Use virStrcpy instead of virStrncpy
Peter Krempa [Tue, 2 Mar 2021 11:49:05 +0000 (12:49 +0100)] 
virDevMapperGetTargetsImpl: Use virStrcpy instead of virStrncpy

virStrncpy was called with -1 for length of the copied source which is
equivalent to virStrcpy.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agosanlock: Use virStrcpy instead of virStrncpy
Peter Krempa [Tue, 2 Mar 2021 11:12:11 +0000 (12:12 +0100)] 
sanlock: Use virStrcpy instead of virStrncpy

We want a (possibly truncated) copy of the full source string so
virStrcpy is a better fit.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agovirProcessRunInForkHelper: Use virStrcpyStatic for static buffers
Peter Krempa [Tue, 2 Mar 2021 10:14:54 +0000 (11:14 +0100)] 
virProcessRunInForkHelper: Use virStrcpyStatic for static buffers

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: virstring: Always copy string in virStrcpy
Peter Krempa [Tue, 2 Mar 2021 10:00:23 +0000 (11:00 +0100)] 
util: virstring: Always copy string in virStrcpy

15 out of 72 invocations of virStrcpy(Static) ignore the return value as
it's either impossible to fail or in certain cases a truncated copy is
still good enough. Unfortunately virStrcpy doesn't copy anything in
such case as the checks are done first.

Fix this by using g_strlcpy for the implementation and removing
G_GNUC_WARN_UNUSED_RESULT from the function so that callers can decide
when it's okay.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agodocs: Document qemu.conf locations
Michal Privoznik [Thu, 4 Mar 2021 19:32:29 +0000 (20:32 +0100)] 
docs: Document qemu.conf locations

Surprisingly, we never documented the relationship between
connection URI and the location of qemu.conf. Users might wonder
what qemu.conf is loaded when they are connecting to the session
daemon or embed URI. And what to do if the file doesn't exist for
the URI they're using.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agoglib: Use safe glib event workaround in other event loops
Martin Kletzander [Thu, 4 Mar 2021 09:00:06 +0000 (10:00 +0100)] 
glib: Use safe glib event workaround in other event loops

Similarly to the crash workaround:

  commit 0db4743645b7a0611a3c0687f834205c9956f7fc
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Tue Jul 28 16:52:47 2020 +0100

    util: avoid crash due to race in glib event loop code

we need to do this in the other event loop as crash in that one was also
reported:

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoutil: Move glib event loop workaround to glibcompat
Martin Kletzander [Thu, 4 Mar 2021 08:34:19 +0000 (09:34 +0100)] 
util: Move glib event loop workaround to glibcompat

This way it can be used from other places as well.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoutil: Drop virFileMakePath() and virFileMakePathWithMode()
Michal Privoznik [Fri, 26 Feb 2021 08:30:07 +0000 (09:30 +0100)] 
util: Drop virFileMakePath() and virFileMakePathWithMode()

These functions are now unused.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agolib: Replace virFileMakePath() with g_mkdir_with_parents()
Michal Privoznik [Fri, 26 Feb 2021 08:37:10 +0000 (09:37 +0100)] 
lib: Replace virFileMakePath() with g_mkdir_with_parents()

Generated using the following spatch:

  @@
  expression path;
  @@
  - virFileMakePath(path)
  + g_mkdir_with_parents(path, 0777)

However, 14 occurrences were not replaced, e.g. in
virHostdevManagerNew(). I don't really understand why.
Fixed by hand afterwards.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agolib: Replace virFileMakePathWithMode() with g_mkdir_with_parents()
Michal Privoznik [Fri, 26 Feb 2021 08:17:30 +0000 (09:17 +0100)] 
lib: Replace virFileMakePathWithMode() with g_mkdir_with_parents()

These functions are identical. Made using this spatch:

  @@
  expression path, mode;
  @@
  - virFileMakePathWithMode(path, mode)
  + g_mkdir_with_parents(path, mode)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agobuild: Require glib >= 2.56
Jim Fehlig [Mon, 1 Mar 2021 22:57:05 +0000 (15:57 -0700)] 
build:  Require glib >= 2.56

There are a few uses of g_autoslist in the qemu driver and likely more
will come throughout the codebase in the future. g_autoslist first
appeared in glib 2.56, so bump the minimum version

https://developer.gnome.org/glib/stable/glib-Miscellaneous-Macros.html#g-autoslist

Bumping the minimum version is an opportune time to update the list of
minimum glib versions found on the distros targeted by libvirt's
platform support policy

   RHEL-7: 2.56.1
   RHEL-8: 2.56.4
   Debian (Buster): 2.58.3
   OpenBSD (Ports): 2.66.7
   FreeBSD (Ports): 2.66.7
   openSUSE Leap 15.2, SLE15-SP2: 2.62.6
   Ubuntu (Bionic): 2.56.1
   macOS (Homebrew): 2.66.7

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agodocs: Spell out our policy concerning minor releases
Andrea Bolognani [Wed, 3 Mar 2021 09:36:10 +0000 (10:36 +0100)] 
docs: Spell out our policy concerning minor releases

We've already applied this policy on multiple occasions, but it's
good to have it written down so that there can be no confusion.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
4 years agonetdev_bandwidth_conf: Remove redundant variables/labels
Kristina Hanicova [Wed, 3 Mar 2021 10:48:20 +0000 (11:48 +0100)] 
netdev_bandwidth_conf: Remove redundant variables/labels

In functions: virNetDevBandwidthParseRate(),
virNetDevBandwidthParse()

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 agoUse g_autoptr instead of virNetDevBandwidthFree where possible
Kristina Hanicova [Wed, 3 Mar 2021 10:48:19 +0000 (11:48 +0100)] 
Use g_autoptr instead of virNetDevBandwidthFree where possible

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 agoUse g_steal_pointer where possible
Kristina Hanicova [Wed, 3 Mar 2021 10:48:18 +0000 (11:48 +0100)] 
Use g_steal_pointer where possible

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 agonetdev_bandwidth_conf: Refractor virNetDevBandwidthParse()
Kristina Hanicova [Wed, 3 Mar 2021 10:48:17 +0000 (11:48 +0100)] 
netdev_bandwidth_conf: Refractor virNetDevBandwidthParse()

Refractoring includes:
* removal of VIR_FREE
* inversion of the condition

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 agonetdev_bandwidth_conf: Use g_autofree where possible
Kristina Hanicova [Wed, 3 Mar 2021 10:48:16 +0000 (11:48 +0100)] 
netdev_bandwidth_conf: Use g_autofree where possible

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 agovsh-table: Use g_autofree where possible
Kristina Hanicova [Wed, 3 Mar 2021 10:48:15 +0000 (11:48 +0100)] 
vsh-table: Use g_autofree where possible

In: vshTableRowNew(), vshTablePrint(), vshTablePrintToStdout().

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 agobuild-aux: require GNU grep on FreeBSD
Roman Bogorodskiy [Tue, 2 Mar 2021 14:31:36 +0000 (18:31 +0400)] 
build-aux: require GNU grep on FreeBSD

FreeBSD 13.x and newer ship BSD grep which apparently has some
performance issues causing certain syntax check tests to run longer than
the default 30 seconds timeout used by meson.

However, GNU grep is still available through the textproc/gnugrep port,
so require it on FreeBSD if /usr/bin/grep is a BSD grep to make checks
pass in a reasonable time.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agonode_device_conf: Remove redundant variables/labels
Kristina Hanicova [Wed, 3 Mar 2021 16:17:27 +0000 (17:17 +0100)] 
node_device_conf: Remove redundant variables/labels

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agonode_device_conf: use g_autoptr in virNodeDevCapPCIDevIommuGroupParseXML()
Kristina Hanicova [Wed, 3 Mar 2021 16:17:26 +0000 (17:17 +0100)] 
node_device_conf: use g_autoptr in virNodeDevCapPCIDevIommuGroupParseXML()

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agonode_device_conf: Refactoring functions in order to remove VIR_FREE
Kristina Hanicova [Wed, 3 Mar 2021 16:17:25 +0000 (17:17 +0100)] 
node_device_conf: Refactoring functions in order to remove VIR_FREE

By:
* declaration of an autofreed variable in for loop
* use of a new variable
* removal of VIR_FREE

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agonode_device_conf: Use g_autofree where possible
Kristina Hanicova [Wed, 3 Mar 2021 16:17:24 +0000 (17:17 +0100)] 
node_device_conf: Use g_autofree where possible

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodomain_conf: Fix check for hyperv stimer
Tim Wiederhake [Thu, 4 Mar 2021 08:35:31 +0000 (09:35 +0100)] 
domain_conf: Fix check for hyperv stimer

VIR_DOMAIN_HYPERV_STIMER happens to have the same numerical value as
VIR_DOMAIN_FEATURE_HYPERV, resulting in the if-block to always being
executed when a "<hyperv>" tag is found, whether or not it actually
contained a "<stimer>" tag. This had no ill effects, as virXPathNodeSet()
would simply return 0 if that tag does not exist.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodomain_conf: Add missing break in switch
Tim Wiederhake [Thu, 4 Mar 2021 08:35:30 +0000 (09:35 +0100)] 
domain_conf: Add missing break in switch

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodomain_conf: Reduce scope of node in virDomainFeaturesDefParse
Tim Wiederhake [Thu, 4 Mar 2021 08:35:29 +0000 (09:35 +0100)] 
domain_conf: Reduce scope of node in virDomainFeaturesDefParse

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodomain_conf: Reduce scope of gic_version in virDomainFeaturesDefParse
Tim Wiederhake [Thu, 4 Mar 2021 08:35:28 +0000 (09:35 +0100)] 
domain_conf: Reduce scope of gic_version in virDomainFeaturesDefParse

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodomain_conf: Reduce scope of tmp in virDomainFeaturesDefParse
Tim Wiederhake [Thu, 4 Mar 2021 08:35:27 +0000 (09:35 +0100)] 
domain_conf: Reduce scope of tmp in virDomainFeaturesDefParse

Variables using `g_autofree` should not be manually VIR_FREE'd and reused.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroup: drop unused function virCgroupSetupCpuShares
Pavel Hrdina [Wed, 3 Mar 2021 13:29:22 +0000 (14:29 +0100)] 
vircgroup: drop unused function virCgroupSetupCpuShares

Previous commit removed all usage of this function so we can remove it.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocgroup: use virCgroupSetCpuShares instead of virCgroupSetupCpuShares
Pavel Hrdina [Wed, 3 Mar 2021 13:26:53 +0000 (14:26 +0100)] 
cgroup: use virCgroupSetCpuShares instead of virCgroupSetupCpuShares

Now that we enforce the cpu.shares range kernel will no longer silently
change the value that libvirt configures so there is no need to read
the value back to get the actual configuration.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroup: enforce range limit for cpu.shares
Pavel Hrdina [Wed, 3 Mar 2021 13:10:15 +0000 (14:10 +0100)] 
vircgroup: enforce range limit for cpu.shares

Before the conversion to using systemd DBus API to set the cpu.shares
there was some magic conversion done by kernel which was documented in
virsh manpage as well. Now systemd errors out if the value is out of
range.

Since we enforce the range for other cpu cgroup attributes 'quota' and
'period' it makes sense to do the same for 'shares' as well.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu_map: Fix spelling of svme-addr-chk feature
Jiri Denemark [Thu, 4 Mar 2021 07:43:09 +0000 (08:43 +0100)] 
cpu_map: Fix spelling of svme-addr-chk feature

Commit a208176ca1d9eedf8aa6bf12fde6a7a9579ab549 introduced this feature
with an incorrect "svme-addr-check" spelling.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
4 years agolibxl: Fix node device detach when driver unspecified
Jim Fehlig [Mon, 1 Mar 2021 22:41:44 +0000 (15:41 -0700)] 
libxl: Fix node device detach when driver unspecified

Commit 887dd0d331 caused a small regression in NodeDeviceDetach in the libxl
driver when the 'driver' parameter is not specified. E.g.

# virsh nodedev-detach pci_0000_0a_10_0
error: Failed to detach device pci_0000_0a_10_0
error: An error occurred, but the cause is unknown

If the driver name is not specified, NULL is passed to
virDomainDriverNodeDeviceDetachFlags, in which case virPCIDeviceSetStubDriver
is never called to set the stub to pciback. Fix it by setting the driver to
"xen" if it is not specified when invoking NodeDeviceDetach.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoTranslated using Weblate (Finnish)
Ricky Tigg [Tue, 2 Mar 2021 09:40:22 +0000 (10:40 +0100)] 
Translated using Weblate (Finnish)

Currently translated at 17.1% (1805 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 agocpu_map: Install x86_EPYC-Milan.xml
Jiri Denemark [Tue, 2 Mar 2021 09:32:42 +0000 (10:32 +0100)] 
cpu_map: Install x86_EPYC-Milan.xml

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agocpu_map: Add EPYC-Milan x86 CPU model
Jiri Denemark [Mon, 1 Mar 2021 18:20:51 +0000 (19:20 +0100)] 
cpu_map: Add EPYC-Milan x86 CPU model

Introduced in QEMU 6.0.0 by 623972ceae091b31331ae4a1dc94fe5cbb891937

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoutil: virerror: Remove virReportOOMError
Peter Krempa [Wed, 24 Feb 2021 10:34:00 +0000 (11:34 +0100)] 
util: virerror: Remove virReportOOMError

Trying to report an OOM error is pointless since our infrastructure to
report error needs to allocate memory to report the error.

In addition our code mistakenly reported OOM errors even in cases where
a function could fail for another reason, which would make issues harder
to debug.

Remove the virReportOOMError and backend so that programmers are forced
to think about what can happen. In case when there's another failure
possible a specific error should be reported and otherwise a direct
abort() is better since the logger would abort on g_new anyways.

This patch also removes the syntas-check which forces use of
virReportOOMError instead of using VIR_ERR_NO_MEMORY with other
functions. This allows possible future use when we'd end up in a
situation where trying to recover from an OOM would make sense, such as
when attempting to allocate a massive buffer.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agovirVMXConvertToUTF8: Report non-OOM error on failure of xmlBufferCreateStatic
Peter Krempa [Wed, 24 Feb 2021 10:30:24 +0000 (11:30 +0100)] 
virVMXConvertToUTF8: Report non-OOM error on failure of xmlBufferCreateStatic

The function has also non-OOM failure case when the passed string has 0
length, so reporting OOM error is not correct.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agostorage: Don't report OOM error on failure of glfs_new
Peter Krempa [Wed, 24 Feb 2021 09:22:52 +0000 (10:22 +0100)] 
storage: Don't report OOM error on failure of glfs_new

OOM isn't the only failure glfs_new can encounter. Report an error which
might give more insight. libgfapi seems to be setting errno but
reporting a system error migt be misleading.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agoutil: json: Report non-OOM error on yajl failure
Peter Krempa [Wed, 24 Feb 2021 09:13:27 +0000 (10:13 +0100)] 
util: json: Report non-OOM error on yajl failure

The yajl library returns a wide range of error codes so reporting OOM on
any failure is wrong. In case the error was really based by memory issue
the error reporting will probably cause an abort anyways. Change the
error message so that we know that it happened in JSON at least.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agovirVBoxSnapshotConfSaveVboxFile: abort() on failure to allocate xmlDoc and comment
Peter Krempa [Wed, 24 Feb 2021 10:28:56 +0000 (11:28 +0100)] 
virVBoxSnapshotConfSaveVboxFile: abort() on failure to allocate xmlDoc and comment

'xmlNewDoc' and 'xmlNewDocComment' return NULL only on allocation
failure. Attempting to raise an error is pointless.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>