[libvirt] [libvirt-glib] API to deal with storage pool(s)
Daniel P. Berrange
berrange at redhat.com
Thu Oct 6 17:53:55 UTC 2011
On Thu, Oct 06, 2011 at 06:46:05PM +0200, Christophe Fergeau wrote:
> On Tue, Sep 27, 2011 at 01:19:56AM +0300, Zeeshan Ali (Khattak) wrote:
> > +gboolean gvir_connection_fetch_storage_pools(GVirConnection *conn,
> > + GCancellable *cancellable,
> > + GError **err)
> > +{
> > + GVirConnectionPrivate *priv = conn->priv;
> > + GHashTable *pools;
> > + gchar **inactive = NULL;
> > + gint ninactive = 0;
> > + gchar **active = NULL;
> > + gint nactive = 0;
> > + gboolean ret = FALSE;
> > + gint i;
> > + virConnectPtr vconn = NULL;
> > +
> > + g_mutex_lock(priv->lock);
> > + if (!priv->conn) {
> > + *err = gvir_error_new(GVIR_CONNECTION_ERROR,
> > + 0,
> > + "Connection is not open");
>
> gvir_error_new creates a new GError and automatically appends the last
> error message reported by libvirt (if any) to it. In this case, won't we
> get a potentially confusing error message from libvirt since we don't
> really know what happened before this function was called? The same pattern
> occurs several times throughout this file.
Yep, gvir_error_new should only be used immediately after a libvirt
API call has failed. In any other case, use the normal g_error_new
functions
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
More information about the libvir-list
mailing list