Re: [PATCH 2/6] Add DBus helper methods for creating reply messages

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

 



On 20.03.2014 13:28, Daniel P. Berrange wrote:
The test suites often have to create DBus method reply messages
with payloads. Create two helpers for simplifying the process
of creating replies with payloads.

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
  src/libvirt_private.syms |  2 ++
  src/util/virdbus.c       | 60 ++++++++++++++++++++++++++++++++++++++++++++++++
  src/util/virdbus.h       |  5 ++++
  3 files changed, 67 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 6091c67..6a89d1f 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1160,6 +1160,8 @@ virDBusCallMethod;
  virDBusCloseSystemBus;
  virDBusCreateMethod;
  virDBusCreateMethodV;
+virDBusCreateReply;
+virDBusCreateReplyV;
  virDBusGetSessionBus;
  virDBusGetSystemBus;
  virDBusHasSystemBus;
diff --git a/src/util/virdbus.c b/src/util/virdbus.c
index d4e0381..d5d3e01 100644
--- a/src/util/virdbus.c
+++ b/src/util/virdbus.c
@@ -1227,6 +1227,66 @@ int virDBusCreateMethod(DBusMessage **call,


  /**
+ * virDBusCreateReplyV:
+ * @reply: pointer to be filled with a method reply message
+ * @types: type signature for following method arguments
+ * @args: method arguments
+ *
+ * This creates a DBus method reply message and saves a
+ * pointer to it in @reply.
+ *
+ * The @types parameter is a DBus signature describing
+ * the method call parameters which will be provided
+ * as variadic args. See virDBusCreateMethodV for a
+ * description of this parameter.
+ */
+int virDBusCreateReplyV(DBusMessage **reply,
+                        const char *types,
+                        va_list args)
+{
+    int ret = -1;
+
+    if (!(*reply = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN))) {
+        virReportOOMError();
+        goto cleanup;
+    }
+
+    if (virDBusMessageEncodeArgs(*reply, types, args) < 0) {
+        dbus_message_unref(*reply);
+        *reply = NULL;
+        goto cleanup;
+    }
+
+    ret = 0;
+ cleanup:

Indentation's off.

+    return ret;
+}
+
+

ACK with that fixed.

Michal

--
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]