]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
5 years agotools: Use consistent error preservation and restoration calls
John Ferlan [Thu, 6 Dec 2018 17:33:57 +0000 (12:33 -0500)]
tools: Use consistent error preservation and restoration calls

Provide some consistency over error message variable name and usage
when saving error messages across possible other errors or possibility
of resetting of the last error.

Instead of virSaveLastError paired up with virSetError and virFreeError,
we should use the newer virErrorPreserveLast and virRestoreError.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovz: Use consistent error preservation and restoration calls
John Ferlan [Thu, 6 Dec 2018 17:33:49 +0000 (12:33 -0500)]
vz: Use consistent error preservation and restoration calls

Provide some consistency over error message variable name and usage
when saving error messages across possible other errors or possibility
of resetting of the last error.

Instead of virSaveLastError paired up with virSetError and virFreeError,
we should use the newer virErrorPreserveLast and virRestoreError.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: Use consistent error preservation and restoration calls
John Ferlan [Thu, 6 Dec 2018 17:33:39 +0000 (12:33 -0500)]
util: Use consistent error preservation and restoration calls

Provide some consistency over error message variable name and usage
when saving error messages across possible other errors or possibility
of resetting of the last error.

Instead of virSaveLastError paired up with virSetError and virFreeError,
we should use the newer virErrorPreserveLast and virRestoreError.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agostorage: Use consistent error preservation and restoration calls
John Ferlan [Thu, 6 Dec 2018 17:33:30 +0000 (12:33 -0500)]
storage: Use consistent error preservation and restoration calls

Provide some consistency over error message variable name and usage
when saving error messages across possible other errors or possibility
of resetting of the last error.

Instead of virSaveLastError paired up with virSetError and virFreeError,
we should use the newer virErrorPreserveLast and virRestoreError.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoremote: Use consistent error preservation and restoration calls
John Ferlan [Thu, 6 Dec 2018 17:33:20 +0000 (12:33 -0500)]
remote: Use consistent error preservation and restoration calls

Provide some consistency over error message variable name and usage
when saving error messages across possible other errors or possibility
of resetting of the last error.

Instead of virSaveLastError paired up with virSetError and virFreeError,
we should use the newer virErrorPreserveLast and virRestoreError.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Use consistent error preservation and restoration calls
John Ferlan [Thu, 6 Dec 2018 17:33:04 +0000 (12:33 -0500)]
qemu: Use consistent error preservation and restoration calls

Provide some consistency over error message variable name and usage
when saving error messages across possible other errors or possibility
of resetting of the last error.

Instead of virSaveLastError paired up with virSetError and virFreeError,
we should use the newer virErrorPreserveLast and virRestoreError.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agolxc: Use consistent error preservation and restoration calls
John Ferlan [Thu, 6 Dec 2018 17:32:37 +0000 (12:32 -0500)]
lxc: Use consistent error preservation and restoration calls

Provide some consistency over error message variable name and usage
when saving error messages across possible other errors or possibility
of resetting of the last error.

Instead of virSaveLastError paired up with virSetError and virFreeError,
we should use the newer virErrorPreserveLast and virRestoreError.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agolibxl: Use consistent error preservation and restoration calls
John Ferlan [Thu, 6 Dec 2018 17:32:28 +0000 (12:32 -0500)]
libxl: Use consistent error preservation and restoration calls

Provide some consistency over error message variable name and usage
when saving error messages across possible other errors or possibility
of resetting of the last error.

Instead of virSaveLastError paired up with virSetError and virFreeError,
we should use the newer virErrorPreserveLast and virRestoreError.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agosrc: Use consistent error preservation and restoration calls
John Ferlan [Thu, 6 Dec 2018 17:32:18 +0000 (12:32 -0500)]
src: Use consistent error preservation and restoration calls

Provide some consistency over error message variable name and usage
when saving error messages across possible other errors or possibility
of resetting of the last error.

Instead of virSaveLastError paired up with virSetError and virFreeError,
we should use the newer virErrorPreserveLast and virRestoreError.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: Use consistent error preservation and restoration calls
John Ferlan [Thu, 6 Dec 2018 17:32:06 +0000 (12:32 -0500)]
conf: Use consistent error preservation and restoration calls

Provide some consistency over error message variable name and usage
when saving error messages across possible other errors or possibility
of resetting of the last error.

Instead of virSaveLastError paired up with virSetError and virFreeError,
we should use the newer virErrorPreserveLast and virRestoreError.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: remove parse code for long-extinct "<state devaddr='d:b:s'/>
Laine Stump [Wed, 9 Oct 2019 13:52:25 +0000 (09:52 -0400)]
conf: remove parse code for long-extinct "<state devaddr='d:b:s'/>

