]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
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>
5 years agosecurity: selinux: Restore image label for externalDataStore
Cole Robinson [Sat, 5 Oct 2019 23:45:21 +0000 (19:45 -0400)]
security: selinux: Restore image label for externalDataStore

Rename the existing virSecuritySELinuxRestoreImageLabelInt
to virSecuritySELinuxRestoreImageLabelSingle, and extend the new
ImageLabelInt handle externalDataStore

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: Add is_toplevel to SetImageLabelInternal
Cole Robinson [Mon, 7 Oct 2019 19:55:20 +0000 (15:55 -0400)]
security: selinux: Add is_toplevel to SetImageLabelInternal

This will simplify future patches and make the logic easier to follow

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: Drop !parent handling in SetImageLabelInternal
Cole Robinson [Mon, 7 Oct 2019 19:53:27 +0000 (15:53 -0400)]
security: selinux: Drop !parent handling in SetImageLabelInternal

The only caller always passes in a non-null parent

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: Simplify SetImageLabelInternal
Cole Robinson [Sat, 5 Oct 2019 14:24:44 +0000 (10:24 -0400)]
security: selinux: Simplify SetImageLabelInternal

All the SetFileCon calls only differ by the label they pass in.
Rework the conditionals to track what label we need, and use a
single SetFileCon call

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: dac: Label externalDataStore
Cole Robinson [Mon, 7 Oct 2019 20:20:12 +0000 (16:20 -0400)]
security: dac: Label externalDataStore

We mirror the labeling strategy that was used for its sibling
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: dac: break out SetImageLabelRelative
Cole Robinson [Mon, 7 Oct 2019 20:12:22 +0000 (16:12 -0400)]
security: dac: 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>
5 years agosecurity: dac: Restore image label for externalDataStore
Cole Robinson [Sat, 5 Oct 2019 23:47:43 +0000 (19:47 -0400)]
security: dac: Restore image label for externalDataStore

Rename the existing virSecurityDACRestoreImageLabelInt
to virSecurityDACRestoreImageLabelSingle, and extend the new
ImageLabelInt handle externalDataStore

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: dac: Add is_toplevel to SetImageLabelInternal
Cole Robinson [Mon, 7 Oct 2019 20:14:02 +0000 (16:14 -0400)]
security: dac: Add is_toplevel to SetImageLabelInternal

This will simplify future patches and make the logic easier to follow

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: dac: Drop !parent handling in SetImageLabelInternal
Cole Robinson [Mon, 7 Oct 2019 20:13:19 +0000 (16:13 -0400)]
security: dac: Drop !parent handling in SetImageLabelInternal

The only caller always passes in a non-null parent

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 agostoragefile: Fill in meta->externalDataStore
Cole Robinson [Sat, 5 Oct 2019 18:39:32 +0000 (14:39 -0400)]
storagefile: Fill in meta->externalDataStore

Add virStorageSourceNewFromExternalData, similar to
virStorageSourceNewFromBacking and use it to fill in a
virStorageSource for externalDataStore

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 agostoragefile: Add externalDataStore member
Cole Robinson [Sat, 5 Oct 2019 18:39:22 +0000 (14:39 -0400)]
storagefile: Add externalDataStore member

Add the plumbing to track a externalDataStoreRaw as a virStorageSource

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 agostoragefile: Split out virStorageSourceNewFromChild
Cole Robinson [Sat, 5 Oct 2019 18:13:46 +0000 (14:13 -0400)]
storagefile: Split out virStorageSourceNewFromChild

Future patches will use this for external data file handling

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 agostoragefile: Don't access backingStoreRaw directly in FromBackingRelative
Cole Robinson [Sat, 5 Oct 2019 18:07:06 +0000 (14:07 -0400)]
storagefile: Don't access backingStoreRaw directly in FromBackingRelative

For the only usage, the rel == parent->backingStoreRaw, so drop
the direct access

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 agostoragefile: Fill in meta->externalDataStoreRaw
Cole Robinson [Sat, 5 Oct 2019 00:19:22 +0000 (20:19 -0400)]
storagefile: Fill in meta->externalDataStoreRaw

Call qcow2GetExtensions to actually fill in the virStorageSource
externalDataStoreRaw member

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 agostoragefile: Add externalDataStoreRaw member
Cole Robinson [Fri, 4 Oct 2019 21:18:21 +0000 (17:18 -0400)]
storagefile: Add externalDataStoreRaw member

Add the plumbing to track a qcow2 external data file path in
virStorageSource

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 agostoragefile: Fix backing format \0 check
Cole Robinson [Fri, 4 Oct 2019 23:41:36 +0000 (19:41 -0400)]
storagefile: Fix backing format \0 check

From qemu.git docs/interop/qcow2.txt

  == String header extensions ==

  Some header extensions (such as the backing file format name and
  the external data file name) are just a single string. In this case,
  the header extension length is the string length and the string is
  not '\0' terminated. (The header extension padding can make it look
  like a string is '\0' terminated, but neither is padding always
  necessary nor is there a guarantee that zero bytes are used
  for padding.)

So we shouldn't be checking for a \0 byte at the end of the backing
format section. I think in practice there always is a \0 but we
shouldn't depend on that.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
5 years agostoragefile: Rename qcow2GetExtensions 'format' argument
Cole Robinson [Fri, 4 Oct 2019 22:47:24 +0000 (18:47 -0400)]
storagefile: Rename qcow2GetExtensions 'format' argument

To backingFormat, which makes it more clear. Move it to the end of
the argument list which will scale nicer with future patches

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 agostoragefile: Rename qcow2GetBackingStoreFormat
Cole Robinson [Fri, 4 Oct 2019 23:59:23 +0000 (19:59 -0400)]
storagefile: Rename qcow2GetBackingStoreFormat

...to qcow2GetExtensions. We will extend it for more extension
parsing in future patches

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 agostoragefile: Push extension_end calc to qcow2GetBackingStoreFormat
Cole Robinson [Fri, 4 Oct 2019 23:57:55 +0000 (19:57 -0400)]
storagefile: Push extension_end calc to qcow2GetBackingStoreFormat

This is a step towards making this qcow2GetBackingStoreFormat into
a generic qcow2 extensions parser

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 agostoragefile: Push 'start' into qcow2GetBackingStoreFormat
Cole Robinson [Fri, 4 Oct 2019 23:51:31 +0000 (19:51 -0400)]
storagefile: Push 'start' into qcow2GetBackingStoreFormat

This is a step towards making this qcow2GetBackingStoreFormat into
a generic qcow2 extensions parser

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 agostoragefile: Use qcowXGetBackingStore directly
Cole Robinson [Fri, 4 Oct 2019 22:14:49 +0000 (18:14 -0400)]
storagefile: Use qcowXGetBackingStore directly

The qcow1 and qcow2 variants are identical, so remove the wrappers

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 agostoragefile: Drop now unused isQCow2 argument
Cole Robinson [Fri, 4 Oct 2019 22:13:21 +0000 (18:13 -0400)]
storagefile: Drop now unused isQCow2 argument

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 agostoragefile: Check version to determine if qcow2 or not
Cole Robinson [Fri, 4 Oct 2019 22:12:14 +0000 (18:12 -0400)]
storagefile: Check version to determine if qcow2 or not

Rather than require a boolean to be passed in

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 agostoragefile: qcow1: Let qcowXGetBackingStore fill in format
Cole Robinson [Fri, 4 Oct 2019 22:04:46 +0000 (18:04 -0400)]
storagefile: qcow1: Let qcowXGetBackingStore fill in format

Letting qcowXGetBackingStore fill in format gives the same behavior
we were opencoding in qcow1GetBackingStore

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 agostoragefile: qcow1: Fix check for empty backing file
Cole Robinson [Fri, 4 Oct 2019 22:00:55 +0000 (18:00 -0400)]
storagefile: qcow1: Fix check for empty backing file

