[dbus PATCH 3/3] Implement LookupByUUID 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 |  6 ++++++
 src/connect.c                | 29 +++++++++++++++++++++++++++++
 test/test_connect.py         |  1 +
 3 files changed, 36 insertions(+)

diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index c99f700..5b5dd4c 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -38,6 +38,12 @@
       <arg name="name" type="s" direction="in"/>
       <arg name="domain" type="o" direction="out"/>
     </method>
+    <method name="LookupByUUID">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainLookupByUUIDString"/>
+      <arg name="uuid" type="s" direction="in"/>
+      <arg name="domain" type="o" direction="out"/>
+    </method>
     <signal name="DomainCrashed">
       <annotation name="org.gtk.GDBus.DocString"
         value="See https://libvirt.org/html/libvirt-libvirt-domain.html#VIR_DOMAIN_EVENT_CRASHED"/>
diff --git a/src/connect.c b/src/connect.c
index 5952ff3..f580d30 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -251,6 +251,34 @@ virtDBusDomainLookupByName(GVariant *inArgs,
     *outArgs = g_variant_new("(o)", path);
 }
 
+static void
+virtDBusDomainLookupByUUID(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_autoptr(virDomain) domain = NULL;
+    g_autofree gchar *path = NULL;
+    const gchar *uuidstr;
+
+    g_variant_get(inArgs, "(s)", &uuidstr);
+
+    if (!virtDBusConnectOpen(connect, NULL))
+        return;
+
+    domain = virDomainLookupByUUIDString(connect->connection, uuidstr);
+    if (!domain)
+        return virtDBusUtilSetLastVirtError(error);
+
+    path = virtDBusUtilBusPathForVirDomain(domain, connect->domainPath);
+
+    *outArgs = g_variant_new("(o)", path);
+}
+
 static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] = {
     { "Version", virtDBusConnectGetVersion, NULL },
     { NULL, NULL, NULL }
@@ -262,6 +290,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
     { "DefineXML", virtDBusConnectDefineXML },
     { "LookupByID", virtDBusDomainLookupByID },
     { "LookupByName", virtDBusDomainLookupByName },
+    { "LookupByUUID", virtDBusDomainLookupByUUID },
     { NULL, NULL }
 };
 
diff --git a/test/test_connect.py b/test/test_connect.py
index a7a6a91..2d0f051 100755
--- a/test/test_connect.py
+++ b/test/test_connect.py
@@ -56,6 +56,7 @@ class TestConnect(libvirttest.BaseTestClass):
     @pytest.mark.parametrize("lookup_method_name,lookup_item", [
         ("LookupByID", 'Id'),
         ("LookupByName", 'Name'),
+        ("LookupByUUID", 'UUID'),
     ])
     def test_connect_lookup_by_id(self, lookup_method_name, lookup_item):
         """Parameterized test for all LookupBy* API calls of Connect interface
-- 
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