Back in July 2009, in the days before libvirt supported explicitly
assigning a PCI address to every device, code was added to save the
PCI addresses of hotplugged network, disk, and hostdevs in the domain
status with this XML element:

   <state devaddr='domain:bus:slot'/>

This was added in commits 4e21a95a01654107, in v0.7.0, and 0c5b7b93
in v0.7.1.

Then just a few months later, in November 2009, The code that actually
formatted the "devaddr='blah'" into the status XML was removed by
commit 1b0cce7d3 (which "introduced a standardized data structure for
device addresses"). The code to *parse* the devaddr from the status
was left in for backward compatibility though (it just parses it into
the "standard" PCI address).

At the time the devaddr attribute was added, a few other attributes
already existed in the <state> element for network devices, and these
were removed over time (I haven't checked the exact dates of this),
but 10 years later, in libvirt v5.8.0, we *still* maintain code to
parse <state devaddr='blah'/> from the domain status.

In the meantime, even distros so old that we no longer support them in
upstream libvirt are using a libvirt new enough that it doesn't ever
write <state devaddr='blah'/> to the domain status XML.

Since the only way a current libvirt would ever encounter this element
would be if someone was upgrading directly from libvirt <= v0.7.5 with
running guests, it seems safe to finally remove the code that parses it.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agointernal: delete VIR_STEAL_PTR
Ján Tomko [Wed, 16 Oct 2019 11:48:56 +0000 (13:48 +0200)]
internal: delete VIR_STEAL_PTR

Delete the macro to prevent its usage in new code.

The GLib version should be used instead:
    p = g_steal_pointer(&ptr);

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoUse g_steal_pointer instead of VIR_STEAL_PTR everywhere
Ján Tomko [Wed, 16 Oct 2019 11:45:15 +0000 (13:45 +0200)]
Use g_steal_pointer instead of VIR_STEAL_PTR everywhere

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: use g_steal_pointer instead of VIR_STEAL_PTR
Ján Tomko [Wed, 16 Oct 2019 11:43:52 +0000 (13:43 +0200)]
util: use g_steal_pointer instead of VIR_STEAL_PTR

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotools: use g_steal_pointer instead of VIR_STEAL_PTR
Ján Tomko [Wed, 16 Oct 2019 11:43:36 +0000 (13:43 +0200)]
tools: use g_steal_pointer instead of VIR_STEAL_PTR

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: use g_steal_pointer instead of VIR_STEAL_PTR
Ján Tomko [Wed, 16 Oct 2019 11:43:18 +0000 (13:43 +0200)]
qemu: use g_steal_pointer instead of VIR_STEAL_PTR

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: use g_steal_pointer instead of VIR_STEAL_PTR
Ján Tomko [Wed, 16 Oct 2019 11:43:01 +0000 (13:43 +0200)]
conf: use g_steal_pointer instead of VIR_STEAL_PTR

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agointernal: delete VIR_RETURN_PTR
Ján Tomko [Wed, 16 Oct 2019 11:35:14 +0000 (13:35 +0200)]
internal: delete VIR_RETURN_PTR

Remove the macro definition to prevent its usage in new code.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoRemove all usage of VIR_RETURN_PTR
Ján Tomko [Wed, 16 Oct 2019 11:35:54 +0000 (13:35 +0200)]
Remove all usage of VIR_RETURN_PTR

Prefer:
    return g_steal_pointer(&ptr);

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: delete VIR_AUTOFREE
Ján Tomko [Wed, 16 Oct 2019 11:33:16 +0000 (13:33 +0200)]
util: delete VIR_AUTOFREE

Commit 1e2ae2e311c7453e7894e93688f8785736aa0618 deleted the last use
of VIR_AUTOFREE but forgot to delete the macro definition.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoRemove virautoclean.h
Ján Tomko [Tue, 15 Oct 2019 14:04:32 +0000 (16:04 +0200)]
Remove virautoclean.h

Now that we no longer use any of the macros from this file, remove it.

This also removes a typo.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoDelete virObjectAutoUnref
Ján Tomko [Tue, 15 Oct 2019 14:03:36 +0000 (16:03 +0200)]
Delete virObjectAutoUnref

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoUse g_autoptr instead of VIR_AUTOUNREF
Ján Tomko [Tue, 15 Oct 2019 12:47:50 +0000 (14:47 +0200)]
Use g_autoptr instead of VIR_AUTOUNREF

Now that all the types using VIR_AUTOUNREF have a cleanup func defined
to virObjectUnref, use g_autoptr instead of VIR_AUTOUNREF.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoDefine G_DEFINE_AUTOPTR_CLEANUP_FUNC for virDomainCheckpointDef
Ján Tomko [Tue, 15 Oct 2019 12:47:50 +0000 (14:47 +0200)]
Define G_DEFINE_AUTOPTR_CLEANUP_FUNC for virDomainCheckpointDef

Allow g_autoptr to be used instead of VIR_AUTOUNREF.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoUse g_autoptr instead of VIR_AUTOPTR
Ján Tomko [Tue, 15 Oct 2019 12:47:50 +0000 (14:47 +0200)]
Use g_autoptr instead of VIR_AUTOPTR

Since commit 44e7f029159ed701b4a1739ac711507ee53790ed
    util: rewrite auto cleanup macros to use glib's equivalent

VIR_AUTOPTR aliases to g_autoptr. Replace all of its use by the GLib
macro version.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoUse G_DEFINE_AUTOPTR_CLEANUP_FUNC instead of VIR_DEFINE_AUTOPTR_FUNC
Ján Tomko [Tue, 15 Oct 2019 12:47:50 +0000 (14:47 +0200)]
Use G_DEFINE_AUTOPTR_CLEANUP_FUNC instead of VIR_DEFINE_AUTOPTR_FUNC

Since commit 44e7f029159ed701b4a1739ac711507ee53790ed
    util: rewrite auto cleanup macros to use glib's equivalent

VIR_AUTOPTR aliases to g_autoptr. Replace all uses of VIR_DEFINE_AUTOPTR_FUNC
with G_DEFINE_AUTOPTR_CLEANUP_FUNC in preparation for replacing the
rest.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoUse g_autofree instead of VIR_AUTOFREE
Ján Tomko [Tue, 15 Oct 2019 13:16:31 +0000 (15:16 +0200)]
Use g_autofree instead of VIR_AUTOFREE

Since commit 44e7f029159ed701b4a1739ac711507ee53790ed
    util: rewrite auto cleanup macros to use glib's equivalent

VIR_AUTOFREE is just an alias for g_autofree. Use the GLib macros
directly instead of our custom aliases.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovirbuffer: use g_auto directly for virBuffer
Ján Tomko [Tue, 15 Oct 2019 12:47:50 +0000 (14:47 +0200)]
virbuffer: use g_auto directly for virBuffer

Since commit 44e7f029159ed701b4a1739ac711507ee53790ed
    util: rewrite auto cleanup macros to use glib's equivalent

VIR_AUTOCLEAN is just an alias for g_auto. Use the GLib macros
directly instead of our custom aliases.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: xml: use g_auto directly for VIR_XPATH_NODE_AUTORESTORE
Ján Tomko [Tue, 15 Oct 2019 12:47:50 +0000 (14:47 +0200)]
util: xml: use g_auto directly for VIR_XPATH_NODE_AUTORESTORE

Since commit 44e7f029159ed701b4a1739ac711507ee53790ed
    util: rewrite auto cleanup macros to use glib's equivalent

VIR_AUTOCLEAN is just an alias for g_auto. Use the GLib macros
directly instead of our custom aliases.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoUse G_N_ELEMENTS instead of ARRAY_CARDINALITY
Ján Tomko [Tue, 15 Oct 2019 11:55:26 +0000 (13:55 +0200)]
Use G_N_ELEMENTS instead of ARRAY_CARDINALITY

Prefer the GLib version of the macro.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoexamples: Use G_N_ELEMENTS instead of ARRAY_CARDINALITY
Ján Tomko [Tue, 15 Oct 2019 11:51:20 +0000 (13:51 +0200)]
examples: Use G_N_ELEMENTS instead of ARRAY_CARDINALITY

We try to keep the example programs independent of libraries
other than libvirt.

Rename the locally defined ARRAY_CARDINALITY macro to G_N_ELEMENTS
which GLib provides, even though we don't actually include GLib.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoUse G_GNUC_FALLTHROUGH instead of ATTRIBUTE_FALLTHROUGH
Ján Tomko [Tue, 15 Oct 2019 11:38:21 +0000 (13:38 +0200)]
Use G_GNUC_FALLTHROUGH instead of ATTRIBUTE_FALLTHROUGH

Also define the macro for building with GLib older than 2.60

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoDocument the ATTRIBUTE_FALLTHROUGH macro
Ján Tomko [Tue, 15 Oct 2019 11:36:47 +0000 (13:36 +0200)]
Document the ATTRIBUTE_FALLTHROUGH macro

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoUse G_GNUC_PRINTF instead of ATTRIBUTE_FMT_PRINTF
Ján Tomko [Tue, 15 Oct 2019 11:35:07 +0000 (13:35 +0200)]
Use G_GNUC_PRINTF instead of ATTRIBUTE_FMT_PRINTF

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoUse G_GNUC_NO_INLINE instead of ATTRIBUTE_NOINLINE
Ján Tomko [Tue, 15 Oct 2019 11:24:34 +0000 (13:24 +0200)]
Use G_GNUC_NO_INLINE instead of ATTRIBUTE_NOINLINE

Define the macro for older GLib versions.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agosyntax-check: prohibit_attribute_macros: generalize error
Ján Tomko [Tue, 15 Oct 2019 11:13:39 +0000 (13:13 +0200)]
syntax-check: prohibit_attribute_macros: generalize error

Instead of enumerating every single macro variant, just emit
a more generic error.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agosyntax-check: mock-noinline: fix after G_GNUC attribute invocations
Ján Tomko [Tue, 15 Oct 2019 11:12:34 +0000 (13:12 +0200)]
syntax-check: mock-noinline: fix after G_GNUC attribute invocations

We started using G_GNUC macros instead of ATTRIBUTE for some attributes.
Adjust this syntax-check accordingly.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: fix EFI nvram removal on domain undefine
Pavel Mores [Tue, 15 Oct 2019 08:31:22 +0000 (10:31 +0200)]
qemu: fix EFI nvram removal on domain undefine

When undefining a UEFI domain its nvram file has to be properly handled as
well.  It's mandatory to use one of --nvram and --keep-nvram options when
'virsh undefine <domain>' is issued for a UEFI domain.  To fix the bug as
reported, virsh should return an error message if neither option is used
and the nvram file should be removed when --nvram is given.

The cause of the problem is that when qemuDomainUndefineFlags() is invoked
on an inactive domain the path to its nvram file is empty.  This commit
aims to fix this by formatting and filling in the path in time for the
nvram removal code to run properly.

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

Signed-off-by: Pavel Mores <pmores@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agosyntax-check: forbid ATTRIBUTE macros with a GLib replacement
Ján Tomko [Mon, 14 Oct 2019 15:46:42 +0000 (17:46 +0200)]
syntax-check: forbid ATTRIBUTE macros with a GLib replacement

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agointernal: remove no longer used ATTRIBUTE macros
Ján Tomko [Mon, 14 Oct 2019 12:32:36 +0000 (14:32 +0200)]
internal: remove no longer used ATTRIBUTE macros

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agogendispatch: generate G_GNUC_UNUSED instead of ATTRIBUTE_UNUSED
Ján Tomko [Mon, 14 Oct 2019 13:03:17 +0000 (15:03 +0200)]
gendispatch: generate G_GNUC_UNUSED instead of ATTRIBUTE_UNUSED

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agosyntax-check: check for G_GNUC_UNUSED instead of ATTRIBUTE_UNUSED
Ján Tomko [Mon, 14 Oct 2019 13:02:40 +0000 (15:02 +0200)]
syntax-check: check for G_GNUC_UNUSED instead of ATTRIBUTE_UNUSED

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoUse G_GNUC_UNUSED everywhere
Ján Tomko [Mon, 14 Oct 2019 12:45:33 +0000 (14:45 +0200)]
Use G_GNUC_UNUSED everywhere

Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovz: use G_GNUC_UNUSED
Ján Tomko [Mon, 14 Oct 2019 12:45:33 +0000 (14:45 +0200)]
vz: use G_GNUC_UNUSED

Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovbox: use G_GNUC_UNUSED
Ján Tomko [Mon, 14 Oct 2019 12:45:33 +0000 (14:45 +0200)]
vbox: use G_GNUC_UNUSED

Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: use G_GNUC_UNUSED
Ján Tomko [Mon, 14 Oct 2019 12:45:33 +0000 (14:45 +0200)]
util: use G_GNUC_UNUSED

Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotools: use G_GNUC_UNUSED
Ján Tomko [Mon, 14 Oct 2019 12:44:29 +0000 (14:44 +0200)]
tools: use G_GNUC_UNUSED

Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: use G_GNUC_UNUSED
Ján Tomko [Mon, 14 Oct 2019 12:45:03 +0000 (14:45 +0200)]
tests: use G_GNUC_UNUSED

Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotest: use G_GNUC_UNUSED
Ján Tomko [Mon, 14 Oct 2019 12:45:33 +0000 (14:45 +0200)]
test: use G_GNUC_UNUSED

Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agostorage: use G_GNUC_UNUSED
Ján Tomko [Mon, 14 Oct 2019 12:45:33 +0000 (14:45 +0200)]
storage: use G_GNUC_UNUSED

Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agosecurity: use G_GNUC_UNUSED
Ján Tomko [Mon, 14 Oct 2019 12:45:33 +0000 (14:45 +0200)]
security: use G_GNUC_UNUSED

Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agorpc: use G_GNUC_UNUSED
Ján Tomko [Mon, 14 Oct 2019 12:45:33 +0000 (14:45 +0200)]
rpc: use G_GNUC_UNUSED

Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoremote: use G_GNUC_UNUSED
Ján Tomko [Mon, 14 Oct 2019 12:45:33 +0000 (14:45 +0200)]
remote: use G_GNUC_UNUSED

Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: use G_GNUC_UNUSED
Ján Tomko [Mon, 14 Oct 2019 12:45:33 +0000 (14:45 +0200)]
qemu: use G_GNUC_UNUSED

Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoopenvz: use G_GNUC_UNUSED
Ján Tomko [Mon, 14 Oct 2019 12:45:33 +0000 (14:45 +0200)]
openvz: use G_GNUC_UNUSED

Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agonwfilter: use G_GNUC_UNUSED
Ján Tomko [Mon, 14 Oct 2019 12:45:33 +0000 (14:45 +0200)]
nwfilter: use G_GNUC_UNUSED

Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agonode_device: use G_GNUC_UNUSED
Ján Tomko [Mon, 14 Oct 2019 12:45:33 +0000 (14:45 +0200)]
node_device: use G_GNUC_UNUSED

Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agonetwork: use G_GNUC_UNUSED
Ján Tomko [Mon, 14 Oct 2019 12:45:33 +0000 (14:45 +0200)]
network: use G_GNUC_UNUSED

Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agolxc: use G_GNUC_UNUSED
Ján Tomko [Mon, 14 Oct 2019 12:45:33 +0000 (14:45 +0200)]
lxc: use G_GNUC_UNUSED

Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agologging: use G_GNUC_UNUSED
Ján Tomko [Mon, 14 Oct 2019 12:45:33 +0000 (14:45 +0200)]
logging: use G_GNUC_UNUSED

Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agolocking: use G_GNUC_UNUSED
Ján Tomko [Mon, 14 Oct 2019 12:45:33 +0000 (14:45 +0200)]
locking: use G_GNUC_UNUSED

Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agolibxl: use G_GNUC_UNUSED
Ján Tomko [Mon, 14 Oct 2019 12:45:33 +0000 (14:45 +0200)]
libxl: use G_GNUC_UNUSED

Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoesx: use G_GNUC_UNUSED
Ján Tomko [Mon, 14 Oct 2019 12:45:33 +0000 (14:45 +0200)]
esx: use G_GNUC_UNUSED

Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agocpu: use G_GNUC_UNUSED
Ján Tomko [Mon, 14 Oct 2019 12:45:33 +0000 (14:45 +0200)]
cpu: use G_GNUC_UNUSED

Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: use G_GNUC_UNUSED
Ján Tomko [Mon, 14 Oct 2019 12:45:33 +0000 (14:45 +0200)]
conf: use G_GNUC_UNUSED

Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agobhyve: use G_GNUC_UNUSED
Ján Tomko [Mon, 14 Oct 2019 12:45:33 +0000 (14:45 +0200)]
bhyve: use G_GNUC_UNUSED

Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoadmin: use G_GNUC_UNUSED
Ján Tomko [Mon, 14 Oct 2019 12:45:33 +0000 (14:45 +0200)]
admin: use G_GNUC_UNUSED

Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoaccess: use G_GNUC_UNUSED
Ján Tomko [Mon, 14 Oct 2019 12:45:33 +0000 (14:45 +0200)]
access: use G_GNUC_UNUSED

Use G_GNUC_UNUSED from GLib instead of ATTRIBUTE_UNUSED.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoexamples: use G_GNUC_UNUSED
Ján Tomko [Mon, 14 Oct 2019 12:45:33 +0000 (14:45 +0200)]
examples: use G_GNUC_UNUSED

Name the macro G_GNUC_UNUSED instead of ATTRIBUTE_UNUSED
to match the rest of libvirt code.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoUse G_GNUC_WARN_UNUSED_RESULT instead of ATTRIBUTE_RETURN_CHECK
Ján Tomko [Mon, 14 Oct 2019 12:25:14 +0000 (14:25 +0200)]
Use G_GNUC_WARN_UNUSED_RESULT instead of ATTRIBUTE_RETURN_CHECK

Introduced in GLib 2.10.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agouse G_GNUC_NULL_TERMINATED instead of ATTRIBUTE_SENTINEL
Ján Tomko [Mon, 14 Oct 2019 12:13:31 +0000 (14:13 +0200)]
use G_GNUC_NULL_TERMINATED instead of ATTRIBUTE_SENTINEL

Prefer G_GNUC_NULL_TERMINATED which was introduced in GLib 2.8.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agouse G_GNUC_NORETURN instead of ATTRIBUTE_NORETURN
Ján Tomko [Mon, 14 Oct 2019 12:07:39 +0000 (14:07 +0200)]
use G_GNUC_NORETURN instead of ATTRIBUTE_NORETURN

Remove all usage of ATTRIBUTE_NORETURN in favor of GLib's
G_GNUC_NORETURN.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoapibuild: ignore GLib macros too
Ján Tomko [Mon, 14 Oct 2019 12:31:15 +0000 (14:31 +0200)]
apibuild: ignore GLib macros too

Add an exception for the GLib versions of the macros we already ignore.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoutil: remove MIN and MAX macros
Ján Tomko [Wed, 2 Oct 2019 20:38:01 +0000 (22:38 +0200)]
util: remove MIN and MAX macros

They are already defined in glib.h.

(libxml2 also has them defined)

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agosecurity_stack: Perform rollback if one of stacked drivers fails
Michal Privoznik [Wed, 11 Sep 2019 09:19:06 +0000 (11:19 +0200)]
security_stack: Perform rollback if one of stacked drivers fails

In order to have multiple security drivers hidden under one
virSecurity* call, we have virSecurityStack driver which holds a
list of registered security drivers and for every virSecurity*
call it iterates over the list and calls corresponding callback
in real security drivers. For instance, for
virSecurityManagerSetAllLabel() it calls
domainSetSecurityAllLabel callback sequentially in NOP, DAC and
(possibly) SELinux or AppArmor drivers. This works just fine if
the callback from every driver returns success. Problem arises
when one of the drivers fails. For instance, aforementioned
SetAllLabel() succeeds for DAC but fails in SELinux in which
case all files that DAC relabelled are now owned by qemu:qemu (or
whomever runs qemu) and thus permissions are leaked. This is even
more visible with XATTRs which remain set for DAC.

The solution is to perform a rollback on failure, i.e. call
opposite action on drivers that succeeded.

I'm providing rollback only for set calls and intentionally
omitting restore calls for two reasons:

1) restore calls are less likely to fail (they merely remove
XATTRs and chown()/setfilecon() file - all of these operations
succeeded in set call),

2) we are not really interested in restore failures - in a very
few places we check for retval of a restore function we do so
only to print a warning.

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
5 years agosecurity_stack: Turn list of nested drivers into a doubly linked list
Michal Privoznik [Wed, 11 Sep 2019 08:33:19 +0000 (10:33 +0200)]
security_stack: Turn list of nested drivers into a doubly linked list

In near future we will need to walk through the list of internal
drivers in reversed order. The simplest solution is to turn
singly linked list into a doubly linked list.
We will not need to start from the end really, so there's no tail
pointer kept.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
5 years agosecurity: Introduce virSecurityManagerGetDriver()
Michal Privoznik [Wed, 11 Sep 2019 09:40:04 +0000 (11:40 +0200)]
security: Introduce virSecurityManagerGetDriver()

This function returns the name of the secdriver. Since the name
is invariant we don't really need to lock the manager - it won't
change.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
5 years agosecurity: Rename virSecurityManagerGetDriver() to virSecurityManagerGetVirtDriver()
Michal Privoznik [Wed, 11 Sep 2019 09:20:53 +0000 (11:20 +0200)]
security: Rename virSecurityManagerGetDriver() to virSecurityManagerGetVirtDriver()

This function is in fact returning the name of the virtualization
driver that registered the security manager/driver.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
5 years agosecurity: Pass @migrated to virSecurityManagerSetAllLabel
Michal Privoznik [Wed, 11 Sep 2019 05:53:09 +0000 (07:53 +0200)]
security: Pass @migrated to virSecurityManagerSetAllLabel

In upcoming commits, virSecurityManagerSetAllLabel() will perform
rollback in case of failure by calling
virSecurityManagerRestoreAllLabel(). But in order to do that, the
former needs to have @migrated argument so that it can be passed
to the latter.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
5 years agobuild: remove use of usleep gnulib module in favour of g_usleep
Daniel P. Berrangé [Wed, 2 Oct 2019 17:01:11 +0000 (18:01 +0100)]
build: remove use of usleep gnulib module in favour of g_usleep

