Signed-off-by: Anya Harter <aharter(a)redhat.com>
---
data/org.libvirt.Interface.xml | 5 ++++
src/interface.c | 45 ++++++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+)
diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml
index 93fa32f..d98a646 100644
--- a/data/org.libvirt.Interface.xml
+++ b/data/org.libvirt.Interface.xml
@@ -3,5 +3,10 @@
<node name="/org/libvirt/interface">
<interface name="org.libvirt.Interface">
+ <method name="Create">
+ <annotation name="org.gtk.GDBus.DocString"
+ value="See
https://libvirt.org/html/libvirt-libvirt-interface.html#virInterfaceCreat...
+ <arg name="flags" type="u" direction="in"/>
+ </method>
</interface>
</node>
diff --git a/src/interface.c b/src/interface.c
index 3c32f0f..4a5e431 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -3,11 +3,56 @@
#include <libvirt/libvirt.h>
+static virInterfacePtr
+virtDBusInterfaceGetVirInterface(virtDBusConnect *connect,
+ const gchar *objectPath,
+ GError **error)
+{
+ virInterfacePtr interface;
+
+ if (virtDBusConnectOpen(connect, error) < 0)
+ return NULL;
+
+ interface = virtDBusUtilVirInterfaceFromBusPath(connect->connection,
+ objectPath,
+ connect->interfacePath);
+ if (!interface) {
+ virtDBusUtilSetLastVirtError(error);
+ return NULL;
+ }
+
+ return interface;
+}
+
+static void
+virtDBusInterfaceCreate(GVariant *inArgs,
+ GUnixFDList *inFDs G_GNUC_UNUSED,
+ const gchar *objectPath,
+ gpointer userData,
+ GVariant **outArgs G_GNUC_UNUSED,
+ GUnixFDList **outFDs G_GNUC_UNUSED,
+ GError **error)
+{
+ virtDBusConnect *connect = userData;
+ g_autoptr(virInterface) interface = NULL;
+ guint flags;
+
+ g_variant_get(inArgs, "(u)", &flags);
+
+ interface = virtDBusInterfaceGetVirInterface(connect, objectPath, error);
+ if (!interface)
+ return;
+
+ if (virInterfaceCreate(interface, flags) < 0)
+ virtDBusUtilSetLastVirtError(error);
+}
+
static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = {
{ 0 }
};
static virtDBusGDBusMethodTable virtDBusInterfaceMethodTable[] = {
+ { "Create", virtDBusInterfaceCreate },
{ 0 }
};
--
2.17.1