Re: [libvirt] [PATCH v2 03/23] dbus: correctly build reply message

2019-09-06 Thread Michal Privoznik

On 8/8/19 4:54 PM, marcandre.lur...@redhat.com wrote:

From: Marc-André Lureau 

dbus_message_new() does not construct correct replies by itself, it is
recommended to use dbus_message_new_method_return() instead.

Signed-off-by: Marc-André Lureau 
---
  src/util/virdbus.c  | 18 --
  src/util/virdbus.h  |  6 --
  tests/virfirewalltest.c |  9 ++---
  tests/virpolkittest.c   |  3 ++-
  4 files changed, 24 insertions(+), 12 deletions(-)


Reviewed-by: Michal Privoznik 

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH v2 03/23] dbus: correctly build reply message

2019-08-08 Thread marcandre . lureau
From: Marc-André Lureau 

dbus_message_new() does not construct correct replies by itself, it is
recommended to use dbus_message_new_method_return() instead.

Signed-off-by: Marc-André Lureau 
---
 src/util/virdbus.c  | 18 --
 src/util/virdbus.h  |  6 --
 tests/virfirewalltest.c |  9 ++---
 tests/virpolkittest.c   |  3 ++-
 4 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/src/util/virdbus.c b/src/util/virdbus.c
index b0ac8d7055..64513eef14 100644
--- a/src/util/virdbus.c
+++ b/src/util/virdbus.c
@@ -1456,6 +1456,7 @@ int virDBusCreateMethod(DBusMessage **call,
 
 /**
  * virDBusCreateReplyV:
+ * @msg: the message to reply to
  * @reply: pointer to be filled with a method reply message
  * @types: type signature for following method arguments
  * @args: method arguments
@@ -1468,13 +1469,14 @@ int virDBusCreateMethod(DBusMessage **call,
  * as variadic args. See virDBusCreateMethodV for a
  * description of this parameter.
  */
-int virDBusCreateReplyV(DBusMessage **reply,
+int virDBusCreateReplyV(DBusMessage *msg,
+DBusMessage **reply,
 const char *types,
 va_list args)
 {
 int ret = -1;
 
-if (!(*reply = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN))) {
+if (!(*reply = dbus_message_new_method_return(msg))) {
 virReportOOMError();
 goto cleanup;
 }
@@ -1493,6 +1495,7 @@ int virDBusCreateReplyV(DBusMessage **reply,
 
 /**
  * virDBusCreateReply:
+ * @msg: the message to reply to
  * @reply: pointer to be filled with a method reply message
  * @types: type signature for following method arguments
  * @...: method arguments
@@ -1500,14 +1503,15 @@ int virDBusCreateReplyV(DBusMessage **reply,
  * See virDBusCreateReplyV for a description of the
  * behaviour of this method.
  */
-int virDBusCreateReply(DBusMessage **reply,
+int virDBusCreateReply(DBusMessage *msg,
+   DBusMessage **reply,
const char *types, ...)
 {
 va_list args;
 int ret;
 
 va_start(args, types);
-ret = virDBusCreateReplyV(reply, types, args);
+ret = virDBusCreateReplyV(msg, reply, types, args);
 va_end(args);
 
 return ret;
@@ -1811,7 +1815,8 @@ int virDBusCreateMethodV(DBusMessage **call 
ATTRIBUTE_UNUSED,
 return -1;
 }
 
-int virDBusCreateReplyV(DBusMessage **reply ATTRIBUTE_UNUSED,
+int virDBusCreateReplyV(DBusMessage *msg ATTRIBUTE_UNUSED,
+DBusMessage **reply ATTRIBUTE_UNUSED,
 const char *types ATTRIBUTE_UNUSED,
 va_list args ATTRIBUTE_UNUSED)
 {
@@ -1820,7 +1825,8 @@ int virDBusCreateReplyV(DBusMessage **reply 
ATTRIBUTE_UNUSED,
 return -1;
 }
 
-int virDBusCreateReply(DBusMessage **reply ATTRIBUTE_UNUSED,
+int virDBusCreateReply(DBusMessage *msg ATTRIBUTE_UNUSED,
+   DBusMessage **reply ATTRIBUTE_UNUSED,
const char *types ATTRIBUTE_UNUSED, ...)
 {
 virReportError(VIR_ERR_INTERNAL_ERROR,
diff --git a/src/util/virdbus.h b/src/util/virdbus.h
index 083c074d59..0303e91045 100644
--- a/src/util/virdbus.h
+++ b/src/util/virdbus.h
@@ -52,9 +52,11 @@ int virDBusCreateMethodV(DBusMessage **call,
  const char *member,
  const char *types,
  va_list args);
-int virDBusCreateReply(DBusMessage **reply,
+int virDBusCreateReply(DBusMessage *msg,
+   DBusMessage **reply,
const char *types, ...);
-int virDBusCreateReplyV(DBusMessage **reply,
+int virDBusCreateReplyV(DBusMessage *msg,
+DBusMessage **reply,
 const char *types,
 va_list args);
 
diff --git a/tests/virfirewalltest.c b/tests/virfirewalltest.c
index 7c586877d3..d2c85a27cc 100644
--- a/tests/virfirewalltest.c
+++ b/tests/virfirewalltest.c
@@ -150,7 +150,8 @@ 
VIR_MOCK_WRAP_RET_ARGS(dbus_connection_send_with_reply_and_block,
 if (nargs == 1 &&
 STREQ(type, "ipv4") &&
 STREQ(args[0], "-L")) {
-if (virDBusCreateReply(,
+if (virDBusCreateReply(message,
+   ,
"s", TEST_FILTER_TABLE_LIST) < 0)
 goto error;
 } else if (nargs == 3 &&
@@ -158,11 +159,13 @@ 
VIR_MOCK_WRAP_RET_ARGS(dbus_connection_send_with_reply_and_block,
STREQ(args[0], "-t") &&
STREQ(args[1], "nat") &&
STREQ(args[2], "-L")) {
-if (virDBusCreateReply(,
+if (virDBusCreateReply(message,
+   ,
"s", TEST_NAT_TABLE_LIST) < 0)
 goto error;
 } else {
-if (virDBusCreateReply(,
+if