]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
4 years agovircgroup: introduce virCgroupCopyMounts helper
Pavel Hrdina [Wed, 14 Oct 2020 09:12:46 +0000 (11:12 +0200)]
vircgroup: introduce virCgroupCopyMounts helper

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroup: introduce virCgroupSetBackends helper
Pavel Hrdina [Wed, 14 Oct 2020 09:08:21 +0000 (11:08 +0200)]
vircgroup: introduce virCgroupSetBackends helper

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroup: remove useless cgroup->path variable
Pavel Hrdina [Wed, 14 Oct 2020 08:29:45 +0000 (10:29 +0200)]
vircgroup: remove useless cgroup->path variable

It is only used for debug and error purposes which can be easily
replaced by @placement.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroupv2: detect controllers enabled in parent cgroup
Pavel Hrdina [Thu, 29 Oct 2020 15:05:20 +0000 (16:05 +0100)]
vircgroupv2: detect controllers enabled in parent cgroup

With cgroups v2 working with controllers is a bit more complicated then
with cgroups v1 where the controller had to be mounted.

There are two files, cgroups.controllers and cgroup.subtree_control.
The file cgroup.controllers lists all controllers enabled in the current
cgroup and cgroups.subtree_control, as the name suggest, controls which
controllers are enabled for a subtree of cgroups.

Now the issue here is that the current code doesn't make any difference
if the @parent variable is NULL or not because ../cgroup.subtree_control
will list the same controllers as ./cgroup.controllers.

The whole point of the @parent variable is when we are building the
cgroup topology ourselves without systemd help we need to detect which
controllers are enabled in the parent cgroup in order to enable them for
the current cgroup as well and for that we need to check
cgroup.controllers of the parent group.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroupv2: properly detect placement of running VM
Pavel Hrdina [Tue, 13 Oct 2020 11:29:43 +0000 (13:29 +0200)]
vircgroupv2: properly detect placement of running VM

When libvirtd starts a VM it internally stores a path to the main
cgroup. When we restart libvirtd we should get to the same state.

When we start a VM on host with systemd the cgroup is created for us and
the process is already placed into that cgroup and we detect the path
created by systemd using /proc/$PID/cgroup. After that we create
sub-cgroups and move all threads there.

Once libvirtd is restarted we again detect the cgroup path using
/proc/$PID/cgroup, but in this case we will get a different path because
the main thread was moved to a "emulator" cgroup.

Instead of ignoring the "emulator" directory when validating cgroups
remove it completely when detecting cgroup otherwise cgroups will not
work properly when libvirtd is restarted.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovircgroupv2: properly detect empty tasks
Pavel Hrdina [Tue, 13 Oct 2020 11:25:22 +0000 (13:25 +0200)]
vircgroupv2: properly detect empty tasks

With cgroups v2 the file cgroup.procs will never be empty if threading
is enabled as it will always have ID of all processes even if all
threads of the processes are moved to sub-cgroups. If that happens the
file cgroup.threads will be empty.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu_dbus: use emulator cgroup for dbus-daemon
Pavel Hrdina [Wed, 28 Oct 2020 02:20:37 +0000 (03:20 +0100)]
qemu_dbus: use emulator cgroup for dbus-daemon

All other helper processes are moved to cgroup with QEMU emulator
thread as we keep the root VM cgroup without any processes. This
assumption is validated in qemuRestoreCgroupState() which is called
when libvirtd is restarted and reconnected to all running VMs.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: remove dead code that setup cgroups for helper processes
Pavel Hrdina [Wed, 28 Oct 2020 02:13:04 +0000 (03:13 +0100)]
qemu: remove dead code that setup cgroups for helper processes

In both cases priv->cgroup will always be NULL because it is called
before the QEMU process is started and cgroups are configured.

In qemuProcessLaunch() the call order is following:

    qemuExtDevicesStart()
    ...
    virCommandRun()
    ...
    qemuSetupCgroup()

where qemuDBusStart() is called from qemuExtDevicesStart() but we
cgroups are created in qemuSetupCgroup().

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu_cgroup: remove unused @empty variable
Pavel Hrdina [Tue, 13 Oct 2020 11:24:32 +0000 (13:24 +0200)]
qemu_cgroup: remove unused @empty variable

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agocpu_map: Unify apostrophe and quotation mark usage
Tim Wiederhake [Mon, 19 Oct 2020 07:36:15 +0000 (09:36 +0200)]
cpu_map: Unify apostrophe and quotation mark usage

Usage was mixed.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agohyperv: call openwsman's ws_serializer_free_mem
Matt Coleman [Tue, 3 Nov 2020 00:22:08 +0000 (19:22 -0500)]
hyperv: call openwsman's ws_serializer_free_mem

This should have been included with the upgrade to openwsman 2.6.3.

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: minor formatting fix in hyperv_wmi.h
Matt Coleman [Tue, 3 Nov 2020 00:22:07 +0000 (19:22 -0500)]
hyperv: minor formatting fix in hyperv_wmi.h

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: consistent names for SettingData functions
Matt Coleman [Tue, 3 Nov 2020 00:22:06 +0000 (19:22 -0500)]
hyperv: consistent names for SettingData functions

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: move hypervGetProcSDByVSSDInstanceId to hyperv_wmi.c
Matt Coleman [Tue, 3 Nov 2020 00:22:05 +0000 (19:22 -0500)]
hyperv: move hypervGetProcSDByVSSDInstanceId to hyperv_wmi.c

