2 * Helpers for using D-Bus
4 * Copyright (C) 2019 Red Hat, Inc.
6 * This work is licensed under the terms of the GNU GPL, version 2. See
7 * the COPYING file in the top-level directory.
10 #include "qemu/osdep.h"
11 #include "qemu/dbus.h"
12 #include "qemu/error-report.h"
13 #include "qapi/error.h"
16 * qemu_dbus_get_queued_owners() - return the list of queued unique names
17 * @connection: A GDBusConnection
18 * @name: a service name
20 * Return: a GStrv of unique names, or NULL on failure.
23 qemu_dbus_get_queued_owners(GDBusConnection
*connection
, const char *name
,
26 g_autoptr(GDBusProxy
) proxy
= NULL
;
27 g_autoptr(GVariant
) result
= NULL
;
28 g_autoptr(GVariant
) child
= NULL
;
29 g_autoptr(GError
) err
= NULL
;
31 proxy
= g_dbus_proxy_new_sync(connection
, G_DBUS_PROXY_FLAGS_NONE
, NULL
,
32 "org.freedesktop.DBus",
33 "/org/freedesktop/DBus",
34 "org.freedesktop.DBus",
37 error_setg(errp
, "Failed to create DBus proxy: %s", err
->message
);
41 result
= g_dbus_proxy_call_sync(proxy
, "ListQueuedOwners",
42 g_variant_new("(s)", name
),
43 G_DBUS_CALL_FLAGS_NO_AUTO_START
,
46 if (g_error_matches(err
,
48 G_DBUS_ERROR_NAME_HAS_NO_OWNER
)) {
49 return g_new0(char *, 1);
51 error_setg(errp
, "Failed to call ListQueuedOwners: %s", err
->message
);
55 child
= g_variant_get_child_value(result
, 0);
56 return g_variant_dup_strv(child
, NULL
);