Re: [dbus PATCH v2] Implement GetIOThreadInfo method for Domain Interface

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

 



On Wed, Apr 25, 2018 at 07:04:25PM +0200, Katerina Koukiou wrote:
> Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx>
> ---
>  data/org.libvirt.Domain.xml |  6 +++++
>  src/domain.c                | 63 +++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 69 insertions(+)
> 
> diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml
> index 96b9220..531cdb5 100644
> --- a/data/org.libvirt.Domain.xml
> +++ b/data/org.libvirt.Domain.xml
> @@ -222,6 +222,12 @@
>        <arg name="flags" type="u" direction="in"/>
>        <arg name="interfaceParameters" type="a{sv}" direction="out"/>
>      </method>
> +    <method name="GetIOThreadInfo">
> +      <annotation name="org.gtk.GDBus.DocString"
> +        value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetIOThreadInfo"/>
> +      <arg name="flags" type="u" direction="in"/>
> +      <arg name="ioThreadInfo" type="a(uab)" direction="out"/>
> +    </method>
>      <method name="GetJobInfo">
>        <annotation name="org.gtk.GDBus.DocString"
>          value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetJobInfo"/>
> diff --git a/src/domain.c b/src/domain.c
> index 76eec1d..e7b4b24 100644
> --- a/src/domain.c
> +++ b/src/domain.c
> @@ -85,6 +85,25 @@ virtDBusDomainFSInfoListClear(virtDBusDomainFSInfoList *info)
>  G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(virtDBusDomainFSInfoList,
>                                   virtDBusDomainFSInfoListClear);
>  
> +struct _virtDBusDomainIOThreadInfoList {
> +    virDomainIOThreadInfoPtr *info;
> +    gint count;
> +};
> +
> +typedef struct _virtDBusDomainIOThreadInfoList virtDBusDomainIOThreadInfoList;
> +
> +static void
> +virtDBusDomainIOThreadInfoListClear(virtDBusDomainIOThreadInfoList *info)
> +{
> +    for (gint i = 0; i < info->count; i++)
> +        virDomainIOThreadInfoFree(info->info[i]);
> +
> +    g_free(info->info);
> +}
> +
> +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(virtDBusDomainIOThreadInfoList,
> +                                 virtDBusDomainIOThreadInfoListClear);
> +
>  static GVariant *
>  virtDBusDomainMemoryStatsToGVariant(virDomainMemoryStatPtr stats,
>                                      gint nr_stats)
> @@ -1218,6 +1237,49 @@ virtDBusDomainGetInterfaceParameters(GVariant *inArgs,
>      *outArgs = g_variant_new_tuple(&grecords, 1);
>  }
>  
> +static void
> +virtDBusDomainGetIOThreadInfo(GVariant *inArgs,
> +                              GUnixFDList *inFDs G_GNUC_UNUSED,
> +                              const gchar *objectPath,
> +                              gpointer userData,
> +                              GVariant **outArgs,
> +                              GUnixFDList **outFDs G_GNUC_UNUSED,
> +                              GError **error)
> +{
> +    virtDBusConnect *connect = userData;
> +    g_autoptr(virDomain) domain = NULL;
> +    g_auto(virtDBusDomainIOThreadInfoList) info = { 0 };
> +    GVariantBuilder builder;
> +    guint flags;
> +    GVariant *gret;
> +
> +    g_variant_get(inArgs, "(u)", &flags);
> +
> +    domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
> +    if (!domain)
> +        return;
> +
> +    info.count = virDomainGetIOThreadInfo(domain, &info.info, flags);
> +    if (info.count < 0)
> +        return virtDBusUtilSetLastVirtError(error);
> +
> +    g_variant_builder_init(&builder, G_VARIANT_TYPE("a(uab)"));
> +
> +    for (gint i = 0; i < info.count; i++) {
> +        g_variant_builder_open(&builder, G_VARIANT_TYPE("(uab)"));
> +        g_variant_builder_add(&builder, "u", info.info[i]->iothread_id);
> +
> +        g_variant_builder_open(&builder, G_VARIANT_TYPE("ab"));
> +        for (gint j = 0; j < info.info[i]->cpumaplen; j++)
> +            g_variant_builder_add(&builder, "b", info.info[i]->cpumap[j]);

Unfortunately it's not that easy :).  The cpumap is unsigned char type
which means it's 8-bit long and each bit represents single CPU.

First we need to get number of host CPUs calling:

    ncpus = virNodeGetCPUMap(connect->connection, NULL, NULL, 0);

And then loop over all CPUs and check whether it's set or not using
VIR_CPU_USED macro.

Pavel

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