[libvirt] [dbus PATCH 03/15] Implement MACString property for Interface Interface

Anya Harter posted 15 patches 7 years, 7 months ago
[libvirt] [dbus PATCH 03/15] Implement MACString property for Interface Interface
Posted by Anya Harter 7 years, 7 months ago
Signed-off-by: Anya Harter <aharter@redhat.com>
---
 data/org.libvirt.Interface.xml |  5 +++++
 src/interface.c                | 22 ++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml
index ad7c326..e6d9f2a 100644
--- a/data/org.libvirt.Interface.xml
+++ b/data/org.libvirt.Interface.xml
@@ -8,5 +8,10 @@
         value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceGetName"/>
       <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
     </property>
+    <property name="MACString" type="s" access="read">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceGetMACString"/>
+      <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
+    </property>
   </interface>
 </node>
diff --git a/src/interface.c b/src/interface.c
index 733ce44..2b62304 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -45,7 +45,29 @@ virtDBusInterfaceGetName(const gchar *objectPath,
     *value = g_variant_new("s", name);
 }
 
+static void
+virtDBusInterfaceGetMACString(const gchar *objectPath,
+                              gpointer userData,
+                              GVariant **value,
+                              GError **error)
+{
+    virtDBusConnect *connect = userData;
+    g_autoptr(virInterface) interface = NULL;
+    const gchar *mac;
+
+    interface = virtDBusInterfaceGetVirInterface(connect, objectPath, error);
+    if (!interface)
+        return;
+
+    mac = virInterfaceGetMACString(interface);
+    if (!mac)
+        return virtDBusUtilSetLastVirtError(error);
+
+    *value = g_variant_new("s", mac);
+}
+
 static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = {
+    { "MACString", virtDBusInterfaceGetMACString, NULL },
     { "Name", virtDBusInterfaceGetName, NULL },
     { 0 }
 };
-- 
2.17.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [dbus PATCH 03/15] Implement MACString property for Interface Interface
Posted by Pavel Hrdina 7 years, 7 months ago
On Fri, Jul 06, 2018 at 05:36:43PM -0400, Anya Harter wrote:
> Signed-off-by: Anya Harter <aharter@redhat.com>
> ---
>  data/org.libvirt.Interface.xml |  5 +++++
>  src/interface.c                | 22 ++++++++++++++++++++++
>  2 files changed, 27 insertions(+)
> 
> diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml
> index ad7c326..e6d9f2a 100644
> --- a/data/org.libvirt.Interface.xml
> +++ b/data/org.libvirt.Interface.xml
> @@ -8,5 +8,10 @@
>          value="See https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceGetName"/>
>        <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
>      </property>
> +    <property name="MACString" type="s" access="read">

I would use only "MAC" like we do with UUIDString.

Pavel
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list