mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 07:17:44 +00:00
Split out most of virDBusIsServiceEnabled
Introduce virDBusIsServiceInList which can be used to call other methods for listing services (ListNames), not just ListActivatableNames. No functional change, fixed the 'Retruns' typo.
This commit is contained in:
parent
d7e0f1133e
commit
65a4cb03c7
@ -1256,13 +1256,7 @@ int virDBusMessageRead(DBusMessage *msg,
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* virDBusIsServiceEnabled:
|
||||
* @name: service name
|
||||
*
|
||||
* Retruns 0 if service is available, -1 on fatal error, or -2 if service is not available
|
||||
*/
|
||||
int virDBusIsServiceEnabled(const char *name)
|
||||
static int virDBusIsServiceInList(const char *listMethod, const char *name)
|
||||
{
|
||||
DBusConnection *conn;
|
||||
DBusMessage *reply = NULL;
|
||||
@ -1280,7 +1274,7 @@ int virDBusIsServiceEnabled(const char *name)
|
||||
"org.freedesktop.DBus",
|
||||
"/org/freedesktop/DBus",
|
||||
"org.freedesktop.DBus",
|
||||
"ListActivatableNames",
|
||||
listMethod,
|
||||
NULL) < 0)
|
||||
return ret;
|
||||
|
||||
@ -1305,13 +1299,25 @@ int virDBusIsServiceEnabled(const char *name)
|
||||
}
|
||||
}
|
||||
|
||||
VIR_DEBUG("Service %s is %s", name, ret ? "unavailable" : "available");
|
||||
|
||||
cleanup:
|
||||
dbus_message_unref(reply);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* virDBusIsServiceEnabled:
|
||||
* @name: service name
|
||||
*
|
||||
* Returns 0 if service is available, -1 on fatal error, or -2 if service is not available
|
||||
*/
|
||||
int virDBusIsServiceEnabled(const char *name)
|
||||
{
|
||||
int ret = virDBusIsServiceInList("ListActivatableNames", name);
|
||||
|
||||
VIR_DEBUG("Service %s is %s", name, ret ? "unavailable" : "available");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#else /* ! WITH_DBUS */
|
||||
void virDBusSetSharedBus(bool shared ATTRIBUTE_UNUSED)
|
||||
|
Loading…
Reference in New Issue
Block a user