Signed-off-by: Anya Harter
---
data/Makefile.am | 1 +
data/org.libvirt.Interface.xml | 7
src/Makefile.am| 2 ++
src/connect.c | 6
src/connect.h | 1 +
src/interface.c| 65 ++
src/interface.h| 9 +
src/util.c | 35 ++
src/util.h | 15
9 files changed, 141 insertions(+)
create mode 100644 data/org.libvirt.Interface.xml
create mode 100644 src/interface.c
create mode 100644 src/interface.h
diff --git a/data/Makefile.am b/data/Makefile.am
index 7b523da..35a0bbd 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -33,6 +33,7 @@ polkit_DATA = \
interfaces_files = \
org.libvirt.Connect.xml \
org.libvirt.Domain.xml \
+ org.libvirt.Interface.xml \
org.libvirt.Network.xml \
org.libvirt.NodeDevice.xml \
org.libvirt.NWFilter.xml \
diff --git a/data/org.libvirt.Interface.xml b/data/org.libvirt.Interface.xml
new file mode 100644
index 000..93fa32f
--- /dev/null
+++ b/data/org.libvirt.Interface.xml
@@ -0,0 +1,7 @@
+http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd";>
+
+
+
+
+
diff --git a/src/Makefile.am b/src/Makefile.am
index b5bf129..d0e8f0d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -41,6 +41,8 @@ libvirt_dbus_SOURCES = \
events.h \
gdbus.c \
gdbus.h \
+ interface.c \
+ interface.h \
main.c \
network.c \
network.h \
diff --git a/src/connect.c b/src/connect.c
index 9275121..3dc434d 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -1,6 +1,7 @@
#include "connect.h"
#include "domain.h"
#include "events.h"
+#include "interface.h"
#include "network.h"
#include "nodedev.h"
#include "nwfilter.h"
@@ -1809,6 +1810,7 @@ virtDBusConnectFree(virtDBusConnect *connect)
virtDBusConnectClose(connect, TRUE);
g_free(connect->domainPath);
+g_free(connect->interfacePath);
g_free(connect->networkPath);
g_free(connect->nodeDevPath);
g_free(connect->nwfilterPath);
@@ -1869,6 +1871,10 @@ virtDBusConnectNew(virtDBusConnect **connectp,
if (error && *error)
return;
+virtDBusInterfaceRegister(connect, error);
+if (error && *error)
+return;
+
virtDBusNetworkRegister(connect, error);
if (error && *error)
return;
diff --git a/src/connect.h b/src/connect.h
index 0b9ae10..961b115 100644
--- a/src/connect.h
+++ b/src/connect.h
@@ -13,6 +13,7 @@ struct virtDBusConnect {
const gchar *uri;
const gchar *connectPath;
gchar *domainPath;
+gchar *interfacePath;
gchar *networkPath;
gchar *nodeDevPath;
gchar *nwfilterPath;
diff --git a/src/interface.c b/src/interface.c
new file mode 100644
index 000..3c32f0f
--- /dev/null
+++ b/src/interface.c
@@ -0,0 +1,65 @@
+#include "interface.h"
+#include "util.h"
+
+#include
+
+static virtDBusGDBusPropertyTable virtDBusInterfacePropertyTable[] = {
+{ 0 }
+};
+
+static virtDBusGDBusMethodTable virtDBusInterfaceMethodTable[] = {
+{ 0 }
+};
+
+static gchar **
+virtDBusInterfaceEnumerate(gpointer userData)
+{
+virtDBusConnect *connect = userData;
+g_autoptr(virInterfacePtr) interfaces = NULL;
+gint num = 0;
+gchar **ret = NULL;
+
+if (!virtDBusConnectOpen(connect, NULL))
+return NULL;
+
+num = virConnectListAllInterfaces(connect->connection, &interfaces, 0);
+if (num < 0)
+return NULL;
+
+if (num == 0)
+return NULL;
+
+ret = g_new0(gchar *, num + 1);
+
+for (gint i = 0; i < num; i++) {
+ret[i] = virtDBusUtilBusPathForVirInterface(interfaces[i],
+connect->interfacePath);
+}
+
+return ret;
+}
+
+static GDBusInterfaceInfo *interfaceInfo;
+
+void
+virtDBusInterfaceRegister(virtDBusConnect *connect,
+ GError **error)
+{
+connect->interfacePath = g_strdup_printf("%s/interface",
+ connect->connectPath);
+
+if (!interfaceInfo) {
+interfaceInfo =
virtDBusGDBusLoadIntrospectData(VIRT_DBUS_INTERFACE_INTERFACE,
+error);
+if (!interfaceInfo)
+return;
+}
+
+virtDBusGDBusRegisterSubtree(connect->bus,
+ connect->interfacePath,
+ interfaceInfo,
+ virtDBusInterfaceEnumerate,
+ virtDBusInterfaceMethodTable,
+ virtDBusInterfacePropertyTable,
+ connect);
+}
diff --git a/src/interface.h b/src/interface.h
new file mode 100644
index 000..8e5ee0a
--- /dev/null
+++ b/src/interface.h
@@ -0,0 +1,9 @@
+#pragma once
+
+#include "connect.h"
+
+#define VIRT_DBUS_INTERFACE_INT