The usleep function was missing on older mingw versions, but we can rely
on it existing everywhere these days. It may only support times upto 1
second in duration though, so we'll prefer to use g_usleep instead.

The commandhelper program is not changed since that can't link to glib.
Fortunately it doesn't need to build on Windows platforms either.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: replace strerror/strerror_r with g_strerror
Daniel P. Berrangé [Wed, 2 Oct 2019 15:30:36 +0000 (16:30 +0100)]
util: replace strerror/strerror_r with g_strerror

g_strerror is offers the safety/correctness benefits of strerror_r, with
the API design convenience of strerror.

Use of virStrerror should be eliminated through the codebase in favour
of g_strerror.

commandhelper.c is a special case as its a tiny single threaded test
program, not linked to glib, so it just uses traditional strerror().

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoconf: convert over to use GRegex for regular expressions
Daniel P. Berrangé [Fri, 20 Sep 2019 14:01:41 +0000 (15:01 +0100)]
conf: convert over to use GRegex for regular expressions

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agolibxl: convert over to use GRegex for regular expressions
Daniel P. Berrangé [Fri, 20 Sep 2019 14:01:41 +0000 (15:01 +0100)]
libxl: convert over to use GRegex for regular expressions

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: convert virIdentity class to use GObject
Daniel P. Berrangé [Thu, 19 Sep 2019 14:38:03 +0000 (15:38 +0100)]
util: convert virIdentity class to use GObject

