Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx> --- data/org.libvirt.Connect.xml | 7 +++++++ src/connect.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index d84fc29..92f74c5 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -25,6 +25,13 @@ <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-host.html#virConnectGetVersion"/> </property> + <method name="BaselineCPU"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-host.html#virConnectBaselineCPU"/> + <arg name="xmlCPUs" type="as" direction="in"/> + <arg name="flags" type="u" direction="in"/> + <arg name="cpu" type="s" direction="out"/> + </method> <method name="DomainCreateXML"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainCreateXML"/> diff --git a/src/connect.c b/src/connect.c index 3a563bb..bd959c7 100644 --- a/src/connect.c +++ b/src/connect.c @@ -206,6 +206,43 @@ virtDBusConnectGetCapabilities(GVariant *inArgs G_GNUC_UNUSED, *outArgs = g_variant_new("(s)", capabilities); } +static void +virtDBusConnectBaselineCPU(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 const gchar **xmlCPUs = NULL; + g_autoptr(GVariantIter) iter = NULL; + const gchar **tmp; + gsize ncpus; + g_autofree gchar *cpu = NULL; + guint flags; + + g_variant_get(inArgs, "(asu)", &iter, &flags); + + ncpus = g_variant_iter_n_children(iter); + if (ncpus > 0) { + xmlCPUs = g_new0(const gchar*, ncpus); + tmp = xmlCPUs; + while (g_variant_iter_next(iter, "&s", tmp)) + tmp++; + } + + if (!virtDBusConnectOpen(connect, error)) + return; + + cpu = virConnectBaselineCPU(connect->connection, xmlCPUs, ncpus, flags); + if (!cpu) + return virtDBusUtilSetLastVirtError(error); + + *outArgs = g_variant_new("(s)", cpu); +} + static void virtDBusConnectDomainCreateXML(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -623,6 +660,7 @@ static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] = { }; static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { + { "BaselineCPU", virtDBusConnectBaselineCPU }, { "DomainCreateXML", virtDBusConnectDomainCreateXML }, { "DomainDefineXML", virtDBusConnectDomainDefineXML }, { "DomainLookupByID", virtDBusConnectDomainLookupByID }, -- 2.15.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list