Hey, Series looks good to me, ACK to both patches. Christophe On Wed, Sep 12, 2012 at 07:42:56PM +0200, Michal Privoznik wrote: > which is basically a wrapper for virConnectGetVersion(). > --- > examples/conn-test.c | 13 +++++++++ > libvirt-gobject/libvirt-gobject-connection.c | 35 ++++++++++++++++++++++++++ > libvirt-gobject/libvirt-gobject-connection.h | 2 + > libvirt-gobject/libvirt-gobject.sym | 1 + > 4 files changed, 51 insertions(+), 0 deletions(-) > > diff --git a/examples/conn-test.c b/examples/conn-test.c > index b9cb417..b98d115 100644 > --- a/examples/conn-test.c > +++ b/examples/conn-test.c > @@ -32,10 +32,13 @@ do_connection_open(GObject *source, > GVirConnection *conn = GVIR_CONNECTION(source); > GError *err = NULL; > gchar *hv_name = NULL; > + gulong hv_version = 0; > + guint major, minor, micro; > > if (!gvir_connection_open_finish(conn, res, &err)) { > g_error("%s", err->message); > } > + > g_print("Connected to libvirt\n"); > > if (!(hv_name = gvir_connection_get_hypervisor_name(conn, &err))) { > @@ -44,6 +47,16 @@ do_connection_open(GObject *source, > > g_print("Hypervisor name: %s\n", hv_name); > > + if (!(hv_version = gvir_connection_get_version(conn, &err))) { > + g_error("%s", err->message); > + } > + > + major = hv_version / 1000000; > + hv_version %= 1000000; > + minor = hv_version / 1000; > + micro = hv_version % 1000; > + g_print("Hypervisor version: %u.%u.%u\n", major, minor, micro); > + > g_free(hv_name); > g_object_unref(conn); > } > diff --git a/libvirt-gobject/libvirt-gobject-connection.c b/libvirt-gobject/libvirt-gobject-connection.c > index 3dff564..428ae38 100644 > --- a/libvirt-gobject/libvirt-gobject-connection.c > +++ b/libvirt-gobject/libvirt-gobject-connection.c > @@ -1066,6 +1066,41 @@ cleanup: > return ret; > } > > +/** > + * gvir_connection_get_version: > + * @conn: a #GVirConnection > + * @err: return location for any #GError > + * > + * Get version of current hypervisor used. > + * > + * Return value: version on success, 0 otherwise and @err set. > + */ > +gulong > +gvir_connection_get_version(GVirConnection *conn, > + GError **err) > +{ > + GVirConnectionPrivate *priv; > + gulong ret = 0; > + > + g_return_val_if_fail(GVIR_IS_CONNECTION(conn), FALSE); > + g_return_val_if_fail(err == NULL || *err == NULL, 0); > + > + priv = conn->priv; > + if (!priv->conn) { > + g_set_error_literal(err, GVIR_CONNECTION_ERROR, 0, > + "Connection is not opened"); > + goto cleanup; > + } > + > + if (virConnectGetVersion(priv->conn, &ret) < 0) { > + gvir_set_error_literal(err, GVIR_CONNECTION_ERROR, 0, > + "Unable to get hypervisor version"); > + } > + > +cleanup: > + return ret; > +} > + > static void gvir_domain_ref(gpointer obj, gpointer ignore G_GNUC_UNUSED) > { > g_object_ref(obj); > diff --git a/libvirt-gobject/libvirt-gobject-connection.h b/libvirt-gobject/libvirt-gobject-connection.h > index 1bdac54..f91ca05 100644 > --- a/libvirt-gobject/libvirt-gobject-connection.h > +++ b/libvirt-gobject/libvirt-gobject-connection.h > @@ -114,6 +114,8 @@ const gchar *gvir_connection_get_uri(GVirConnection *conn); > > gchar *gvir_connection_get_hypervisor_name(GVirConnection *conn, > GError **err); > +gulong gvir_connection_get_version(GVirConnection *conn, > + GError **err); > > GList *gvir_connection_get_domains(GVirConnection *conn); > GVirDomain *gvir_connection_get_domain(GVirConnection *conn, > diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym > index 2c2f1f4..c496540 100644 > --- a/libvirt-gobject/libvirt-gobject.sym > +++ b/libvirt-gobject/libvirt-gobject.sym > @@ -197,6 +197,7 @@ LIBVIRT_GOBJECT_0.1.2 { > LIBVIRT_GOBJECT_0.1.3 { > global: > gvir_connection_get_hypervisor_name; > + gvir_connection_get_version; > } LIBVIRT_GOBJECT_0.1.2; > > # .... define new API here using predicted next version number .... > -- > 1.7.8.6 > > -- > libvir-list mailing list > libvir-list@xxxxxxxxxx > https://www.redhat.com/mailman/listinfo/libvir-list
Attachment:
pgpK9kwrQlXr3.pgp
Description: PGP signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list