vhost: introduce API to start a specific driver
[dpdk.git] / examples / tep_termination / main.c
index 20dafdb..24c62cd 100644 (file)
@@ -1081,7 +1081,7 @@ new_device(int vid)
  * These callback allow devices to be added to the data core when configuration
  * has been fully complete.
  */
-static const struct virtio_net_device_ops virtio_net_device_ops = {
+static const struct vhost_device_ops virtio_net_device_ops = {
        .new_device =  new_device,
        .destroy_device = destroy_device,
 };
@@ -1248,15 +1248,28 @@ main(int argc, char *argv[])
                rte_eal_remote_launch(switch_worker,
                        mbuf_pool, lcore_id);
        }
-       rte_vhost_feature_disable(1ULL << VIRTIO_NET_F_MRG_RXBUF);
 
        ret = rte_vhost_driver_register((char *)&dev_basename, 0);
        if (ret != 0)
                rte_exit(EXIT_FAILURE, "failed to register vhost driver.\n");
 
-       rte_vhost_driver_callback_register(&virtio_net_device_ops);
+       rte_vhost_driver_disable_features(dev_basename,
+               1ULL << VIRTIO_NET_F_MRG_RXBUF);
 
-       rte_vhost_driver_session_start();
+       ret = rte_vhost_driver_callback_register(dev_basename,
+               &virtio_net_device_ops);
+       if (ret != 0) {
+               rte_exit(EXIT_FAILURE,
+                       "failed to register vhost driver callbacks.\n");
+       }
+
+       if (rte_vhost_driver_start(dev_basename) < 0) {
+               rte_exit(EXIT_FAILURE,
+                       "failed to start vhost driver.\n");
+       }
+
+       RTE_LCORE_FOREACH_SLAVE(lcore_id)
+               rte_eal_wait_lcore(lcore_id);
 
        return 0;
 }