Converting from virObject to GObject is reasonably straightforward,
as illustrated by this patch for virIdentity

In the header file

 - Remove

     typedef struct _virIdentity virIdentity

 - Add

     #define VIR_TYPE_IDENTITY virIdentity_get_type ()
     G_DECLARE_FINAL_TYPE (virIdentity, vir_identity, VIR, IDENTITY, GObject);

   Which provides the typedef we just removed, and class
   declaration boilerplate and various other constants/macros.

In the source file

 - Change 'virObject parent' to 'GObject parent' in the struct
 - Remove the virClass variable and its initializing call
 - Add

      G_DEFINE_TYPE(virIdentity, vir_identity, G_TYPE_OBJECT)

   which declares the instance & class constructor functions

 - Add an impl of the instance & class constructors
   wiring up the finalize method to point to our dispose impl

In all files

 - Replace VIR_AUTOUNREF(virIdentityPtr) with g_autoptr(virIdentity)

 - Replace virObjectRef/Unref with g_object_ref/unref. Note
   the latter functions do *NOT* accept a NULL object where as
   libvirt's do. If you replace g_object_unref with g_clear_object
   it is NULL safe, but also clears the pointer.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoremote: convert methods using virIdentityPtr to auto free macros
Daniel P. Berrangé [Tue, 1 Oct 2019 14:37:09 +0000 (15:37 +0100)]
remote: convert methods using virIdentityPtr to auto free macros

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agorpc: convert methods using virIdentityPtr to auto free macros
Daniel P. Berrangé [Tue, 1 Oct 2019 14:37:09 +0000 (15:37 +0100)]
rpc: convert methods using virIdentityPtr to auto free macros

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoadmin: convert admin server code to use auto free macros
Daniel P. Berrangé [Tue, 1 Oct 2019 14:29:39 +0000 (15:29 +0100)]
admin: convert admin server code to use auto free macros

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoaccess: convert polkit driver to auto free memory
Daniel P. Berrangé [Mon, 30 Sep 2019 15:06:41 +0000 (16:06 +0100)]
access: convert polkit driver to auto free memory

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: convert virIdentity implementation and test suite to g_autoptr
Daniel P. Berrangé [Tue, 1 Oct 2019 16:38:12 +0000 (17:38 +0100)]
util: convert virIdentity implementation and test suite to g_autoptr