From f772b3d91fd the intention of this code seems to be to set
format=NONE when the image does not have a backing file. However
'buf' here is the whole qcow1 file header. What we want to be
checking is 'res' which is the parsed backing file path.
qcowXGetBackingStore sets this to NULL when there's no backing file.

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 agostoragefile: qcow1: Check for BACKING_STORE_OK
Cole Robinson [Fri, 4 Oct 2019 21:57:32 +0000 (17:57 -0400)]
storagefile: qcow1: Check for BACKING_STORE_OK

Check explicitly for BACKING_STORE_OK and not its 0 value

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 agostoragefile: Make GetMetadataInternal static
Cole Robinson [Sat, 5 Oct 2019 19:17:48 +0000 (15:17 -0400)]
storagefile: Make GetMetadataInternal static

It is only used in virstoragefile.c

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 agotests: add a test for driver.c:virConnectValidateURIPath()
Daniel Henrique Barboza [Wed, 9 Oct 2019 19:11:44 +0000 (16:11 -0300)]
tests: add a test for driver.c:virConnectValidateURIPath()

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agosecurity: Don't remember labels for TPM
Michal Privoznik [Tue, 1 Oct 2019 08:32:26 +0000 (10:32 +0200)]
security: Don't remember labels for TPM

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

The /dev/tpmN file can be opened only once, as implemented in
drivers/char/tpm/tpm-dev.c:tpm_open() from the kernel's tree. Any
other attempt to open the file fails. And since we're opening the
file ourselves and passing the FD to qemu we will not succeed
opening the file again when locking it for seclabel remembering.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
5 years agosecurity_dac: Allow selective remember/recall for chardevs
Michal Privoznik [Tue, 1 Oct 2019 09:02:36 +0000 (11:02 +0200)]
security_dac: Allow selective remember/recall for chardevs

While in most cases we want to remember/recall label for a
chardev, there are some special ones (like /dev/tpm0) where we
don't want to remember the seclabel nor recall it. See next
commit for rationale behind.

While the easiest way to implement this would be to just add new
argument to virSecurityDACSetChardevLabel() this one is also a
callback for virSecurityManagerSetChardevLabel() and thus has
more or less stable set of arguments. Therefore, the current
virSecurityDACSetChardevLabel() is renamed to
virSecurityDACSetChardevLabelHelper() and the original function
is set to call the new one.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
5 years agosecurity: Try to lock only paths with remember == true
Michal Privoznik [Tue, 1 Oct 2019 08:30:05 +0000 (10:30 +0200)]
security: Try to lock only paths with remember == true

So far all items on the chown/setfilecon list have the same
.remember value.  But this will change shortly. Therefore, don't
try to lock paths which we won't manipulate XATTRs for.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
5 years agosecurity: apparmor: Allow RO /usr/share/edk2/
Cole Robinson [Wed, 9 Oct 2019 18:21:24 +0000 (14:21 -0400)]
security: apparmor: Allow RO /usr/share/edk2/

On Fedora, already whitelisted paths to AAVMF and OVMF binaries
are symlinks to binaries under /usr/share/edk2/. Add that directory
to the RO whitelist so virt-aa-helper-test passes

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
5 years agotests: Add capabilities for QEMU 4.2.0 on aarch64
Andrea Bolognani [Thu, 10 Oct 2019 13:38:37 +0000 (15:38 +0200)]
tests: Add capabilities for QEMU 4.2.0 on aarch64

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agotests: Add capabilities for QEMU 4.2.0 on ppc64
Andrea Bolognani [Thu, 10 Oct 2019 10:44:20 +0000 (12:44 +0200)]
tests: Add capabilities for QEMU 4.2.0 on ppc64

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
5 years agolibxl: add slic_table <-> acpi_firmware conversion
Marek Marczykowski-Górecki [Sun, 15 Sep 2019 19:43:24 +0000 (21:43 +0200)]
libxl: add slic_table <-> acpi_firmware conversion

