[Libguestfs] [v2v PATCH] libosinfo: declare autocleanup funcs with libosinfo < 1.8.0
Richard W.M. Jones
rjones at redhat.com
Fri Jun 19 20:09:05 UTC 2020
On Fri, Jun 19, 2020 at 06:03:40PM +0200, Pino Toscano wrote:
> libosinfo 1.8.0 declares them automatically for all of its classes, so
> there is no need to declare ours. This requires fixing the definition of
> the IS_LIBOSINFO_VERSION macro to wrap its body in brackets.
>
> While in the process, simplify the workaround for a related bug by
> removing a now-useless check.
> ---
> v2v/libosinfo-c.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/v2v/libosinfo-c.c b/v2v/libosinfo-c.c
> index e5327dff..322e7d3d 100644
> --- a/v2v/libosinfo-c.c
> +++ b/v2v/libosinfo-c.c
> @@ -40,8 +40,13 @@
> #define V2V_LIBOSINFO_VERSION_HEX \
> MAKE_VERSION_HEX(OSINFO_MAJOR_VERSION, OSINFO_MINOR_VERSION, OSINFO_MICRO_VERSION)
> #define IS_LIBOSINFO_VERSION(maj, min, mic) \
> - V2V_LIBOSINFO_VERSION_HEX >= MAKE_VERSION_HEX(maj, min, mic)
> + (V2V_LIBOSINFO_VERSION_HEX >= MAKE_VERSION_HEX(maj, min, mic))
>
> +/*
> + * libosinfo 1.8.0 provides auto-cleanup functions for all its classes,
> + * so avoid declaring our own.
> + */
> +#if !IS_LIBOSINFO_VERSION(1, 8, 0)
> G_DEFINE_AUTOPTR_CLEANUP_FUNC(OsinfoFilter, g_object_unref)
> G_DEFINE_AUTOPTR_CLEANUP_FUNC(OsinfoLoader, g_object_unref)
> /*
> @@ -50,11 +55,13 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(OsinfoLoader, g_object_unref)
> * avoid declaring this when:
> * - libosinfo is >= 1.7.0 and < 1.8.0
> * - glib is >= 2.63.3
> + * (the 1.8.0 check is not done, as already covered by the check above)
> */
> -#if !IS_LIBOSINFO_VERSION(1, 7, 0) || IS_LIBOSINFO_VERSION(1, 8, 0) || !GLIB_CHECK_VERSION(2, 63, 3)
> +#if !IS_LIBOSINFO_VERSION(1, 7, 0) || !GLIB_CHECK_VERSION(2, 63, 3)
> G_DEFINE_AUTOPTR_CLEANUP_FUNC(OsinfoList, g_object_unref)
> #endif
> G_DEFINE_AUTOPTR_CLEANUP_FUNC(OsinfoOsList, g_object_unref)
> +#endif
>
> typedef OsinfoDb *OsinfoDb_t;
> typedef OsinfoOs *OsinfoOs_t;
This fixes virt-v2v with osinfo 1.8.0.
But with libosinfo 1.7.1 I still get lots of errors (see attached).
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html
-------------- next part --------------
make all-recursive
make[1]: Entering directory '/home/rjones/d/virt-v2v'
Making all in common/mlstdutils
make[2]: Entering directory '/home/rjones/d/virt-v2v/common/mlstdutils'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/rjones/d/virt-v2v/common/mlstdutils'
Making all in test-data
make[2]: Entering directory '/home/rjones/d/virt-v2v/test-data'
Making all in binaries
make[3]: Entering directory '/home/rjones/d/virt-v2v/test-data/binaries'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/rjones/d/virt-v2v/test-data/binaries'
Making all in blank-disks
make[3]: Entering directory '/home/rjones/d/virt-v2v/test-data/blank-disks'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/rjones/d/virt-v2v/test-data/blank-disks'
Making all in phony-guests
make[3]: Entering directory '/home/rjones/d/virt-v2v/test-data/phony-guests'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/rjones/d/virt-v2v/test-data/phony-guests'
Making all in fake-virtio-win
make[3]: Entering directory '/home/rjones/d/virt-v2v/test-data/fake-virtio-win'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/rjones/d/virt-v2v/test-data/fake-virtio-win'
Making all in fake-virt-tools
make[3]: Entering directory '/home/rjones/d/virt-v2v/test-data/fake-virt-tools'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/rjones/d/virt-v2v/test-data/fake-virt-tools'
Making all in files
make[3]: Entering directory '/home/rjones/d/virt-v2v/test-data/files'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/rjones/d/virt-v2v/test-data/files'
Making all in .
make[3]: Entering directory '/home/rjones/d/virt-v2v/test-data'
make[3]: Nothing to be done for 'all-am'.
make[3]: Leaving directory '/home/rjones/d/virt-v2v/test-data'
make[2]: Leaving directory '/home/rjones/d/virt-v2v/test-data'
Making all in gnulib/lib
make[2]: Entering directory '/home/rjones/d/virt-v2v/gnulib/lib'
make all-recursive
make[3]: Entering directory '/home/rjones/d/virt-v2v/gnulib/lib'
make[4]: Entering directory '/home/rjones/d/virt-v2v/gnulib/lib'
make[4]: Nothing to be done for 'all-am'.
make[4]: Leaving directory '/home/rjones/d/virt-v2v/gnulib/lib'
make[3]: Leaving directory '/home/rjones/d/virt-v2v/gnulib/lib'
make[2]: Leaving directory '/home/rjones/d/virt-v2v/gnulib/lib'
Making all in gnulib/tests
make[2]: Entering directory '/home/rjones/d/virt-v2v/gnulib/tests'
make all-recursive
make[3]: Entering directory '/home/rjones/d/virt-v2v/gnulib/tests'
Making all in .
make[4]: Entering directory '/home/rjones/d/virt-v2v/gnulib/tests'
make[4]: Nothing to be done for 'all-am'.
make[4]: Leaving directory '/home/rjones/d/virt-v2v/gnulib/tests'
make[3]: Leaving directory '/home/rjones/d/virt-v2v/gnulib/tests'
make[2]: Leaving directory '/home/rjones/d/virt-v2v/gnulib/tests'
Making all in common/qemuopts
make[2]: Entering directory '/home/rjones/d/virt-v2v/common/qemuopts'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/rjones/d/virt-v2v/common/qemuopts'
Making all in common/utils
make[2]: Entering directory '/home/rjones/d/virt-v2v/common/utils'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/rjones/d/virt-v2v/common/utils'
Making all in common/mlutils
make[2]: Entering directory '/home/rjones/d/virt-v2v/common/mlutils'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/rjones/d/virt-v2v/common/mlutils'
Making all in common/mlpcre
make[2]: Entering directory '/home/rjones/d/virt-v2v/common/mlpcre'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/rjones/d/virt-v2v/common/mlpcre'
Making all in common/options
make[2]: Entering directory '/home/rjones/d/virt-v2v/common/options'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/rjones/d/virt-v2v/common/options'
Making all in common/mlgettext
make[2]: Entering directory '/home/rjones/d/virt-v2v/common/mlgettext'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/rjones/d/virt-v2v/common/mlgettext'
Making all in common/mlxml
make[2]: Entering directory '/home/rjones/d/virt-v2v/common/mlxml'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/rjones/d/virt-v2v/common/mlxml'
Making all in common/mltools
make[2]: Entering directory '/home/rjones/d/virt-v2v/common/mltools'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/rjones/d/virt-v2v/common/mltools'
Making all in common/mlcustomize
make[2]: Entering directory '/home/rjones/d/virt-v2v/common/mlcustomize'
warning: Run 'make' at the top level to build ../../generator/generator
warning: Run 'make' at the top level to build customize_cmdline.mli customize_cmdline.ml customize-options.pod customize-synopsis.pod
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/rjones/d/virt-v2v/common/mlcustomize'
Making all in common/mlv2v
make[2]: Entering directory '/home/rjones/d/virt-v2v/common/mlv2v'
warning: Run 'make' at the top level to build ../../generator/generator
warning: Run 'make' at the top level to build uefi.mli uefi.ml
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/rjones/d/virt-v2v/common/mlv2v'
Making all in bundled/libvirt-ocaml
make[2]: Entering directory '/home/rjones/d/virt-v2v/bundled/libvirt-ocaml'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/rjones/d/virt-v2v/bundled/libvirt-ocaml'
Making all in v2v
make[2]: Entering directory '/home/rjones/d/virt-v2v/v2v'
make all-am
make[3]: Entering directory '/home/rjones/d/virt-v2v/v2v'
CC virt_v2v-libosinfo-c.o
OCAMLOPT parse_ova.cmx
OCAMLOPT windows_virtio.cmx
OCAMLOPT nbdkit_sources.cmx
OCAMLCMI input_libvirt.cmi
OCAMLOPT create_libvirt_xml.cmx
OCAMLOPT openstack_image_properties.cmx
OCAMLCMI linux_kernels.cmi
OCAMLOPT linux_bootloaders.cmx
OCAMLOPT output_null.cmx
OCAMLOPT output_json.cmx
OCAMLOPT output_qemu.cmx
OCAMLOPT output_rhv.cmx
OCAMLOPT output_rhv_upload.cmx
OCAMLOPT output_vdsm.cmx
In file included from /usr/lib64/glib-2.0/include/glibconfig.h:9,
from /usr/include/glib-2.0/glib/gtypes.h:32,
from /usr/include/glib-2.0/glib/galloca.h:32,
from /usr/include/glib-2.0/glib.h:30,
from /usr/include/glib-2.0/gobject/gbinding.h:28,
from /usr/include/glib-2.0/glib-object.h:22,
from /usr/include/libosinfo-1.0/osinfo/osinfo.h:28,
from libosinfo-c.c:25:
libosinfo-c.c: In function 'v2v_osinfo_os_find_os_by_short_id':
libosinfo-c.c:160:13: error: unknown type name 'OsinfoList_autoptr'
160 | g_autoptr(OsinfoList) list = NULL;
| ^~~~~~~~~~
/usr/include/glib-2.0/glib/gmacros.h:1029:43: note: in definition of macro '_GLIB_AUTOPTR_TYPENAME'
1029 | #define _GLIB_AUTOPTR_TYPENAME(TypeName) TypeName##_autoptr
| ^~~~~~~~
libosinfo-c.c:160:3: note: in expansion of macro 'g_autoptr'
160 | g_autoptr(OsinfoList) list = NULL;
| ^~~~~~~~~
libosinfo-c.c:160:3: error: cleanup argument not a function
libosinfo-c.c:160:32: error: initialization of 'int' from 'void *' makes integer from pointer without a cast [-Werror=int-conversion]
160 | g_autoptr(OsinfoList) list = NULL;
| ^~~~
libosinfo-c.c:166:8: error: assignment to 'int' from 'OsinfoList *' {aka 'struct _OsinfoList *'} makes integer from pointer without a cast [-Werror=int-conversion]
166 | list = osinfo_list_new_filtered (OSINFO_LIST(os_list), filter);
| ^
libosinfo-c.c:168:31: error: passing argument 1 of 'osinfo_list_get_length' makes pointer from integer without a cast [-Werror=int-conversion]
168 | if (osinfo_list_get_length (list) == 0)
| ^~~~
| |
| int
In file included from /usr/include/libosinfo-1.0/osinfo/osinfo_datamaplist.h:27,
from /usr/include/libosinfo-1.0/osinfo/osinfo.h:31,
from libosinfo-c.c:25:
/usr/include/libosinfo-1.0/osinfo/osinfo_list.h:69:41: note: expected 'OsinfoList *' {aka 'struct _OsinfoList *'} but argument is of type 'int'
69 | gint osinfo_list_get_length(OsinfoList *list);
| ~~~~~~~~~~~~^~~~
In file included from /usr/include/glib-2.0/gobject/gobject.h:24,
from /usr/include/glib-2.0/gobject/gbinding.h:29,
from /usr/include/glib-2.0/glib-object.h:22,
from /usr/include/libosinfo-1.0/osinfo/osinfo.h:28,
from libosinfo-c.c:25:
libosinfo-c.c:171:39: error: passing argument 1 of 'osinfo_list_get_nth' makes pointer from integer without a cast [-Werror=int-conversion]
171 | os = OSINFO_OS(osinfo_list_get_nth (list, 0));
| ^~~~
| |
| int
/usr/include/glib-2.0/gobject/gtype.h:2301:57: note: in definition of macro '_G_TYPE_CIC'
2301 | ((ct*) g_type_check_instance_cast ((GTypeInstance*) ip, gt))
| ^~
/usr/include/libosinfo-1.0/osinfo/osinfo_os.h:47:43: note: in expansion of macro 'G_TYPE_CHECK_INSTANCE_CAST'
47 | # define OSINFO_OS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), OSINFO_TYPE_OS, OsinfoOs))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
libosinfo-c.c:171:8: note: in expansion of macro 'OSINFO_OS'
171 | os = OSINFO_OS(osinfo_list_get_nth (list, 0));
| ^~~~~~~~~
In file included from /usr/include/libosinfo-1.0/osinfo/osinfo_datamaplist.h:27,
from /usr/include/libosinfo-1.0/osinfo/osinfo.h:31,
from libosinfo-c.c:25:
/usr/include/libosinfo-1.0/osinfo/osinfo_list.h:70:47: note: expected 'OsinfoList *' {aka 'struct _OsinfoList *'} but argument is of type 'int'
70 | OsinfoEntity *osinfo_list_get_nth(OsinfoList *list, gint idx);
| ~~~~~~~~~~~~^~~~
cc1: all warnings being treated as errors
OCAMLOPT output_openstack.cmx
make[3]: *** [Makefile:2262: virt_v2v-libosinfo-c.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: Leaving directory '/home/rjones/d/virt-v2v/v2v'
make[2]: *** [Makefile:2065: all] Error 2
make[2]: Leaving directory '/home/rjones/d/virt-v2v/v2v'
make[1]: *** [Makefile:1842: all-recursive] Error 1
make[1]: Leaving directory '/home/rjones/d/virt-v2v'
make: *** [Makefile:1760: all] Error 2
More information about the Libguestfs
mailing list