VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_ARP should be added
later on.
Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
data/org.libvirt.Domain.xml | 7 ++++
src/domain.c | 87 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 94 insertions(+)
diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml
index 96a1ca6..d81f14f 100644
--- a/data/org.libvirt.Domain.xml
+++ b/data/org.libvirt.Domain.xml
@@ -310,6 +310,13 @@
value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainInjectNMI&q...
<arg name="flags" type="u" direction="in"/>
</method>
+ <method name="InterfaceAddresses">
+ <annotation name="org.gtk.GDBus.DocString"
+ value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainInterfaceAd...
+ <arg name="source" type="s" direction="in"/>
+ <arg name="flags" type="u" direction="in"/>
+ <arg name="ifaces" type="a(ssa(isu))"
direction="out"/>
+ </method>
<method name="ManagedSave">
<annotation name="org.gtk.GDBus.DocString"
value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainManagedSave...
diff --git a/src/domain.c b/src/domain.c
index 562e709..83ad053 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -35,6 +35,12 @@ VIRT_DBUS_ENUM_IMPL(virtDBusDomainDiskError,
"unspec",
"no-space")
+VIRT_DBUS_ENUM_DECL(virtDBusDomainInterfaceAddressesSource)
+VIRT_DBUS_ENUM_IMPL(virtDBusDomainInterfaceAddressesSource,
+ VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LAST,
+ "lease",
+ "agent")
+
VIRT_DBUS_ENUM_DECL(virtDBusDomainJob)
VIRT_DBUS_ENUM_IMPL(virtDBusDomainJob,
VIR_DOMAIN_JOB_LAST,
@@ -73,6 +79,25 @@ struct _virtDBusDomainFSInfoList {
typedef struct _virtDBusDomainFSInfoList virtDBusDomainFSInfoList;
+struct _virtDBusDomainInterfaceList {
+ virDomainInterfacePtr *ifaces;
+ gint count;
+};
+
+typedef struct _virtDBusDomainInterfaceList virtDBusDomainInterfaceList;
+
+static void
+virtDBusDomainInterfaceListClear(virtDBusDomainInterfaceList *ifaces)
+{
+ for (gint i = 0; i < ifaces->count; i++)
+ virDomainInterfaceFree(ifaces->ifaces[i]);
+
+ g_free(ifaces->ifaces);
+}
+
+G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(virtDBusDomainInterfaceList,
+ virtDBusDomainInterfaceListClear);
+
static void
virtDBusDomainFSInfoListClear(virtDBusDomainFSInfoList *info)
{
@@ -1684,6 +1709,67 @@ virtDBusDomainInjectNMI(GVariant *inArgs,
virtDBusUtilSetLastVirtError(error);
}
+static void
+virtDBusDomainInterfaceAddresses(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(virDomain) domain = NULL;
+ gint source;
+ const gchar *sourceStr;
+ g_auto(virtDBusDomainInterfaceList) ifaces = { 0 };
+ guint flags;
+ GVariantBuilder builder;
+ GVariant *res;
+
+ g_variant_get(inArgs, "(&su)", &sourceStr, &flags);
+
+ domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
+ if (!domain)
+ return;
+
+ source = virtDBusDomainInterfaceAddressesSourceTypeFromString(sourceStr);
+ if (source < 0) {
+ g_set_error(error, VIRT_DBUS_ERROR, VIRT_DBUS_ERROR_LIBVIRT,
+ "Can't get valid virDomainInterfaceAddressesSource from
string '%s'.",
+ sourceStr);
+ return;
+ }
+ ifaces.count = virDomainInterfaceAddresses(domain, &(ifaces.ifaces),
+ source, flags);
+ if (ifaces.count < 0)
+ virtDBusUtilSetLastVirtError(error);
+
+
+ g_variant_builder_init(&builder, G_VARIANT_TYPE("a(ssa(isu))"));
+ for (gint i = 0; i < ifaces.count; i++) {
+ virDomainInterfacePtr iface = ifaces.ifaces[i];
+
+ g_variant_builder_open(&builder, G_VARIANT_TYPE("(ssa(isu))"));
+ g_variant_builder_add(&builder, "s", iface->name);
+ g_variant_builder_add(&builder, "s",
+ iface->hwaddr ? iface->hwaddr : "");
+ g_variant_builder_open(&builder, G_VARIANT_TYPE("a(isu)"));
+ for (guint j = 0; j < iface->naddrs; j++) {
+ g_variant_builder_open(&builder, G_VARIANT_TYPE("(isu)"));
+ g_variant_builder_add(&builder, "i", iface->addrs[j].type);
+ g_variant_builder_add(&builder, "s", iface->addrs[j].addr);
+ g_variant_builder_add(&builder, "u",
iface->addrs[j].prefix);
+ g_variant_builder_close(&builder);
+ }
+ g_variant_builder_close(&builder);
+ g_variant_builder_close(&builder);
+ }
+ res = g_variant_builder_end(&builder);
+
+ *outArgs = g_variant_new_tuple(&res, 1);
+}
+
static void
virtDBusDomainManagedSave(GVariant *inArgs,
GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -2699,6 +2785,7 @@ static virtDBusGDBusMethodTable virtDBusDomainMethodTable[] = {
{ "GetXMLDesc", virtDBusDomainGetXMLDesc },
{ "HasManagedSaveImage", virtDBusDomainHasManagedSaveImage },
{ "InjectNMI", virtDBusDomainInjectNMI },
+ { "InterfaceAddresses", virtDBusDomainInterfaceAddresses },
{ "ManagedSave", virtDBusDomainManagedSave },
{ "ManagedSaveRemove", virtDBusDomainManagedSaveRemove },
{ "MemoryPeek", virtDBusDomainMemoryPeek },
--
2.15.0