This isn't exactly equivalent setting (acpi_firmware may point to
non-SLIC ACPI table), but it's the most behavior preserving option.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
5 years agotests: libxl: ACPI slic table test
Marek Marczykowski-Górecki [Sun, 15 Sep 2019 19:43:23 +0000 (21:43 +0200)]
tests: libxl: ACPI slic table test

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
5 years agolibxl: add acpi slic table support
Ivan Kardykov [Sun, 15 Sep 2019 19:43:22 +0000 (21:43 +0200)]
libxl: add acpi slic table support

Libxl driver did not support setup additional acpi firmware to xen
guest. It is necessary to activate OEM Windows installs. This patch
allow to define in OS section acpi table param (which supported domain
common schema).

Signed-off-by: Ivan Kardykov <kardykov@tabit.pro>
[added info to docs/formatdomain.html.in]
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
5 years agosrc/driver.c: remove duplicated code in virGetConnect* functions
Daniel Henrique Barboza [Tue, 8 Oct 2019 21:02:00 +0000 (18:02 -0300)]
src/driver.c: remove duplicated code in virGetConnect* functions

All the 6 virGetConnect* functions in driver.c shares the
same code base. This patch creates a new static function
virGetConnectGeneric() that contains the common code to
be used with all other virGetConnect*.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agotests: delete objectlocking test code
Daniel P. Berrangé [Tue, 8 Oct 2019 15:18:00 +0000 (16:18 +0100)]
tests: delete objectlocking test code

The object locking test code is not run by any CI tests and has
bitrotted to the point where it isn't worth the effort to try to
fix it.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu_process: Initialize domain definition for QMP query
Michal Privoznik [Thu, 10 Oct 2019 07:44:12 +0000 (09:44 +0200)]
qemu_process: Initialize domain definition for QMP query

When constructing QMP capabilities we allocate a dummy domain
object to pass to qemuMonitorOpen(). However, after 75dd595861
the function also expects domain definition to be allocated for
the domain object. The referenced commit already fixed
qemumonitortestutils.c but forgot to fix the other caller:
qemuProcessQMPConnectMonitor().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agonews: Update for the ccf-assist pSeries feature
Daniel Henrique Barboza [Tue, 8 Oct 2019 20:06:25 +0000 (17:06 -0300)]
news: Update for the ccf-assist pSeries feature

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemu: Implement the ccf-assist pSeries feature
Daniel Henrique Barboza [Tue, 8 Oct 2019 20:06:24 +0000 (17:06 -0300)]
qemu: Implement the ccf-assist pSeries feature

This patch adds the implementation of the ccf-assist pSeries
feature, based on the QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST
capability that was added in the previous patch.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemu: Add capability for the ccf-assist pSeries feature
Daniel Henrique Barboza [Tue, 8 Oct 2019 20:06:23 +0000 (17:06 -0300)]
qemu: Add capability for the ccf-assist pSeries feature

Linux kernel 5.1 added a new PPC KVM capability named
KVM_PPC_CPU_CHAR_BCCTR_FLUSH_ASSIST, which is exposed to the QEMU guest
since QEMU commit 8ff43ee404d under a new sPAPR capability called
SPAPR_CAP_CCF_ASSIST. This cap indicates whether the processor supports
hardware acceleration for the count cache flush workaround, which
is a software workaround that flushes the count cache on context
switch. If the processor has this hardware acceleration, the software
flush can be shortened, resulting in performance gain.

This hardware acceleration is defaulted to 'off' in QEMU. The reason
is that earlier versions of the Power 9 processor didn't support
it (it is available on Power 9 DD2.3 and newer), and defaulting this
option to 'on' would break migration compatibility between the Power 9
processor class.

However, the user running a P9 DD2.3+ hypervisor might want to create
guests with ccf-assist=on, accepting the downside of only being able
to migrate them only between other P9 DD2.3+ hosts running upstream
kernel 5.1+, to get a performance boost.

This patch adds this new capability to Libvirt, with the name of
QEMU_CAPS_MACHINE_PSERIES_CAP_CCF_ASSIST.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemu: add a new video device model 'ramfb'
Jonathon Jongsma [Fri, 13 Sep 2019 21:20:29 +0000 (16:20 -0500)]
qemu: add a new video device model 'ramfb'

