[libvirt] [dbus PATCH v2 5/9] Implement NodeGetMemoryStats method for Connect Interface

Pavel Hrdina phrdina at redhat.com
Thu May 3 13:13:21 UTC 2018


On Wed, May 02, 2018 at 12:34:42PM +0200, Katerina Koukiou wrote:
> Signed-off-by: Katerina Koukiou <kkoukiou at redhat.com>
> ---
>  data/org.libvirt.Connect.xml |  6 ++++++
>  src/connect.c                | 44 ++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 50 insertions(+)
> 
> diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
> index c62d107..4a1ee4a 100644
> --- a/data/org.libvirt.Connect.xml
> +++ b/data/org.libvirt.Connect.xml
> @@ -189,6 +189,12 @@
>        <arg name="flags" type="u" direction="in"/>
>        <arg name="memoryParameters" type="a{sv}" direction="out"/>
>      </method>
> +    <method name="NodeGetMemoryStats">
> +      <annotation name="org.gtk.GDBus.DocString"
> +        value="See https://libvirt.org/html/libvirt-libvirt-host.html#virNodeGetMemoryStats"/>
> +      <arg name="flags" type="u" direction="in"/>
> +      <arg name="stats" type="a{st}" direction="out"/>
> +    </method>

In the review of v1 I've stated that we should drop the cellNum
argument, that was wrong.  I thought that this API will report stats for
all numa nodes, but that's not true.  This is similar to the
NodeGetCPUStats API so it should be same.  Sorry about that.

>      <signal name="DomainEvent">
>        <annotation name="org.gtk.GDBus.DocString"
>          value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectDomainEventCallback"/>
> diff --git a/src/connect.c b/src/connect.c
> index f2c6d45..0ecb333 100644
> --- a/src/connect.c
> +++ b/src/connect.c
> @@ -966,6 +966,49 @@ virtDBusConnectNodeGetMemoryParameters(GVariant *inArgs,
>      *outArgs = g_variant_new_tuple(&grecords, 1);
>  }
>  
> +static void
> +virtDBusConnectNodeGetMemoryStats(GVariant *inArgs,
> +                                  GUnixFDList *inFDs G_GNUC_UNUSED,
> +                                  const gchar *objectPath G_GNUC_UNUSED,
> +                                  gpointer userData,
> +                                  GVariant **outArgs,
> +                                  GUnixFDList **outFDs G_GNUC_UNUSED,
> +                                  GError **error)
> +{
> +    virtDBusConnect *connect = userData;
> +    g_autofree virNodeMemoryStatsPtr params = NULL;
> +    gint nparams = 0;
> +    gint cellNum = VIR_NODE_MEMORY_STATS_ALL_CELLS;
> +    guint flags;
> +    gint ret;
> +    GVariantBuilder builder;
> +    GVariant *res;
> +
> +    g_variant_get(inArgs, "(u)", &flags);
> +
> +    if (!virtDBusConnectOpen(connect, error))
> +        return;
> +
> +    ret = virNodeGetMemoryStats(connect->connection, cellNum, NULL,
> +                                &nparams, flags);
> +    if (ret < 0)
> +        return virtDBusUtilSetLastVirtError(error);

I would put an empty line here.

> +    if (nparams != 0) {
> +        params = g_new0(virNodeMemoryStats, nparams);
> +        if (virNodeGetMemoryStats(connect->connection, cellNum, params,
> +                                  &nparams, flags) < 0) {
> +            return virtDBusUtilSetLastVirtError(error);
> +        }
> +    }

Reviewed-by: Pavel Hrdina <phrdina at redhat.com>

to the v1 patch with the error check fix as it was pointed out for the
v1 patch.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180503/9dbc74b5/attachment-0001.sig>


More information about the libvir-list mailing list