]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
5 years agoqemu: Generate 'xres' and 'yres' for QEMU video devices
Julio Faracco [Thu, 17 Oct 2019 04:30:32 +0000 (01:30 -0300)]
qemu: Generate 'xres' and 'yres' for QEMU video devices

This commit let QEMU command line define 'xres' and 'yres' properties
if XML contains both properties from video model: based on resolution
fields 'x' and 'y'. There is a conditional structure inside
qemuDomainDeviceDefValidateVideo() that validates if video model
supports this feature. This commit includes the necessary changes to
cover resolution for 'video-qxl-resolution' test cases too.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
5 years agoconf: Add 'x' and 'y' resolution into video XML definition
Julio Faracco [Thu, 17 Oct 2019 04:30:31 +0000 (01:30 -0300)]
conf: Add 'x' and 'y' resolution into video XML definition

This commit adds resolution element with parameters 'x' and 'y' into video
XML domain group definition. Both, properties were added into an element
called 'resolution' and it was added inside 'model' element. They are set
as optional. This element does not follow QEMU properties 'xres' and
'yres' format. Both HTML documentation and schema were changed too. This
commit includes a simple test case to cover resolution for QEMU video
models. The new XML format for resolution looks like:

    <model ...>
      <resolution x='800' y='600'/>
    </model>

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
5 years agoqemu: caps: Use unique key for domCaps caching
Cole Robinson [Tue, 15 Oct 2019 15:47:10 +0000 (11:47 -0400)]
qemu: caps: Use unique key for domCaps caching

When searching qemuCaps->domCapsCache for existing domCaps data,
we check for a matching pair of arch+virttype+machine+emulator. However
for the hash table key we only use the machine string. So if the
cache already contains:

  x86_64 + kvm + pc + /usr/bin/qemu-kvm

But a new VM is defined with

  x86_64 + qemu + pc + /usr/bin/qemu-kvm

We correctly fail to find matching cached domCaps, but then attempt
to use a colliding key with virHashAddEntry

Fix this by building a hash key from the 4 values, not just machine

Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
5 years agoqemu_driver.c: use g_strdup_printf
Daniel Henrique Barboza [Wed, 16 Oct 2019 20:54:33 +0000 (17:54 -0300)]
qemu_driver.c: use g_strdup_printf

This patch changes all virAsprintf calls to use the GLib API
g_strdup_printf in qemu_driver.c

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_driver.c: remove unused 'cleanup' labels after g_auto*() changes
Daniel Henrique Barboza [Wed, 16 Oct 2019 20:54:32 +0000 (17:54 -0300)]
qemu_driver.c: remove unused 'cleanup' labels after g_auto*() changes

The g_auto*() changes made by the previous patches made a lot
of 'cleanup' labels obsolete. Let's remove them.

Suggested-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_driver.c: use g_autofree when possible
Daniel Henrique Barboza [Wed, 16 Oct 2019 20:54:31 +0000 (17:54 -0300)]
qemu_driver.c: use g_autofree when possible

String and other scalar pointers an be auto-unref, sparing us
a VIR_FREE() call.

This patch uses g_autofree whenever possible with strings and
other scalar pointer types.

Suggested-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_driver.c: use g_autoptr() when possible
Daniel Henrique Barboza [Wed, 16 Oct 2019 20:54:30 +0000 (17:54 -0300)]
qemu_driver.c: use g_autoptr() when possible

Several pointer types can be auto-unref for the great majority
of the uses made in qemu_driver, sparing us a virObjectUnref()
call.

This patch uses g_autoptr() in the following pointer types inside
qemu_driver.c, whenever possible:

- qemuBlockJobDataPtr
- virCapsPtr
- virConnect
- virDomainCapsPtr
- virNetworkPtr
- virQEMUDriverConfigPtr

Suggested-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu_driver.c: use g_auto* in some functions
Daniel Henrique Barboza [Wed, 16 Oct 2019 20:54:29 +0000 (17:54 -0300)]
qemu_driver.c: use g_auto* in some functions

This patch changes qemuDomainSnapshotLoad, qemuDomainCheckpointLoad and
qemuStateInitialize to use g_autoptr() and g_autofree, cleaning up
some virObjectUnref() and VIR_FREE() calls on each.

The reason this is being sent separately is because these are not
trivial search/replace cases. In all these functions some strings
declarations are moved inside local loops, where they are in fact
used, allowing us to erase VIR_FREE() calls that were made inside
the loop and in 'cleanup' labels.

Following patches with tackle more trivial cases of g_auto* usage
in all qemu_driver.c file.

Suggested-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodocs: hacking: add a conversion table for removed libvirt macros
Ján Tomko [Wed, 16 Oct 2019 14:11:30 +0000 (16:11 +0200)]
docs: hacking: add a conversion table for removed libvirt macros

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodocs: hacking: use <code> for functions/names
Ján Tomko [Wed, 16 Oct 2019 12:43:49 +0000 (14:43 +0200)]
docs: hacking: use <code> for functions/names

Use the <code> element more in the GLib section.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodocs: hacking: separate section about already deleted macros
Ján Tomko [Wed, 16 Oct 2019 13:58:28 +0000 (15:58 +0200)]
docs: hacking: separate section about already deleted macros

Move the recently deleted libvirt macros into a separate section.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agostorage: fix build with musl libc
Carlos Santos [Wed, 16 Oct 2019 11:22:14 +0000 (08:22 -0300)]
storage: fix build with musl libc

On musl _PATH_MOUNTED is defined in paths.h, not in mntent.h, which
causes compilation errors:

storage/storage_backend_fs.c: In function 'virStorageBackendFileSystemIsMounted':
storage/storage_backend_fs.c:255:23: error: '_PATH_MOUNTED' undeclared (first use in this function); did you mean 'XPATH_POINT'?
     if ((mtab = fopen(_PATH_MOUNTED, "r")) == NULL) {
                       ^~~~~~~~~~~~~
                       XPATH_POINT

Fix this including paths.h if _PATH_MOUNTED is still not defined after
including mntent.h. This also works with glibc and uClibc-ng.

Signed-off-by: Carlos Santos <casantos@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: fix build with musl libc
Carlos Santos [Wed, 16 Oct 2019 11:22:13 +0000 (08:22 -0300)]
qemu: fix build with musl libc

On musl libc "stderr" is a preprocessor macro whose expansion leads to
compilation errors:

In file included from qemu/qemu_process.c:66:
qemu/qemu_process.c: In function 'qemuProcessQMPFree':
qemu/qemu_process.c:8418:21: error: expected identifier before '(' token
     VIR_FREE((proc->stderr));
                     ^~~~~~

Prevent this by renaming the homonymous field in the _qemuProcessQMP
struct to "stdErr".

Signed-off-by: Carlos Santos <casantos@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: remove unused cfg variables
Ján Tomko [Thu, 17 Oct 2019 07:57:03 +0000 (09:57 +0200)]
qemu: remove unused cfg variables

These functions got a reference to the driver config
without actually using it:
  processNicRxFilterChangedEvent
  qemuConnectDomainXMLToNative

Signed-off-by: Ján Tomko <jtomko@redhat.com>
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>