This places it next to existing related functions.

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: move hypervGetWmiClass to hyperv_wmi.h
Matt Coleman [Tue, 3 Nov 2020 00:22:04 +0000 (19:22 -0500)]
hyperv: move hypervGetWmiClass to hyperv_wmi.h

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: WMI class list function general cleanup
Matt Coleman [Tue, 3 Nov 2020 00:22:03 +0000 (19:22 -0500)]
hyperv: WMI class list function general cleanup

* use the same section comment in the header and code
* place the items in the same relative location within the .h and .c
* one parameter per line for multiline function definitions

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: remove spaces after hypervObject* casts
Matt Coleman [Tue, 3 Nov 2020 00:22:02 +0000 (19:22 -0500)]
hyperv: remove spaces after hypervObject* casts

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: g_autofree username and password in hypervConnectOpen()
Matt Coleman [Tue, 3 Nov 2020 00:22:01 +0000 (19:22 -0500)]
hyperv: g_autofree username and password in hypervConnectOpen()

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoremove unnecessary cleanup labels and unused return variables
Laine Stump [Tue, 27 Oct 2020 21:49:11 +0000 (17:49 -0400)]
remove unnecessary cleanup labels and unused return variables

After converting all DIR* to g_autoptr(DIR), many cleanup: labels
ended up just having "return ret", and every place that set ret would
just immediately goto cleanup. Remove the cleanup label and its
return, and just return the set value immediately, thus eliminating
the need for the return variable itself.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoutil: refactor function to simplify and remove label
Laine Stump [Tue, 27 Oct 2020 02:04:31 +0000 (22:04 -0400)]
util:  refactor function to simplify and remove label

Once the DIR* in virPCIGetName() was made g_autoptr, the cleanup:
label just had a "return ret;", but the rest of the function was more
compilcated than it needed to be, doing funky things with the value of
ret inside multi-level conditionals and a while loop that might exit
early via a break with ret == 0 or exit early via a goto cleanup with
ret == -1.

It really didn't need to be nearly as complicated. After doing the
trivial replacements of "goto cleanup" with appropriate direct
returns, it became obvious that:

1) the outermost level of the nested conditional at the end of the
   function ("if (ret < 0)") was now redundant, since ret is now
   *always* < 0 by that point (otherwise the function has returned).