This device is a very simple framebuffer device supported by qemu that
is mostly intended to use as a boot framebuffer in conjunction with a
vgpu. However, there is also a standalone ramfb device that can be used
as a primary display device and is useful for e.g. aarch64 guests where
different memory mappings between the host and guest can prevent use of
other devices with framebuffers such as virtio-vga.

https://bugzilla.redhat.com/show_bug.cgi?id=1679680 describes the
issues in more detail.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
5 years agoqemu: add ramfb capability
Jonathon Jongsma [Fri, 13 Sep 2019 21:20:28 +0000 (16:20 -0500)]
qemu: add ramfb capability

Add a qemu capbility to see if the standalone ramfb device is available.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
5 years agoqemu: validate bochs-display capability
Jonathon Jongsma [Fri, 13 Sep 2019 21:20:27 +0000 (16:20 -0500)]
qemu: validate bochs-display capability

When the bochs display type was added, the capability was never checked.
Add that check in the same place as the other video device capability
checks.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
5 years agosecurity: apparmor: Make storage_source_add_files recursively callable
Cole Robinson [Tue, 8 Oct 2019 16:07:17 +0000 (12:07 -0400)]
security: apparmor: Make storage_source_add_files recursively callable

This will simplify adding support for qcow2 external data_file

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
5 years agosecurity: apparmor: Use only virStorageSource for disk paths
Cole Robinson [Tue, 8 Oct 2019 16:04:57 +0000 (12:04 -0400)]
security: apparmor: Use only virStorageSource for disk paths

This is closer to what security_selinux.c does, and will help add
support for qcow2 external data_files

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
5 years agosecurity: apparmor: Push virStorageSource checks to add_file_path
Cole Robinson [Tue, 8 Oct 2019 15:55:24 +0000 (11:55 -0400)]
security: apparmor: Push virStorageSource checks to add_file_path

This mirrors the code layout in security_selinux.c. It will also make
it easier to share the checks for qcow2 external data_file support
eventually

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
5 years agosecurity: apparmor: Pass virStorageSource to add_file_path
Cole Robinson [Tue, 8 Oct 2019 15:53:21 +0000 (11:53 -0400)]
security: apparmor: Pass virStorageSource to add_file_path

The virStorageSource must have everything it needs

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
5 years agosecurity: apparmor: Drop disk_foreach_iterator
Cole Robinson [Tue, 8 Oct 2019 15:50:55 +0000 (11:50 -0400)]
security: apparmor: Drop disk_foreach_iterator

There's only one caller, so open code the file_add_path behavior

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
5 years agosecurity: apparmor: Remove unused ignoreOpenFailure
Cole Robinson [Tue, 8 Oct 2019 15:42:21 +0000 (11:42 -0400)]
security: apparmor: Remove unused ignoreOpenFailure

true is always passed here, so delete the unused code path and
adjust the associated comment

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
5 years agoconf: Move -virDomainDiskDefForeachPath to virt-aa-helper
Cole Robinson [Tue, 8 Oct 2019 15:40:30 +0000 (11:40 -0400)]
conf: Move -virDomainDiskDefForeachPath to virt-aa-helper

It is the only user. Rename it to match the local style

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
5 years agobuild: merge all syntax-check logic into one file
Daniel P. Berrangé [Wed, 2 Oct 2019 16:51:19 +0000 (17:51 +0100)]
build: merge all syntax-check logic into one file

The gnulib syntax-check rules are spread across GNUmakefile, cfg.mk and
maint.mk. This made sense when we were getting two of the files from the
gnulib submodule. Now that we own all files though, we can at least
merge maint.mk and cfg.mk together. GNUmakefile can be eliminated when
we switch to meson.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: delete all syntax check rules we're skipping
Daniel P. Berrangé [Wed, 2 Oct 2019 16:44:04 +0000 (17:44 +0100)]
build: delete all syntax check rules we're skipping

