and switch to libvirt-gobject when connecting to libvirtd and fetching capabilities. --- configure.ac | 24 +++++++++++++++++++++--- examples/Makefile.am | 6 ++++-- examples/virtxml.c | 24 +++++++++--------------- 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/configure.ac b/configure.ac index c4f4383..c214809 100644 --- a/configure.ac +++ b/configure.ac @@ -12,8 +12,8 @@ AM_SILENT_RULES([yes]) LIBOSINFO_REQUIRED=0.0.5 LIBVIRT_GCONFIG_REQUIRED=0.0.9 +LIBVIRT_GOBJECT_REQUIRED=0.0.8 GOBJECT_INTROSPECTION_REQUIRED=0.10.8 -LIBVIRT_REQUIRED=0.9.0 LIBVIRT_DESIGNER_MAJOR_VERSION=`echo $VERSION | awk -F. '{print $1}'` LIBVIRT_DESIGNER_MINOR_VERSION=`echo $VERSION | awk -F. '{print $2}'` @@ -46,7 +46,6 @@ LIBVIRT_DESIGNER_COMPILE_WARNINGS PKG_CHECK_MODULES(LIBOSINFO, libosinfo-1.0 >= $LIBOSINFO_REQUIRED) PKG_CHECK_MODULES(LIBVIRT_GCONFIG, libvirt-gconfig-1.0 >= $LIBVIRT_GCONFIG_REQUIRED) -PKG_CHECK_MODULES(LIBVIRT, libvirt >= $LIBVIRT_REQUIRED) LIBVIRT_DESIGNER_GETTEXT LIBVIRT_DESIGNER_GTK_MISC @@ -54,6 +53,23 @@ LIBVIRT_DESIGNER_WIN32 LIBVIRT_DESIGNER_COVERAGE LIBVIRT_DESIGNER_INTROSPECTION +AC_ARG_ENABLE([examples], + AS_HELP_STRING([--enable-examples], [enable virtxml example. Default is check, meaning it is enabled as long as libvirt-gobject is installed]), + [],[enable_examples=check]) + +if test "x$enable_examples" != "xno" ; then + PKG_CHECK_MODULES([LIBVIRT_GOBJECT], + [libvirt-gobject-1.0 >= $LIBVIRT_GOBJECT_REQUIRED], + [enable_examples=yes], + [ + if test "x$enable_examples" = "xcheck" ; then + enable_examples=no + else + AC_MSG_ERROR([Cannot enable examples because libvirt-gobject is not available]) + fi + ]) +fi +AM_CONDITIONAL(WITH_EXAMPLES, [test "x$enable_examples" = "xyes"]) AC_OUTPUT(Makefile libvirt-designer/Makefile @@ -66,9 +82,11 @@ AC_MSG_NOTICE([Configuration summary]) AC_MSG_NOTICE([=====================]) AC_MSG_NOTICE([]) AC_MSG_NOTICE([]) +AC_MSG_NOTICE([ examples: $enable_examples]) +AC_MSG_NOTICE([]) +AC_MSG_NOTICE([]) AC_MSG_NOTICE([ Libraries:]) AC_MSG_NOTICE([]) AC_MSG_NOTICE([ LIBOSINFO: $LIBOSINFO_CFLAGS $LIBOSINFO_LIBS]) AC_MSG_NOTICE([ LIBVIRT_GCONFIG: $LIBVIRT_GCONFIG_CFLAGS $LIBVIRT_GCONFIG_LIBS]) -AC_MSG_NOTICE([ LIBVIRT: $LIBVIRT_CFLAGS $LIBVIRT_LIBS]) AC_MSG_NOTICE([]) diff --git a/examples/Makefile.am b/examples/Makefile.am index 15f4b95..32549a0 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -10,12 +10,14 @@ virtxml_CFLAGS = \ $(LIBOSINFO_CFLAGS) \ $(LIBVIRT_GCONFIG_CFLAGS) \ $(WARN_CFLAGS) \ - $(LIBVIRT_CFLAGS) \ + $(LIBVIRT_GOBJECT_CFLAGS) \ $(NULL) virtxml_LDFLAGS = \ $(LIBOSINFO_LIBS) \ $(LIBVIRT_GCONFIG_LIBS) \ - $(LIBVIRT_LIBS) + $(LIBVIRT_GOBJECT_LIBS) +if WITH_EXAMPLES bin_PROGRAMS = virtxml +endif diff --git a/examples/virtxml.c b/examples/virtxml.c index 33d029e..9783ba6 100644 --- a/examples/virtxml.c +++ b/examples/virtxml.c @@ -22,8 +22,7 @@ #include <config.h> #include <libvirt-designer/libvirt-designer.h> -#include <libvirt/libvirt.h> -#include <libvirt/virterror.h> +#include <libvirt-gobject/libvirt-gobject.h> #include <stdio.h> #include <stdlib.h> @@ -310,8 +309,7 @@ main(int argc, char *argv[]) GVirConfigCapabilities *caps = NULL; GVirConfigDomain *config = NULL; GVirDesignerDomain *domain = NULL; - virConnectPtr conn = NULL; - char *caps_str = NULL; + GVirConnection *conn = NULL; gchar *xml = NULL; static char *os_str = NULL; static char *platform_str = NULL; @@ -358,20 +356,15 @@ main(int argc, char *argv[]) return EXIT_FAILURE; } - conn = virConnectOpenAuth(connect_uri, virConnectAuthPtrDefault, VIR_CONNECT_RO); - if (!conn) { - print_error("Unable to connect to libvirt"); - return EXIT_FAILURE; - } + conn = gvir_connection_new(connect_uri); + gvir_connection_open(conn, NULL, &error); + CHECK_ERROR; - if ((caps_str = virConnectGetCapabilities(conn)) == NULL) { - print_error("failed to get capabilities"); - goto cleanup; - } + caps = gvir_connection_get_capabilities(conn, &error); + CHECK_ERROR; os = osinfo_os_new(os_str); platform = osinfo_platform_new(platform_str); - caps = gvir_config_capabilities_new_from_xml(caps_str, NULL); domain = gvir_designer_domain_new(os, platform, caps); @@ -395,6 +388,7 @@ main(int argc, char *argv[]) ret = EXIT_SUCCESS; cleanup: - virConnectClose(conn); + if (conn) + gvir_connection_close(conn); return ret; } -- 1.7.8.6 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list