[libvirt] [libvirt-glib] RFC: Empty statistics for user-mode interfaces
Zeeshan Ali (Khattak)
zeeshanak at gnome.org
Thu Mar 1 03:57:24 UTC 2012
From: "Zeeshan Ali (Khattak)" <zeeshanak at gnome.org>
One of the limitations of user-mode networking of libvirt is that you
can't get statistics for it (not yet, at least). Instead of erroring-out
in that case, simply return empty statistics result and spit a debug
message.
I will merge this into my 'Remove now redundant 'path' property' patch
once someone tells me that this makes sense. :)
---
libvirt-gobject/libvirt-gobject-domain-interface.c | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/libvirt-gobject/libvirt-gobject-domain-interface.c b/libvirt-gobject/libvirt-gobject-domain-interface.c
index 0a9bde0..4436466 100644
--- a/libvirt-gobject/libvirt-gobject-domain-interface.c
+++ b/libvirt-gobject/libvirt-gobject-domain-interface.c
@@ -94,7 +94,11 @@ static gchar *gvir_domain_interface_get_path(GVirDomainInterface *self)
gchar *path = NULL;
config = gvir_domain_device_get_config(GVIR_DOMAIN_DEVICE(self));
- path = gvir_config_domain_interface_get_ifname(GVIR_CONFIG_DOMAIN_INTERFACE (config));
+ if (GVIR_CONFIG_IS_DOMAIN_INTERFACE_USER(self))
+ /* FIXME: One of the limitations of user-mode networking of libvirt */
+ g_debug("Statistics gathering for user-mode network not yet supported");
+ else
+ path = gvir_config_domain_interface_get_ifname(GVIR_CONFIG_DOMAIN_INTERFACE (config));
g_object_unref (config);
@@ -123,6 +127,10 @@ GVirDomainInterfaceStats *gvir_domain_interface_get_stats(GVirDomainInterface *s
handle = gvir_domain_device_get_domain_handle(GVIR_DOMAIN_DEVICE(self));
path = gvir_domain_interface_get_path (self);
+ if (path == NULL) {
+ ret = g_slice_new0(GVirDomainInterfaceStats);
+ goto end;
+ }
if (virDomainInterfaceStats(handle, path, &stats, sizeof (stats)) < 0) {
gvir_set_error_literal(err, GVIR_DOMAIN_INTERFACE_ERROR,
--
1.7.7.6
More information about the libvir-list
mailing list