1. 14 10月, 2019 8 次提交
    • D
      c87cfa13
    • D
      src: add support for g_autoptr with virObject instances · 667ff797
      Daniel P. Berrangé 提交于
      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: NJán Tomko <jtomko@redhat.com>
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      667ff797
    • D
      util: rewrite auto cleanup macros to use glib's equivalent · 44e7f029
      Daniel P. Berrangé 提交于
      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: NJán Tomko <jtomko@redhat.com>
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      44e7f029
    • D
      util: convert virSystemdActivation to use VIR_DEFINE_AUTOPTR_FUNC · 74d93267
      Daniel P. Berrangé 提交于
      Using the standard macro will facilitate the conversion to glib's
      auto cleanup macros.
      Reviewed-by: NJán Tomko <jtomko@redhat.com>
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      74d93267
    • D
      util: use glib string allocation/formatting functions · bb9a1a14
      Daniel P. Berrangé 提交于
      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: NJán Tomko <jtomko@redhat.com>
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      bb9a1a14
    • D
      util: use glib memory allocation functions · e85e34f3
      Daniel P. Berrangé 提交于
      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: NJán Tomko <jtomko@redhat.com>
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      e85e34f3
    • D
      build: link to glib library · cfbe9f12
      Daniel P. Berrangé 提交于
      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: NDaniel P. Berrangé <berrange@redhat.com>
      cfbe9f12
    • D
      build: probe for glib-2 library in configure · 58e7c9bc
      Daniel P. Berrangé 提交于
      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: NJán Tomko <jtomko@redhat.com>
      Reviewed-by: NPavel Hrdina <phrdina@redhat.com>
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      58e7c9bc
  2. 12 10月, 2019 30 次提交
  3. 11 10月, 2019 2 次提交