[dbus PATCH v2 4/4] Implement DomainLookupByUUID 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 fd673c8..f24dff4 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="DomainLookupByUUID">
+      <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 b94360f..56ead8d 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 },
     { "DomainLookupByID", virtDBusDomainLookupByID },
     { "DomainLookupByName", virtDBusDomainLookupByName },
+    { "DomainLookupByUUID", virtDBusDomainLookupByUUID },
     { NULL, NULL }
 };
 
diff --git a/test/test_connect.py b/test/test_connect.py
index 8a0f8ba..2b3c5c3 100755
--- a/test/test_connect.py
+++ b/test/test_connect.py
@@ -57,6 +57,7 @@ class TestConnect(libvirttest.BaseTestClass):
     @pytest.mark.parametrize("lookup_method_name,lookup_item", [
         ("DomainLookupByID", 'Id'),
         ("DomainLookupByName", 'Name'),
+        ("DomainLookupByUUID", '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