2) by switching the sense of the next level of the conditional (making
   it "if (!physPortID)", the "else" (which is now just "return 0;"
   becomes the "if", and the new "else" no longer needs to be inside
   the conditional.

3) the value of firstEntryName can be moved into *netname with
   g_steal_pointer()

Once that is all done, ret is no longer used and can be removed.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoutil: remove unused VIR_DIR_CLOSE() macro
Laine Stump [Mon, 26 Oct 2020 02:43:20 +0000 (22:43 -0400)]
util: remove unused VIR_DIR_CLOSE() macro

Since every single use of DIR* was converted to use g_autoptr, this
function is not currently needed. Even if someone comes up with a
usage for a non-g_autoptr DIR* in the future, they can just use
virDirClose(), since there is no longer a semantic difference between
the two (VIR_DIR_CLOSE() previously had an extra & on the pointer so
that it could be transparently passed as a DIR** to virDirClose(), but
that was removed several commits back.)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoconf: convert final DIR* to g_autoptr
Laine Stump [Mon, 26 Oct 2020 02:40:40 +0000 (22:40 -0400)]
conf: convert final DIR* to g_autoptr

This use of DIR* was re-using the same function-scope DIR* each time
through a for loop, and due to multiple error gotos in the loop, it
needed to have the scope of the DIR* reduced to just the loop at the
same time as switching to g_autoptr. That's what this patch does.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agochange DIR* int g_autoptr(DIR) where appropriate
Laine Stump [Sun, 25 Oct 2020 21:50:51 +0000 (17:50 -0400)]
change DIR* int g_autoptr(DIR) where appropriate

All of these conversions are trivial - VIR_DIR_CLOSE() (aka
virDirClose()) is called only once on the DIR*, and it happens just
before going out of scope.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoutil: declare g_autoptr cleanup function to auto-close DIR*
Laine Stump [Mon, 19 Oct 2020 13:15:50 +0000 (09:15 -0400)]
util: declare g_autoptr cleanup function to auto-close DIR*

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoutil: change virDirClose to take a DIR* instead of DIR**.
Laine Stump [Tue, 13 Oct 2020 13:58:57 +0000 (09:58 -0400)]
util: change virDirClose to take a DIR* instead of DIR**.

In order to make a usable g_autoptr(DIR), we need to have a close
function that is a NOP when the pointer is NULL, but takes a simple
DIR*. But virDirClose() (candidate to be the g_autoptr cleanup
function) currently takes a DIR**, not DIR*. It does this so that it
can clear the pointer, thus making it safe to call virDirClose on the
same DIR multiple times.

In the past the clearing of the DIR* was essential in a few places,
but those few places have now been changed, so we can modify
virDirClose() to take a DIR*, and remove the side effect of clearing
the DIR*. This will make it directly usable as the g_autoptr cleanup,
and will mean that this:

   {
   DIR *dirp = NULL;
   blah blah ...
   VIR_DIR_CLOSE(dirp)
   }

is functionally identical to

   {
   g_autoptr(DIR) dirp = NULL;
   blah blah ...
   }

which will make conversion to using g_autoptr mechanical and simple to review.

(Note that virDirClose() will still check for NULL before attempting
to close, so that it can always be safely called, as long as the DIR*
was initialized to NULL (another prerequisite of becoming a g_autoptr
cleanup function)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoutil: manually set dirp to NULL after closing in virCapabilitiesInitCache()
Laine Stump [Mon, 26 Oct 2020 01:10:08 +0000 (21:10 -0400)]
util: manually set dirp to NULL after closing in virCapabilitiesInitCache()

In all uses of VIR_DIR_CLOSE() except one, the DIR* is never
referenced after closing all the way until it goes out of
scope. virCapabilitiesInitCaches(), however, reuses the same DIR* over
and over in a loop, but due to having many error conditions that
result in a goto out of the loop, it's not well suited to reducing the
scope of the variable until we introduce a g_autoptr cleanup function
for DIR*.

In preparation for doing just that, we need to get rid of the side
effect of VIR_DIR_CLOSE() setting the DIR* to NULL, so in this one
case, let's manually set the DIR* to NULL. Then in an upcoming patch
we can safely remove the side effect from VIR_DIR_CLOSE().

This extra/ugly bit of code is only temporary: once we introduce the
g_autoptr cleanup function for DIR*, we will remove this manual
close/clear completely anyway.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoutil: reduce scope of a DIR * in virCgroupV1SetOwner()
Laine Stump [Sun, 25 Oct 2020 21:31:53 +0000 (17:31 -0400)]
util: reduce scope of a DIR * in virCgroupV1SetOwner()

DIR *dh is being re-used each time through the for loop of this
function, so it must be closed and then re-opened, which means we
can't convert it to g_autoptr. By moving the definition of dh inside
the for loop, we make it possible to trivially convert to g_autoptr
(which will happen in a subsequent patch)

NB: VIR_DIR_CLOSE() is already called at the bottom of the for loop,
so removing the VIR_DIR_CLOSE() at the end of the function is *not*
creating a leak of a DIR*!

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agostorage: remove extraneous call to VIR_DIR_CLOSE()
Laine Stump [Mon, 26 Oct 2020 02:28:09 +0000 (22:28 -0400)]
storage: remove extraneous call to VIR_DIR_CLOSE()

VIR_DIR_CLOSE(dir) is called in the middle of
virStorageBackendRefreshLocal(), which is okay, but redundant - there
is no reference to dir between that call and the end of the function,
where VIR_DIR_CLOSE() is called again. Remove the extra call in the
middle to simplify the function and make the conversion to g_autoptr
trivial/mechanical.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agotools: reduce scope of a DIR* in virHostValidateIOMMU()
Laine Stump [Sun, 25 Oct 2020 21:56:22 +0000 (17:56 -0400)]
tools: reduce scope of a DIR* in virHostValidateIOMMU()

This will make the trivial nature of a conversion to g_autoptr (in a
later patch) more obvious.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoconsistently use VIR_DIR_CLOSE() instead of virDirClose()
Laine Stump [Tue, 13 Oct 2020 13:40:54 +0000 (09:40 -0400)]
consistently use VIR_DIR_CLOSE() instead of virDirClose()

This will make it easier to review upcoming patches that use g_autoptr
to auto-close all DIRs.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agovirDomainNetDefParseXML: Fix error message for unknown value of //mac/@type
Michal Privoznik [Mon, 2 Nov 2020 19:49:38 +0000 (20:49 +0100)]
virDomainNetDefParseXML: Fix error message for unknown value of //mac/@type

In v6.6.0-rc1~124 we've introduced a new mechanism for MAC
addresses for ESX: ignore all checks (type='static') that libvirt
or ESX would do (and possibly fail) for specified MAC address.
Accepted values for the @type attribute are "generated" and
"static". But the error message mentions a different attribute.

Fixes 454e5961abf40c14f8b6d7ee216229e68fd170bf
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1892130
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: do not overwrite errors from hypervInvokeMethod()
Matt Coleman [Thu, 22 Oct 2020 16:38:24 +0000 (12:38 -0400)]
hyperv: do not overwrite errors from hypervInvokeMethod()

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: reduce duplicate code for Msvm_ComputerSystem lookups
Matt Coleman [Thu, 22 Oct 2020 16:38:23 +0000 (12:38 -0400)]
hyperv: reduce duplicate code for Msvm_ComputerSystem lookups

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: remove unneeded braces in hypervDomainGetInfo() and hypervDomainGetXMLDesc()
Matt Coleman [Thu, 22 Oct 2020 16:38:22 +0000 (12:38 -0400)]
hyperv: remove unneeded braces in hypervDomainGetInfo() and hypervDomainGetXMLDesc()

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: remove duplicate function hypervGetMemSDByVSSDInstanceId()
Matt Coleman [Thu, 22 Oct 2020 16:38:21 +0000 (12:38 -0400)]
hyperv: remove duplicate function hypervGetMemSDByVSSDInstanceId()

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: remove duplicate function hypervGetVSSDFromUUID()
Matt Coleman [Thu, 22 Oct 2020 16:38:20 +0000 (12:38 -0400)]
hyperv: remove duplicate function hypervGetVSSDFromUUID()

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: reformat WQL query strings
Matt Coleman [Thu, 22 Oct 2020 16:38:19 +0000 (12:38 -0400)]
hyperv: reformat WQL query strings

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: capabilities: Re-enable detection of QEMU_CAPS_BLOCK_EXPORT_ADD
Peter Krempa [Mon, 26 Oct 2020 12:09:17 +0000 (13:09 +0100)]
qemu: capabilities: Re-enable detection of QEMU_CAPS_BLOCK_EXPORT_ADD

Now that qemu stabilized it's interface and we've switched to the new
design we can re-enable use of 'block-export-add'

This reverts commit b87cfc957f57c1d9f7e5bf828ee4b23972085991

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqemu: Update to new design of 'block-export-add'
Peter Krempa [Mon, 26 Oct 2020 12:06:17 +0000 (13:06 +0100)]
qemu: Update to new design of 'block-export-add'

qemu decided to modify the arguments of 'block-export-add' to include an
array of bitmaps rather than a single bitmap.

Since we've added the code prior to qemu setting the interface in stone
and thus it will be changed incompatibly and we already have tests for
the new interface we need to update the code and qemu capabilities data
at the same time.

Use a array of bitmaps as the 'bitmaps' argument instead of 'bitmap' and
bump qemu capabilities for the upcoming 5.2.0 release to
v5.1.0-2827-g2c6605389c

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoutil: virhash: Standardize on 'opaque' for opaque data
Peter Krempa [Fri, 23 Oct 2020 09:45:16 +0000 (11:45 +0200)]
util: virhash: Standardize on 'opaque' for opaque data

Rename 'data' argument which is used for opaque data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: Add test cases for 'host_cdrom' blockdev backend via <disk>
Peter Krempa [Thu, 15 Oct 2020 11:47:46 +0000 (13:47 +0200)]
qemu: Add test cases for 'host_cdrom' blockdev backend via <disk>

Simulate that the device is a cdrom when the path equals to /dev/cdrom
to provide testing for the 'host_cdrom' backend.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agodocs: page.xsl: Improve generation of paragraph anchor links
Peter Krempa [Mon, 26 Oct 2020 12:44:19 +0000 (13:44 +0100)]
docs: page.xsl: Improve generation of paragraph anchor links

Use the 'parent' axis to check whether the parent is a div with
class='section' rather than looking for 'toc-backref' anchor to see
whether to generate one of the headerlink alternatives. Both hare
docutils-specific thus apply to docs generated from RST documents.

This adds the links for pages generated from RST documents which don't
have a table of contents (and thus lack the 'toc-backref' anchors) and
thus fixes pages such as hacking.html and news.html to have reasonable
links which can be shared.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agonews: Remove empty section
Andrea Bolognani [Mon, 2 Nov 2020 11:07:24 +0000 (12:07 +0100)]
news: Remove empty section

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
4 years agonews: Fix an RST alignment typo with '=' which breaks the pipeline
Erik Skultety [Mon, 2 Nov 2020 10:56:15 +0000 (11:56 +0100)]
news: Fix an RST alignment typo with '=' which breaks the pipeline

This is just a warning, but because we're invoking rst2html5 with
--strict, it will fail at encountering a single minor issue.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
4 years agoPost-release version bump to 6.10.0
Jiri Denemark [Mon, 2 Nov 2020 10:18:13 +0000 (11:18 +0100)]
Post-release version bump to 6.10.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
4 years agoRelease of libvirt-6.9.0
Jiri Denemark [Mon, 2 Nov 2020 10:16:26 +0000 (11:16 +0100)]
Release of libvirt-6.9.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
4 years agonews: mention vdpa support
Jonathon Jongsma [Fri, 30 Oct 2020 20:01:42 +0000 (15:01 -0500)]
news: mention vdpa support

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agonode_device: fix leak of DIR*
Laine Stump [Wed, 28 Oct 2020 01:43:47 +0000 (21:43 -0400)]
node_device: fix leak of DIR*

Commit 53aec799fa31 introduced the function udevGetVDPACharDev(),
which scans a directory using virDirOpenIfExists() and
virDirRead(). It unfortunately forgets to close the DIR* when it is
finished with it. This patch fixes that omission.

Fixes: 53aec799fa31711ffaeacc7ec17ec6d3c2e3cadf
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoTranslated using Weblate (Ukrainian)
Yuri Chornoivan [Tue, 27 Oct 2020 09:32:02 +0000 (10:32 +0100)]
Translated using Weblate (Ukrainian)

Currently translated at 100.0% (10399 of 10399 strings)

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

Translated using Weblate (Ukrainian)

Currently translated at 99.3% (10328 of 10399 strings)

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

Co-authored-by: Yuri Chornoivan <yurchor@ukr.net>
Signed-off-by: Yuri Chornoivan <yurchor@ukr.net>
4 years agoUpdate translation files
Weblate [Tue, 27 Oct 2020 09:32:00 +0000 (10:32 +0100)]
Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

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

Co-authored-by: Weblate <noreply@weblate.org>
Signed-off-by: Fedora Weblate Translation <i18n@lists.fedoraproject.org>
4 years agotests: fix stat mocking with Fedora rawhide
Daniel P. Berrangé [Thu, 29 Oct 2020 17:25:07 +0000 (17:25 +0000)]
tests: fix stat mocking with Fedora rawhide

GLibC has a really complicated way of dealing with the 'stat' function
historically, which means our mocks in turn have to look at four
different possible functions to replace, stat, stat64, __xstat,
__xstat64.

In Fedora 33 and earlier:

 - libvirt.so links to __xstat64
 - libc.so library exports stat, stat64, __xstat, __xstat64
 - sys/stat.h header exposes stat and __xstat

In Fedora 34 rawhide:

 - libvirt.so links to stat64
 - libc.so library exports stat, stat64, __xstat, __xstat64
 - sys/stat.h header exposes stat

Historically we only looked at the exported symbols from libc.so to
decide which to mock.

In F34 though we must not consider __xstat / __xstat64 though because
they only existance for binary compatibility. Newly built binaries
won't reference them.

Thus we must introduce a header file check into our logic for deciding
which symbol to mock. We must ignore the __xstat / __xstat64 symbols
if they don't appear in the sys/stat.h header, even if they appear
in libc.so

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agorpm: tell meson whether to use libssh or libssh2 explicitly
Daniel P. Berrangé [Wed, 28 Oct 2020 12:24:38 +0000 (12:24 +0000)]
rpm: tell meson whether to use libssh or libssh2 explicitly

The %meson macro sets "--auto-features=enabled", thus any feature in the
RPM which has a "with_XXX" condition, needs to explicitly pass a
"-DXXX=state" arg to %meson to override the auto features setting.

The with_libssh and with_libssh2 conditions were not exposed to meson,
so if either was set disabled, then meson would fail the build if the
-devel packages were not found.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agorpm: remove with_bash_completion condition
Daniel P. Berrangé [Wed, 28 Oct 2020 12:24:38 +0000 (12:24 +0000)]
rpm: remove with_bash_completion condition

The %meson macro sets "--auto-features=enabled", thus any feature in the
RPM which has a "with_XXX" condition, needs to explicitly pass a
"-DXXX=state" arg to %meson to override the auto features setting.

The with_bash_completion condition is always set to 1, so rather than
adding an arg to %meson, just remove the condition.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: capabilities: Disable detection of QEMU_CAPS_BLOCK_EXPORT_ADD
Peter Krempa [Mon, 26 Oct 2020 10:26:50 +0000 (11:26 +0100)]
qemu: capabilities: Disable detection of QEMU_CAPS_BLOCK_EXPORT_ADD

We use the capability to switch to using 'block-export-add' in the
upcoming qemu release instead of the at the same time deprecated
'nbd-server-add'.

Unfortunately qemu wants to change the interface of 'block-export-add'
before the release. Since we've tried to stay up to date and added the
code before it was written in stone, we need to disable the use of the
new interface for the upcoming libvirt release so that we don't have a
version of libvirt which would not work with the upcoming qemu version.

Remove the detection of 'block-export-add' until we are more sure how
the qemu interface will look.

This patch partially reverts commit adb9f7123adb94645

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoutil: Avoid double free in virProcessSetAffinity
Martin Kletzander [Tue, 27 Oct 2020 12:48:38 +0000 (13:48 +0100)]
util: Avoid double free in virProcessSetAffinity

The cpu mask was free()'d immediately on any error and at the end of the
function, where it was expected that it would either error out and return or
goto another allocation if the code was to fail.  However since commit
9514e24984ee the error path did not return in one new case which caused
double-free in such situation.  In order to make the code more straightforward
just free the mask after it's been used even before checking the return code of
the call.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agonews: Mention nodedev support for CSS on S390
Boris Fiuczynski [Tue, 27 Oct 2020 12:52:04 +0000 (13:52 +0100)]
news: Mention nodedev support for CSS on S390

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
4 years agoqemu: honour fatal errors dealing with qemu slirp helper
Daniel P. Berrangé [Thu, 15 Oct 2020 11:12:15 +0000 (12:12 +0100)]
qemu: honour fatal errors dealing with qemu slirp helper

Currently all errors from qemuInterfacePrepareSlirp() are completely
ignored by the callers. The intention is that missing qemu-slirp binary
should cause the caller to fallback to the built-in slirp impl.

Many of the possible errors though should indeed be considered fatal.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoRevert "spec: Simplify setting features off by default"
Neal Gompa [Mon, 26 Oct 2020 21:53:55 +0000 (17:53 -0400)]
Revert "spec: Simplify setting features off by default"

As it turns out, the rather complicated structure that is
currently used for enabling or disabling features in the libvirt
build does not cleanly map well to RPM's bcond feature.

Consequently, we need these back in order to support trivially
activating these features through extra macros as build inputs.

This reverts commit 31d687a3218c9072d7050dd608e013e063ca180f.

Signed-off-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agonews: Mention virt-ssh-helper detection fix
Andrea Bolognani [Mon, 26 Oct 2020 23:25:53 +0000 (00:25 +0100)]
news: Mention virt-ssh-helper detection fix

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agorpc: Fix virt-ssh-helper detection
Andrea Bolognani [Mon, 26 Oct 2020 23:15:33 +0000 (00:15 +0100)]
rpc: Fix virt-ssh-helper detection

When trying to figure out whether virt-ssh-helper is available
on the remote host, we mistakenly look for the helper by the
name it had while the feature was being worked on instead of
the one that was ultimately picked, and thus end up using the
netcat fallback every single time.

Fixes: f8ec7c842df9e40c6607eae9b0223766cb226336
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agopo: Refresh potfile for v6.9.0
Jiri Denemark [Mon, 26 Oct 2020 17:56:11 +0000 (18:56 +0100)]
po: Refresh potfile for v6.9.0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
4 years agoqemuMonitorJSONCheckReply: Use g_autofree
Yi Li [Wed, 21 Oct 2020 09:23:40 +0000 (17:23 +0800)]
qemuMonitorJSONCheckReply: Use g_autofree

Eliminate cleanup code by using g_autofree.

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 agoNEWS: Fix vertical spacing between sections
Andrea Bolognani [Mon, 26 Oct 2020 13:37:23 +0000 (14:37 +0100)]
NEWS: Fix vertical spacing between sections

Looking at the entire repository reveals we're not too consistent
about this, but at least in this specific document we mostly have
two blank lines between sections, so let's stick with that.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
4 years agoqemu_migration: Don't mangle NBD part of migration cookie
Michal Privoznik [Mon, 26 Oct 2020 10:28:13 +0000 (11:28 +0100)]
qemu_migration: Don't mangle NBD part of migration cookie

In recent commit v6.8.0-135-g518be41aaa the formatting of NBD
into migration cookie was moved into a separate function and with
it it was switched from direct printing into the output buffer to
virXMLFormatElement(). But there was a typo. The
virXMLFormatElement() accepts two buffers on input, one for
element attributes and another for child elements. Well, the line
that was supposed to add NBD port into the attributes buffer
printed the attribute directly into the output buffer which
produced this mangled XML:

<qemu-migration>
   port='49153'<nbd>
    <disk target='vda' capacity='8589934592'/>
    <disk target='vdb' capacity='12746752000'/>
  </nbd>
</qemu-migration>

Changing the incriminated line to print into the attributes
buffer fixes the problem.

Fixes: 518be41aaa3ebaac5f2307f268d24dc1b40b6b5c
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu: Don't try to start NBD server twice
Michal Privoznik [Mon, 26 Oct 2020 08:49:35 +0000 (09:49 +0100)]
qemu: Don't try to start NBD server twice

In one of recent patches the way that we start NBD server for
incoming migration was reworked (v6.8.0-rc1~298). A new boolean
was introduced that tracks whether the NBD server was started so
that we don't start it twice nor record in the port in the port
allocator twice. Well, this idea is good, but in the
implementation the boolean is never set, so we are reserving the
port twice and would be starting the NBD server twice too if it
wasn't for port reservation fail.

Fixes: e74d627bb3bc2684cbe3edc1e2f7cc745b4e1ff3
Reported-by: Vjaceslavs Klimovs <vklimovs@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agonews: introduce memory failure event
zhenwei pi [Fri, 23 Oct 2020 13:53:49 +0000 (21:53 +0800)]
news: introduce memory failure event

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agovirt-aa-helper: allow hard links for mounts
Christian Schoenebeck [Thu, 22 Oct 2020 14:58:00 +0000 (16:58 +0200)]
virt-aa-helper: allow hard links for mounts

Guests should be allowed to create hard links on mounted pathes, since
many applications rely on this functionality and would error on guest
with current "rw" AppArmor permission with 9pfs.

Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: Don't pass mode when opening domain log file for reading
Michal Privoznik [Fri, 23 Oct 2020 17:39:03 +0000 (19:39 +0200)]
qemu: Don't pass mode when opening domain log file for reading

In qemuDomainLogContextNew() the domain log file is opened.
Twice, the first time for writing, and the second time for
reading (if required by caller). When opening the log file for
reading a mode is provided. This doesn't do much harm, but is
unnecessary. Drop the mode.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoInclude vdpa devices in node device list
Jonathon Jongsma [Wed, 14 Oct 2020 17:08:30 +0000 (12:08 -0500)]
Include vdpa devices in node device list

The current udev node device driver ignores all events related to vdpa
devices. Since libvirt now supports vDPA network devices, include these
devices in the device list.

Example output:

virsh # nodedev-list
[...ommitted long list of nodedevs...]
vdpa_vdpa0

virsh # nodedev-dumpxml vdpa_vdpa0
<device>
  <name>vdpa_vdpa0</name>
  <path>/sys/devices/vdpa0</path>
  <parent>computer</parent>
  <driver>
    <name>vhost_vdpa</name>
  </driver>
  <capability type='vdpa'>
    <chardev>/dev/vhost-vdpa-0</chardev>
  </capability>
</device>

NOTE: normally the 'parent' would be a PCI device instead of 'computer',
but this example output is from the vdpa_sim kernel module, so it
doesn't have a normal parent device.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
4 years agoqemu: combine conditionals
Jonathon Jongsma [Fri, 23 Oct 2020 21:40:09 +0000 (16:40 -0500)]
qemu: combine conditionals

Trivial fix to improve readability by combining these into a compound
conditional.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agoqemu: fix memory leak reported by coverity
Jonathon Jongsma [Fri, 23 Oct 2020 21:40:08 +0000 (16:40 -0500)]
qemu: fix memory leak reported by coverity

Let g_autoptr clean up on early return.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agoqemu: fix potential resource leak
Jonathon Jongsma [Wed, 21 Oct 2020 21:50:06 +0000 (16:50 -0500)]
qemu: fix potential resource leak

Coverity reported a potential resource leak. While it's probably not
a real-world scenario, the code could technically jump to cleanup
between the time that vdpafd is opened and when it is used. Ensure that
it gets cleaned up in that case.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
4 years agotests: Use flat namespace for qemu test driver
Roman Bolshakov [Sun, 18 Oct 2020 15:30:58 +0000 (18:30 +0300)]
tests: Use flat namespace for qemu test driver

The change re-introduces f6d6086dbfec ("tests: Make references to global
symbols indirect in test drivers") that got lost during meson
conversion.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agotests: Re-introduce stat/lstat mocks on macOS
Roman Bolshakov [Sun, 18 Oct 2020 15:30:57 +0000 (18:30 +0300)]
tests: Re-introduce stat/lstat mocks on macOS

Commit d6b17edd5163 ("tests: Lookup extended stat/lstat in mocks")
adds support for mocking of stat() and lstat() on macOS.

The change was broken because virmockstathelpers.c only follows glibc
logic and MOCK_STAT and MOCK_LSTAT are not getting defined on macOS.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agotests: Fix lstat() mock initialization on macOS
Roman Bolshakov [Sun, 18 Oct 2020 15:30:56 +0000 (18:30 +0300)]
tests: Fix lstat() mock initialization on macOS

There is a typo that prevents initialization of real_lstat.

Fixes: d6b17edd5163 ("tests: Lookup extended stat/lstat in mocks")
Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu: implement memory failure event
zhenwei pi [Wed, 14 Oct 2020 10:37:51 +0000 (18:37 +0800)]
qemu: implement memory failure event

Since QEMU 5.2 (commit-77b285f7f6), QEMU supports 'memory failure'
event, posts event to monitor if hitting a hardware memory error.
Fully support this feature for QEMU.

Test with commit 'libvirt: support memory failure event', build a
little complex environment(nested KVM):
1, install newly built libvirt in L1, and start a L2 vm. run command
in L1:
 ~# virsh event l2 --event memory-failure

2, run command in L0 to inject MCE to L1:
 ~# virsh qemu-monitor-command l1 --hmp mce 0 9 0xbd000000000000c0 0xd 0x62000000 0x8c

Test result in l1(recipient hypervisor case):
event 'memory-failure' for domain l2:
recipient: hypervisor
action: ignore
flags:
        action required: 0
        recursive: 0

Test result in l1(recipient guest case):
event 'memory-failure' for domain l2:
recipient: guest
action: inject
flags:
        action required: 0
        recursive: 0

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agolibvirt: support memory failure event
zhenwei pi [Wed, 14 Oct 2020 10:37:50 +0000 (18:37 +0800)]
libvirt: support memory failure event

Introduce memory failure event. Libvirt should monitor domain's
event, then posts it to uplayer. According to the hardware memory
corrupted message, a cloud scheduler could migrate domain to another
health physical server.

Several changes in this patch:
public API:
    include/*
    src/conf/*
    src/remote/*
    src/remote_protocol-structs

client:
    examples/c/misc/event-test.c
    tools/virsh-domain.c

With this patch, each driver could implement its own method to run
this new event.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agohyperv: Reformat
Michal Privoznik [Wed, 21 Oct 2020 12:53:12 +0000 (14:53 +0200)]
hyperv: Reformat

This is mostly opening hyperv driver sources in vim, selecting
everything, hitting reformat and then fixing a very few places.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Matt Coleman <matt@datto.com>
4 years agohyperv: Use two empty lines between functions
Michal Privoznik [Wed, 21 Oct 2020 12:29:47 +0000 (14:29 +0200)]
hyperv: Use two empty lines between functions

In some places we separate functions with only one line, in
others with three lines and the rest uses two lines.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Matt Coleman <matt@datto.com>
4 years agohyperv: Use hypervRequestStateChange() in hypervDomainSuspend()
Michal Privoznik [Wed, 21 Oct 2020 12:36:16 +0000 (14:36 +0200)]
hyperv: Use hypervRequestStateChange() in hypervDomainSuspend()

A few commits ago, hypervRequestStateChange() helper was
introduced which has exactly the same code as a part of
hypervDomainSuspend(). Deduplicate by calling the helper.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Matt Coleman <matt@datto.com>
4 years agohyperv: Don't overwrite errors from hypervCreateInvokeParamsList()
Michal Privoznik [Wed, 21 Oct 2020 12:25:37 +0000 (14:25 +0200)]
hyperv: Don't overwrite errors from hypervCreateInvokeParamsList()

The hypervCreateInvokeParamsList() function sets an error on a
failure, therefore there is no need to report another error in
callers.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Matt Coleman <matt@datto.com>
4 years agovirHashRemoveAll: Don't return number of removed items
Peter Krempa [Wed, 21 Oct 2020 12:57:36 +0000 (14:57 +0200)]
virHashRemoveAll: Don't return number of removed items

Nobody uses the return value.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoutil: virhash: Remove key handling callbacks
Peter Krempa [Wed, 21 Oct 2020 11:52:01 +0000 (13:52 +0200)]
util: virhash: Remove key handling callbacks

Since we use virHashTable for string-keyed values only, we can remove
all the callbacks which allowed universal keys.

Code which wishes to use non-string keys should use glib's GHashTable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoutil: hash: Change type of hash table name/key to 'char'
Peter Krempa [Wed, 21 Oct 2020 11:31:16 +0000 (13:31 +0200)]
util: hash: Change type of hash table name/key to 'char'

All users of virHashTable pass strings as the name/key of the entry.
Make this an official requirement by turning the variables to 'const
char *'.

For any other case it's better to use glib's GHashTable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoutil: hash: Remove virHashCreateFull
Peter Krempa [Tue, 20 Oct 2020 16:17:16 +0000 (18:17 +0200)]
util: hash: Remove virHashCreateFull

The only place we call it is in virHashNew. Move the code to virHashNew
and remove virHashCreateFull.

Code wishing to use non-strings as hash table keys will be better off
using glib's GHashTable directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoutil: hash: Remove virHashValueFree
Peter Krempa [Wed, 21 Oct 2020 10:08:22 +0000 (12:08 +0200)]
util: hash: Remove virHashValueFree

Use 'g_free' directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoReplace all instances of 'virHashCreate' with 'virHashNew'
Peter Krempa [Tue, 20 Oct 2020 16:43:20 +0000 (18:43 +0200)]
Replace all instances of 'virHashCreate' with 'virHashNew'

It doesn't make much sense to configure the bucket count in the hash
table for each case specifically. Replace all calls of virHashCreate
with virHashNew which has a pre-set size and remove virHashCreate
completely.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoqemuDomainObjPrivateAlloc: Use virHashNew instead of virHashCreate
Peter Krempa [Wed, 21 Oct 2020 11:12:08 +0000 (13:12 +0200)]
qemuDomainObjPrivateAlloc: Use virHashNew instead of virHashCreate

virHashCreate will be removed in upcoming patches. This change has an
impact on ordering of the blockjob entries in one of the status XML->XML
tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agotests: hash: Prepare for replacement of virHashCreate
Peter Krempa [Wed, 21 Oct 2020 07:41:50 +0000 (09:41 +0200)]
tests: hash: Prepare for replacement of virHashCreate

Most callers pass a random number. We have virHashNew which doesn't give
the callers the option to configure the table. Since we are going to
switch to virHashNew replace it in tests and remove multiple instances
of the 'testHashGrow' case as it doesn't make sense with the new
semantics.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoconf: nwfilter: Replace 'virNWFilterHashTableCreate' with 'virHashNew'
Peter Krempa [Tue, 20 Oct 2020 16:41:27 +0000 (18:41 +0200)]
conf: nwfilter: Replace 'virNWFilterHashTableCreate' with 'virHashNew'

Export the freeing function rather than having a wrapper for the hash
creation function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agovirHashAtomicNew: Remove 'size' argument
Peter Krempa [Tue, 20 Oct 2020 16:28:21 +0000 (18:28 +0200)]
virHashAtomicNew: Remove 'size' argument

Use 'virHashNew' internally which uses a default size.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoconf: domain_addr: Refactor hash usage in zpci reservation code
Peter Krempa [Tue, 20 Oct 2020 15:31:23 +0000 (17:31 +0200)]
conf: domain_addr: Refactor hash usage in zpci reservation code

Rewrite using GHashTable which already has interfaces for using a number
as hash key.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agovirCgroupKillRecursive: Refactor cleanup
Peter Krempa [Thu, 22 Oct 2020 07:59:52 +0000 (09:59 +0200)]
virCgroupKillRecursive: Refactor cleanup

Remove 'cleanup' label and simplify remembering of the returned value
from the callback.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoutil: cgroup: Use GHashTable instead of virHashTable
Peter Krempa [Tue, 20 Oct 2020 15:01:51 +0000 (17:01 +0200)]
util: cgroup: Use GHashTable instead of virHashTable

Rewrite using GHashTable which already has interfaces for using a number
as hash key. Glib's implementation doesn't copy the key by default, so
we need to allocate it, but overal the interface is more suited for this
case.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoutil: virhash: Remove virHashTableSize
Peter Krempa [Tue, 20 Oct 2020 14:32:54 +0000 (16:32 +0200)]
util: virhash: Remove virHashTableSize

It's used only in one place in tests which isn't even automatically
evaluated.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agovirCgroupKillRecursive: Return -1 on failure condition
Peter Krempa [Thu, 22 Oct 2020 07:56:46 +0000 (09:56 +0200)]
virCgroupKillRecursive: Return -1 on failure condition

virCgroupKillRecursive sneakily initializes 'ret' to 0 rather than the
usual -1. 401030499bf moved an error condition but didn't actually
modify 'ret' return the proper error code.

Fixes: 401030499bf
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoparthelper: Don't leak @canonical_path
Michal Privoznik [Thu, 22 Oct 2020 10:55:40 +0000 (12:55 +0200)]
parthelper: Don't leak @canonical_path

The @canonical_path variable holds canonicalized path passed as
argv[1]. The canonicalized path is obtained either via
virFileResolveLink() or plain g_strdup(). Nevertheless, in both
cases it must be freed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoparthelper: Initialize error object
Michal Privoznik [Thu, 22 Oct 2020 10:49:44 +0000 (12:49 +0200)]
parthelper: Initialize error object

Some functions called from parthelper can report an error. But
that means that the error object must be initialized otherwise
virResetError() (which happens as a part of virReportError())
will free random pointers.

Reported-by: Katerina Koukiou <kkoukiou@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoqemu: stop passing -enable-fips to QEMU >= 5.2.0
Daniel P. Berrangé [Tue, 20 Oct 2020 16:48:59 +0000 (17:48 +0100)]
qemu: stop passing -enable-fips to QEMU >= 5.2.0

Use of the -enable-fips option is being deprecated in QEMU >= 5.2.0. If
FIPS compliance is required, QEMU must be built with libcrypt which will
unconditionally enforce it.

Thus there is no need for libvirt to pass -enable-fips to modern QEMU.
Unfortunately there was never any way to probe for -enable-fips in the
first instance, it was enabled by libvirt based on version number
originally, and then later unconditionally enabled when libvirt dropped
support for older QEMU. Similarly we now use a version number check to
decide when to stop passing -enable-fips.

Note that the qemu-5.2 capabilities are currently from the pre-release
version and will be updated once qemu-5.2 is released.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemuxml2argvtest: Sanitize testing of '-enable-fips'
Peter Krempa [Wed, 21 Oct 2020 08:08:11 +0000 (10:08 +0200)]
qemuxml2argvtest: Sanitize testing of '-enable-fips'

Rename 'FLAG_FIPS' to 'FLAG_FIPS_HOST' to signify that we are simulating
a host supporting fips mode and use the flag to assert 'enabeFips'
argument of 'qemuProcessCreatePretendCmdBuild' rather than passing it
via QEMU_CAPS_ENABLE_FIPS.

This prepares the testsuite for testing of -enable-fips deprecation in
qemu-5.2.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>