]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
driver: Introduce global driver feature flag handling function
authorPeter Krempa <pkrempa@redhat.com>
Wed, 16 Feb 2022 12:01:39 +0000 (13:01 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 17 Feb 2022 12:15:46 +0000 (13:15 +0100)
The 'virDrvFeature' has a combination of features which are asserted by
the specific driver and features which are actually global.

In many cases the implementation was cargo-culted into newer drivers
without re-assesing whether it makes sense.

This patch introduces a global function which will specifically handle
these global flags and defer the rest to the driver.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
12 files changed:
src/ch/ch_driver.c
src/driver.c
src/driver.h
src/esx/esx_driver.c
src/libvirt_private.syms
src/libxl/libxl_driver.c
src/lxc/lxc_driver.c
src/network/bridge_driver.c
src/openvz/openvz_driver.c
src/qemu/qemu_driver.c
src/test/test_driver.c
src/vz/vz_driver.c

index a0ff687d050a9de62db5e60156cfd63301053af6..ac9298c0b57272763d68fd1545a3fe76045f6981 100644 (file)
@@ -919,9 +919,14 @@ static int
 chConnectSupportsFeature(virConnectPtr conn,
                          int feature)
 {
+    int supported;
+
     if (virConnectSupportsFeatureEnsureACL(conn) < 0)
         return -1;
 
+    if (virDriverFeatureIsGlobal(feature, &supported))
+        return supported;
+
     switch ((virDrvFeature) feature) {
         case VIR_DRV_FEATURE_TYPED_PARAM_STRING:
         case VIR_DRV_FEATURE_NETWORK_UPDATE_HAS_CORRECT_ORDER:
index 9ae95cb4c382fdde7ee1db05d846e2d9d254ed89..8c70662ccbd2d805a9578ba860d11722765428c7 100644 (file)
@@ -316,3 +316,44 @@ virConnectValidateURIPath(const char *uriPath,
 
     return true;
 }
+
+
+/**
+ * virDriverFeatureIsGlobal:
+ * @feat: a VIR_DRV_FEATURE
+ * @supported: If a feature is globally handled
+ *
+ * Certain driver feature flags are really not for individual drivers to decide
+ * whether they implement them or not, but are rather global based on e.g.
+ * whether the RPC protocol supports it.
+ *
+ * This function returns 'true' and fills @supported if a feature is a global
+ * feature and the individual driver implementations don't decide whether
+ * they support it or not.
+ */
+bool
+virDriverFeatureIsGlobal(virDrvFeature feat,
+                         int *supported G_GNUC_UNUSED)
+
+{
+    switch (feat) {
+    case VIR_DRV_FEATURE_TYPED_PARAM_STRING:
+    case VIR_DRV_FEATURE_NETWORK_UPDATE_HAS_CORRECT_ORDER:
+    case VIR_DRV_FEATURE_FD_PASSING:
+    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_XML_MIGRATABLE:
+    case VIR_DRV_FEATURE_MIGRATION_OFFLINE:
+    case VIR_DRV_FEATURE_MIGRATION_PARAMS:
+    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 false;
+    }
+}
index 7f45231f2476967b90d995622ae3b51ee7c1b17f..cd7cd96844f702b6a7ca96a30b86eae34b69b836 100644 (file)
@@ -131,3 +131,6 @@ int virSetConnectStorage(virConnectPtr conn);
 bool virConnectValidateURIPath(const char *uriPath,
                                const char *entityName,
                                bool privileged);
+
+bool virDriverFeatureIsGlobal(virDrvFeature feat,
+                              int *supported);
index 467740804aea2c109413c3b886231e05a9b9d9d4..3149f3e963d8b705d54731d0b954cc0f9ff7e3fb 100644 (file)
@@ -1018,6 +1018,10 @@ esxConnectSupportsFeature(virConnectPtr conn, int feature)
 {
     esxPrivate *priv = conn->privateData;
     esxVI_Boolean supportsVMotion = esxVI_Boolean_Undefined;
+    int supported;
+
+    if (virDriverFeatureIsGlobal(feature, &supported))
+        return supported;
 
     switch ((virDrvFeature) feature) {
       case VIR_DRV_FEATURE_MIGRATION_V1:
index 2380f02b881bf52e6d7b25f74a44a46574f0b8fc..6f0d72ca389996f88852a695f94a3022b5b605cb 100644 (file)
@@ -1528,6 +1528,7 @@ virStreamClass;
 
 # driver.h
 virConnectValidateURIPath;
+virDriverFeatureIsGlobal;
 virDriverShouldAutostart;
 virGetConnectInterface;
 virGetConnectNetwork;
index 4c61d330edb9f2097708a4506a7b14e72d14e3b5..478ab3e941e1dc7a95687a0d690c4598e2f066a4 100644 (file)
@@ -5697,9 +5697,14 @@ libxlConnectListAllDomains(virConnectPtr conn,
 static int
 libxlConnectSupportsFeature(virConnectPtr conn, int feature)
 {
+    int supported;
+
     if (virConnectSupportsFeatureEnsureACL(conn) < 0)
         return -1;
 
+    if (virDriverFeatureIsGlobal(feature, &supported))
+        return supported;
+
     switch ((virDrvFeature) feature) {
     case VIR_DRV_FEATURE_MIGRATION_V3:
     case VIR_DRV_FEATURE_TYPED_PARAM_STRING:
index ff83557bac046e9c614e237bdc6eafd5a46a1bd9..020ec257aef1742fa3792dbab69cb34041ae61cf 100644 (file)
@@ -1618,9 +1618,14 @@ static int lxcStateCleanup(void)
 static int
 lxcConnectSupportsFeature(virConnectPtr conn, int feature)
 {
+    int supported;
+
     if (virConnectSupportsFeatureEnsureACL(conn) < 0)
         return -1;
 
+    if (virDriverFeatureIsGlobal(feature, &supported))
+        return supported;
+
     switch ((virDrvFeature) feature) {
     case VIR_DRV_FEATURE_TYPED_PARAM_STRING:
     case VIR_DRV_FEATURE_NETWORK_UPDATE_HAS_CORRECT_ORDER:
index 3750da796219a42d05b24ba263d71b22634a3698..d6ae05360b244d1b66c43556dd4c3d57a3513391 100644 (file)
@@ -857,9 +857,14 @@ static int networkConnectIsAlive(virConnectPtr conn G_GNUC_UNUSED)
 static int
 networkConnectSupportsFeature(virConnectPtr conn, int feature)
 {
+    int supported;
+
     if (virConnectSupportsFeatureEnsureACL(conn) < 0)
         return -1;
 
+    if (virDriverFeatureIsGlobal(feature, &supported))
+        return supported;
+
     switch ((virDrvFeature) feature) {
     case VIR_DRV_FEATURE_NETWORK_UPDATE_HAS_CORRECT_ORDER:
         return 1;
index b2589059c81abce256c99f4bdcff18538ba43df2..aa1db095400b39ef44e6f2d95ce91717c0778ee9 100644 (file)
@@ -1938,6 +1938,11 @@ openvzNodeGetCPUMap(virConnectPtr conn G_GNUC_UNUSED,
 static int
 openvzConnectSupportsFeature(virConnectPtr conn G_GNUC_UNUSED, int feature)
 {
+    int supported;
+
+    if (virDriverFeatureIsGlobal(feature, &supported))
+        return supported;
+
     switch ((virDrvFeature) feature) {
     case VIR_DRV_FEATURE_MIGRATION_PARAMS:
     case VIR_DRV_FEATURE_MIGRATION_V3:
index f2620200f05fd3e2401f82e96a82859ecd3552dc..f1f708e511dc371a7e9d93c0d7f3d6ee6a6c5453 100644 (file)
@@ -1173,9 +1173,14 @@ static int qemuConnectClose(virConnectPtr conn)
 static int
 qemuConnectSupportsFeature(virConnectPtr conn, int feature)
 {
+    int supported;
+
     if (virConnectSupportsFeatureEnsureACL(conn) < 0)
         return -1;
 
+    if (virDriverFeatureIsGlobal(feature, &supported))
+        return supported;
+
     switch ((virDrvFeature) feature) {
     case VIR_DRV_FEATURE_MIGRATION_V2:
     case VIR_DRV_FEATURE_MIGRATION_V3:
index 03c41ca1925be68707df7e525ee90cc0e585171c..4eca5c4a65e157028cd9f934240fa5d8e7064876 100644 (file)
@@ -1667,6 +1667,11 @@ static int
 testConnectSupportsFeature(virConnectPtr conn G_GNUC_UNUSED,
                            int feature)
 {
+    int supported;
+
+    if (virDriverFeatureIsGlobal(feature, &supported))
+        return supported;
+
     switch ((virDrvFeature) feature) {
     case VIR_DRV_FEATURE_TYPED_PARAM_STRING:
     case VIR_DRV_FEATURE_NETWORK_UPDATE_HAS_CORRECT_ORDER:
index 86bc53d6312ba4895c505e1b9e898cae241952c9..fc91b6dddf4578849bc0fcfe855b652dbd216da5 100644 (file)
@@ -3006,9 +3006,14 @@ vzDomainMigratePrepare3Params(virConnectPtr conn,
 static int
 vzConnectSupportsFeature(virConnectPtr conn G_GNUC_UNUSED, int feature)
 {
+    int supported;
+
     if (virConnectSupportsFeatureEnsureACL(conn) < 0)
         return -1;
 
+    if (virDriverFeatureIsGlobal(feature, &supported))
+        return supported;
+
     switch ((virDrvFeature) feature) {
     case VIR_DRV_FEATURE_MIGRATION_PARAMS:
     case VIR_DRV_FEATURE_MIGRATION_P2P: