mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-20 11:48:28 -06:00
Change way we fake dbus method calls
Ubuntu libdbus.so links with -Bsymbolic-functions, which means that we can only LD_PRELOAD functions that we directly call. Functions which libdbus.so calls internally can not be replaced. Thus we cannot use dbus_message_new_error or dbus_message_new_method_return Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
dd3688e4d1
commit
dbd2bc8c8b
@ -65,22 +65,32 @@ dbus_bool_t dbus_message_set_reply_serial(DBusMessage *message ATTRIBUTE_UNUSED,
|
|||||||
}
|
}
|
||||||
|
|
||||||
DBusMessage *dbus_connection_send_with_reply_and_block(DBusConnection *connection ATTRIBUTE_UNUSED,
|
DBusMessage *dbus_connection_send_with_reply_and_block(DBusConnection *connection ATTRIBUTE_UNUSED,
|
||||||
DBusMessage *message,
|
DBusMessage *message ATTRIBUTE_UNUSED,
|
||||||
int timeout_milliseconds ATTRIBUTE_UNUSED,
|
int timeout_milliseconds ATTRIBUTE_UNUSED,
|
||||||
DBusError *error)
|
DBusError *error)
|
||||||
{
|
{
|
||||||
DBusMessage *reply = NULL;
|
DBusMessage *reply = NULL;
|
||||||
|
|
||||||
if (getenv("FAIL_BAD_SERVICE"))
|
if (getenv("FAIL_BAD_SERVICE")) {
|
||||||
reply = dbus_message_new_error(message,
|
DBusMessageIter iter;
|
||||||
"org.freedesktop.systemd.badthing",
|
const char *error_message = "Something went wrong creating the machine";
|
||||||
"Something went wrong creating the machine");
|
if (!(reply = dbus_message_new(DBUS_MESSAGE_TYPE_ERROR)))
|
||||||
else if (getenv("FAIL_NO_SERVICE"))
|
return NULL;
|
||||||
|
dbus_message_set_error_name(reply, "org.freedesktop.systemd.badthing");
|
||||||
|
dbus_message_iter_init_append(reply, &iter);
|
||||||
|
if (!dbus_message_iter_append_basic(&iter,
|
||||||
|
DBUS_TYPE_STRING,
|
||||||
|
&error_message)) {
|
||||||
|
dbus_message_unref(reply);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
} else if (getenv("FAIL_NO_SERVICE")) {
|
||||||
dbus_set_error(error,
|
dbus_set_error(error,
|
||||||
"org.freedesktop.DBus.Error.ServiceUnknown",
|
"org.freedesktop.DBus.Error.ServiceUnknown",
|
||||||
"%s", "The name org.freedesktop.machine1 was not provided by any .service files");
|
"%s", "The name org.freedesktop.machine1 was not provided by any .service files");
|
||||||
else
|
} else {
|
||||||
reply = dbus_message_new_method_return(message);
|
reply = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN);
|
||||||
|
}
|
||||||
|
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user