If we've marked rules as skipped, there's no sense keeping them in the
maint.mk file.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: remove all logic unrelated to syntax-check
Daniel P. Berrangé [Wed, 2 Oct 2019 16:36:23 +0000 (17:36 +0100)]
build: remove all logic unrelated to syntax-check

The standard maint.mk from gnulib provides alot more than just the
'syntax-check' target. This can all be purged to give a more minimal
file.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: move syntax-check code into build-aux directory
Daniel P. Berrangé [Wed, 9 Oct 2019 11:25:08 +0000 (12:25 +0100)]
build: move syntax-check code into build-aux directory

The syntax-check rules are the one bit of make usage that will
stay around for a while after the meson conversion. Move them
into the build-aux directory in preparation for refactoring
to make them independent from automake.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: import gnulib's syntax-check make rules
Daniel P. Berrangé [Wed, 2 Oct 2019 16:04:31 +0000 (17:04 +0100)]
build: import gnulib's syntax-check make rules

We're going to be eliminating autotools and gnulib, but we still wish to
have the 'make syntax-check' functionality.

This imports the minimal set of gnulib files required to keep this
working.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoRevert "qemu: Obtain reference on monConfig"
Michal Privoznik [Tue, 8 Oct 2019 07:49:18 +0000 (09:49 +0200)]
Revert "qemu: Obtain reference on monConfig"

This reverts commit a5a777a8bae61cb9e41c4dcd12d2962ad1a65a0d.

After previous commit the domain won't disappear while connecting
to monitor. There's no need to ref monitor config then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemu: Fix @vm locking issue when connecting to the monitor
Michal Privoznik [Tue, 8 Oct 2019 07:24:23 +0000 (09:24 +0200)]
qemu: Fix @vm locking issue when connecting to the monitor

When connecting to qemu's monitor the @vm object is unlocked.
This is justified - connecting may take a long time and we don't
want to wait with the domain object locked. However, just before
the domain object is locked again, the monitor's FD is registered
in the event loop. Therefore, there is a small window where the
event loop has a chance to call a handler for an event that
occurred on the monitor FD but vm is not initalized properly just
yet (i.e. priv->mon is not set). For instance, if there's an
incoming migration, qemu creates its socket but then fails to
initialize (for various reasons, I'm reproducing this by using
hugepages but leaving the HP pool empty) then the following may
happen:

1) qemuConnectMonitor() unlocks @vm

2) qemuMonitorOpen() connects to the monitor socket and by
   calling qemuMonitorOpenInternal() which subsequently calls
   qemuMonitorRegister() the event handler is installed

3) qemu fails to initialize and exit()-s, which closes the
   monitor

4) The even loop sees EOF on the monitor and the control gets to
   qemuProcessEventHandler() which locks @vm and calls
   processMonitorEOFEvent() which then calls
   qemuMonitorLastError(priv->mon). But priv->mon is not set just
   yet.

5) qemuMonitorLastError() dereferences NULL pointer

The solution is to unlock the domain object for a shorter time
and most importantly, register event handler with domain object
locked so that any possible event processing is done only after
@vm's private data was properly initialized.

This issue is also mentioned in v4.2.0-99-ga5a777a8ba.

Since we are unlocking @vm and locking it back, another thread
might have destroyed the domain meanwhile. Therefore we have to
check if domain is still active, and we have to do it at the
same place where domain lock is acquired back, i.e. in
qemuMonitorOpen(). This creates a small problem for our test
suite which calls qemuMonitorOpen() directly and passes @vm which
has no definition. This makes virDomainObjIsActive() call crash.
Fortunately, allocating empty domain definition is sufficient.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemu: Adapt to changed ppc64 CPU model names
Jiri Denemark [Thu, 17 May 2018 15:08:42 +0000 (17:08 +0200)]
qemu: Adapt to changed ppc64 CPU model names

QEMU 2.11 for ppc64 changed all CPU model names to lower case. Since
libvirt can't change the model names for compatibility reasons, we need
to translate the matching lower case models to the names known by
libvirt.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoRevert "domcaps: Treat host models as case-insensitive strings"
Jiri Denemark [Wed, 16 May 2018 14:58:47 +0000 (16:58 +0200)]
Revert "domcaps: Treat host models as case-insensitive strings"

