[dbus PATCH 4/4] connect: Implement DomainCreateXMLWithFiles method

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

 



Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 data/org.libvirt.Connect.xml |  8 ++++++++
 src/connect.c                | 40 ++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+)

diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index 0c009cd..2b82a76 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -49,6 +49,14 @@
       <arg name="flags" type="u" direction="in"/>
       <arg name="domain" type="o" direction="out"/>
     </method>
+    <method name="DomainCreateXMLWithFiles">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainCreateXMLWithFiles"/>
+      <arg name="xml" type="s" direction="in"/>
+      <arg name="files" type="ah" direction="in"/>
+      <arg name="flags" type="u" direction="in"/>
+      <arg name="domain" type="o" direction="out"/>
+    </method>
     <method name="DomainDefineXML">
       <annotation name="org.gtk.GDBus.DocString"
         value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainDefineXML"/>
diff --git a/src/connect.c b/src/connect.c
index 79b5d8f..096671f 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -5,6 +5,7 @@
 #include "storagepool.h"
 #include "util.h"
 
+#include <gio/gunixfdlist.h>
 #include <glib/gprintf.h>
 
 static gint virtDBusConnectCredType[] = {
@@ -309,6 +310,44 @@ virtDBusConnectDomainCreateXML(GVariant *inArgs,
     *outArgs = g_variant_new("(o)", path);
 }
 
+static void
+virtDBusConnectDomainCreateXMLWithFiles(GVariant *inArgs,
+                                        GUnixFDList *inFDs,
+                                        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;
+    gchar *xml;
+    const gint *files = NULL;
+    guint nfiles = 0;
+    guint flags;
+
+    g_variant_get(inArgs, "(&sahu)", &xml, NULL, &flags);
+
+    if (inFDs) {
+        nfiles = g_unix_fd_list_get_length(inFDs);
+        if (nfiles > 0)
+            files = g_unix_fd_list_peek_fds(inFDs, NULL);
+    }
+
+    if (!virtDBusConnectOpen(connect, error))
+        return;
+
+    domain = virDomainCreateXMLWithFiles(connect->connection, xml, nfiles,
+                                         (gint *)files, flags);
+    if (!domain)
+        return virtDBusUtilSetLastVirtError(error);
+
+    path = virtDBusUtilBusPathForVirDomain(domain, connect->domainPath);
+
+    *outArgs = g_variant_new("(o)", path);
+}
+
 static void
 virtDBusConnectDomainDefineXML(GVariant *inArgs,
                                GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -1176,6 +1215,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
     { "BaselineCPU", virtDBusConnectBaselineCPU },
     { "CompareCPU", virtDBusConnectCompareCPU },
     { "DomainCreateXML", virtDBusConnectDomainCreateXML },
+    { "DomainCreateXMLWithFiles", virtDBusConnectDomainCreateXMLWithFiles },
     { "DomainDefineXML", virtDBusConnectDomainDefineXML },
     { "DomainLookupByID", virtDBusConnectDomainLookupByID },
     { "DomainLookupByName", virtDBusConnectDomainLookupByName },
-- 
2.17.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