[libvirt] [dbus PATCH 04/10] Implement NetworkLookupByUUID method for network interface.
Pavel Hrdina
phrdina at redhat.com
Thu Apr 5 13:58:31 UTC 2018
On Thu, Apr 05, 2018 at 03:29:28PM +0200, Katerina Koukiou wrote:
> Signed-off-by: Katerina Koukiou <kkoukiou at 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#virNetworkLookupByUUID"/>
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#virConnectDomainEventCallback"/>
> 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 at redhat.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180405/830fb8b0/attachment-0001.sig>
More information about the libvir-list
mailing list