Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx> --- data/org.libvirt.Domain.xml | 6 +++++ src/domain.c | 64 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml index 84ef3bf..bda63f4 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(uay)" 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 3c1fec7..f611fbf 100644 --- a/src/domain.c +++ b/src/domain.c @@ -85,6 +85,25 @@ virtDBusDomainFSInfoListFree(virtDBusDomainFSInfoList *info) G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(virtDBusDomainFSInfoList, virtDBusDomainFSInfoListFree); +struct _virtDBusDomainIOThreadInfoList { + virDomainIOThreadInfoPtr *info; + gint count; +}; + +typedef struct _virtDBusDomainIOThreadInfoList virtDBusDomainIOThreadInfoList; + +static void +virtDBusDomainIOThreadInfoListFree(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, + virtDBusDomainIOThreadInfoListFree); + static GVariant * virtDBusDomainMemoryStatsToGVariant(virDomainMemoryStatPtr stats, gint nr_stats) @@ -1219,6 +1238,50 @@ virtDBusDomainGetInterfaceParameters(GVariant *inArgs, *outArgs = g_variant_new_tuple(&grecords, 1); } +static void +virtDBusDomainGetIOThreadInfo(GVariant *inArgs G_GNUC_UNUSED, + 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(uay)")); + + for (gint i = 0; i < info.count; i++) { + g_variant_builder_open(&builder, G_VARIANT_TYPE("(uay)")); + g_variant_builder_add(&builder, "u", info.info[i]->iothread_id); + + g_variant_builder_open(&builder, G_VARIANT_TYPE("ay")); + for (gint j = 0; j < info.info[i]->cpumaplen; j++) { + g_variant_builder_add(&builder, "y", info.info[i]->cpumap[j]); + g_variant_builder_close(&builder); + } + g_variant_builder_close(&builder); + } + gret = g_variant_builder_end(&builder); + + *outArgs = g_variant_new_tuple(&gret, 1); +} + static void virtDBusDomainGetJobInfo(GVariant *inArgs G_GNUC_UNUSED, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -2302,6 +2365,7 @@ static virtDBusGDBusMethodTable virtDBusDomainMethodTable[] = { { "GetGuestVcpus", virtDBusDomainGetGuestVcpus }, { "GetHostname", virtDBusDomainGetHostname }, { "GetInterfaceParameters", virtDBusDomainGetInterfaceParameters }, + { "GetIOThreadInfo", virtDBusDomainGetIOThreadInfo }, { "GetJobInfo", virtDBusDomainGetJobInfo }, { "GetMemoryParameters", virtDBusDomainGetMemoryParameters }, { "GetSchedulerParameters", virtDBusDomainGetSchedulerParameters }, -- 2.15.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list