To simplify the later conversion from virObject to GObject, introduce
the use of g_autoptr to the virIdentity implementnation and test suite.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: use glib base64 encoding/decoding APIs
Daniel P. Berrangé [Mon, 16 Sep 2019 12:29:20 +0000 (13:29 +0100)]
util: use glib base64 encoding/decoding APIs

Replace use of the gnulib base64 module with glib's own base64 API family.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoconf: convert virSecretObj APIs to use autofree
Daniel P. Berrangé [Fri, 4 Oct 2019 11:21:07 +0000 (12:21 +0100)]
conf: convert virSecretObj APIs to use autofree

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: add support for g_autoptr with virObject instances
Daniel P. Berrangé [Fri, 4 Oct 2019 16:14:10 +0000 (17:14 +0100)]
src: add support for g_autoptr with virObject instances

Libvirt currently uses the VIR_AUTOUNREF macro for auto cleanup of
virObject instances. GLib approaches things differently with GObject,
reusing their g_autoptr() concept.

This introduces support for g_autoptr() with virObject, to facilitate
the conversion to GObject.

Only virObject classes which are currently used with VIR_AUTOREF are
updated. Any others should be converted to GObject before introducing
use of autocleanup.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: rewrite auto cleanup macros to use glib's equivalent
Daniel P. Berrangé [Tue, 1 Oct 2019 09:52:28 +0000 (10:52 +0100)]
util: rewrite auto cleanup macros to use glib's equivalent

To facilitate porting over to glib, this rewrites the auto cleanup
macros to use glib's equivalent.

As a result it is now possible to use g_autoptr/VIR_AUTOPTR, and
g_auto/VIR_AUTOCLEAN, g_autofree/VIR_AUTOFREE interchangably, regardless
of which macros were used to declare the cleanup types.

Within the scope of any single method, code must remain consistent
using either GLib or Libvirt macros, never mixing both. New code
must preferentially use the GLib macros, and old code will be
converted incrementally.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: convert virSystemdActivation to use VIR_DEFINE_AUTOPTR_FUNC
Daniel P. Berrangé [Tue, 1 Oct 2019 09:50:34 +0000 (10:50 +0100)]
util: convert virSystemdActivation to use VIR_DEFINE_AUTOPTR_FUNC

Using the standard macro will facilitate the conversion to glib's
auto cleanup macros.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: use glib string allocation/formatting functions
Daniel P. Berrangé [Fri, 6 Sep 2019 12:10:24 +0000 (13:10 +0100)]
util: use glib string allocation/formatting functions

Convert the string duplication APIs to use the g_strdup family of APIs.

We previously used the 'strdup-posix' gnulib module because mingw does
not set errno to ENOMEM on failure

We previously used the 'strndup' gnulib module because this function
does not exist on mingw.

We previously used the 'vasprintf' gnulib module because of many GNU
supported format specifiers not working on non-Linux platforms. glib's
own equivalent standardizes on GNU format specifiers too.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: use glib memory allocation functions
Daniel P. Berrangé [Mon, 7 Oct 2019 16:56:08 +0000 (17:56 +0100)]
util: use glib memory allocation functions

Convert the VIR_ALLOC family of APIs with use of the g_malloc family of
APIs. Use of VIR_ALLOC related functions should be incrementally phased
out over time, allowing return value checks to be dropped. Use of
VIR_FREE should be replaced with auto-cleanup whenever possible.

We previously used the 'calloc-posix' gnulib module because mingw does
not set errno to ENOMEM on failure.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: link to glib library
Daniel P. Berrangé [Thu, 29 Aug 2019 15:12:24 +0000 (16:12 +0100)]
build: link to glib library

Add the main glib.h to internal.h so that all common code can use it.

Historically glib allowed applications to register an alternative
memory allocator, so mixing g_malloc/g_free with malloc/free was not
safe.

This was feature was dropped in 2.46.0 with:

      commit 3be6ed60aa58095691bd697344765e715a327fc1
      Author: Alexander Larsson <alexl@redhat.com>
      Date:   Sat Jun 27 18:38:42 2015 +0200

        Deprecate and drop support for memory vtables

Applications are still encourged to match g_malloc/g_free, but it is no
longer a mandatory requirement for correctness, just stylistic. This is
explicitly clarified in

    commit 1f24b36607bf708f037396014b2cdbc08d67b275
    Author: Daniel P. Berrangé <berrange@redhat.com>
    Date:   Thu Sep 5 14:37:54 2019 +0100

        gmem: clarify that g_malloc always uses the system allocator

Applications can still use custom allocators in general, but they must
do this by linking to a library that replaces the core malloc/free
implemenentation entirely, instead of via a glib specific call.

This means that libvirt does not need to be concerned about use of
g_malloc/g_free causing an ABI change in the public libary, and can
avoid memory copying when talking to external libraries.

This patch probes for glib, which provides the foundation layer with
a collection of data structures, helper APIs, and platform portability
logic.

Later patches will introduce linkage to gobject which provides the
object type system, built on glib, and gio which providing objects
for various interesting tasks, most notably including DBus client
and server support and portable sockets APIs, but much more too.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: probe for glib-2 library in configure
Daniel P. Berrangé [Tue, 30 Jul 2019 09:13:36 +0000 (10:13 +0100)]
build: probe for glib-2 library in configure

Prepare for linking with glib by probing for it at configure
time. Per supported platforms target, the min glib versions on
relevant distros are:

  RHEL-8: 2.56.1
  RHEL-7: 2.50.3
  Debian (Buster): 2.58.3
  Debian (Stretch): 2.50.3
  OpenBSD (Ports): 2.58.3
  FreeBSD (Ports): 2.56.3
  OpenSUSE Leap 15: 2.54.3
  SLE12-SP2: 2.48.2
  Ubuntu (Xenial): 2.48.0
  macOS (Homebrew): 2.56.0

This suggests that a minimum glib of 2.48 is a reasonable target.
This aligns with the minimum version required by qemu too.

We must disable the bad-function-cast warning as various GLib APIs
and macros will trigger this.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosecurity: selinux: Label externalDataStore
Cole Robinson [Mon, 7 Oct 2019 20:20:16 +0000 (16:20 -0400)]
security: selinux: Label externalDataStore

We mirror the labeling strategy that was used for its top image

Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
5 years agosecurity: selinux: break out SetImageLabelRelative
Cole Robinson [Mon, 7 Oct 2019 19:40:49 +0000 (15:40 -0400)]
security: selinux: break out SetImageLabelRelative

This will be used for recursing into externalDataStore

Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>