| 690 | } |
| 691 | |
| 692 | static void |
| 693 | destroy_device(int vid) |
| 694 | { |
| 695 | char path[PATH_MAX]; |
| 696 | struct vhost_blk_ctrlr *ctrlr; |
| 697 | struct vhost_blk_queue *vq; |
| 698 | int i, ret; |
| 699 | |
| 700 | ret = rte_vhost_get_ifname(vid, path, PATH_MAX); |
| 701 | if (ret) { |
| 702 | fprintf(stderr, "Destroy Ctrlr Failed\n"); |
| 703 | return; |
| 704 | } |
| 705 | |
| 706 | fprintf(stdout, "Destroy %s Device ID %d\n", path, vid); |
| 707 | ctrlr = vhost_blk_ctrlr_find(path); |
| 708 | if (!ctrlr) { |
| 709 | fprintf(stderr, "Destroy Ctrlr Failed\n"); |
| 710 | return; |
| 711 | } |
| 712 | |
| 713 | if (!ctrlr->started) |
| 714 | return; |
| 715 | |
| 716 | worker_thread_status = WORKER_STATE_STOP; |
| 717 | sem_wait(&exit_sem); |
| 718 | |
| 719 | for (i = 0; i < NUM_OF_BLK_QUEUES; i++) { |
| 720 | vq = &ctrlr->queues[i]; |
| 721 | if (vq->packed_ring) { |
| 722 | vq->last_avail_idx |= (vq->avail_wrap_counter << |
| 723 | 15); |
| 724 | vq->last_used_idx |= (vq->used_wrap_counter << |
| 725 | 15); |
| 726 | } |
| 727 | |
| 728 | rte_vhost_set_vring_base(ctrlr->vid, i, |
| 729 | vq->last_avail_idx, |
| 730 | vq->last_used_idx); |
| 731 | } |
| 732 | |
| 733 | free_task_pool(ctrlr); |
| 734 | free(ctrlr->mem); |
| 735 | |
| 736 | ctrlr->started = 0; |
| 737 | } |
| 738 | |
| 739 | static int |
| 740 | new_connection(int vid) |
no test coverage detected