This reverts commit 2d8721e2606806164782028ecf1ee33a9bbaa8fe.

This fix was both incomplete and too general. It only fixed domain
startup, but libvirt would still report empty list of supported CPU
models with recent QEMU for ppc64. On the other hand, while ppc64 QEMU
ignores case when looking up CPU model names, x86_64 QEMU does case
sensitive lookup. Without reverting this patch, libvirt could happily
accept CPU model names which are not supported by QEMU.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agobuild: stop clang complaining about redefined typedefs
Daniel P. Berrangé [Tue, 8 Oct 2019 14:37:11 +0000 (15:37 +0100)]
build: stop clang complaining about redefined typedefs

Clang's gnu99 mode is not quite the same as GCC's. It will complain
about redefined typedefs being a C11 feature, while GCC does not
complain and allows them in gnu99 mode.

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoRevert "src: Document autostart for session demon"
Michal Privoznik [Sat, 5 Oct 2019 07:22:15 +0000 (09:22 +0200)]
Revert "src: Document autostart for session demon"

This reverts commit 61b4e8aaf1bce07f282c152de556c3d6aa8d65be.

After previous commits this is no longer needed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agonews: Document autostart fix
Michal Privoznik [Mon, 7 Oct 2019 09:10:13 +0000 (11:10 +0200)]
news: Document autostart fix

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agolib: autostart objects exactly once
Michal Privoznik [Sat, 5 Oct 2019 07:15:24 +0000 (09:15 +0200)]
lib: autostart objects exactly once

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

With the recent work in daemon split and socket activation
daemons can come and go. They can and will be started many times
during a session which results in objects being autostarted
multiple times. This is not optimal. Use
virDriverShouldAutostart() to determine if autostart should be
done or not.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agodriver: Introduce virDriverShouldAutostart()
Michal Privoznik [Fri, 4 Oct 2019 14:57:04 +0000 (16:57 +0200)]
driver: Introduce virDriverShouldAutostart()

Some of objects we manage can be autostarted on libvirtd startup
(e.g. domains, network, storage pools). The idea was that when
the host is started up these objects are started too without need
of user intervention. However, with the latest daemon split and
switch to socket activated, short lived daemons (we put --timeout
120 onto each daemon's command line) this doesn't do what we want
it to. The problem is not new though, we already had the session
daemon come and go and we circumvented this problem by
documenting it (see v4.10.0-92-g61b4e8aaf1). But now that we meet
the same problem at all fronts it's time to deal with it.

The solution implemented in this commit is to have a file (one
per each driver) that:

  1) if doesn't exist, is created and autostart is allowed for
     given driver,

  2) if it does exist, then autostart is suppressed for given
     driver.

All the files live in a location that doesn't survive host
reboots (/var/run/ for instance) and thus the file is
automatically not there on fresh host boot.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu_driver: Fix comment of qemuStateCleanup()
Michal Privoznik [Fri, 4 Oct 2019 14:33:37 +0000 (16:33 +0200)]
qemu_driver: Fix comment of qemuStateCleanup()

The comment says that the function kills domains and networks.
This is obviously not the case.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agom4: fix setting of warning flags
Daniel P. Berrangé [Tue, 8 Oct 2019 12:41:19 +0000 (13:41 +0100)]
m4: fix setting of warning flags

When adding the -std=gnu99 flag, we set $wantwarn instead
of appending to it. This meant all the compiler warnings
were accidentally discarded.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: ask for -std=gnu99 explicitly
Daniel P. Berrangé [Mon, 7 Oct 2019 13:07:28 +0000 (14:07 +0100)]
build: ask for -std=gnu99 explicitly

We previously got -std=gnu99 secretly enabled as a side-effect
of requesting the 'stdarg' gnulib module. We rely on some
extensions from c99/gnu99 and while RHEL-7 supports this, it
still defaults to gnu89.  RHEL-7 also supports some newer
standards but declares them experimental/incomplete, so sticking
with gnu99 is best bet for now & matches historical usage.

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: force -Werror for distcheck target
Daniel P. Berrangé [Mon, 7 Oct 2019 13:03:47 +0000 (14:03 +0100)]
build: force -Werror for distcheck target

The 'make distcheck' target validates that a tarball builds and
is ready for release. We expect that libvirt builds cleanly on
all supported platforms, so we should be enabling -Werror when
running distcheck.

This ensures that our CI systems in turn also use -Werror.

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: remove the sched gnulib module
Daniel P. Berrangé [Thu, 3 Oct 2019 15:34:39 +0000 (16:34 +0100)]
build: remove the sched gnulib module

The 'sched' module provides a sched.h header file for platforms which
lack it. We already check for the functions we need in configure, and
protect the use of sched.h where relevant, so don't need the compat
header in libvirt.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: drop the isatty gnulib module
Daniel P. Berrangé [Thu, 3 Oct 2019 15:29:23 +0000 (16:29 +0100)]
build: drop the isatty gnulib module

The isatty gnulib module adds a fix for Win32 platforms where it doesn't
work correctly with character devices like NUL. This is not a compelling
enough problem for libvirt to be concerned with.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: drop the ldexp gnulib module
Daniel P. Berrangé [Thu, 3 Oct 2019 15:27:12 +0000 (16:27 +0100)]
build: drop the ldexp gnulib module

The ldexp gnulib module adds "-lm" to the $LIBS variable if-and-only-if
the ldexp() function require linking to libm. There is no harm in
linking to libm even if it isn't required for ldexp(), so simply drop
the gnulib module.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: drop the ignore-value gnulib module
Daniel P. Berrangé [Thu, 3 Oct 2019 15:25:45 +0000 (16:25 +0100)]
build: drop the ignore-value gnulib module

We don't need to care about very old GCC versions, so implementing the
ignore_value macro directly is not a significant burden.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agobuild: remove all gnulib bit manipulation modules
Daniel P. Berrangé [Thu, 3 Oct 2019 14:51:30 +0000 (15:51 +0100)]
build: remove all gnulib bit manipulation modules

We're using gnulib to get ffs, ffsl, rotl32, count_one_bits,
and count_leading_zeros. Except for rotl32 they can all be
replaced with gcc/clangs builtins. rotl32 is a one-line
trivial function.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agofixed handling of sourceless disks in 'domblkinfo' cmd
Pavel Mores [Fri, 4 Oct 2019 11:35:09 +0000 (13:35 +0200)]
fixed handling of sourceless disks in 'domblkinfo' cmd

virDomainGetBlockInfo() returns error if called on a disk with no
source (a sourceless disk might be a removable media drive with no
media in it, for instance an empty CDROM or floppy drive).

So far this caused the virsh domblkinfo --all command to abort and
ignore any remaining (not yet displayed) disk devices.  This patch
fixes the problem by first checking for existence of a <source>
element in the corresponding XML.  If none is found, we avoid calling
virDomainGetBlockInfo() altogether as we know it's bound to fail in
that case.

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

Signed-off-by: Pavel Mores <pmores@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: qemuxml2argv: Make use of versioned cpu-tsc-frequency and cpu-host-model-cmt...
Peter Krempa [Mon, 7 Oct 2019 06:55:31 +0000 (08:55 +0200)]
tests: qemuxml2argv: Make use of versioned cpu-tsc-frequency and cpu-host-model-cmt tests

Commit fb973cfbb4de added versioned test outputs for the above mentioned
tests but didn't actually enable them. Fix that mistake and fix the
output of the tsc-frequency test.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: qemuxml2argv: Remove unused output of 'mlock-on' legacy test
Peter Krempa [Mon, 7 Oct 2019 06:47:56 +0000 (08:47 +0200)]
tests: qemuxml2argv: Remove unused output of 'mlock-on' legacy test

The test data was modernized to use actual caps but commit 4dadcaa98e5
forgot to delete this test data.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>