X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_vhost%2Fvhost.c;h=13ce864db3634de2a22590af92e4e05d4b3aa193;hb=2396806765e4b797dd30bc265126c2bbc1a879cc;hp=2f190d3ca339f7cb9945283873114e4ac4a8c8b2;hpb=973bd0c1da3c1c480bf80bebe4c343c3d1e6b68e;p=dpdk.git diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c index 2f190d3ca3..13ce864db3 100644 --- a/lib/librte_vhost/vhost.c +++ b/lib/librte_vhost/vhost.c @@ -296,6 +296,22 @@ vhost_new_device(void) return i; } +void +vhost_destroy_device_notify(struct virtio_net *dev) +{ + struct rte_vdpa_device *vdpa_dev; + int did; + + if (dev->flags & VIRTIO_DEV_RUNNING) { + did = dev->vdpa_dev_id; + vdpa_dev = rte_vdpa_get_device(did); + if (vdpa_dev && vdpa_dev->ops->dev_close) + vdpa_dev->ops->dev_close(dev->vid); + dev->flags &= ~VIRTIO_DEV_RUNNING; + dev->notify_ops->destroy_device(dev->vid); + } +} + /* * Invoked when there is the vhost-user connection is broken (when * the virtio device is being detached). @@ -304,20 +320,11 @@ void vhost_destroy_device(int vid) { struct virtio_net *dev = get_device(vid); - struct rte_vdpa_device *vdpa_dev; - int did = -1; if (dev == NULL) return; - if (dev->flags & VIRTIO_DEV_RUNNING) { - did = dev->vdpa_dev_id; - vdpa_dev = rte_vdpa_get_device(did); - if (vdpa_dev && vdpa_dev->ops->dev_close) - vdpa_dev->ops->dev_close(dev->vid); - dev->flags &= ~VIRTIO_DEV_RUNNING; - dev->notify_ops->destroy_device(vid); - } + vhost_destroy_device_notify(dev); cleanup_device(dev, 1); free_device(dev);