[dbus PATCH 01/10] virtDBusDomainGetVcpus: Should be implemented as method and not as property

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

 



Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx>
---
 data/org.libvirt.Domain.xml |  5 ++++-
 src/domain.c                | 51 ++++++++++++++++++++++++++-------------------
 test/test_domain.py         |  3 ++-
 3 files changed, 35 insertions(+), 24 deletions(-)

diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml
index 48bf40f..1ecf826 100644
--- a/data/org.libvirt.Domain.xml
+++ b/data/org.libvirt.Domain.xml
@@ -6,12 +6,15 @@
     <property name="Name" type="s" access="read"/>
     <property name="UUID" type="s" access="read"/>
     <property name="Id" type="u" access="read"/>
-    <property name="Vcpus" type="u" access="read"/>
     <property name="OSType" type="s" access="read"/>
     <property name="Active" type="b" access="read"/>
     <property name="Persistent" type="b" access="read"/>
     <property name="State" type="s" access="read"/>
     <property name="Autostart" type="b" access="read"/>
+    <method name="GetVcpus">
+      <arg name="flags" type="u" direction="in"/>
+      <arg name="vcpus" type="u" direction="out"/>
+    </method>
     <method name="GetXMLDesc">
       <arg name="flags" type="u" direction="in"/>
       <arg name="xml" type="s" direction="out"/>
diff --git a/src/domain.c b/src/domain.c
index e4404c1..09b3440 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -86,27 +86,6 @@ virtDBusDomainGetId(const gchar *objectPath,
     *value = g_variant_new("u", id);
 }
 
-static void
-virtDBusDomainGetVcpus(const gchar *objectPath,
-                       gpointer userData,
-                       GVariant **value,
-                       GError **error)
-{
-    virtDBusConnect *connect = userData;
-    g_autoptr(virDomain) domain = NULL;
-    gint vcpus;
-
-    domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
-    if (!domain)
-        return;
-
-    vcpus = virDomainGetVcpusFlags(domain, VIR_DOMAIN_VCPU_CURRENT);
-    if (vcpus < 0)
-        return virtDBusUtilSetLastVirtError(error);
-
-    *value = g_variant_new("u", vcpus);
-}
-
 static void
 virtDBusDomainGetOsType(const gchar *objectPath,
                         gpointer userData,
@@ -239,6 +218,34 @@ virtDBusDomainGetAutostart(const gchar *objectPath,
     *value = g_variant_new("b", !!autostart);
 }
 
+static void
+virtDBusDomainGetVcpus(GVariant *inArgs,
+                       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;
+    gint vcpus;
+    guint flags;
+
+    g_variant_get(inArgs, "(u)", &flags);
+
+    domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
+    if (!domain)
+        return;
+
+    vcpus = virDomainGetVcpusFlags(domain, flags);
+    if (vcpus < 0)
+        return virtDBusUtilSetLastVirtError(error);
+
+    *outArgs = g_variant_new("(u)", vcpus);
+}
+
 static void
 virtDBusDomainGetXMLDesc(GVariant *inArgs,
                          GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -435,7 +442,6 @@ static virtDBusGDBusPropertyTable virtDBusDomainPropertyTable[] = {
     { "Name", virtDBusDomainGetName, NULL },
     { "UUID", virtDBusDomainGetUUID, NULL },
     { "Id", virtDBusDomainGetId, NULL },
-    { "Vcpus", virtDBusDomainGetVcpus, NULL },
     { "OSType", virtDBusDomainGetOsType, NULL },
     { "Active", virtDBusDomainGetActive, NULL },
     { "Persistent", virtDBusDomainGetPersistent, NULL },
@@ -445,6 +451,7 @@ static virtDBusGDBusPropertyTable virtDBusDomainPropertyTable[] = {
 };
 
 static virtDBusGDBusMethodTable virtDBusDomainMethodTable[] = {
+    { "GetVcpus", virtDBusDomainGetVcpus },
     { "GetXMLDesc", virtDBusDomainGetXMLDesc },
     { "GetStats", virtDBusDomainGetStats },
     { "Shutdown", virtDBusDomainShutdown },
diff --git a/test/test_domain.py b/test/test_domain.py
index 1bf9c1b..22039dc 100755
--- a/test/test_domain.py
+++ b/test/test_domain.py
@@ -17,7 +17,6 @@ class TestDomain(libvirttest.BaseTestClass):
         assert isinstance(props['Name'], dbus.String)
         assert isinstance(props['UUID'], dbus.String)
         assert isinstance(props['Id'], dbus.UInt32)
-        assert isinstance(props['Vcpus'], dbus.UInt32)
         assert isinstance(props['OSType'], dbus.String)
         assert isinstance(props['Active'], dbus.Boolean)
         assert isinstance(props['Persistent'], dbus.Boolean)
@@ -29,6 +28,8 @@ class TestDomain(libvirttest.BaseTestClass):
 
         xml = domain.GetXMLDesc(0)
         assert isinstance(xml, dbus.String)
+        vcpus = domain.GetVcpus(0)
+        assert isinstance(vcpus, dbus.UInt32)
 
         domain.Reboot(0)
         domain.Shutdown()
-- 
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