src/util/virsystemd: convert to use GLib DBus

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Pavel Hrdina 2020-09-09 16:42:42 +02:00
parent 10cf523a8d
commit bf5f2ed09c
3 changed files with 254 additions and 292 deletions

View File

@ -26,7 +26,7 @@
#include "virsystemd.h" #include "virsystemd.h"
#include "virbuffer.h" #include "virbuffer.h"
#include "virdbus.h" #include "virgdbus.h"
#include "virstring.h" #include "virstring.h"
#include "viralloc.h" #include "viralloc.h"
#include "virutil.h" #include "virutil.h"
@ -157,13 +157,13 @@ virSystemdHasMachined(void)
if (val != -1) if (val != -1)
return val; return val;
if ((ret = virDBusIsServiceEnabled("org.freedesktop.machine1")) < 0) { if ((ret = virGDBusIsServiceEnabled("org.freedesktop.machine1")) < 0) {
if (ret == -2) if (ret == -2)
g_atomic_int_set(&virSystemdHasMachinedCachedValue, -2); g_atomic_int_set(&virSystemdHasMachinedCachedValue, -2);
return ret; return ret;
} }
if ((ret = virDBusIsServiceRegistered("org.freedesktop.systemd1")) == -1) if ((ret = virGDBusIsServiceRegistered("org.freedesktop.systemd1")) == -1)
return ret; return ret;
g_atomic_int_set(&virSystemdHasMachinedCachedValue, ret); g_atomic_int_set(&virSystemdHasMachinedCachedValue, ret);
return ret; return ret;
@ -179,14 +179,14 @@ virSystemdHasLogind(void)
if (val != -1) if (val != -1)
return val; return val;
ret = virDBusIsServiceEnabled("org.freedesktop.login1"); ret = virGDBusIsServiceEnabled("org.freedesktop.login1");
if (ret < 0) { if (ret < 0) {
if (ret == -2) if (ret == -2)
g_atomic_int_set(&virSystemdHasLogindCachedValue, -2); g_atomic_int_set(&virSystemdHasLogindCachedValue, -2);
return ret; return ret;
} }
if ((ret = virDBusIsServiceRegistered("org.freedesktop.login1")) == -1) if ((ret = virGDBusIsServiceRegistered("org.freedesktop.login1")) == -1)
return ret; return ret;
g_atomic_int_set(&virSystemdHasLogindCachedValue, ret); g_atomic_int_set(&virSystemdHasLogindCachedValue, ret);
@ -197,53 +197,59 @@ virSystemdHasLogind(void)
char * char *
virSystemdGetMachineNameByPID(pid_t pid) virSystemdGetMachineNameByPID(pid_t pid)
{ {
DBusConnection *conn; GDBusConnection *conn;
DBusMessage *reply = NULL; g_autoptr(GVariant) message = NULL;
char *name = NULL, *object = NULL; g_autoptr(GVariant) reply = NULL;
g_autoptr(GVariant) gvar = NULL;
g_autofree char *object = NULL;
char *name = NULL;
if (virSystemdHasMachined() < 0) if (virSystemdHasMachined() < 0)
goto cleanup; return NULL;
if (!(conn = virDBusGetSystemBus())) if (!(conn = virGDBusGetSystemBus()))
goto cleanup; return NULL;
if (virDBusCallMethod(conn, &reply, NULL, message = g_variant_new("(u)", pid);
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"GetMachineByPID",
"u", pid) < 0)
goto cleanup;
if (virDBusMessageDecode(reply, "o", &object) < 0) if (virGDBusCallMethod(conn,
goto cleanup; &reply,
NULL,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"GetMachineByPID",
message) < 0)
return NULL;
virDBusMessageUnref(reply); g_variant_get(reply, "(o)", &object);
g_variant_unref(reply);
reply = NULL; reply = NULL;
VIR_DEBUG("Domain with pid %lld has object path '%s'", VIR_DEBUG("Domain with pid %lld has object path '%s'",
(long long) pid, object); (long long) pid, object);
if (virDBusCallMethod(conn, &reply, NULL, g_variant_unref(message);
"org.freedesktop.machine1", message = g_variant_new("(ss)",
object, "org.freedesktop.machine1.Machine", "Name");
"org.freedesktop.DBus.Properties",
"Get",
"ss",
"org.freedesktop.machine1.Machine",
"Name") < 0)
goto cleanup;
if (virDBusMessageDecode(reply, "v", "s", &name) < 0) if (virGDBusCallMethod(conn,
goto cleanup; &reply,
NULL,
"org.freedesktop.machine1",
object,
"org.freedesktop.DBus.Properties",
"Get",
message) < 0)
return NULL;
g_variant_get(reply, "(v)", &gvar);
g_variant_get(gvar, "s", &name);
VIR_DEBUG("Domain with pid %lld has machine name '%s'", VIR_DEBUG("Domain with pid %lld has machine name '%s'",
(long long) pid, name); (long long) pid, name);
cleanup:
VIR_FREE(object);
virDBusMessageUnref(reply);
return name; return name;
} }
@ -274,26 +280,28 @@ int virSystemdCreateMachine(const char *name,
const char *partition, const char *partition,
unsigned int maxthreads) unsigned int maxthreads)
{ {
int ret; int rc;
DBusConnection *conn; GDBusConnection *conn;
char *creatorname = NULL; GVariant *guuid;
char *slicename = NULL; GVariant *gnicindexes;
char *scopename = NULL; GVariant *gprops;
GVariant *message;
g_autofree char *creatorname = NULL;
g_autofree char *slicename = NULL;
g_autofree char *scopename = NULL;
static int hasCreateWithNetwork = 1; static int hasCreateWithNetwork = 1;
if ((ret = virSystemdHasMachined()) < 0) if ((rc = virSystemdHasMachined()) < 0)
return ret; return rc;
if (!(conn = virDBusGetSystemBus())) if (!(conn = virGDBusGetSystemBus()))
return -1; return -1;
ret = -1;
creatorname = g_strdup_printf("libvirt-%s", drivername); creatorname = g_strdup_printf("libvirt-%s", drivername);
if (partition) { if (partition) {
if (!(slicename = virSystemdMakeSliceName(partition))) if (!(slicename = virSystemdMakeSliceName(partition)))
goto cleanup; return -1;
} else { } else {
slicename = g_strdup(""); slicename = g_strdup("");
} }
@ -352,122 +360,138 @@ int virSystemdCreateMachine(const char *name,
VIR_DEBUG("Attempting to create machine via systemd"); VIR_DEBUG("Attempting to create machine via systemd");
if (g_atomic_int_get(&hasCreateWithNetwork)) { if (g_atomic_int_get(&hasCreateWithNetwork)) {
virError error; g_autoptr(virError) error = NULL;
memset(&error, 0, sizeof(error));
if (virDBusCallMethod(conn, if (VIR_ALLOC(error) < 0)
NULL, return -1;
&error,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"CreateMachineWithNetwork",
"sayssusa&ia(sv)",
name,
16,
uuid[0], uuid[1], uuid[2], uuid[3],
uuid[4], uuid[5], uuid[6], uuid[7],
uuid[8], uuid[9], uuid[10], uuid[11],
uuid[12], uuid[13], uuid[14], uuid[15],
creatorname,
iscontainer ? "container" : "vm",
(unsigned int)pidleader,
NULLSTR_EMPTY(rootdir),
nnicindexes, nicindexes,
3,
"Slice", "s", slicename,
"After", "as", 1, "libvirtd.service",
"Before", "as", 1, "virt-guest-shutdown.target") < 0)
goto cleanup;
if (error.level == VIR_ERR_ERROR) { guuid = g_variant_new_fixed_array(G_VARIANT_TYPE("y"),
if (virDBusErrorIsUnknownMethod(&error)) { uuid, 16, sizeof(unsigned char));
gnicindexes = g_variant_new_fixed_array(G_VARIANT_TYPE("i"),
nicindexes, nnicindexes, sizeof(int));
gprops = g_variant_new_parsed("[('Slice', <%s>),"
" ('After', <['libvirtd.service']>),"
" ('Before', <['virt-guest-shutdown.target']>)]",
slicename);
message = g_variant_new("(s@ayssus@ai@a(sv))",
name,
guuid,
creatorname,
iscontainer ? "container" : "vm",
(unsigned int)pidleader,
NULLSTR_EMPTY(rootdir),
gnicindexes,
gprops);
rc = virGDBusCallMethod(conn,
NULL,
error,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"CreateMachineWithNetwork",
message);
g_variant_unref(message);
if (rc < 0)
return -1;
if (error->level == VIR_ERR_ERROR) {
if (virGDBusErrorIsUnknownMethod(error)) {
VIR_INFO("CreateMachineWithNetwork isn't supported, switching " VIR_INFO("CreateMachineWithNetwork isn't supported, switching "
"to legacy CreateMachine method for systemd-machined"); "to legacy CreateMachine method for systemd-machined");
virResetError(&error); virResetError(error);
g_atomic_int_set(&hasCreateWithNetwork, 0); g_atomic_int_set(&hasCreateWithNetwork, 0);
/* Could re-structure without Using goto, but this /* Could re-structure without Using goto, but this
* avoids another atomic read which would trigger * avoids another atomic read which would trigger
* another memory barrier */ * another memory barrier */
goto fallback; goto fallback;
} }
virReportErrorObject(&error); virReportErrorObject(error);
virResetError(&error); virResetError(error);
goto cleanup; return -1;
} }
} else { } else {
fallback: fallback:
if (virDBusCallMethod(conn, guuid = g_variant_new_fixed_array(G_VARIANT_TYPE("y"),
NULL, uuid, 16, sizeof(unsigned char));
NULL, gprops = g_variant_new_parsed("[('Slice', <%s>),"
"org.freedesktop.machine1", " ('After', <['libvirtd.service']>),"
"/org/freedesktop/machine1", " ('Before', <['virt-guest-shutdown.target']>)]",
"org.freedesktop.machine1.Manager", slicename);
"CreateMachine", message = g_variant_new("(s@ayssus@a(sv))",
"sayssusa(sv)", name,
name, guuid,
16, creatorname,
uuid[0], uuid[1], uuid[2], uuid[3], iscontainer ? "container" : "vm",
uuid[4], uuid[5], uuid[6], uuid[7], (unsigned int)pidleader,
uuid[8], uuid[9], uuid[10], uuid[11], NULLSTR_EMPTY(rootdir),
uuid[12], uuid[13], uuid[14], uuid[15], gprops);
creatorname,
iscontainer ? "container" : "vm", rc = virGDBusCallMethod(conn,
(unsigned int)pidleader, NULL,
NULLSTR_EMPTY(rootdir), NULL,
3, "org.freedesktop.machine1",
"Slice", "s", slicename, "/org/freedesktop/machine1",
"After", "as", 1, "libvirtd.service", "org.freedesktop.machine1.Manager",
"Before", "as", 1, "virt-guest-shutdown.target") < 0) "CreateMachine",
goto cleanup; message);
g_variant_unref(message);
if (rc < 0)
return -1;
} }
if (maxthreads > 0) { if (maxthreads > 0) {
if (!(scopename = virSystemdMakeScopeName(name, drivername, false))) if (!(scopename = virSystemdMakeScopeName(name, drivername, false)))
goto cleanup; return -1;
if (virDBusCallMethod(conn, gprops = g_variant_new_parsed("[('TasksMax', <%llu>)]",
NULL, (uint64_t)maxthreads);
NULL,
"org.freedesktop.systemd1", message = g_variant_new("(sb@a(sv))",
"/org/freedesktop/systemd1", scopename,
"org.freedesktop.systemd1.Manager", true,
"SetUnitProperties", gprops);
"sba(sv)",
scopename, rc = virGDBusCallMethod(conn,
true, NULL,
1, NULL,
"TasksMax", "t", (uint64_t)maxthreads) < 0) "org.freedesktop.systemd1",
goto cleanup; "/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"SetUnitProperties",
message);
g_variant_unref(message);
if (rc < 0)
return -1;
} }
ret = 0; return 0;
cleanup:
VIR_FREE(creatorname);
VIR_FREE(slicename);
VIR_FREE(scopename);
return ret;
} }
int virSystemdTerminateMachine(const char *name) int virSystemdTerminateMachine(const char *name)
{ {
int ret; int rc;
DBusConnection *conn; GDBusConnection *conn;
virError error; g_autoptr(GVariant) message = NULL;
g_autoptr(virError) error = NULL;
if (!name) if (!name)
return 0; return 0;
memset(&error, 0, sizeof(error)); if ((rc = virSystemdHasMachined()) < 0)
return rc;
if ((ret = virSystemdHasMachined()) < 0) if (!(conn = virGDBusGetSystemBus()))
goto cleanup; return -1;
ret = -1; if (VIR_ALLOC(error) < 0)
return -1;
if (!(conn = virDBusGetSystemBus()))
goto cleanup;
/* /*
* The systemd DBus API we're invoking has the * The systemd DBus API we're invoking has the
@ -479,31 +503,27 @@ int virSystemdTerminateMachine(const char *name)
* in 'ps' listing & similar * in 'ps' listing & similar
*/ */
VIR_DEBUG("Attempting to terminate machine via systemd"); message = g_variant_new("(s)", name);
if (virDBusCallMethod(conn,
NULL,
&error,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"TerminateMachine",
"s",
name) < 0)
goto cleanup;
if (error.level == VIR_ERR_ERROR && VIR_DEBUG("Attempting to terminate machine via systemd");
if (virGDBusCallMethod(conn,
NULL,
error,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"TerminateMachine",
message) < 0)
return -1;
if (error->level == VIR_ERR_ERROR &&
STRNEQ_NULLABLE("org.freedesktop.machine1.NoSuchMachine", STRNEQ_NULLABLE("org.freedesktop.machine1.NoSuchMachine",
error.str1)) { error->str1)) {
virReportErrorObject(&error); virReportErrorObject(error);
goto cleanup; return -1;
} }
ret = 0; return 0;
cleanup:
virResetError(&error);
return ret;
} }
void void
@ -559,41 +579,32 @@ virSystemdNotifyStartup(void)
static int static int
virSystemdPMSupportTarget(const char *methodName, bool *result) virSystemdPMSupportTarget(const char *methodName, bool *result)
{ {
int ret; int rc;
DBusConnection *conn; GDBusConnection *conn;
DBusMessage *message = NULL; g_autoptr(GVariant) reply = NULL;
char *response; char *response;
if ((ret = virSystemdHasLogind()) < 0) if ((rc = virSystemdHasLogind()) < 0)
return ret; return rc;
if (!(conn = virDBusGetSystemBus())) if (!(conn = virGDBusGetSystemBus()))
return -1; return -1;
ret = -1; if (virGDBusCallMethod(conn,
&reply,
NULL,
"org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
methodName,
NULL) < 0)
return -1;
if (virDBusCallMethod(conn, g_variant_get(reply, "(&s)", &response);
&message,
NULL,
"org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
methodName,
NULL) < 0)
return ret;
if ((ret = virDBusMessageDecode(message, "s", &response)) < 0)
goto cleanup;
*result = STREQ("yes", response) || STREQ("challenge", response); *result = STREQ("yes", response) || STREQ("challenge", response);
ret = 0; return 0;
cleanup:
virDBusMessageUnref(message);
VIR_FREE(response);
return ret;
} }
int virSystemdCanSuspend(bool *result) int virSystemdCanSuspend(bool *result)

View File

@ -332,6 +332,7 @@ tests += [
{ 'name': 'virschematest' }, { 'name': 'virschematest' },
{ 'name': 'virshtest' }, { 'name': 'virshtest' },
{ 'name': 'virstringtest' }, { 'name': 'virstringtest' },
{ 'name': 'virsystemdtest' },
{ 'name': 'virtimetest' }, { 'name': 'virtimetest' },
{ 'name': 'virtypedparamtest' }, { 'name': 'virtypedparamtest' },
{ 'name': 'viruritest' }, { 'name': 'viruritest' },
@ -362,7 +363,6 @@ endif
if conf.has('WITH_DBUS') if conf.has('WITH_DBUS')
tests += [ tests += [
{ 'name': 'virdbustest', 'deps': [ dbus_dep ] }, { 'name': 'virdbustest', 'deps': [ dbus_dep ] },
{ 'name': 'virsystemdtest', 'deps': [ dbus_dep ] },
] ]
endif endif

View File

@ -20,9 +20,8 @@
#include "testutils.h" #include "testutils.h"
#if defined(WITH_DBUS) && defined(__linux__) #if defined(__linux__)
# include <dbus/dbus.h>
# include <fcntl.h> # include <fcntl.h>
# include <unistd.h> # include <unistd.h>
@ -30,7 +29,7 @@
# include "virsystemdpriv.h" # include "virsystemdpriv.h"
# include "virsystemd.h" # include "virsystemd.h"
# include "virdbus.h" # include "virgdbus.h"
# include "virlog.h" # include "virlog.h"
# include "virmock.h" # include "virmock.h"
# include "rpc/virnetsocket.h" # include "rpc/virnetsocket.h"
@ -39,125 +38,77 @@
VIR_LOG_INIT("tests.systemdtest"); VIR_LOG_INIT("tests.systemdtest");
VIR_MOCK_WRAP_RET_ARGS(dbus_connection_send_with_reply_and_block, VIR_MOCK_WRAP_RET_ARGS(g_dbus_connection_call_sync,
DBusMessage *, GVariant *,
DBusConnection *, connection, GDBusConnection *, connection,
DBusMessage *, message, const gchar *, bus_name,
int, timeout_milliseconds, const gchar *, object_path,
DBusError *, error) const gchar *, interface_name,
const gchar *, method_name,
GVariant *, parameters,
const GVariantType *, reply_type,
GDBusCallFlags, flags,
gint, timeout_msec,
GCancellable *, cancellable,
GError **, error)
{ {
DBusMessage *reply = NULL; GVariant *reply = NULL;
const char *service = dbus_message_get_destination(message);
const char *member = dbus_message_get_member(message);
VIR_MOCK_REAL_INIT(dbus_connection_send_with_reply_and_block); if (parameters)
g_variant_unref(parameters);
if (STREQ(service, "org.freedesktop.machine1")) { VIR_MOCK_REAL_INIT(g_dbus_connection_call_sync);
if (STREQ(bus_name, "org.freedesktop.machine1")) {
if (getenv("FAIL_BAD_SERVICE")) { if (getenv("FAIL_BAD_SERVICE")) {
dbus_set_error_const(error, *error = g_dbus_error_new_for_dbus_error(
"org.freedesktop.systemd.badthing", "org.freedesktop.systemd.badthing",
"Something went wrong creating the machine"); "Something went wrong creating the machine");
} else { } else {
reply = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN); if (STREQ(method_name, "GetMachineByPID")) {
reply = g_variant_new("(o)",
if (STREQ(member, "GetMachineByPID")) { "/org/freedesktop/machine1/machine/qemu_2ddemo");
const char *object_path = "/org/freedesktop/machine1/machine/qemu_2ddemo"; } else if (STREQ(method_name, "Get")) {
DBusMessageIter iter; reply = g_variant_new("(v)", g_variant_new_string("qemu-demo"));
} else {
dbus_message_iter_init_append(reply, &iter); reply = g_variant_new("()");
if (!dbus_message_iter_append_basic(&iter,
DBUS_TYPE_OBJECT_PATH,
&object_path))
goto error;
} else if (STREQ(member, "Get")) {
const char *name = "qemu-demo";
DBusMessageIter iter;
DBusMessageIter sub;
dbus_message_iter_init_append(reply, &iter);
dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
"s", &sub);
if (!dbus_message_iter_append_basic(&sub,
DBUS_TYPE_STRING,
&name))
goto error;
dbus_message_iter_close_container(&iter, &sub);
} }
} }
} else if (STREQ(service, "org.freedesktop.login1")) { } else if (STREQ(bus_name, "org.freedesktop.login1")) {
char *supported = getenv("RESULT_SUPPORT"); reply = g_variant_new("(s)", getenv("RESULT_SUPPORT"));
DBusMessageIter iter; } else if (STREQ(bus_name, "org.freedesktop.DBus") &&
reply = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN); STREQ(method_name, "ListActivatableNames")) {
dbus_message_iter_init_append(reply, &iter); GVariantBuilder builder;
if (!dbus_message_iter_append_basic(&iter, g_variant_builder_init(&builder, G_VARIANT_TYPE("as"));
DBUS_TYPE_STRING,
&supported))
goto error;
} else if (STREQ(service, "org.freedesktop.DBus") &&
STREQ(member, "ListActivatableNames")) {
const char *svc1 = "org.foo.bar.wizz";
const char *svc2 = "org.freedesktop.machine1";
const char *svc3 = "org.freedesktop.login1";
DBusMessageIter iter;
DBusMessageIter sub;
reply = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN);
dbus_message_iter_init_append(reply, &iter);
dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
"s", &sub);
if (!dbus_message_iter_append_basic(&sub, g_variant_builder_add(&builder, "s", "org.foo.bar.wizz");
DBUS_TYPE_STRING,
&svc1))
goto error;
if (!getenv("FAIL_NO_SERVICE") &&
!dbus_message_iter_append_basic(&sub,
DBUS_TYPE_STRING,
&svc2))
goto error;
if (!getenv("FAIL_NO_SERVICE") &&
!dbus_message_iter_append_basic(&sub,
DBUS_TYPE_STRING,
&svc3))
goto error;
dbus_message_iter_close_container(&iter, &sub);
} else if (STREQ(service, "org.freedesktop.DBus") &&
STREQ(member, "ListNames")) {
const char *svc1 = "org.foo.bar.wizz";
const char *svc2 = "org.freedesktop.systemd1";
const char *svc3 = "org.freedesktop.login1";
DBusMessageIter iter;
DBusMessageIter sub;
reply = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN);
dbus_message_iter_init_append(reply, &iter);
dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
"s", &sub);
if (!dbus_message_iter_append_basic(&sub, if (!getenv("FAIL_NO_SERVICE")) {
DBUS_TYPE_STRING, g_variant_builder_add(&builder, "s", "org.freedesktop.machine1");
&svc1)) g_variant_builder_add(&builder, "s", "org.freedesktop.login1");
goto error; }
if ((!getenv("FAIL_NO_SERVICE") && !getenv("FAIL_NOT_REGISTERED")) &&
!dbus_message_iter_append_basic(&sub, reply = g_variant_new("(@as)", g_variant_builder_end(&builder));
DBUS_TYPE_STRING, } else if (STREQ(bus_name, "org.freedesktop.DBus") &&
&svc2)) STREQ(method_name, "ListNames")) {
goto error; GVariantBuilder builder;
if ((!getenv("FAIL_NO_SERVICE") && !getenv("FAIL_NOT_REGISTERED")) &&
!dbus_message_iter_append_basic(&sub, g_variant_builder_init(&builder, G_VARIANT_TYPE("as"));
DBUS_TYPE_STRING,
&svc3)) g_variant_builder_add(&builder, "s", "org.foo.bar.wizz");
goto error;
dbus_message_iter_close_container(&iter, &sub); if (!getenv("FAIL_NO_SERVICE") && !getenv("FAIL_NOT_REGISTERED")) {
g_variant_builder_add(&builder, "s", "org.freedesktop.systemd1");
g_variant_builder_add(&builder, "s", "org.freedesktop.login1");
}
reply = g_variant_new("(@as)", g_variant_builder_end(&builder));
} else { } else {
reply = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN); reply = g_variant_new("()");
} }
return reply; return reply;
error:
virDBusMessageUnref(reply);
return NULL;
} }
@ -794,12 +745,12 @@ mymain(void)
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
} }
VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("virdbus")) VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("virgdbus"))
#else /* ! (WITH_DBUS && __linux__) */ #else /* ! __linux__ */
int int
main(void) main(void)
{ {
return EXIT_AM_SKIP; return EXIT_AM_SKIP;
} }
#endif /* ! WITH_DBUS */ #endif /* ! __linux__ */