[dbus PATCH 7/8] Implement GetCPUModelNames method for Connect Interface

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

 



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.html#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.html#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.html#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;
+    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);
+    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);
+}
+
 static void
 virtDBusConnectGetSysinfo(GVariant *inArgs,
                           GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -782,6 +816,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
     { "FindStoragePoolSources", virtDBusConnectFindStoragePoolSources },
     { "GetAllDomainStats", virtDBusConnectGetAllDomainStats },
     { "GetCapabilities", virtDBusConnectGetCapabilities },
+    { "GetCPUModelNames", virtDBusConnectGetCPUModelNames },
     { "GetSysinfo", virtDBusConnectGetSysinfo },
     { "ListDomains", virtDBusConnectListDomains },
     { "ListNetworks", virtDBusConnectListNetworks },
diff --git a/tests/test_connect.py b/tests/test_connect.py
index d7ec704..57f0658 100755
--- a/tests/test_connect.py
+++ b/tests/test_connect.py
@@ -116,6 +116,10 @@ class TestConnect(libvirttest.BaseTestClass):
     def test_connect_get_capabilities(self):
         assert isinstance(self.connect.GetCapabilities(), dbus.String)
 
+    def test_connect_get_cpu_model_names(self):
+        arch = "x86_64"
+        assert isinstance(self.connect.GetCPUModelNames(arch, 0), dbus.Array)
+
     def test_connect_network_create_xml(self):
         def network_started(path, _event):
             assert isinstance(path, dbus.ObjectPath)
-- 
2.15.0

--
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