]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
4 years agogitlab: Fix build container dependencies for build jobs
Andrea Bolognani [Tue, 9 Feb 2021 09:26:55 +0000 (10:26 +0100)]
gitlab: Fix build container dependencies for build jobs

A couple of these were wrong, resulting in the build job not
waiting for the correct container to be built before starting.

Fixes: 77296c807b18d22286be4b0ba5595d13103910a1
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
4 years agocpu: Fix build on some aarch64 platforms
Andrea Bolognani [Fri, 5 Feb 2021 13:07:27 +0000 (14:07 +0100)]
cpu: Fix build on some aarch64 platforms

On platforms that lack both getauxval() and elf_aux_info(),
such as OpenBSD and macOS, host CPU detection can't work.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agocpu: Only retrieve AT_HWCAP once
Andrea Bolognani [Fri, 5 Feb 2021 14:01:46 +0000 (15:01 +0100)]
cpu: Only retrieve AT_HWCAP once

No need to fetch the same information twice.

As a side effect, this solves a bug where, on platforms where
elf_aux_info() is used instead of getauxval(), we would not
make sure the CPUID feature is available before attempting to
use it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agocpu: Only include <sys/auxv.h> if available
Andrea Bolognani [Fri, 5 Feb 2021 14:03:32 +0000 (15:03 +0100)]
cpu: Only include <sys/auxv.h> if available

This header is not present on several non-Linux targets that
nonetheless support aarch64.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agoqemu: Release <memory/> device address on failed hotplug
Michal Privoznik [Mon, 8 Feb 2021 14:21:16 +0000 (15:21 +0100)]
qemu: Release <memory/> device address on failed hotplug

A few commits back I've introduced new 'virtio-pmem' <memory/>
device. Since it's virtio it goes onto PCI bus. Therefore, on
hotplug new PCI address is generated (or provided one is
reserved). However, if hotplug fails (for whatever reason) the
address needs to be released. This is different to 'dimm' type of
address because for that type we don't keep a map of used slots
rather generate one on each address assign request. The map is
then thrown away. But for PCI addresses we keep internal state
and thus has to keep it updated. Therefore, this new
qemuDomainReleaseMemoryDeviceSlot() function is NOP for those
models which use 'dimm' address type ('dimm' and 'nvdimm').

While I'm at it, let's release the address in case of hot unplug.
Not that is supported (any such attempt fails with the following
error:

  "virtio based memory devices cannot be unplugged"

But if QEMU ever implements hot unplug then we don't have to
remember to fix our code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
4 years agobhyve: auto allocate nmdm console paths
Roman Bogorodskiy [Sun, 7 Feb 2021 03:57:07 +0000 (07:57 +0400)]
bhyve: auto allocate nmdm console paths

Currently, nmdm console device requires user to specify master and slave
path attributes (such as /dev/nmdm0A and /dev/nmdm0B respectively).
However, making user find a non-occupied device name might be not
convenient, especially for the remote connections.

Update the logic to make these attributes optional. In case if not
specified, use /dev/nmdm$UUID[AB], where $UUID is a domain's UUID.
With this schema it's unlikely nmdm device will clash with other domains
or even other non-bhyve nmdm devices.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
4 years agoTranslated using Weblate (Finnish)
Jan Kuparinen [Sat, 6 Feb 2021 19:40:11 +0000 (20:40 +0100)]
Translated using Weblate (Finnish)

Currently translated at 13.5% (1415 of 10451 strings)

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

Co-authored-by: Jan Kuparinen <copper_fin@hotmail.com>
Signed-off-by: Jan Kuparinen <copper_fin@hotmail.com>
4 years agoconf: allow virtio driver attributes for vhostuser disk
Pavel Hrdina [Fri, 5 Feb 2021 12:05:54 +0000 (13:05 +0100)]
conf: allow virtio driver attributes for vhostuser disk

All of these options are actually supported by vhostuser disk so
we should allow them to be usable.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agobhyve: drop emulator binary value check
Roman Bogorodskiy [Thu, 4 Feb 2021 15:29:44 +0000 (19:29 +0400)]
bhyve: drop emulator binary value check

Currently, requesting domain capabilities fails when the specified
emulator binary does not equal to "/usr/sbin/bhyve". As we're
not using user-specified emulator anyway, drop this check to avoid
showing errors for values like "bhyve" (without absolute path).

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodocs: Remove broken link to Xen channel doc
Jim Fehlig [Thu, 4 Feb 2021 23:32:50 +0000 (16:32 -0700)]
docs: Remove broken link to Xen channel doc

Many of Xen's text documents have been converted to man pages over
the years, the channel doc being one of them. Replace the broken
channel.txt link with the name of the man page providing the same
information.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodocs: Add 'known_hosts_verify' parameter for libssh(2) connection uris
Jakob Meng [Fri, 29 Jan 2021 12:55:06 +0000 (13:55 +0100)]
docs: Add 'known_hosts_verify' parameter for libssh(2) connection uris

Parameter 'known_hosts_verify' is supported for some time now,
but it is not yet documented.

Signed-off-by: Jakob Meng <jakobmeng@web.de>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemuDomainAttachRedirdevDevice: Remove need_release variable
Yi Li [Wed, 3 Feb 2021 06:18:34 +0000 (14:18 +0800)]
qemuDomainAttachRedirdevDevice: Remove need_release variable

Get rid of the 'need_release' variable. The code can be rewritten
so that it is not needed.

Signed-off-by: Yi Li <yili@winhong.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoRevert "tests: Avoid gnulib replacements in mocks"
Andrea Bolognani [Thu, 4 Feb 2021 10:05:48 +0000 (11:05 +0100)]
Revert "tests: Avoid gnulib replacements in mocks"

Now that we're no longer using gnulib, we can treat macOS the
same as all other targets.

This reverts commit 0ae6f5cea54d95c0d1dedf04a0a2accfe2529fb2

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Tested-by: Roman Bolshakov <r.bolshakov@yadro.com>
4 years agoutil: Remove '\n' from vhostuser ifname
Yalei Li [Fri, 5 Feb 2021 03:10:51 +0000 (11:10 +0800)]
util: Remove '\n' from vhostuser ifname

When deleting the vhostuserclient interface, OVS prompts that the interface does not exist,
Through the XML file, I found that the "target dev" has a '\n', results in an XML parsing error.

XML file:

<target dev='vm-20ac9c030a47
'/>

That is because 'ovs-vsctl' returns a newline result, always come with a '\n',
and the vircommandrun function puts it in ifname.

So virNetDevOpenvswitchGetVhostuserIfname should remove '\n' from ifname.

Signed-off-by: Yalei Li <liyl43@chinatelecom.cn>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agodatatypes: replace VIR_FREE with g_free in all *Dispose() functions
Laine Stump [Wed, 3 Feb 2021 20:16:43 +0000 (15:16 -0500)]
datatypes: replace VIR_FREE with g_free in all *Dispose() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agotests: replace VIR_FREE with g_free in all *Dispose() functions
Laine Stump [Wed, 3 Feb 2021 20:15:50 +0000 (15:15 -0500)]
tests: replace VIR_FREE with g_free in all *Dispose() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoconf: replace VIR_FREE with g_free in all *Dispose() functions
Laine Stump [Wed, 3 Feb 2021 20:15:35 +0000 (15:15 -0500)]
conf: replace VIR_FREE with g_free in all *Dispose() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoutil: replace VIR_FREE with g_free in all *Dispose() functions
Laine Stump [Wed, 3 Feb 2021 20:15:23 +0000 (15:15 -0500)]
util: replace VIR_FREE with g_free in all *Dispose() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agosecurity: replace VIR_FREE with g_free in all *Dispose() functions
Laine Stump [Wed, 3 Feb 2021 20:15:18 +0000 (15:15 -0500)]
security: replace VIR_FREE with g_free in all *Dispose() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agorpc: replace VIR_FREE with g_free in all *Dispose() functions
Laine Stump [Wed, 3 Feb 2021 20:14:57 +0000 (15:14 -0500)]
rpc: replace VIR_FREE with g_free in all *Dispose() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agologging: replace VIR_FREE with g_free in all *Dispose() functions
Laine Stump [Wed, 3 Feb 2021 20:14:51 +0000 (15:14 -0500)]
logging: replace VIR_FREE with g_free in all *Dispose() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agohypervisor: replace VIR_FREE with g_free in all *Dispose() functions
Laine Stump [Wed, 3 Feb 2021 20:14:27 +0000 (15:14 -0500)]
hypervisor: replace VIR_FREE with g_free in all *Dispose() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoaccess: replace VIR_FREE with g_free in all *Dispose() functions
Laine Stump [Wed, 3 Feb 2021 20:14:21 +0000 (15:14 -0500)]
access: replace VIR_FREE with g_free in all *Dispose() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agointerface: replace VIR_FREE with g_free in all *Dispose() functions
Laine Stump [Wed, 3 Feb 2021 19:55:20 +0000 (14:55 -0500)]
interface: replace VIR_FREE with g_free in all *Dispose() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoqemu: replace VIR_FREE with g_free in all *Dispose() functions
Laine Stump [Wed, 3 Feb 2021 20:13:53 +0000 (15:13 -0500)]
qemu: replace VIR_FREE with g_free in all *Dispose() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agolibxl: replace VIR_FREE with g_free in all *Dispose() functions
Laine Stump [Wed, 3 Feb 2021 20:13:46 +0000 (15:13 -0500)]
libxl: replace VIR_FREE with g_free in all *Dispose() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agobhyve: replace VIR_FREE with g_free in all *Dispose() functions
Laine Stump [Wed, 3 Feb 2021 20:13:23 +0000 (15:13 -0500)]
bhyve: replace VIR_FREE with g_free in all *Dispose() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agorpc: eliminate static function virNetLibsshSessionAuthMethodsFree()
Laine Stump [Thu, 4 Feb 2021 02:12:21 +0000 (21:12 -0500)]
rpc: eliminate static function virNetLibsshSessionAuthMethodsFree()

This function is only called from one place, and has, well... not a
*misleading* name, but it doesn't fit the standard frame of functions
that end in "Free" (it doesn't actually free the object pointed to by
its argument, but frees *some parts* of the content of the object).

Rather than try to think up an appropriate name, let's just move the
meat of this function into its one and only caller,
virNetLibsshSessionDispose(), which will allow us to convert its
VIR_FREEs into g_free in a future patch.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoconf: simplify virDomainCapsDispose()
Laine Stump [Tue, 2 Feb 2021 06:11:30 +0000 (01:11 -0500)]
conf: simplify virDomainCapsDispose()

virDomainCapsDispose() was the only caller of
virDomainCapsStringValuesFree(), which 1) didn't actually free the
object it was called with, but only cleared it, making it less
mechanical to convert from VIR_FREE to g_free (since it's not
immediately obvious from looking at virDomainCapsStringValuesFree()
that the pointers being cleared will never again be used).

