On Fri, 2018-04-20 at 13:39 +0200, Ján Tomko wrote: > On Thu, Apr 19, 2018 at 03:58:06PM +0200, Katerina Koukiou wrote: > > Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx> > > --- > > data/org.libvirt.Connect.xml | 7 +++++++ > > src/connect.c | 35 > > +++++++++++++++++++++++++++++++++++ > > tests/test_connect.py | 4 ++++ > > 3 files changed, 46 insertions(+) > > > > diff --git a/data/org.libvirt.Connect.xml > > b/data/org.libvirt.Connect.xml > > index 3ef965d..43a6241 100644 > > --- a/data/org.libvirt.Connect.xml > > +++ b/data/org.libvirt.Connect.xml > > @@ -106,6 +106,13 @@ > > value="See https://libvirt.org/html/libvirt-libvirt-host.ht > > ml#virConnectGetCapabilities"/>; > > <arg name="capabilities" type="s" direction="out"/> > > </method> > > + <method name="GetCPUModelNames"> > > + <annotation name="org.gtk.GDBus.DocString" > > + value="See https://libvirt.org/html/libvirt-libvirt-host.h > > tml#virConnectGetCPUModelNames"/>; > > + <arg name="arch" type="s" direction="in"/> > > + <arg name="flags" type="u" direction="in"/> > > + <arg name="models" type="as" direction="out"/> > > + </method> > > <method name="GetSysinfo"> > > <annotation name="org.gtk.GDBus.DocString" > > value="See https://libvirt.org/html/libvirt-libvirt-host.ht > > ml#virConnectGetSysinfo"/>; > > diff --git a/src/connect.c b/src/connect.c > > index e774fa4..169a070 100644 > > --- a/src/connect.c > > +++ b/src/connect.c > > @@ -542,6 +542,40 @@ virtDBusConnectGetAllDomainStats(GVariant > > *inArgs, > > *outArgs = g_variant_new_tuple(&gret, 1); > > } > > > > +static void > > +virtDBusConnectGetCPUModelNames(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; > > + const gchar *arch; > > + guint flags; > > + g_autoptr(GCharArray) models = NULL; > > This will need to be changed. > > > + gint nmodels; > > + GVariant *gret; > > + GVariantBuilder builder; > > + > > + g_variant_get(inArgs, "(&su)", &arch, &flags); > > + > > + if (!virtDBusConnectOpen(connect, error)) > > + return; > > + > > + nmodels = virConnectGetCPUModelNames(connect->connection, > > arch, &models, flags); > > The API documentation also states: > Pass NULL if only the list length is needed. > But that does not seem like useful functionality. Anyway, we can't support it, since @models is output and not input variable, so we can't pass NULL there somehow. Katerina > > > + if (nmodels < 0) > > + return virtDBusUtilSetLastVirtError(error); > > + > > + g_variant_builder_init(&builder, G_VARIANT_TYPE("as")); > > + for (gint i = 0; i < nmodels; i++) > > + g_variant_builder_add(&builder, "s", models[i]); > > + gret = g_variant_builder_end(&builder); > > + > > + *outArgs = g_variant_new_tuple(&gret, 1); > > +} > > + > > Reviewed-by: Ján Tomko <jtomko@xxxxxxxxxx> > > Jano -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list