+ if (tap_get_flags(data->tapfds[0], &tap_flags) < 0) {
+ PMD_DRV_LOG(ERR, "fail to get tap flags for tap %s", dev->ifname);
+ goto err_tapfds;
+ }
+ if ((tap_flags & IFF_MULTI_QUEUE) == 0 && dev->max_queue_pairs > 1) {
+ PMD_DRV_LOG(ERR, "tap %s does not support multi queue", dev->ifname);
+ goto err_tapfds;
+ }
+
+ for (i = 1; i < dev->max_queue_pairs; i++) {
+ data->tapfds[i] = tap_open(dev->ifname, true);
+ if (data->tapfds[i] < 0)
+ goto err_tapfds;
+ }
+
+ dev->backend_data = data;
+
+ return 0;
+
+err_tapfds:
+ for (i = 0; i < dev->max_queue_pairs; i++) {
+ if (data->vhostfds[i] >= 0)
+ close(data->vhostfds[i]);
+ if (data->tapfds[i] >= 0)
+ close(data->tapfds[i]);
+ }
+
+ free(data->tapfds);
+err_vhostfds:
+ free(data->vhostfds);
+err_data:
+ free(data);
+
+ return -1;
+}
+
+static int
+vhost_kernel_destroy(struct virtio_user_dev *dev)
+{
+ struct vhost_kernel_data *data = dev->backend_data;
+ uint32_t i;
+
+ if (!data)
+ return 0;
+
+ for (i = 0; i < dev->max_queue_pairs; ++i) {
+ if (data->vhostfds[i] >= 0)
+ close(data->vhostfds[i]);
+ if (data->tapfds[i] >= 0)
+ close(data->tapfds[i]);
+ }
+
+ free(data->vhostfds);
+ free(data->tapfds);
+ free(data);
+ dev->backend_data = NULL;