[dbus PATCH 2/8] Implement CompareCPU 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                | 43 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+)

diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index 92f74c5..0fc34e3 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -32,6 +32,13 @@
       <arg name="flags" type="u" direction="in"/>
       <arg name="cpu" type="s" direction="out"/>
     </method>
+    <method name="CompareCPU">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-host.html#virConnectCompareCPU"/>
+      <arg name="xmlDesc" type="s" direction="in"/>
+      <arg name="flags" type="u" direction="in"/>
+      <arg name="compareResult" 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 bd959c7..86fea4f 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -6,6 +6,13 @@
 
 #include <glib/gprintf.h>
 
+VIRT_DBUS_ENUM_DECL(virtDBusConnectCPUCompareResult)
+VIRT_DBUS_ENUM_IMPL(virtDBusConnectCPUCompareResult,
+                    VIR_CPU_COMPARE_LAST,
+                    "incompatible",
+                    "identical",
+                    "superset")
+
 static gint virtDBusConnectCredType[] = {
     VIR_CRED_AUTHNAME,
     VIR_CRED_ECHOPROMPT,
@@ -243,6 +250,41 @@ virtDBusConnectBaselineCPU(GVariant *inArgs,
     *outArgs = g_variant_new("(s)", cpu);
 }
 
+static void
+virtDBusConnectCompareCPU(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 *xmlDesc;
+    guint flags;
+    gint compareResult;
+    g_autofree const gchar* compareResultStr = NULL;
+
+    g_variant_get(inArgs, "(&su)", &xmlDesc, &flags);
+
+    if (!virtDBusConnectOpen(connect, error))
+        return;
+
+    compareResult = virConnectCompareCPU(connect->connection, xmlDesc, flags);
+    if (compareResult < 0)
+        return virtDBusUtilSetLastVirtError(error);
+
+    compareResultStr = virtDBusConnectCPUCompareResultTypeToString(compareResult);
+    if (!compareResultStr) {
+        g_set_error(error, VIRT_DBUS_ERROR, VIRT_DBUS_ERROR_LIBVIRT,
+                    "Can't format virCPUCompareResult '%d' to string.",
+                    compareResult);
+        return;
+    }
+
+    *outArgs = g_variant_new("(s)", compareResultStr);
+}
+
 static void
 virtDBusConnectDomainCreateXML(GVariant *inArgs,
                                GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -661,6 +703,7 @@ static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] = {
 
 static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
     { "BaselineCPU", virtDBusConnectBaselineCPU },
+    { "CompareCPU", virtDBusConnectCompareCPU },
     { "DomainCreateXML", virtDBusConnectDomainCreateXML },
     { "DomainDefineXML", virtDBusConnectDomainDefineXML },
     { "DomainLookupByID", virtDBusConnectDomainLookupByID },
-- 
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