We could have renamed the function to virDomainCapsStringValuesClear()
to side-step the confusion of what the function actually does, but
that would just make the upcoming switch from VIR_FREE to g_free
require more thought. But since there is only a single caller to the
function, and it is a vir*Dispose() function (indicating that the
object containing the virDomainCapsStringValues is going to be freed
immediately after the function finishes), and thus VIR_FREE() *could*
be safely replaced by g_free()), we instead just move the contents of
virDomainCapsStringValuesFree() into virDomainCapsDispose() (and
*that* function will be trivially converted in an upcoming
"mechanical" patch).

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agorpc: rename virNetSessionAuthMethodsFree to virNetSessionAuthMethodsClear
Laine Stump [Thu, 4 Feb 2021 02:51:04 +0000 (21:51 -0500)]
rpc: rename virNetSessionAuthMethodsFree to virNetSessionAuthMethodsClear

This is another *Free() function that doesn't free the object it is
passed. Instead it frees and clears some parts of the object.

In this case, the function is actually called from two places, and one
of them (virNetSSHSessionAuthReset) appears to be assuming that the
pointers actually *will* be cleared. So the proper thing to do here
(?) is to rename the function to virNetSSHSesionAuthMethodsClear().

(NB: virNetSSHSessionAuthReset is seemingly never called from
anywhere. Is this one of those functions that actually *is* called by
some strange MACRO invocation? Or it is truly one of those
"written-but-never-used" functions that can be deleted? (if the latter
is the case, then I would rather move the contents of
virNetSessionAuthMethodsFree() into its only other caller,
virNetSSHSessionDispose(), so that the VIR_FREEs could be replaced
with g_free.)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoqemu: replace VIR_FREE with g_free in qemuFirmware*FreeContent()
Laine Stump [Thu, 4 Feb 2021 02:07:20 +0000 (21:07 -0500)]
qemu: replace VIR_FREE with g_free in qemuFirmware*FreeContent()

These functions are all only called as a part of qemuFirmwareFree(),
which frees the qemuFirmware object before return, so we can be sure
none of the pointers is referenced after freeing (and thus there is no
need to clear any of them).

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoqemu: pass pointers instead of copying objects for qemuFirmware*FreeContent()
Laine Stump [Wed, 3 Feb 2021 21:57:57 +0000 (16:57 -0500)]
qemu: pass pointers instead of copying objects for qemuFirmware*FreeContent()

These functions all cooperate to free memory pointed to by a single
object that contains (doesn't *point to*, but actually contains)
several sub-objects. They were written to send copies of these
sub-objects to subordinate functions, rather than just sending
pointers to the sub-objects.

Let's change these functions to just send pointers to the objects
they're cleaning out rather than all the wasteful and pointless
copying.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoqemu: rename virFirmware*Free() functions to have more accurate names
Laine Stump [Wed, 3 Feb 2021 21:07:59 +0000 (16:07 -0500)]
qemu: rename virFirmware*Free() functions to have more accurate names

Several functions had the names virFirmware[something]Free(), but they
aren't taking a pointer to some object and freeing it. Instead, they
are making a copy of the content of an entire object, then Freeing the
objects pointed to by that content.

As a first step in a too-complicated cleanup just to eliminate a few
occurrences of VIR_FREE(), this patch renames those functions to more
accurately reflect what they do - they Free the *Content* of their
arguments.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoutil: rename two *Free() functions while changing VIR_FREE to g_free
Laine Stump [Thu, 4 Feb 2021 02:38:59 +0000 (21:38 -0500)]
util: rename two *Free() functions while changing VIR_FREE to g_free

dhcpHostFree() and addnHostFree() don't follow the normal pattern of
*Free functions in the rest of libvirt code - they are actually more
similar to the *Dispose() functions, in that they free all subordinate
objects, but not the object pointed to by the argument
itself. However, the arguments aren't virObjects, so it wouldn't be
proper to name them *Dispose() either.

They *currently* behave similar to a *Clear() function, in that they
free all the subordinate objects and nullify the pointers of those
objects. HOWEVER, we don't actually need or want that behavior - the
two functions in question are only called as part of a higher level
*Free() function, and the pointers are not referenced in any way
between the time they are freed and when the parent object is freed.

So, since the current name isn't correct, nor is *Dispose(), and we
want to change the behavior in such a way that *Clear() also wouldn't
be correct, lets name the functions *FreeContent(), which is an
accurate description of what the functions do, and what we *want* them
to do.

And since it's such a small patch, we can go ahead and change that
behavior - replacing the VIR_FREEs with g_free.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agolibvirtd: replace straggler VIR_FREE with g_free in all vir*Free() functions
Laine Stump [Wed, 3 Feb 2021 19:58:38 +0000 (14:58 -0500)]
libvirtd: replace straggler VIR_FREE with g_free in all vir*Free() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agostorage: replace VIR_FREE with g_free in all vir*Free() functions
Laine Stump [Wed, 3 Feb 2021 19:35:44 +0000 (14:35 -0500)]
storage: replace VIR_FREE with g_free in all vir*Free() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agotests: replace VIR_FREE with g_free in all vir*Free() functions
Laine Stump [Wed, 3 Feb 2021 19:35:02 +0000 (14:35 -0500)]
tests: replace VIR_FREE with g_free in all vir*Free() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agotools: replace VIR_FREE with g_free in all vir*Free() functions
Laine Stump [Wed, 3 Feb 2021 19:32:55 +0000 (14:32 -0500)]
tools: replace VIR_FREE with g_free in all vir*Free() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agosecurity: replace VIR_FREE with g_free in all vir*Free() functions
Laine Stump [Wed, 3 Feb 2021 19:40:30 +0000 (14:40 -0500)]
security: replace VIR_FREE with g_free in all vir*Free() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agorpc: replace VIR_FREE with g_free in all vir*Free() functions
Laine Stump [Wed, 3 Feb 2021 19:40:09 +0000 (14:40 -0500)]
rpc: replace VIR_FREE with g_free in all vir*Free() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoremote: replace VIR_FREE with g_free in all vir*Free() functions
Laine Stump [Wed, 3 Feb 2021 19:54:59 +0000 (14:54 -0500)]
remote: replace VIR_FREE with g_free in all vir*Free() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agologging: replace VIR_FREE with g_free in all vir*Free() functions
Laine Stump [Wed, 3 Feb 2021 19:37:07 +0000 (14:37 -0500)]
logging: replace VIR_FREE with g_free in all vir*Free() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agolocking: replace VIR_FREE with g_free in all vir*Free() functions
Laine Stump [Wed, 3 Feb 2021 19:37:59 +0000 (14:37 -0500)]
locking: replace VIR_FREE with g_free in all vir*Free() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoadmin: replace VIR_FREE with g_free in all vir*Free() functions
Laine Stump [Wed, 3 Feb 2021 19:57:46 +0000 (14:57 -0500)]
admin: replace VIR_FREE with g_free in all vir*Free() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agovz: replace VIR_FREE with g_free in all vir*Free() functions
Laine Stump [Wed, 3 Feb 2021 19:35:19 +0000 (14:35 -0500)]
vz: replace VIR_FREE with g_free in all vir*Free() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agovmx: replace VIR_FREE with g_free in all vir*Free() functions
Laine Stump [Wed, 3 Feb 2021 19:56:20 +0000 (14:56 -0500)]
vmx: replace VIR_FREE with g_free in all vir*Free() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agovbox: replace VIR_FREE with g_free in all vir*Free() functions
Laine Stump [Wed, 3 Feb 2021 19:55:36 +0000 (14:55 -0500)]
vbox: replace VIR_FREE with g_free in all vir*Free() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agotest_driver: replace VIR_FREE with g_free in all vir*Free() functions
Laine Stump [Wed, 3 Feb 2021 19:54:40 +0000 (14:54 -0500)]
test_driver: replace VIR_FREE with g_free in all vir*Free() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoqemu: replace VIR_FREE with g_free in all vir*Free() functions
Laine Stump [Wed, 3 Feb 2021 19:36:01 +0000 (14:36 -0500)]
qemu: replace VIR_FREE with g_free in all vir*Free() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agolibxl: replace VIR_FREE with g_free in all vir*Free() functions
Laine Stump [Wed, 3 Feb 2021 19:40:15 +0000 (14:40 -0500)]
libxl: replace VIR_FREE with g_free in all vir*Free() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agobhyve: replace VIR_FREE with g_free in all vir*Free() functions
Laine Stump [Wed, 3 Feb 2021 19:55:29 +0000 (14:55 -0500)]
bhyve: replace VIR_FREE with g_free in all vir*Free() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoutil: replace VIR_FREE with g_free in all vir*Free() functions
Laine Stump [Wed, 3 Feb 2021 19:32:34 +0000 (14:32 -0500)]
util: replace VIR_FREE with g_free in all vir*Free() functions

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agoconf: replace remaining straggler VIR_FREE with g_free in vir*Free()
Laine Stump [Wed, 3 Feb 2021 19:34:14 +0000 (14:34 -0500)]
conf: replace remaining straggler VIR_FREE with g_free in vir*Free()

I missed a few in commit f9f81f1c

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
4 years agotests: Improve macOS stat() mocking logic
Andrea Bolognani [Wed, 3 Feb 2021 11:32:46 +0000 (12:32 +0100)]
tests: Improve macOS stat() mocking logic

We should not mock stat64() when building on Apple Silicon,
because the declaration is not present in the header file.
Detect this situation and handle it gracefully.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agotests: Split macOS stat() mocking logic
Andrea Bolognani [Wed, 3 Feb 2021 11:32:13 +0000 (12:32 +0100)]
tests: Split macOS stat() mocking logic

On macOS, most of the symbols and declarations that we look at
to determine which versions of stat() we need to mock are not
present; on the other hand, there are some specific wrinkles
that are introduced with Apple Silicon which we will need to
take care of.

To avoid making the logic even more of an opaque mess than it
currently is, move the macOS part to a separate branch.

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 agoqemu_driver: increase recorded counter for disk block stats
Pavel Hrdina [Wed, 3 Feb 2021 15:28:40 +0000 (16:28 +0100)]
qemu_driver: increase recorded counter for disk block stats

Commit <318d807a0bd3372b634d1952b559c5c627ccfa5b> added a fix to skip
most of the block stat code to not log error message for missing storage
sources but forgot to increase the recordnr counter.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoqemu_monitor_json: fix JSON generator for VC chardev
Pavel Hrdina [Mon, 1 Feb 2021 10:59:48 +0000 (11:59 +0100)]
qemu_monitor_json: fix JSON generator for VC chardev

The correct backend type is 'vc', same as in qemuBuildChrChardevStr()
where we generate qemu command line.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
4 years agoTranslated using Weblate (Finnish)
Jan Kuparinen [Wed, 3 Feb 2021 18:40:09 +0000 (19:40 +0100)]
Translated using Weblate (Finnish)

Currently translated at 13.4% (1404 of 10451 strings)

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

Co-authored-by: Jan Kuparinen <copper_fin@hotmail.com>
Signed-off-by: Jan Kuparinen <copper_fin@hotmail.com>
4 years agovircgroup: Don't leak @parent in virCgroupEnableMissingControllers()
Michal Privoznik [Wed, 3 Feb 2021 19:17:15 +0000 (20:17 +0100)]
vircgroup: Don't leak @parent in virCgroupEnableMissingControllers()

A memory leak was identified in
virCgroupEnableMissingControllers():

==11680==    at 0x483EAE5: calloc (vg_replace_malloc.c:760)
==11680==    by 0x4E51780: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.6701.0)
==11680==    by 0x4908618: virCgroupNew (vircgroup.c:701)
==11680==    by 0x49096F4: virCgroupEnableMissingControllers (vircgroup.c:1146)
==11680==    by 0x4909B17: virCgroupNewMachineSystemd (vircgroup.c:1228)
==11680==    by 0x4909E94: virCgroupNewMachine (vircgroup.c:1313)
==11680==    by 0x1694FDBC: qemuInitCgroup (qemu_cgroup.c:946)
==11680==    by 0x1695046B: qemuSetupCgroup (qemu_cgroup.c:1083)
==11680==    by 0x16A60126: qemuProcessLaunch (qemu_process.c:7077)
==11680==    by 0x16A61504: qemuProcessStart (qemu_process.c:7384)
==11680==    by 0x169B84C2: qemuDomainObjStart (qemu_driver.c:6590)
==11680==    by 0x169B8776: qemuDomainCreateWithFlags (qemu_driver.c:6641)

What happens is that new virCgroup is created and stored into
@parent. Then, if @tokens is not empty the for() loop is entered
into where another virCgroup is created and @parent is replaced
with this new virCgroup. But nothing freed the old @parent.

Fixes: 77291414c7a8745cf4d2b06d3c38d269cfbcfe32
Reported-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
4 years agobuild: fix specfile logic for disabling netcf
Laine Stump [Tue, 2 Feb 2021 17:51:48 +0000 (12:51 -0500)]
build: fix specfile logic for disabling netcf

I *thought* I had tested all the combinations of manually setting
--without netcf, different versions of Fedora, etc, but apparently
not.

The check in libvirt.spec.in to see if the target was an older Fedora
or older RHEL would alway resolve to true, because, e.g., if {?fedora}
is undefined, then "0%{?fedora} < 34" is "0 < 34", which is always
true. Since both {?fedora} and {?rhel} are never defined at the same
time, the result of the entire expression is always true.

Fix this by qualifying each subexpression.

Fixes: 35d5b26aa433bd33f4b33be3dbb67313357f97f9
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: implement vhost-user-blk support
Pavel Hrdina [Mon, 1 Feb 2021 11:00:35 +0000 (12:00 +0100)]
qemu: implement vhost-user-blk support

Implements QEMU support for vhost-user-blk together with live
hotplug/unplug.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu_capabilities: introduce vhost-user-blk capability
Pavel Hrdina [Tue, 2 Feb 2021 12:37:02 +0000 (13:37 +0100)]
qemu_capabilities: introduce vhost-user-blk capability

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoconf: implement support for vhostuser disk
Pavel Hrdina [Mon, 25 Jan 2021 17:13:29 +0000 (18:13 +0100)]
conf: implement support for vhostuser disk

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agodocs: introduces new vhostuser disk type
Pavel Hrdina [Mon, 25 Jan 2021 14:59:02 +0000 (15:59 +0100)]
docs: introduces new vhostuser disk type

     <disk type='vhostuser' device='disk'>
       <driver name='qemu' type='raw'/>
       <source type='unix' path='/tmp/vhost-blk.sock'>
         <reconnect enabled='yes' timeout='10'/>
       </source>
       <target dev='vda' bus='virtio'/>
     </disk>

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu_validate: move and refactor qemuValidateDomainDefVirtioFSSharedMemory
Pavel Hrdina [Mon, 1 Feb 2021 17:52:04 +0000 (18:52 +0100)]
qemu_validate: move and refactor qemuValidateDomainDefVirtioFSSharedMemory

Make the function reusable by other vhost-user based devices.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu_alias: introduce qemuDomainGetVhostUserAlias helper
Pavel Hrdina [Mon, 1 Feb 2021 10:59:03 +0000 (11:59 +0100)]
qemu_alias: introduce qemuDomainGetVhostUserAlias helper

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
4 years agoqemu: taint the VM if it is using a deprecated machine type
Daniel P. Berrangé [Fri, 22 Jan 2021 11:48:23 +0000 (11:48 +0000)]
qemu: taint the VM if it is using a deprecated machine type

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: taint the VM if it is using a deprecated CPU model
Daniel P. Berrangé [Fri, 22 Jan 2021 11:48:23 +0000 (11:48 +0000)]
qemu: taint the VM if it is using a deprecated CPU model

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: add ability to associate a string message with taint warning
Daniel P. Berrangé [Fri, 22 Jan 2021 11:44:32 +0000 (11:44 +0000)]
qemu: add ability to associate a string message with taint warning

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoconf: introduce new taint flag for deprecated configuration
Daniel P. Berrangé [Fri, 22 Jan 2021 11:43:02 +0000 (11:43 +0000)]
conf: introduce new taint flag for deprecated configuration

Hypervisors are capable of reporting that some features are deprecated.
This should be used to mark a domain as tainted.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: report whether a machine type is deprecated in capabilities
Daniel P. Berrangé [Fri, 22 Jan 2021 12:16:23 +0000 (12:16 +0000)]
qemu: report whether a machine type is deprecated in capabilities

QEMU has the ability to mark machine types as deprecated. This should be
exposed to management applications in the capabilities.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: report whether a CPU model is deprecated in dom capabilities
Daniel P. Berrangé [Fri, 22 Jan 2021 11:15:08 +0000 (11:15 +0000)]
qemu: report whether a CPU model is deprecated in dom capabilities

QEMU has the ability to mark CPUs as deprecated. This should be exposed
to management applications in the domain capabilities.

This attribute is only set when the model is actually deprecated.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agodocs: use a relative link to the kbase page
Daniel P. Berrangé [Fri, 22 Jan 2021 15:24:34 +0000 (15:24 +0000)]
docs: use a relative link to the kbase page

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoviralloc: Remove VIR_ALLOC_VAR
Peter Krempa [Wed, 3 Feb 2021 12:43:28 +0000 (13:43 +0100)]
viralloc: Remove VIR_ALLOC_VAR

The use case VIR_ALLOC_VAR deals with is very unlikely. We had just 2
legitimate uses, which were reimplemented locally using g_malloc0 and
sizeof instead as they used a static number of members of the trailing
array.

Remove VIR_ALLOC_VAR since in most cases the direct implementation is
shorter and clearer and there are no users of it currently.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirNetDevGetEthtoolGFeatures: Avoid use of VIR_ALLOC_VAR
Peter Krempa [Wed, 3 Feb 2021 12:33:24 +0000 (13:33 +0100)]
virNetDevGetEthtoolGFeatures: Avoid use of VIR_ALLOC_VAR

In this case we need a 'struct ethtool_gfeatures' followed by two
'struct ethtool_get_features_block' so there's no risk of overflow.

Use g_malloc0 and sizeof() to allocate the memory instead of
VIR_ALLOC_VAR.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agolocking: sanlock: Avoid use of VIR_ALLOC_VAR for 'struct sanlk_resource'
Peter Krempa [Wed, 3 Feb 2021 12:31:15 +0000 (13:31 +0100)]
locking: sanlock: Avoid use of VIR_ALLOC_VAR for 'struct sanlk_resource'

In both cases we need memory for a 'struct sanlk_resource' followed by
one 'struct sanlk_disk', thus there's no risk of overflow.

Use g_malloc0 and sizeof() to allocate the memory instead of
VIR_ALLOC_VAR.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirLockManagerSanlockAddDisk: Refactor cleanup
Peter Krempa [Wed, 3 Feb 2021 12:25:46 +0000 (13:25 +0100)]
virLockManagerSanlockAddDisk: Refactor cleanup

Use g_autofree to allow removal of 'cleanup:' and the 'ret' variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirLockManagerSanlockAddLease: Refactor cleanup
Peter Krempa [Wed, 3 Feb 2021 12:25:40 +0000 (13:25 +0100)]
virLockManagerSanlockAddLease: Refactor cleanup

Use g_autofree and remove the 'cleanup' section and 'ret' variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirNWFilterVarCombIter: Allocate 'iter' member separately
Peter Krempa [Wed, 3 Feb 2021 12:42:00 +0000 (13:42 +0100)]
virNWFilterVarCombIter: Allocate 'iter' member separately

Switch to the more common approach of having arrays allocated separately
rather than trailing the struct.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoutil: alloc: Remove VIR_DISPOSE_STRING
Peter Krempa [Tue, 2 Feb 2021 15:22:43 +0000 (16:22 +0100)]
util: alloc: Remove VIR_DISPOSE_STRING

Users were replaced with virSecureEraseString with explicit freeing of
the memory.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirnetlibsshsession: Replace VIR_DISPOSE_STRING with virSecureEraseString
Peter Krempa [Tue, 2 Feb 2021 16:22:02 +0000 (17:22 +0100)]
virnetlibsshsession: Replace VIR_DISPOSE_STRING with virSecureEraseString

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoutil: alloc: Remove VIR_AUTODISPOSE_STR
Peter Krempa [Tue, 2 Feb 2021 15:21:50 +0000 (16:21 +0100)]
util: alloc: Remove VIR_AUTODISPOSE_STR

There are no users any more. The replacement is to use g_auto and
virSecureEraseString explicitly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirNetLibsshAuthenticatePassword: Use virSecureEraseString instead of VIR_AUTODISPOSE_STR
Peter Krempa [Tue, 2 Feb 2021 16:05:23 +0000 (17:05 +0100)]
virNetLibsshAuthenticatePassword: Use virSecureEraseString instead of VIR_AUTODISPOSE_STR

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agocmdSecretGetValue: Use virSecureEraseString instead of VIR_AUTODISPOSE_STR
Peter Krempa [Tue, 2 Feb 2021 16:05:23 +0000 (17:05 +0100)]
cmdSecretGetValue: Use virSecureEraseString instead of VIR_AUTODISPOSE_STR

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirStorageBackendRBDOpenRADOSConn: Use virSecureEraseString instead of VIR_AUTODISPOS...
Peter Krempa [Tue, 2 Feb 2021 16:05:23 +0000 (17:05 +0100)]
virStorageBackendRBDOpenRADOSConn: Use virSecureEraseString instead of VIR_AUTODISPOSE_STR

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemuBuildRBDSecinfoURI: Use virSecureEraseString instead of VIR_AUTODISPOSE_STR
Peter Krempa [Tue, 2 Feb 2021 16:04:30 +0000 (17:04 +0100)]
qemuBuildRBDSecinfoURI: Use virSecureEraseString instead of VIR_AUTODISPOSE_STR

In this instance attempting to be correct is really pointless since the
secret is formatted into another string which is not erased securely and
then put on the commandline.

Keep the secure handling for correctness.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agolibxlMakeNetworkDiskSrc: Use virSecureEraseString instead of VIR_AUTODISPOSE_STR
Peter Krempa [Tue, 2 Feb 2021 15:49:30 +0000 (16:49 +0100)]
libxlMakeNetworkDiskSrc: Use virSecureEraseString instead of VIR_AUTODISPOSE_STR

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoutil: virsecureerase: Introduce virSecureEraseString
Peter Krempa [Tue, 2 Feb 2021 14:49:10 +0000 (15:49 +0100)]
util: virsecureerase: Introduce virSecureEraseString

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoutil: viralloc: Remove VIR_DISPOSE(_N)
Peter Krempa [Mon, 1 Feb 2021 13:18:25 +0000 (14:18 +0100)]
util: viralloc: Remove VIR_DISPOSE(_N)

The macros are unused now and callers who care about clearing the memory
they use should use memset() appropriately.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agotests: viralloc: Remove testDispose case
Peter Krempa [Mon, 1 Feb 2021 13:16:54 +0000 (14:16 +0100)]
tests: viralloc: Remove testDispose case

The VIR_DISPOSE* APIs will be phased out. Additionally the test isn't
really doing useful work in ensuring that the values are indeed cleared
thus there's no point in keeping it around.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agostorageBackendCreateQemuImgSecretPath: Use virSecureErase instead of VIR_DISPOSE_N
Peter Krempa [Mon, 1 Feb 2021 13:13:53 +0000 (14:13 +0100)]
storageBackendCreateQemuImgSecretPath: Use virSecureErase instead of VIR_DISPOSE_N

Clear out the value using virSecureErase and free it with g_free so
that VIR_DISPOSE_N can be phased out.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirCryptoEncryptDataAESgnutls: Use virSecureErase instead of memset
Peter Krempa [Tue, 2 Feb 2021 14:44:55 +0000 (15:44 +0100)]
virCryptoEncryptDataAESgnutls: Use virSecureErase instead of memset

Clear the key and IV structs using virSecureErase.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirCryptoEncryptDataAESgnutls: Use virSecureErase instead of VIR_DISPOSE_N
Peter Krempa [Mon, 1 Feb 2021 13:13:53 +0000 (14:13 +0100)]
virCryptoEncryptDataAESgnutls: Use virSecureErase instead of VIR_DISPOSE_N

Clear out the value using virSecureErase and free it with g_free so
that VIR_DISPOSE_N can be phased out.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirStorageBackendRBDOpenRADOSConn: Use virSecureErase instead of VIR_DISPOSE_N
Peter Krempa [Mon, 1 Feb 2021 13:11:52 +0000 (14:11 +0100)]
virStorageBackendRBDOpenRADOSConn: Use virSecureErase instead of VIR_DISPOSE_N

Switch the secret value to 'g_autofree' for handling of the memory and
clear it out using virSecureErase.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirsh: cmdSecretGetValue: Use virSecureErase instead of VIR_DISPOSE_N
Peter Krempa [Mon, 1 Feb 2021 13:09:01 +0000 (14:09 +0100)]
virsh: cmdSecretGetValue: Use virSecureErase instead of VIR_DISPOSE_N

Switch the secret value to 'g_autofree' for handling of the memory and
clear it out using virSecureErase.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqemu: domain: Use virSecureErase for clearing secrets instead of VIR_DISPOSE_N
Peter Krempa [Mon, 1 Feb 2021 11:55:27 +0000 (12:55 +0100)]
qemu: domain: Use virSecureErase for clearing secrets instead of VIR_DISPOSE_N

Phase out use of VIR_DISPOSE_N from the qemu driver. Use memset in the
appropriate cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agolibxlMakeNetworkDiskSrc: Avoid use of VIR_DISPOSE_N
Peter Krempa [Mon, 1 Feb 2021 11:50:00 +0000 (12:50 +0100)]
libxlMakeNetworkDiskSrc: Avoid use of VIR_DISPOSE_N

Clear the secret right after use with virSecureErase.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agostorage_backend_iscsi(_direct): Properly clear secrets
Peter Krempa [Mon, 1 Feb 2021 11:15:57 +0000 (12:15 +0100)]
storage_backend_iscsi(_direct): Properly clear secrets

The code pretends that it cares about clearing the secret values, but
passes the secret value to a realloc, which may copy the value somewhere
else and doesn't sanitize the original location when it does so.

Since we want to construct a string from the value, let's copy it to a
new piece of memory which has the space for the 'NUL' byte ourselves, to
prevent a random realloc keeping the data around.

While at it, use virSecureErase instead of VIR_DISPOSE_N since it's
being phased out.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agovirsh: cmdSecretSetValue: Rework handling of the secret value
Peter Krempa [Mon, 1 Feb 2021 13:01:57 +0000 (14:01 +0100)]
virsh: cmdSecretSetValue: Rework handling of the secret value

Use a single buffer for the secret to make it easier to follow it's
lifecycle. For base64 decoding use a local temporary buffer which will
be cleared right away.

This also uses virSecureErase for clearing the bufer instead of
VIR_DISPOSE_N which is being phased out.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoutil: Introduce virsecureerase module
Peter Krempa [Tue, 2 Feb 2021 14:27:22 +0000 (15:27 +0100)]
util: Introduce virsecureerase module

The module will provide functions for disposing secrets stored in
memory.

Note that for now it's implemented using memset, which is not really
secure.

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