diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c index a949f5c4d..16e8c69de 100644 --- a/lib/vhost/vhost.c +++ b/lib/vhost/vhost.c @@ -677,16 +677,10 @@ spdk_vhost_allocate_reactor(uint64_t cpumask) uint32_t i, selected_core; uint32_t min_ctrlrs; - cpumask &= spdk_app_get_core_mask(); - - if (cpumask == 0) { - return 0; - } - min_ctrlrs = INT_MAX; - selected_core = 0; + selected_core = spdk_env_get_first_core(); - for (i = 0; i < RTE_MAX_LCORE && i < 64; i++) { + SPDK_ENV_FOREACH_CORE(i) { if (!((1ULL << i) & cpumask)) { continue; } diff --git a/test/unit/lib/vhost/vhost.c/vhost_ut.c b/test/unit/lib/vhost/vhost.c/vhost_ut.c index ec63b37a2..bf69d5feb 100644 --- a/test/unit/lib/vhost/vhost.c/vhost_ut.c +++ b/test/unit/lib/vhost/vhost.c/vhost_ut.c @@ -48,6 +48,8 @@ DEFINE_STUB(spdk_mem_register, int, (void *vaddr, size_t len), 0); DEFINE_STUB(spdk_mem_unregister, int, (void *vaddr, size_t len), 0); DEFINE_STUB(spdk_app_get_core_mask, uint64_t, (void), 0); DEFINE_STUB(spdk_app_parse_core_mask, int, (const char *mask, uint64_t *cpumask), 0); +DEFINE_STUB(spdk_env_get_first_core, uint32_t, (void), 0); +DEFINE_STUB(spdk_env_get_next_core, uint32_t, (uint32_t prev_core), 0); DEFINE_STUB_V(spdk_app_stop, (int rc)); DEFINE_STUB_V(spdk_event_call, (struct spdk_event *event)); DEFINE_STUB(spdk_poller_register, struct spdk_poller *, (spdk_poller_fn fn, void *arg,