From: "Daniel P. Berrange" <berrange(a)redhat.com>
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(a)redhat.com>
---
src/driver.h | 2 +-
src/libvirt.c | 4 ++--
src/libvirt_internal.h | 2 +-
src/libxl/libxl_driver.c | 2 +-
src/lxc/lxc_driver.c | 4 ++--
src/network/bridge_driver.c | 2 +-
src/node_device/node_device_hal.c | 2 +-
src/node_device/node_device_udev.c | 2 +-
src/nwfilter/nwfilter_driver.c | 2 +-
src/parallels/parallels_storage.c | 2 +-
src/qemu/qemu_conf.h | 2 +-
src/qemu/qemu_driver.c | 2 +-
src/remote/remote_driver.c | 6 +++---
src/secret/secret_driver.c | 2 +-
src/storage/storage_driver.c | 2 +-
src/uml/uml_conf.h | 2 +-
src/uml/uml_driver.c | 2 +-
src/util/cgroup.c | 34 ++++++++++++++++++----------------
src/util/cgroup.h | 10 +++++-----
src/xen/xen_driver.c | 6 +++---
20 files changed, 47 insertions(+), 45 deletions(-)
diff --git a/src/driver.h b/src/driver.h
index 7d5a367..622ed87 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -1487,7 +1487,7 @@ struct _virStorageDriver {
};
# ifdef WITH_LIBVIRTD
-typedef int (*virDrvStateInitialize) (int privileged);
+typedef int (*virDrvStateInitialize) (bool privileged);
typedef int (*virDrvStateCleanup) (void);
typedef int (*virDrvStateReload) (void);
typedef int (*virDrvStateActive) (void);
diff --git a/src/libvirt.c b/src/libvirt.c
index 86c3deb..0e73d64 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -789,13 +789,13 @@ virRegisterStateDriver(virStateDriverPtr driver)
/**
* 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.
*
* Returns 0 if all succeed, -1 upon any failure.
*/
-int virStateInitialize(int privileged) {
+int virStateInitialize(bool privileged) {
int i;
if (virInitialize() < 0)
diff --git a/src/libvirt_internal.h b/src/libvirt_internal.h
index a39aaa4..b85a29d 100644
--- a/src/libvirt_internal.h
+++ b/src/libvirt_internal.h
@@ -28,7 +28,7 @@
# include "internal.h"
# ifdef WITH_LIBVIRTD
-int virStateInitialize(int privileged);
+int virStateInitialize(bool privileged);
int virStateCleanup(void);
int virStateReload(void);
int virStateActive(void);
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index bc75730..ae4451a 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -834,7 +834,7 @@ libxlShutdown(void)
}
static int
-libxlStartup(int privileged) {
+libxlStartup(bool privileged) {
const libxl_version_info *ver_info;
char *log_file = NULL;
virCommandPtr cmd;
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 991b593..6cb3fe2 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -69,7 +69,7 @@
#define LXC_NB_MEM_PARAM 3
-static int lxcStartup(int privileged);
+static int lxcStartup(bool privileged);
static int lxcShutdown(void);
virLXCDriverPtr lxc_driver = NULL;
@@ -1397,7 +1397,7 @@ error:
}
-static int lxcStartup(int privileged)
+static int lxcStartup(bool privileged)
{
char *ld;
int rc;
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index fb167dc..67ee262 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -330,7 +330,7 @@ firewalld_dbus_filter_bridge(DBusConnection *connection
ATTRIBUTE_UNUSED,
* Initialization function for the QEmu daemon
*/
static int
-networkStartup(int privileged) {
+networkStartup(bool privileged) {
char *base = NULL;
#ifdef HAVE_FIREWALLD
DBusConnection *sysbus = NULL;
diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_device_hal.c
index ff73db0..953e1d3 100644
--- a/src/node_device/node_device_hal.c
+++ b/src/node_device/node_device_hal.c
@@ -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;
char **udi = NULL;
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index acd78f2..bc4e2e9 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1604,7 +1604,7 @@ out:
return ret;
}
-static int udevDeviceMonitorStartup(int privileged ATTRIBUTE_UNUSED)
+static int udevDeviceMonitorStartup(bool privileged ATTRIBUTE_UNUSED)
{
udevPrivate *priv = NULL;
struct udev *udev = NULL;
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index 12f47ef..a0ee4f1 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -165,7 +165,7 @@ nwfilterDriverInstallDBusMatches(DBusConnection *sysbus
ATTRIBUTE_UNUSED)
* Initialization function for the QEmu daemon
*/
static int
-nwfilterDriverStartup(int privileged)
+nwfilterDriverStartup(bool privileged)
{
char *base = NULL;
DBusConnection *sysbus = NULL;
diff --git a/src/parallels/parallels_storage.c b/src/parallels/parallels_storage.c
index 8d4e2c6..9075dfd 100644
--- a/src/parallels/parallels_storage.c
+++ b/src/parallels/parallels_storage.c
@@ -121,7 +121,7 @@ parallelsStorageOpen(virConnectPtr conn,
{
char *base = NULL;
virStorageDriverStatePtr storageState;
- int privileged = (geteuid() == 0);
+ bool privileged = (geteuid() == 0);
parallelsConnPtr privconn = conn->privateData;
size_t i;
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 4c729e4..b7378a7 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -56,7 +56,7 @@ struct qemud_driver {
virThreadPoolPtr workerPool;
- int privileged;
+ bool privileged;
const char *uri;
uid_t user;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 8e098ef..186b79f 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -610,7 +610,7 @@ qemuDomainFindMaxID(void *payload,
* Initialization function for the QEmu daemon
*/
static int
-qemuStartup(int privileged) {
+qemuStartup(bool privileged) {
char *base = NULL;
char *driverConf = NULL;
int rc;
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index ec33698..01cebb4 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -68,7 +68,7 @@
# define HYPER_TO_ULONG(_to, _from) (_to) = (_from)
#endif
-static int inside_daemon = 0;
+static bool inside_daemon = false;
static virDriverPtr remoteDriver = NULL;
struct private_data {
@@ -150,12 +150,12 @@ static char *get_transport_from_scheme(char *scheme);
#ifdef WITH_LIBVIRTD
static int
-remoteStartup(int privileged ATTRIBUTE_UNUSED)
+remoteStartup(bool privileged ATTRIBUTE_UNUSED)
{
/* Mark that we're inside the daemon so we can avoid
* re-entering ourselves
*/
- inside_daemon = 1;
+ inside_daemon = true;
return 0;
}
#endif
diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c
index 51e1e46..c7aabfc 100644
--- a/src/secret/secret_driver.c
+++ b/src/secret/secret_driver.c
@@ -1073,7 +1073,7 @@ secretDriverCleanup(void)
}
static int
-secretDriverStartup(int privileged)
+secretDriverStartup(bool privileged)
{
char *base = NULL;
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 2e33b80..d27bb41 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -128,7 +128,7 @@ storageDriverAutostart(virStorageDriverStatePtr driver) {
* Initialization function for the QEmu daemon
*/
static int
-storageDriverStartup(int privileged)
+storageDriverStartup(bool privileged)
{
char *base = NULL;
diff --git a/src/uml/uml_conf.h b/src/uml/uml_conf.h
index 274041d..ebae24e 100644
--- a/src/uml/uml_conf.h
+++ b/src/uml/uml_conf.h
@@ -44,7 +44,7 @@
struct uml_driver {
virMutex lock;
- int privileged;
+ bool privileged;
unsigned long umlVersion;
int nextvmid;
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 62077e1..5a87e31 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -419,7 +419,7 @@ cleanup:
* Initialization function for the Uml daemon
*/
static int
-umlStartup(int privileged)
+umlStartup(bool privileged)
{
char *base = NULL;
char *userdir = NULL;
diff --git a/src/util/cgroup.c b/src/util/cgroup.c
index 41a6e4a..9a564cc 100644
--- a/src/util/cgroup.c
+++ b/src/util/cgroup.c
@@ -526,8 +526,10 @@ static int virCgroupSetMemoryUseHierarchy(virCgroupPtr group)
return rc;
}
-static int virCgroupMakeGroup(virCgroupPtr parent, virCgroupPtr group,
- int create, unsigned int flags)
+static int virCgroupMakeGroup(virCgroupPtr parent,
+ virCgroupPtr group,
+ bool create,
+ unsigned int flags)
{
int i;
int rc = 0;
@@ -641,9 +643,9 @@ err:
return rc;
}
-static int virCgroupAppRoot(int privileged,
+static int virCgroupAppRoot(bool privileged,
virCgroupPtr *group,
- int create)
+ bool create)
{
virCgroupPtr rootgrp = NULL;
int rc;
@@ -924,8 +926,8 @@ cleanup:
#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
int virCgroupForDriver(const char *name,
virCgroupPtr *group,
- int privileged,
- int create)
+ bool privileged,
+ bool create)
{
int rc;
char *path = NULL;
@@ -957,8 +959,8 @@ out:
#else
int virCgroupForDriver(const char *name ATTRIBUTE_UNUSED,
virCgroupPtr *group ATTRIBUTE_UNUSED,
- int privileged ATTRIBUTE_UNUSED,
- int create ATTRIBUTE_UNUSED)
+ bool privileged ATTRIBUTE_UNUSED,
+ bool create ATTRIBUTE_UNUSED)
{
/* Claim no support */
return -ENXIO;
@@ -979,7 +981,7 @@ int virCgroupForDriver(const char *name ATTRIBUTE_UNUSED,
int virCgroupForDomain(virCgroupPtr driver,
const char *name,
virCgroupPtr *group,
- int create)
+ bool create)
{
int rc;
char *path;
@@ -1015,7 +1017,7 @@ int virCgroupForDomain(virCgroupPtr driver,
int virCgroupForDomain(virCgroupPtr driver ATTRIBUTE_UNUSED,
const char *name ATTRIBUTE_UNUSED,
virCgroupPtr *group ATTRIBUTE_UNUSED,
- int create ATTRIBUTE_UNUSED)
+ bool create ATTRIBUTE_UNUSED)
{
return -ENXIO;
}
@@ -1034,7 +1036,7 @@ int virCgroupForDomain(virCgroupPtr driver ATTRIBUTE_UNUSED,
int virCgroupForVcpu(virCgroupPtr driver,
int vcpuid,
virCgroupPtr *group,
- int create)
+ bool create)
{
int rc;
char *path;
@@ -1060,7 +1062,7 @@ int virCgroupForVcpu(virCgroupPtr driver,
int virCgroupForVcpu(virCgroupPtr driver ATTRIBUTE_UNUSED,
int vcpuid ATTRIBUTE_UNUSED,
virCgroupPtr *group ATTRIBUTE_UNUSED,
- int create ATTRIBUTE_UNUSED)
+ bool create ATTRIBUTE_UNUSED)
{
return -ENXIO;
}
@@ -1076,8 +1078,8 @@ int virCgroupForVcpu(virCgroupPtr driver ATTRIBUTE_UNUSED,
*/
#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
int virCgroupForEmulator(virCgroupPtr driver,
- virCgroupPtr *group,
- int create)
+ virCgroupPtr *group,
+ bool create)
{
int rc;
char *path;
@@ -1101,8 +1103,8 @@ int virCgroupForEmulator(virCgroupPtr driver,
}
#else
int virCgroupForEmulator(virCgroupPtr driver ATTRIBUTE_UNUSED,
- virCgroupPtr *group ATTRIBUTE_UNUSED,
- int create ATTRIBUTE_UNUSED)
+ virCgroupPtr *group ATTRIBUTE_UNUSED,
+ bool create ATTRIBUTE_UNUSED)
{
return -ENXIO;
}
diff --git a/src/util/cgroup.h b/src/util/cgroup.h
index 38fa4b7..e717227 100644
--- a/src/util/cgroup.h
+++ b/src/util/cgroup.h
@@ -44,22 +44,22 @@ VIR_ENUM_DECL(virCgroupController);
int virCgroupForDriver(const char *name,
virCgroupPtr *group,
- int privileged,
- int create);
+ bool privileged,
+ bool create);
int virCgroupForDomain(virCgroupPtr driver,
const char *name,
virCgroupPtr *group,
- int create);
+ bool create);
int virCgroupForVcpu(virCgroupPtr driver,
int vcpuid,
virCgroupPtr *group,
- int create);
+ bool create);
int virCgroupForEmulator(virCgroupPtr driver,
virCgroupPtr *group,
- int create);
+ bool create);
int virCgroupPathOfController(virCgroupPtr group,
int controller,
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index bfdca3d..5a40757 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -90,7 +90,7 @@ static struct xenUnifiedDriver const * const
drivers[XEN_UNIFIED_NR_DRIVERS] = {
};
#if defined WITH_LIBVIRTD || defined __sun
-static int inside_daemon;
+static bool inside_daemon = false;
#endif
/**
@@ -201,9 +201,9 @@ done:
#ifdef WITH_LIBVIRTD
static int
-xenInitialize(int privileged ATTRIBUTE_UNUSED)
+xenInitialize(bool privileged ATTRIBUTE_UNUSED)
{
- inside_daemon = 1;
+ inside_daemon = true;
return 0;
}
--
1.7.11.7