Add typedef for the anonymous enum used for the driver features. This
allows the usage of the type in a switch statement and taking
advantage of the compilers feature to detect uncovered cases.
Signed-off-by: Marc Hartmayer <mhartmay(a)linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy(a)linux.vnet.ibm.com>
---
src/esx/esx_driver.c | 18 ++++++++++++++++--
src/libvirt_internal.h | 4 ++--
src/libxl/libxl_driver.c | 13 ++++++++++++-
src/lxc/lxc_driver.c | 24 +++++++++++++++++++-----
src/openvz/openvz_driver.c | 15 ++++++++++++++-
src/qemu/qemu_driver.c | 8 +++++++-
src/remote/remote_daemon_dispatch.c | 19 ++++++++++++++++---
src/vz/vz_driver.c | 15 ++++++++++++++-
src/xen/xen_driver.c | 15 ++++++++++++++-
9 files changed, 114 insertions(+), 17 deletions(-)
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index b065cdc51323..927267f1cc98 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -1122,7 +1122,7 @@ esxConnectSupportsFeature(virConnectPtr conn, int feature)
esxPrivate *priv = conn->privateData;
esxVI_Boolean supportsVMotion = esxVI_Boolean_Undefined;
- switch (feature) {
+ switch ((virDrvFeature) feature) {
case VIR_DRV_FEATURE_MIGRATION_V1:
supportsVMotion = esxSupportsVMotion(priv);
@@ -1133,7 +1133,21 @@ esxConnectSupportsFeature(virConnectPtr conn, int feature)
return priv->vCenter &&
supportsVMotion == esxVI_Boolean_True ? 1 : 0;
- default:
+ case VIR_DRV_FEATURE_FD_PASSING:
+ case VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTION:
+ case VIR_DRV_FEATURE_MIGRATION_DIRECT:
+ case VIR_DRV_FEATURE_MIGRATION_OFFLINE:
+ case VIR_DRV_FEATURE_MIGRATION_P2P:
+ case VIR_DRV_FEATURE_MIGRATION_PARAMS:
+ case VIR_DRV_FEATURE_MIGRATION_V2:
+ case VIR_DRV_FEATURE_MIGRATION_V3:
+ case VIR_DRV_FEATURE_PROGRAM_KEEPALIVE:
+ case VIR_DRV_FEATURE_REMOTE:
+ case VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK:
+ case VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK:
+ case VIR_DRV_FEATURE_TYPED_PARAM_STRING:
+ case VIR_DRV_FEATURE_XML_MIGRATABLE:
+ default:
return 0;
}
}
diff --git a/src/libvirt_internal.h b/src/libvirt_internal.h
index 62f490a7dfd5..0e008a65518d 100644
--- a/src/libvirt_internal.h
+++ b/src/libvirt_internal.h
@@ -45,7 +45,7 @@ int virStateStop(void);
* feature. Queries for VIR_DRV_FEATURE_PROGRAM* features are answered
* directly by the RPC layer and not by the real driver.
*/
-enum {
+typedef enum {
/* Driver supports V1-style virDomainMigrate, ie. domainMigratePrepare/
* domainMigratePerform/domainMigrateFinish.
*/
@@ -123,7 +123,7 @@ enum {
* Support for driver close callback rpc
*/
VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK = 15,
-};
+} virDrvFeature;
int virConnectSupportsFeature(virConnectPtr conn, int feature);
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index c3616a86d7f4..562966cc2062 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -5684,12 +5684,23 @@ libxlConnectSupportsFeature(virConnectPtr conn, int feature)
if (virConnectSupportsFeatureEnsureACL(conn) < 0)
return -1;
- switch (feature) {
+ switch ((virDrvFeature) feature) {
case VIR_DRV_FEATURE_MIGRATION_V3:
case VIR_DRV_FEATURE_TYPED_PARAM_STRING:
case VIR_DRV_FEATURE_MIGRATION_PARAMS:
case VIR_DRV_FEATURE_MIGRATION_P2P:
return 1;
+ case VIR_DRV_FEATURE_FD_PASSING:
+ case VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTION:
+ case VIR_DRV_FEATURE_MIGRATION_DIRECT:
+ case VIR_DRV_FEATURE_MIGRATION_OFFLINE:
+ case VIR_DRV_FEATURE_MIGRATION_V1:
+ case VIR_DRV_FEATURE_MIGRATION_V2:
+ case VIR_DRV_FEATURE_PROGRAM_KEEPALIVE:
+ case VIR_DRV_FEATURE_REMOTE:
+ case VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK:
+ case VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK:
+ case VIR_DRV_FEATURE_XML_MIGRATABLE:
default:
return 0;
}
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index fa6fc4643ee2..4f6b93bdbd30 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -1793,11 +1793,25 @@ lxcConnectSupportsFeature(virConnectPtr conn, int feature)
if (virConnectSupportsFeatureEnsureACL(conn) < 0)
return -1;
- switch (feature) {
- case VIR_DRV_FEATURE_TYPED_PARAM_STRING:
- return 1;
- default:
- return 0;
+ switch ((virDrvFeature) feature) {
+ case VIR_DRV_FEATURE_TYPED_PARAM_STRING:
+ return 1;
+ case VIR_DRV_FEATURE_FD_PASSING:
+ case VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTION:
+ case VIR_DRV_FEATURE_MIGRATION_DIRECT:
+ case VIR_DRV_FEATURE_MIGRATION_OFFLINE:
+ case VIR_DRV_FEATURE_MIGRATION_P2P:
+ case VIR_DRV_FEATURE_MIGRATION_PARAMS:
+ case VIR_DRV_FEATURE_MIGRATION_V1:
+ case VIR_DRV_FEATURE_MIGRATION_V2:
+ case VIR_DRV_FEATURE_MIGRATION_V3:
+ case VIR_DRV_FEATURE_PROGRAM_KEEPALIVE:
+ case VIR_DRV_FEATURE_REMOTE:
+ case VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK:
+ case VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK:
+ case VIR_DRV_FEATURE_XML_MIGRATABLE:
+ default:
+ return 0;
}
}
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 9bd73d85c49f..312cac35a3c3 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -2204,10 +2204,23 @@ openvzNodeGetCPUMap(virConnectPtr conn ATTRIBUTE_UNUSED,
static int
openvzConnectSupportsFeature(virConnectPtr conn ATTRIBUTE_UNUSED, int feature)
{
- switch (feature) {
+ switch ((virDrvFeature) feature) {
case VIR_DRV_FEATURE_MIGRATION_PARAMS:
case VIR_DRV_FEATURE_MIGRATION_V3:
return 1;
+ case VIR_DRV_FEATURE_FD_PASSING:
+ case VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTION:
+ case VIR_DRV_FEATURE_MIGRATION_DIRECT:
+ case VIR_DRV_FEATURE_MIGRATION_OFFLINE:
+ case VIR_DRV_FEATURE_MIGRATION_P2P:
+ case VIR_DRV_FEATURE_MIGRATION_V1:
+ case VIR_DRV_FEATURE_MIGRATION_V2:
+ case VIR_DRV_FEATURE_PROGRAM_KEEPALIVE:
+ case VIR_DRV_FEATURE_REMOTE:
+ case VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK:
+ case VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK:
+ case VIR_DRV_FEATURE_TYPED_PARAM_STRING:
+ case VIR_DRV_FEATURE_XML_MIGRATABLE:
default:
return 0;
}
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 9e715e7a00d4..874cb46981a3 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1206,7 +1206,7 @@ qemuConnectSupportsFeature(virConnectPtr conn, int feature)
if (virConnectSupportsFeatureEnsureACL(conn) < 0)
return -1;
- switch (feature) {
+ switch ((virDrvFeature) feature) {
case VIR_DRV_FEATURE_MIGRATION_V2:
case VIR_DRV_FEATURE_MIGRATION_V3:
case VIR_DRV_FEATURE_MIGRATION_P2P:
@@ -1217,6 +1217,12 @@ qemuConnectSupportsFeature(virConnectPtr conn, int feature)
case VIR_DRV_FEATURE_MIGRATION_OFFLINE:
case VIR_DRV_FEATURE_MIGRATION_PARAMS:
return 1;
+ case VIR_DRV_FEATURE_MIGRATION_DIRECT:
+ case VIR_DRV_FEATURE_MIGRATION_V1:
+ case VIR_DRV_FEATURE_PROGRAM_KEEPALIVE:
+ case VIR_DRV_FEATURE_REMOTE:
+ case VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK:
+ case VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK:
default:
return 0;
}
diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c
index ea67cb7bc018..82f6400ca49d 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -4645,7 +4645,7 @@ static int remoteDispatchConnectSupportsFeature(virNetServerPtr
server ATTRIBUTE
remote_connect_supports_feature_ret
*ret)
{
int rv = -1;
- int supported;
+ int supported = -1;
struct daemonClientPrivate *priv =
virNetServerClientGetPrivateData(client);
@@ -4664,17 +4664,30 @@ static int remoteDispatchConnectSupportsFeature(virNetServerPtr
server ATTRIBUTE
goto cleanup;
}
- switch (args->feature) {
+ switch ((virDrvFeature) args->feature) {
case VIR_DRV_FEATURE_FD_PASSING:
case VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK:
case VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK:
supported = 1;
break;
-
+ case VIR_DRV_FEATURE_MIGRATION_V1:
+ case VIR_DRV_FEATURE_REMOTE:
+ case VIR_DRV_FEATURE_MIGRATION_V2:
+ case VIR_DRV_FEATURE_MIGRATION_P2P:
+ case VIR_DRV_FEATURE_MIGRATION_DIRECT:
+ case VIR_DRV_FEATURE_MIGRATION_V3:
+ case VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTION:
+ case VIR_DRV_FEATURE_TYPED_PARAM_STRING:
+ case VIR_DRV_FEATURE_XML_MIGRATABLE:
+ case VIR_DRV_FEATURE_MIGRATION_OFFLINE:
+ case VIR_DRV_FEATURE_MIGRATION_PARAMS:
default:
if ((supported = virConnectSupportsFeature(priv->conn, args->feature)) <
0)
goto cleanup;
break;
+ case VIR_DRV_FEATURE_PROGRAM_KEEPALIVE:
+ /* should not be possible! */
+ goto cleanup;
}
done:
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 6d02ef274fec..a425bc85529d 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -3079,10 +3079,23 @@ vzConnectSupportsFeature(virConnectPtr conn ATTRIBUTE_UNUSED, int
feature)
if (virConnectSupportsFeatureEnsureACL(conn) < 0)
return -1;
- switch (feature) {
+ switch ((virDrvFeature) feature) {
case VIR_DRV_FEATURE_MIGRATION_PARAMS:
case VIR_DRV_FEATURE_MIGRATION_P2P:
return 1;
+ case VIR_DRV_FEATURE_FD_PASSING:
+ case VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTION:
+ case VIR_DRV_FEATURE_MIGRATION_DIRECT:
+ case VIR_DRV_FEATURE_MIGRATION_OFFLINE:
+ case VIR_DRV_FEATURE_MIGRATION_V1:
+ case VIR_DRV_FEATURE_MIGRATION_V2:
+ case VIR_DRV_FEATURE_MIGRATION_V3:
+ case VIR_DRV_FEATURE_PROGRAM_KEEPALIVE:
+ case VIR_DRV_FEATURE_REMOTE:
+ case VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK:
+ case VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK:
+ case VIR_DRV_FEATURE_TYPED_PARAM_STRING:
+ case VIR_DRV_FEATURE_XML_MIGRATABLE:
default:
return 0;
}
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index f521fd1f2c03..85c3424b11ed 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -619,10 +619,23 @@ xenUnifiedConnectSupportsFeature(virConnectPtr conn, int feature)
if (virConnectSupportsFeatureEnsureACL(conn) < 0)
return -1;
- switch (feature) {
+ switch ((virDrvFeature) feature) {
case VIR_DRV_FEATURE_MIGRATION_V1:
case VIR_DRV_FEATURE_MIGRATION_DIRECT:
return 1;
+ case VIR_DRV_FEATURE_MIGRATION_V2:
+ case VIR_DRV_FEATURE_MIGRATION_V3:
+ case VIR_DRV_FEATURE_MIGRATION_P2P:
+ case VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTION:
+ case VIR_DRV_FEATURE_FD_PASSING:
+ case VIR_DRV_FEATURE_TYPED_PARAM_STRING:
+ case VIR_DRV_FEATURE_XML_MIGRATABLE:
+ case VIR_DRV_FEATURE_MIGRATION_OFFLINE:
+ case VIR_DRV_FEATURE_MIGRATION_PARAMS:
+ case VIR_DRV_FEATURE_PROGRAM_KEEPALIVE:
+ case VIR_DRV_FEATURE_REMOTE:
+ case VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK:
+ case VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK:
default:
return 0;
}
--
2.13.4