The vdev_netvsc driver auto-injects itself on Hyper-V via an
RTE_INIT constructor. This interferes with tests on github actions
which uses Azure where the driver probes in forked subprocesses
and crashes on uninitialized interrupt instances.

Guard the auto-detection behind RTE_LIBRTE_VDEV_NETVSC_AUTO
(disabled by default). The driver must now be explicitly
requested with --vdev=net_vdev_netvsc.

Signed-off-by: Stephen Hemminger <[email protected]>
---
 config/rte_config.h                    |  3 +++
 doc/guides/nics/vdev_netvsc.rst        | 11 ++++++-----
 doc/guides/rel_notes/release_26_03.rst |  8 ++++++++
 drivers/net/vdev_netvsc/vdev_netvsc.c  | 20 ++++++++++++++++++--
 4 files changed, 35 insertions(+), 7 deletions(-)

diff --git a/config/rte_config.h b/config/rte_config.h
index a2609fa403..e1977081e6 100644
--- a/config/rte_config.h
+++ b/config/rte_config.h
@@ -153,4 +153,7 @@
 /* DLB2 defines */
 // RTE_LIBRTE_PMD_DLB2_QUELL_STATS is not set
 
+/* vdev_netvsc defines */
+// RTE_LIBRTE_VDEV_NETVSC_AUTO is not set
+
 #endif /* _RTE_CONFIG_H_ */
diff --git a/doc/guides/nics/vdev_netvsc.rst b/doc/guides/nics/vdev_netvsc.rst
index 8dd5981947..4a3049ef42 100644
--- a/doc/guides/nics/vdev_netvsc.rst
+++ b/doc/guides/nics/vdev_netvsc.rst
@@ -65,8 +65,9 @@ a new NetVSC driver will be integrated.
 Runtime Configuration
 ---------------------
 
-This driver is invoked automatically in Hyper-V VM systems unless the user
-invoked it by command line using ``--vdev=net_vdev_netvsc`` EAL option.
+This driver can be invoked automatically if ``RTE_LIBRTE_VDEV_NETVSC_AUTO``
+is defined in the build configuration. Otherwise, it must be enabled
+using the ``--vdev=net_vdev_netvsc`` EAL command line option.
 
 The following device parameters are supported:
 
@@ -87,12 +88,12 @@ The following device parameters are supported:
 
 - ``ignore`` [int]
 
-  If nonzero, ignores the driver running (actually used to disable the
-  auto-detection in Hyper-V VM).
+  If auto-detection is enabled in the build, this parameter disables the
+  auto-detection of network interfaces.
 
 .. note::
 
    Not specifying either ``iface`` or ``mac`` makes this driver attach itself 
to
    all unrouted NetVSC interfaces found on the system.
    Specifying the device makes this driver attach itself to the device
-   regardless the device routes.
+   regardless of the device routes.
diff --git a/doc/guides/rel_notes/release_26_03.rst 
b/doc/guides/rel_notes/release_26_03.rst
index b4499ec066..43d5b89695 100644
--- a/doc/guides/rel_notes/release_26_03.rst
+++ b/doc/guides/rel_notes/release_26_03.rst
@@ -106,6 +106,14 @@ New Features
   Added handling of the key combination Control+L
   to clear the screen before redisplaying the prompt.
 
+* **Updated Microsoft vdev_netvsc driver.**
+
+  * Disabled automatic detection on Hyper-V/Azure by default.
+    The driver must now be explicitly requested with 
``--vdev=net_vdev_netvsc``.
+    The previous auto-detection behavior can be restored by building with
+    ``RTE_LIBRTE_VDEV_NETVSC_AUTO`` defined.
+
+
 Removed Items
 -------------
 
diff --git a/drivers/net/vdev_netvsc/vdev_netvsc.c 
b/drivers/net/vdev_netvsc/vdev_netvsc.c
index f4a84783ce..a0d9d2aea9 100644
--- a/drivers/net/vdev_netvsc/vdev_netvsc.c
+++ b/drivers/net/vdev_netvsc/vdev_netvsc.c
@@ -42,7 +42,9 @@
 #define VDEV_NETVSC_ARG_IFACE "iface"
 #define VDEV_NETVSC_ARG_MAC "mac"
 #define VDEV_NETVSC_ARG_FORCE "force"
+#ifdef RTE_LIBRTE_VDEV_NETVSC_AUTO
 #define VDEV_NETVSC_ARG_IGNORE "ignore"
+#endif
 #define VDEV_NETVSC_PROBE_MS 1000
 
 #define NETVSC_CLASS_ID "{f8615163-df3e-46c5-913f-f2d2f965ed0e}"
@@ -653,7 +655,9 @@ vdev_netvsc_vdev_probe(struct rte_vdev_device *dev)
                VDEV_NETVSC_ARG_IFACE,
                VDEV_NETVSC_ARG_MAC,
                VDEV_NETVSC_ARG_FORCE,
+#ifdef RTE_LIBRTE_VDEV_NETVSC_AUTO
                VDEV_NETVSC_ARG_IGNORE,
+#endif
                NULL,
        };
        const char *name = rte_vdev_device_name(dev);
@@ -663,7 +667,9 @@ vdev_netvsc_vdev_probe(struct rte_vdev_device *dev)
        unsigned int specified = 0;
        unsigned int matched = 0;
        int force = 0;
+#ifdef RTE_LIBRTE_VDEV_NETVSC_AUTO
        int ignore = 0;
+#endif
        unsigned int i;
        int ret;
 
@@ -678,14 +684,18 @@ vdev_netvsc_vdev_probe(struct rte_vdev_device *dev)
 
                if (!strcmp(pair->key, VDEV_NETVSC_ARG_FORCE))
                        force = !!atoi(pair->value);
+#ifdef RTE_LIBRTE_VDEV_NETVSC_AUTO
                else if (!strcmp(pair->key, VDEV_NETVSC_ARG_IGNORE))
                        ignore = !!atoi(pair->value);
+#endif
                else if (!strcmp(pair->key, VDEV_NETVSC_ARG_IFACE) ||
                         !strcmp(pair->key, VDEV_NETVSC_ARG_MAC))
                        ++specified;
        }
+#ifdef RTE_LIBRTE_VDEV_NETVSC_AUTO
        if (ignore)
                goto ignore;
+#endif
        if (specified > 1) {
                DRV_LOG(ERR, "More than one way used to specify the netvsc"
                        " device.");
@@ -713,7 +723,9 @@ vdev_netvsc_vdev_probe(struct rte_vdev_device *dev)
        }
 error:
        ++vdev_netvsc_ctx_inst;
+#ifdef RTE_LIBRTE_VDEV_NETVSC_AUTO
 ignore:
+#endif
        rte_kvargs_free(kvargs);
        /* Reset alarm if there are device context created */
        if (vdev_netvsc_ctx_count) {
@@ -765,9 +777,12 @@ RTE_PMD_REGISTER_ALIAS(VDEV_NETVSC_DRIVER, 
eth_vdev_netvsc);
 RTE_PMD_REGISTER_PARAM_STRING(net_vdev_netvsc,
                              VDEV_NETVSC_ARG_IFACE "=<string> "
                              VDEV_NETVSC_ARG_MAC "=<string> "
-                             VDEV_NETVSC_ARG_FORCE "=<int> "
-                             VDEV_NETVSC_ARG_IGNORE "=<int>");
+#ifdef RTE_LIBRTE_VDEV_NETVSC_AUTO
+                             VDEV_NETVSC_ARG_IGNORE "=<int> ");
+#endif
+                             VDEV_NETVSC_ARG_FORCE "=<int>");
 
+#ifdef RTE_LIBRTE_VDEV_NETVSC_AUTO
 /** Compare function for vdev find device operation. */
 static int
 vdev_netvsc_cmp_rte_device(const struct rte_device *dev1,
@@ -808,3 +823,4 @@ RTE_INIT(vdev_netvsc_custom_scan_add)
        if (rte_hypervisor_get() == RTE_HYPERVISOR_HYPERV)
                rte_vdev_add_custom_scan(vdev_netvsc_scan_callback, NULL);
 }
+#endif /* RTE_LIBRTE_VDEV_NETVSC_AUTO */
-- 
2.51.0

Reply via email to