Re: [dbus PATCH v2 1/5] Introduce Network Interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 04, 2018 at 02:26:09PM +0200, Katerina Koukiou wrote:
> Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx>
> ---
>  data/Makefile.am             |  3 ++-
>  data/org.libvirt.Network.xml |  7 +++++
>  src/Makefile.am              |  3 ++-
>  src/connect.c                |  5 ++++
>  src/connect.h                |  1 +
>  src/network.c                | 64 ++++++++++++++++++++++++++++++++++++++++++++
>  src/network.h                |  9 +++++++
>  src/util.c                   | 20 ++++++++++++++
>  src/util.h                   | 10 +++++++
>  9 files changed, 120 insertions(+), 2 deletions(-)
>  create mode 100644 data/org.libvirt.Network.xml
>  create mode 100644 src/network.c
>  create mode 100644 src/network.h
> 
> diff --git a/data/Makefile.am b/data/Makefile.am
> index dd60713..61702df 100644
> --- a/data/Makefile.am
> +++ b/data/Makefile.am
> @@ -20,7 +20,8 @@ polkit_DATA = $(polkit_files:.rules.in=.rules)
>  
>  interfaces_files = \
>  	org.libvirt.Connect.xml \
> -	org.libvirt.Domain.xml
> +	org.libvirt.Domain.xml \
> +	org.libvirt.Network.xml
>  interfacesdir = $(DBUS_INTERFACES_DIR)
>  interfaces_DATA = $(interfaces_files)
>  
> diff --git a/data/org.libvirt.Network.xml b/data/org.libvirt.Network.xml
> new file mode 100644
> index 0000000..2b7c4f7
> --- /dev/null
> +++ b/data/org.libvirt.Network.xml
> @@ -0,0 +1,7 @@
> +<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
> +"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd";>
> +
> +<node name="/org/libvirt/network">
> +  <interface name="org.libvirt.Network">
> +  </interface>
> +</node>
> diff --git a/src/Makefile.am b/src/Makefile.am
> index 7248561..158398a 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -8,7 +8,8 @@ DAEMON_SOURCES = \
>  	util.c util.h \
>  	domain.c domain.h \
>  	events.c events.h \
> -	gdbus.c gdbus.h
> +	gdbus.c gdbus.h \
> +	network.c network.h
>  
>  EXTRA_DIST = \
>  	$(DAEMON_SOURCES)
> diff --git a/src/connect.c b/src/connect.c
> index 2350736..7b3f834 100644
> --- a/src/connect.c
> +++ b/src/connect.c
> @@ -1,6 +1,7 @@
>  #include "connect.h"
>  #include "domain.h"
>  #include "events.h"
> +#include "network.h"
>  #include "util.h"
>  
>  #include <glib/gprintf.h>
> @@ -345,6 +346,10 @@ virtDBusConnectNew(virtDBusConnect **connectp,
>      if (error && *error)
>          return;
>  
> +    virtDBusNetworkRegister(connect, error);
> +    if (error && *error)
> +        return;
> +
>      *connectp = connect;
>      connect = NULL;
>  }
> diff --git a/src/connect.h b/src/connect.h
> index 9572857..7ed84b8 100644
> --- a/src/connect.h
> +++ b/src/connect.h
> @@ -13,6 +13,7 @@ struct virtDBusConnect {
>      const gchar *uri;
>      const gchar *connectPath;
>      gchar *domainPath;
> +    gchar *networkPath;
>      virConnectPtr connection;
>      GMutex lock;
>  
> diff --git a/src/network.c b/src/network.c
> new file mode 100644
> index 0000000..0d0e992
> --- /dev/null
> +++ b/src/network.c
> @@ -0,0 +1,64 @@
> +#include "network.h"
> +#include "util.h"
> +
> +#include <libvirt/libvirt.h>
> +
> +static virtDBusGDBusPropertyTable virtDBusNetworkPropertyTable[] = {
> +    { 0 }
> +};
> +
> +static virtDBusGDBusMethodTable virtDBusNetworkMethodTable[] = {
> +    { 0 }
> +};
> +
> +static gchar **
> +virtDBusNetworkEnumerate(gpointer userData)
> +{
> +    virtDBusConnect *connect = userData;
> +    g_autoptr(virNetworkPtr) networks = NULL;
> +    gint num = 0;
> +    gchar **ret = NULL;
> +
> +    if (!virtDBusConnectOpen(connect, NULL))
> +        return NULL;
> +
> +    num = virConnectListAllNetworks(connect->connection, &networks, 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] = virtDBusUtilBusPathForVirNetwork(networks[i],
> +                                                  connect->networkPath);
> +    }
> +
> +    return ret;
> +}
> +
> +static GDBusInterfaceInfo *interfaceInfo = NULL;
> +
> +void
> +virtDBusNetworkRegister(virtDBusConnect *connect,
> +                       GError **error)

Indentation is off here.

With the virtDBusConnectFree addition

Reviewed-by: Pavel Hrdina <phrdina@xxxxxxxxxx>

Attachment: signature.asc
Description: PGP signature

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

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux