[libvirt] [dbus PATCH 11/15] Implement InterfaceLookupByMACString method for Connect Interface
Pavel Hrdina
phrdina at redhat.com
Tue Jul 10 08:36:27 UTC 2018
On Fri, Jul 06, 2018 at 05:36:51PM -0400, Anya Harter wrote:
> Signed-off-by: Anya Harter <aharter at redhat.com>
> ---
> data/org.libvirt.Connect.xml | 6 ++++++
> src/connect.c | 29 +++++++++++++++++++++++++++++
> 2 files changed, 35 insertions(+)
>
> diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
> index f99e205..535d225 100644
> --- a/data/org.libvirt.Connect.xml
> +++ b/data/org.libvirt.Connect.xml
> @@ -170,6 +170,12 @@
> <arg name="flags" type="u" direction="in"/>
> <arg name="interface" type="o" direction="out"/>
> </method>
> + <method name="InterfaceLookupByMACString">
Same here, I would use only "InterfaceLookupByMAC".
> + <annotation name="org.gtk.GDBus.DocString"
> + value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceLookupByMACString"/>
> + <arg name="macstr" type="s" direction="in"/>
> + <arg name="interface" type="o" direction="out"/>
> + </method>
> <method name="InterfaceLookupByName">
> <annotation name="org.gtk.GDBus.DocString"
> value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceLookupByName"/>
> diff --git a/src/connect.c b/src/connect.c
> index 51a6ba0..f611965 100644
> --- a/src/connect.c
> +++ b/src/connect.c
> @@ -827,6 +827,34 @@ virtDBusConnectInterfaceDefineXML(GVariant *inArgs,
> *outArgs = g_variant_new("(o)", path);
> }
>
> +static void
> +virtDBusConnectInterfaceLookupByMACString(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(virInterface) interface = NULL;
> + g_autofree gchar *path = NULL;
> + const gchar *macstr;
> +
> + g_variant_get(inArgs, "(s)", &macstr);
The format string needs to be "(&s)" otherwise we would have to free
@macstr. The "&" means that we will get only the pointer to the memory,
without it we will get a new copy of the memory.
Pavel
-------------- 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/20180710/3a6f5f85/attachment-0001.sig>
More information about the libvir-list
mailing list