|
|
43fe83 |
From 47e18ab1d1b8a343e7d29f1f3884a040a18147c6 Mon Sep 17 00:00:00 2001
|
|
|
43fe83 |
Message-Id: <47e18ab1d1b8a343e7d29f1f3884a040a18147c6.1381871412.git.jdenemar@redhat.com>
|
|
|
43fe83 |
From: "Daniel P. Berrange" <berrange@redhat.com>
|
|
|
43fe83 |
Date: Mon, 14 Oct 2013 16:45:14 +0100
|
|
|
43fe83 |
Subject: [PATCH] Change way we fake dbus method calls
|
|
|
43fe83 |
|
|
|
43fe83 |
For
|
|
|
43fe83 |
|
|
|
43fe83 |
https://bugzilla.redhat.com/show_bug.cgi?id=1018730
|
|
|
43fe83 |
|
|
|
43fe83 |
Ubuntu libdbus.so links with -Bsymbolic-functions, which means
|
|
|
43fe83 |
that we can only LD_PRELOAD functions that we directly call.
|
|
|
43fe83 |
Functions which libdbus.so calls internally can not be replaced.
|
|
|
43fe83 |
Thus we cannot use dbus_message_new_error or dbus_message_new_method_return
|
|
|
43fe83 |
|
|
|
43fe83 |
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
|
|
|
43fe83 |
(cherry picked from commit dbd2bc8c8bdd927f3e9132afc8579dbaa1de91de)
|
|
|
43fe83 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
43fe83 |
---
|
|
|
43fe83 |
tests/virsystemdmock.c | 26 ++++++++++++++++++--------
|
|
|
43fe83 |
1 file changed, 18 insertions(+), 8 deletions(-)
|
|
|
43fe83 |
|
|
|
43fe83 |
diff --git a/tests/virsystemdmock.c b/tests/virsystemdmock.c
|
|
|
43fe83 |
index ded52d2..5dbd33f 100644
|
|
|
43fe83 |
--- a/tests/virsystemdmock.c
|
|
|
43fe83 |
+++ b/tests/virsystemdmock.c
|
|
|
43fe83 |
@@ -65,22 +65,32 @@ dbus_bool_t dbus_message_set_reply_serial(DBusMessage *message ATTRIBUTE_UNUSED,
|
|
|
43fe83 |
}
|
|
|
43fe83 |
|
|
|
43fe83 |
DBusMessage *dbus_connection_send_with_reply_and_block(DBusConnection *connection ATTRIBUTE_UNUSED,
|
|
|
43fe83 |
- DBusMessage *message,
|
|
|
43fe83 |
+ DBusMessage *message ATTRIBUTE_UNUSED,
|
|
|
43fe83 |
int timeout_milliseconds ATTRIBUTE_UNUSED,
|
|
|
43fe83 |
DBusError *error)
|
|
|
43fe83 |
{
|
|
|
43fe83 |
DBusMessage *reply = NULL;
|
|
|
43fe83 |
|
|
|
43fe83 |
- if (getenv("FAIL_BAD_SERVICE"))
|
|
|
43fe83 |
- reply = dbus_message_new_error(message,
|
|
|
43fe83 |
- "org.freedesktop.systemd.badthing",
|
|
|
43fe83 |
- "Something went wrong creating the machine");
|
|
|
43fe83 |
- else if (getenv("FAIL_NO_SERVICE"))
|
|
|
43fe83 |
+ if (getenv("FAIL_BAD_SERVICE")) {
|
|
|
43fe83 |
+ DBusMessageIter iter;
|
|
|
43fe83 |
+ const char *error_message = "Something went wrong creating the machine";
|
|
|
43fe83 |
+ if (!(reply = dbus_message_new(DBUS_MESSAGE_TYPE_ERROR)))
|
|
|
43fe83 |
+ return NULL;
|
|
|
43fe83 |
+ dbus_message_set_error_name(reply, "org.freedesktop.systemd.badthing");
|
|
|
43fe83 |
+ dbus_message_iter_init_append(reply, &iter);
|
|
|
43fe83 |
+ if (!dbus_message_iter_append_basic(&iter,
|
|
|
43fe83 |
+ DBUS_TYPE_STRING,
|
|
|
43fe83 |
+ &error_message)) {
|
|
|
43fe83 |
+ dbus_message_unref(reply);
|
|
|
43fe83 |
+ return NULL;
|
|
|
43fe83 |
+ }
|
|
|
43fe83 |
+ } else if (getenv("FAIL_NO_SERVICE")) {
|
|
|
43fe83 |
dbus_set_error(error,
|
|
|
43fe83 |
"org.freedesktop.DBus.Error.ServiceUnknown",
|
|
|
43fe83 |
"%s", "The name org.freedesktop.machine1 was not provided by any .service files");
|
|
|
43fe83 |
- else
|
|
|
43fe83 |
- reply = dbus_message_new_method_return(message);
|
|
|
43fe83 |
+ } else {
|
|
|
43fe83 |
+ reply = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN);
|
|
|
43fe83 |
+ }
|
|
|
43fe83 |
|
|
|
43fe83 |
return reply;
|
|
|
43fe83 |
}
|
|
|
43fe83 |
--
|
|
|
43fe83 |
1.8.3.2
|
|
|
43fe83 |
|