Turn some dual-state int parameters into booleans

The virStateInitialize method and several cgroups methods were
using an 'int privileged' parameter or similar for dual-state
values. These are better represented with the bool type.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange 2012-10-31 19:03:54 +00:00
parent d442ee23bd
commit f4ea67f5b3
20 changed files with 47 additions and 45 deletions

View File

@ -1500,7 +1500,7 @@ struct _virStorageDriver {
}; };
# ifdef WITH_LIBVIRTD # ifdef WITH_LIBVIRTD
typedef int (*virDrvStateInitialize) (int privileged); typedef int (*virDrvStateInitialize) (bool privileged);
typedef int (*virDrvStateCleanup) (void); typedef int (*virDrvStateCleanup) (void);
typedef int (*virDrvStateReload) (void); typedef int (*virDrvStateReload) (void);
typedef int (*virDrvStateActive) (void); typedef int (*virDrvStateActive) (void);

View File

@ -789,13 +789,13 @@ virRegisterStateDriver(virStateDriverPtr driver)
/** /**
* virStateInitialize: * virStateInitialize:
* @privileged: set to 1 if running with root privilege, 0 otherwise * @privileged: set to true if running with root privilege, false otherwise
* *
* Initialize all virtualization drivers. * Initialize all virtualization drivers.
* *
* Returns 0 if all succeed, -1 upon any failure. * Returns 0 if all succeed, -1 upon any failure.
*/ */
int virStateInitialize(int privileged) { int virStateInitialize(bool privileged) {
int i; int i;
if (virInitialize() < 0) if (virInitialize() < 0)

View File

@ -28,7 +28,7 @@
# include "internal.h" # include "internal.h"
# ifdef WITH_LIBVIRTD # ifdef WITH_LIBVIRTD
int virStateInitialize(int privileged); int virStateInitialize(bool privileged);
int virStateCleanup(void); int virStateCleanup(void);
int virStateReload(void); int virStateReload(void);
int virStateActive(void); int virStateActive(void);

View File

@ -834,7 +834,7 @@ libxlShutdown(void)
} }
static int static int
libxlStartup(int privileged) { libxlStartup(bool privileged) {
const libxl_version_info *ver_info; const libxl_version_info *ver_info;
char *log_file = NULL; char *log_file = NULL;
virCommandPtr cmd; virCommandPtr cmd;

View File

@ -69,7 +69,7 @@
#define LXC_NB_MEM_PARAM 3 #define LXC_NB_MEM_PARAM 3
static int lxcStartup(int privileged); static int lxcStartup(bool privileged);
static int lxcShutdown(void); static int lxcShutdown(void);
virLXCDriverPtr lxc_driver = NULL; virLXCDriverPtr lxc_driver = NULL;
@ -1397,7 +1397,7 @@ error:
} }
static int lxcStartup(int privileged) static int lxcStartup(bool privileged)
{ {
char *ld; char *ld;
int rc; int rc;

View File

@ -330,7 +330,7 @@ firewalld_dbus_filter_bridge(DBusConnection *connection ATTRIBUTE_UNUSED,
* Initialization function for the QEmu daemon * Initialization function for the QEmu daemon
*/ */
static int static int
networkStartup(int privileged) { networkStartup(bool privileged) {
char *base = NULL; char *base = NULL;
#ifdef HAVE_FIREWALLD #ifdef HAVE_FIREWALLD
DBusConnection *sysbus = NULL; DBusConnection *sysbus = NULL;

View File

@ -588,7 +588,7 @@ static void device_prop_modified(LibHalContext *ctx ATTRIBUTE_UNUSED,
static int halDeviceMonitorStartup(int privileged ATTRIBUTE_UNUSED) static int halDeviceMonitorStartup(bool privileged ATTRIBUTE_UNUSED)
{ {
LibHalContext *hal_ctx = NULL; LibHalContext *hal_ctx = NULL;
char **udi = NULL; char **udi = NULL;

View File

@ -1604,7 +1604,7 @@ out:
return ret; return ret;
} }
static int udevDeviceMonitorStartup(int privileged ATTRIBUTE_UNUSED) static int udevDeviceMonitorStartup(bool privileged ATTRIBUTE_UNUSED)
{ {
udevPrivate *priv = NULL; udevPrivate *priv = NULL;
struct udev *udev = NULL; struct udev *udev = NULL;

View File

@ -165,7 +165,7 @@ nwfilterDriverInstallDBusMatches(DBusConnection *sysbus ATTRIBUTE_UNUSED)
* Initialization function for the QEmu daemon * Initialization function for the QEmu daemon
*/ */
static int static int
nwfilterDriverStartup(int privileged) nwfilterDriverStartup(bool privileged)
{ {
char *base = NULL; char *base = NULL;
DBusConnection *sysbus = NULL; DBusConnection *sysbus = NULL;

View File

@ -121,7 +121,7 @@ parallelsStorageOpen(virConnectPtr conn,
{ {
char *base = NULL; char *base = NULL;
virStorageDriverStatePtr storageState; virStorageDriverStatePtr storageState;
int privileged = (geteuid() == 0); bool privileged = (geteuid() == 0);
parallelsConnPtr privconn = conn->privateData; parallelsConnPtr privconn = conn->privateData;
size_t i; size_t i;

View File

@ -59,7 +59,7 @@ struct _virQEMUDriver {
virThreadPoolPtr workerPool; virThreadPoolPtr workerPool;
int privileged; bool privileged;
const char *uri; const char *uri;
uid_t user; uid_t user;

View File

@ -610,7 +610,7 @@ qemuDomainFindMaxID(void *payload,
* Initialization function for the QEmu daemon * Initialization function for the QEmu daemon
*/ */
static int static int
qemuStartup(int privileged) { qemuStartup(bool privileged) {
char *base = NULL; char *base = NULL;
char *driverConf = NULL; char *driverConf = NULL;
int rc; int rc;

View File

@ -68,7 +68,7 @@
# define HYPER_TO_ULONG(_to, _from) (_to) = (_from) # define HYPER_TO_ULONG(_to, _from) (_to) = (_from)
#endif #endif
static int inside_daemon = 0; static bool inside_daemon = false;
static virDriverPtr remoteDriver = NULL; static virDriverPtr remoteDriver = NULL;
struct private_data { struct private_data {
@ -150,12 +150,12 @@ static char *get_transport_from_scheme(char *scheme);
#ifdef WITH_LIBVIRTD #ifdef WITH_LIBVIRTD
static int static int
remoteStartup(int privileged ATTRIBUTE_UNUSED) remoteStartup(bool privileged ATTRIBUTE_UNUSED)
{ {
/* Mark that we're inside the daemon so we can avoid /* Mark that we're inside the daemon so we can avoid
* re-entering ourselves * re-entering ourselves
*/ */
inside_daemon = 1; inside_daemon = true;
return 0; return 0;
} }
#endif #endif

View File

@ -1073,7 +1073,7 @@ secretDriverCleanup(void)
} }
static int static int
secretDriverStartup(int privileged) secretDriverStartup(bool privileged)
{ {
char *base = NULL; char *base = NULL;

View File

@ -128,7 +128,7 @@ storageDriverAutostart(virStorageDriverStatePtr driver) {
* Initialization function for the QEmu daemon * Initialization function for the QEmu daemon
*/ */
static int static int
storageDriverStartup(int privileged) storageDriverStartup(bool privileged)
{ {
char *base = NULL; char *base = NULL;

View File

@ -44,7 +44,7 @@
struct uml_driver { struct uml_driver {
virMutex lock; virMutex lock;
int privileged; bool privileged;
unsigned long umlVersion; unsigned long umlVersion;
int nextvmid; int nextvmid;

View File

@ -419,7 +419,7 @@ cleanup:
* Initialization function for the Uml daemon * Initialization function for the Uml daemon
*/ */
static int static int
umlStartup(int privileged) umlStartup(bool privileged)
{ {
char *base = NULL; char *base = NULL;
char *userdir = NULL; char *userdir = NULL;

View File

@ -526,8 +526,10 @@ static int virCgroupSetMemoryUseHierarchy(virCgroupPtr group)
return rc; return rc;
} }
static int virCgroupMakeGroup(virCgroupPtr parent, virCgroupPtr group, static int virCgroupMakeGroup(virCgroupPtr parent,
int create, unsigned int flags) virCgroupPtr group,
bool create,
unsigned int flags)
{ {
int i; int i;
int rc = 0; int rc = 0;
@ -641,9 +643,9 @@ err:
return rc; return rc;
} }
static int virCgroupAppRoot(int privileged, static int virCgroupAppRoot(bool privileged,
virCgroupPtr *group, virCgroupPtr *group,
int create) bool create)
{ {
virCgroupPtr rootgrp = NULL; virCgroupPtr rootgrp = NULL;
int rc; int rc;
@ -924,8 +926,8 @@ cleanup:
#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R #if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
int virCgroupForDriver(const char *name, int virCgroupForDriver(const char *name,
virCgroupPtr *group, virCgroupPtr *group,
int privileged, bool privileged,
int create) bool create)
{ {
int rc; int rc;
char *path = NULL; char *path = NULL;
@ -957,8 +959,8 @@ out:
#else #else
int virCgroupForDriver(const char *name ATTRIBUTE_UNUSED, int virCgroupForDriver(const char *name ATTRIBUTE_UNUSED,
virCgroupPtr *group ATTRIBUTE_UNUSED, virCgroupPtr *group ATTRIBUTE_UNUSED,
int privileged ATTRIBUTE_UNUSED, bool privileged ATTRIBUTE_UNUSED,
int create ATTRIBUTE_UNUSED) bool create ATTRIBUTE_UNUSED)
{ {
/* Claim no support */ /* Claim no support */
return -ENXIO; return -ENXIO;
@ -994,7 +996,7 @@ int virCgroupGetAppRoot(virCgroupPtr *group)
int virCgroupForDomain(virCgroupPtr driver, int virCgroupForDomain(virCgroupPtr driver,
const char *name, const char *name,
virCgroupPtr *group, virCgroupPtr *group,
int create) bool create)
{ {
int rc; int rc;
char *path; char *path;
@ -1030,7 +1032,7 @@ int virCgroupForDomain(virCgroupPtr driver,
int virCgroupForDomain(virCgroupPtr driver ATTRIBUTE_UNUSED, int virCgroupForDomain(virCgroupPtr driver ATTRIBUTE_UNUSED,
const char *name ATTRIBUTE_UNUSED, const char *name ATTRIBUTE_UNUSED,
virCgroupPtr *group ATTRIBUTE_UNUSED, virCgroupPtr *group ATTRIBUTE_UNUSED,
int create ATTRIBUTE_UNUSED) bool create ATTRIBUTE_UNUSED)
{ {
return -ENXIO; return -ENXIO;
} }
@ -1049,7 +1051,7 @@ int virCgroupForDomain(virCgroupPtr driver ATTRIBUTE_UNUSED,
int virCgroupForVcpu(virCgroupPtr driver, int virCgroupForVcpu(virCgroupPtr driver,
int vcpuid, int vcpuid,
virCgroupPtr *group, virCgroupPtr *group,
int create) bool create)
{ {
int rc; int rc;
char *path; char *path;
@ -1075,7 +1077,7 @@ int virCgroupForVcpu(virCgroupPtr driver,
int virCgroupForVcpu(virCgroupPtr driver ATTRIBUTE_UNUSED, int virCgroupForVcpu(virCgroupPtr driver ATTRIBUTE_UNUSED,
int vcpuid ATTRIBUTE_UNUSED, int vcpuid ATTRIBUTE_UNUSED,
virCgroupPtr *group ATTRIBUTE_UNUSED, virCgroupPtr *group ATTRIBUTE_UNUSED,
int create ATTRIBUTE_UNUSED) bool create ATTRIBUTE_UNUSED)
{ {
return -ENXIO; return -ENXIO;
} }
@ -1091,8 +1093,8 @@ int virCgroupForVcpu(virCgroupPtr driver ATTRIBUTE_UNUSED,
*/ */
#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R #if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
int virCgroupForEmulator(virCgroupPtr driver, int virCgroupForEmulator(virCgroupPtr driver,
virCgroupPtr *group, virCgroupPtr *group,
int create) bool create)
{ {
int rc; int rc;
char *path; char *path;
@ -1116,8 +1118,8 @@ int virCgroupForEmulator(virCgroupPtr driver,
} }
#else #else
int virCgroupForEmulator(virCgroupPtr driver ATTRIBUTE_UNUSED, int virCgroupForEmulator(virCgroupPtr driver ATTRIBUTE_UNUSED,
virCgroupPtr *group ATTRIBUTE_UNUSED, virCgroupPtr *group ATTRIBUTE_UNUSED,
int create ATTRIBUTE_UNUSED) bool create ATTRIBUTE_UNUSED)
{ {
return -ENXIO; return -ENXIO;
} }

View File

@ -44,24 +44,24 @@ VIR_ENUM_DECL(virCgroupController);
int virCgroupForDriver(const char *name, int virCgroupForDriver(const char *name,
virCgroupPtr *group, virCgroupPtr *group,
int privileged, bool privileged,
int create); bool create);
int virCgroupGetAppRoot(virCgroupPtr *group); int virCgroupGetAppRoot(virCgroupPtr *group);
int virCgroupForDomain(virCgroupPtr driver, int virCgroupForDomain(virCgroupPtr driver,
const char *name, const char *name,
virCgroupPtr *group, virCgroupPtr *group,
int create); bool create);
int virCgroupForVcpu(virCgroupPtr driver, int virCgroupForVcpu(virCgroupPtr driver,
int vcpuid, int vcpuid,
virCgroupPtr *group, virCgroupPtr *group,
int create); bool create);
int virCgroupForEmulator(virCgroupPtr driver, int virCgroupForEmulator(virCgroupPtr driver,
virCgroupPtr *group, virCgroupPtr *group,
int create); bool create);
int virCgroupPathOfController(virCgroupPtr group, int virCgroupPathOfController(virCgroupPtr group,
int controller, int controller,

View File

@ -90,7 +90,7 @@ static struct xenUnifiedDriver const * const drivers[XEN_UNIFIED_NR_DRIVERS] = {
}; };
#if defined WITH_LIBVIRTD || defined __sun #if defined WITH_LIBVIRTD || defined __sun
static int inside_daemon; static bool inside_daemon = false;
#endif #endif
/** /**
@ -201,9 +201,9 @@ done:
#ifdef WITH_LIBVIRTD #ifdef WITH_LIBVIRTD
static int static int
xenInitialize(int privileged ATTRIBUTE_UNUSED) xenInitialize(bool privileged ATTRIBUTE_UNUSED)
{ {
inside_daemon = 1; inside_daemon = true;
return 0; return 0;
} }