On Thu, Apr 05, 2018 at 03:29:28PM +0200, Katerina Koukiou wrote:
Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
data/org.libvirt.Connect.xml | 6 ++++++
src/connect.c | 29 +++++++++++++++++++++++++++++
test/test_connect.py | 1 +
3 files changed, 36 insertions(+)
diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index 043ee32..d15c2f6 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -56,6 +56,12 @@
<arg name="name" type="s" direction="in"/>
<arg name="network" type="o"
direction="out"/>
</method>
+ <method name="NetworkLookupByUUID">
+ <annotation name="org.gtk.GDBus.DocString"
+ value="See
https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkLookupByU...
This should mention virNetworkLookupByUUIDString.
+ <arg name="uuid" type="s"
direction="in"/>
+ <arg name="network" type="o"
direction="out"/>
+ </method>
<signal name="DomainEvent">
<annotation name="org.gtk.GDBus.DocString"
value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectDomainEven...
diff --git a/src/connect.c b/src/connect.c
index d036753..f22f682 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -348,6 +348,34 @@ virtDBusNetworkLookupByName(GVariant *inArgs,
*outArgs = g_variant_new("(o)", path);
}
+static void
+virtDBusNetworkLookupByUUID(GVariant *inArgs,
+ GUnixFDList *inFDs G_GNUC_UNUSED,
+ const gchar *objectPath G_GNUC_UNUSED,
+ gpointer userData,
+ GVariant **outArgs,
+ GUnixFDList **outFDs G_GNUC_UNUSED,
+ GError **error)
+{
+ virtDBusConnect *connect = userData;
+ g_autoptr(virNetwork) network = NULL;
+ g_autofree gchar *path = NULL;
+ const gchar *uuidstr;
+
+ g_variant_get(inArgs, "(s)", &uuidstr);
In order to use const gchar you need to use "(&s)" as the format string.
The "&" indicates that the string is not copied to the variable but you
get only a pointer.
+
+ if (!virtDBusConnectOpen(connect, error))
+ return;
+
+ network = virNetworkLookupByUUIDString(connect->connection, uuidstr);
+ if (!network)
+ return virtDBusUtilSetLastVirtError(error);
+
+ path = virtDBusUtilBusPathForVirNetwork(network, connect->networkPath);
+
+ *outArgs = g_variant_new("(o)", path);
+}
Reviewed-by: Pavel Hrdina <phrdina(a)redhat.com>