2 * vhost transport for vsock
4 * Copyright (C) 2013-2015 Red Hat, Inc.
5 * Author: Asias He <asias@redhat.com>
6 * Stefan Hajnoczi <stefanha@redhat.com>
8 * This work is licensed under the terms of the GNU GPL, version 2.
10 #include <linux/miscdevice.h>
11 #include <linux/atomic.h>
12 #include <linux/module.h>
13 #include <linux/mutex.h>
14 #include <linux/vmalloc.h>
16 #include <linux/virtio_vsock.h>
17 #include <linux/vhost.h>
18 #include <linux/hashtable.h>
20 #include <net/af_vsock.h>
23 #define VHOST_VSOCK_DEFAULT_HOST_CID 2
24 /* Max number of bytes transferred before requeueing the job.
25 * Using this limit prevents one virtqueue from starving others. */
26 #define VHOST_VSOCK_WEIGHT 0x80000
27 /* Max number of packets transferred before requeueing the job.
28 * Using this limit prevents one virtqueue from starving others with
31 #define VHOST_VSOCK_PKT_WEIGHT 256
34 VHOST_VSOCK_FEATURES
= VHOST_FEATURES
,
37 /* Used to track all the vhost_vsock instances on the system. */
38 static DEFINE_SPINLOCK(vhost_vsock_lock
);
39 static DEFINE_READ_MOSTLY_HASHTABLE(vhost_vsock_hash
, 8);
43 struct vhost_virtqueue vqs
[2];
45 /* Link to global vhost_vsock_hash, writes use vhost_vsock_lock */
46 struct hlist_node hash
;
48 struct vhost_work send_pkt_work
;
49 spinlock_t send_pkt_list_lock
;
50 struct list_head send_pkt_list
; /* host->guest pending packets */
52 atomic_t queued_replies
;
57 static u32
vhost_transport_get_local_cid(void)
59 return VHOST_VSOCK_DEFAULT_HOST_CID
;
62 /* Callers that dereference the return value must hold vhost_vsock_lock or the
65 static struct vhost_vsock
*vhost_vsock_get(u32 guest_cid
)
67 struct vhost_vsock
*vsock
;
69 hash_for_each_possible_rcu(vhost_vsock_hash
, vsock
, hash
, guest_cid
) {
70 u32 other_cid
= vsock
->guest_cid
;
72 /* Skip instances that have no CID yet */
76 if (other_cid
== guest_cid
) {
85 vhost_transport_do_send_pkt(struct vhost_vsock
*vsock
,
86 struct vhost_virtqueue
*vq
)
88 struct vhost_virtqueue
*tx_vq
= &vsock
->vqs
[VSOCK_VQ_TX
];
89 int pkts
= 0, total_len
= 0;
91 bool restart_tx
= false;
93 mutex_lock(&vq
->mutex
);
95 if (!vq
->private_data
)
98 /* Avoid further vmexits, we're already processing the virtqueue */
99 vhost_disable_notify(&vsock
->dev
, vq
);
102 struct virtio_vsock_pkt
*pkt
;
103 struct iov_iter iov_iter
;
109 spin_lock_bh(&vsock
->send_pkt_list_lock
);
110 if (list_empty(&vsock
->send_pkt_list
)) {
111 spin_unlock_bh(&vsock
->send_pkt_list_lock
);
112 vhost_enable_notify(&vsock
->dev
, vq
);
116 pkt
= list_first_entry(&vsock
->send_pkt_list
,
117 struct virtio_vsock_pkt
, list
);
118 list_del_init(&pkt
->list
);
119 spin_unlock_bh(&vsock
->send_pkt_list_lock
);
121 head
= vhost_get_vq_desc(vq
, vq
->iov
, ARRAY_SIZE(vq
->iov
),
122 &out
, &in
, NULL
, NULL
);
124 spin_lock_bh(&vsock
->send_pkt_list_lock
);
125 list_add(&pkt
->list
, &vsock
->send_pkt_list
);
126 spin_unlock_bh(&vsock
->send_pkt_list_lock
);
130 if (head
== vq
->num
) {
131 spin_lock_bh(&vsock
->send_pkt_list_lock
);
132 list_add(&pkt
->list
, &vsock
->send_pkt_list
);
133 spin_unlock_bh(&vsock
->send_pkt_list_lock
);
135 /* We cannot finish yet if more buffers snuck in while
136 * re-enabling notify.
138 if (unlikely(vhost_enable_notify(&vsock
->dev
, vq
))) {
139 vhost_disable_notify(&vsock
->dev
, vq
);
146 virtio_transport_free_pkt(pkt
);
147 vq_err(vq
, "Expected 0 output buffers, got %u\n", out
);
151 len
= iov_length(&vq
->iov
[out
], in
);
152 iov_iter_init(&iov_iter
, READ
, &vq
->iov
[out
], in
, len
);
154 nbytes
= copy_to_iter(&pkt
->hdr
, sizeof(pkt
->hdr
), &iov_iter
);
155 if (nbytes
!= sizeof(pkt
->hdr
)) {
156 virtio_transport_free_pkt(pkt
);
157 vq_err(vq
, "Faulted on copying pkt hdr\n");
161 nbytes
= copy_to_iter(pkt
->buf
, pkt
->len
, &iov_iter
);
162 if (nbytes
!= pkt
->len
) {
163 virtio_transport_free_pkt(pkt
);
164 vq_err(vq
, "Faulted on copying pkt buf\n");
168 vhost_add_used(vq
, head
, sizeof(pkt
->hdr
) + pkt
->len
);
174 val
= atomic_dec_return(&vsock
->queued_replies
);
176 /* Do we have resources to resume tx processing? */
177 if (val
+ 1 == tx_vq
->num
)
181 /* Deliver to monitoring devices all correctly transmitted
184 virtio_transport_deliver_tap_pkt(pkt
);
186 total_len
+= pkt
->len
;
187 virtio_transport_free_pkt(pkt
);
188 } while(likely(!vhost_exceeds_weight(vq
, ++pkts
, total_len
)));
190 vhost_signal(&vsock
->dev
, vq
);
193 mutex_unlock(&vq
->mutex
);
196 vhost_poll_queue(&tx_vq
->poll
);
199 static void vhost_transport_send_pkt_work(struct vhost_work
*work
)
201 struct vhost_virtqueue
*vq
;
202 struct vhost_vsock
*vsock
;
204 vsock
= container_of(work
, struct vhost_vsock
, send_pkt_work
);
205 vq
= &vsock
->vqs
[VSOCK_VQ_RX
];
207 vhost_transport_do_send_pkt(vsock
, vq
);
211 vhost_transport_send_pkt(struct virtio_vsock_pkt
*pkt
)
213 struct vhost_vsock
*vsock
;
218 /* Find the vhost_vsock according to guest context id */
219 vsock
= vhost_vsock_get(le64_to_cpu(pkt
->hdr
.dst_cid
));
222 virtio_transport_free_pkt(pkt
);
227 atomic_inc(&vsock
->queued_replies
);
229 spin_lock_bh(&vsock
->send_pkt_list_lock
);
230 list_add_tail(&pkt
->list
, &vsock
->send_pkt_list
);
231 spin_unlock_bh(&vsock
->send_pkt_list_lock
);
233 vhost_work_queue(&vsock
->dev
, &vsock
->send_pkt_work
);
240 vhost_transport_cancel_pkt(struct vsock_sock
*vsk
)
242 struct vhost_vsock
*vsock
;
243 struct virtio_vsock_pkt
*pkt
, *n
;
250 /* Find the vhost_vsock according to guest context id */
251 vsock
= vhost_vsock_get(vsk
->remote_addr
.svm_cid
);
255 spin_lock_bh(&vsock
->send_pkt_list_lock
);
256 list_for_each_entry_safe(pkt
, n
, &vsock
->send_pkt_list
, list
) {
259 list_move(&pkt
->list
, &freeme
);
261 spin_unlock_bh(&vsock
->send_pkt_list_lock
);
263 list_for_each_entry_safe(pkt
, n
, &freeme
, list
) {
266 list_del(&pkt
->list
);
267 virtio_transport_free_pkt(pkt
);
271 struct vhost_virtqueue
*tx_vq
= &vsock
->vqs
[VSOCK_VQ_TX
];
274 new_cnt
= atomic_sub_return(cnt
, &vsock
->queued_replies
);
275 if (new_cnt
+ cnt
>= tx_vq
->num
&& new_cnt
< tx_vq
->num
)
276 vhost_poll_queue(&tx_vq
->poll
);
285 static struct virtio_vsock_pkt
*
286 vhost_vsock_alloc_pkt(struct vhost_virtqueue
*vq
,
287 unsigned int out
, unsigned int in
)
289 struct virtio_vsock_pkt
*pkt
;
290 struct iov_iter iov_iter
;
295 vq_err(vq
, "Expected 0 input buffers, got %u\n", in
);
299 pkt
= kzalloc(sizeof(*pkt
), GFP_KERNEL
);
303 len
= iov_length(vq
->iov
, out
);
304 iov_iter_init(&iov_iter
, WRITE
, vq
->iov
, out
, len
);
306 nbytes
= copy_from_iter(&pkt
->hdr
, sizeof(pkt
->hdr
), &iov_iter
);
307 if (nbytes
!= sizeof(pkt
->hdr
)) {
308 vq_err(vq
, "Expected %zu bytes for pkt->hdr, got %zu bytes\n",
309 sizeof(pkt
->hdr
), nbytes
);
314 if (le16_to_cpu(pkt
->hdr
.type
) == VIRTIO_VSOCK_TYPE_STREAM
)
315 pkt
->len
= le32_to_cpu(pkt
->hdr
.len
);
321 /* The pkt is too big */
322 if (pkt
->len
> VIRTIO_VSOCK_MAX_PKT_BUF_SIZE
) {
327 pkt
->buf
= kmalloc(pkt
->len
, GFP_KERNEL
);
333 nbytes
= copy_from_iter(pkt
->buf
, pkt
->len
, &iov_iter
);
334 if (nbytes
!= pkt
->len
) {
335 vq_err(vq
, "Expected %u byte payload, got %zu bytes\n",
337 virtio_transport_free_pkt(pkt
);
344 /* Is there space left for replies to rx packets? */
345 static bool vhost_vsock_more_replies(struct vhost_vsock
*vsock
)
347 struct vhost_virtqueue
*vq
= &vsock
->vqs
[VSOCK_VQ_TX
];
350 smp_rmb(); /* paired with atomic_inc() and atomic_dec_return() */
351 val
= atomic_read(&vsock
->queued_replies
);
353 return val
< vq
->num
;
356 static void vhost_vsock_handle_tx_kick(struct vhost_work
*work
)
358 struct vhost_virtqueue
*vq
= container_of(work
, struct vhost_virtqueue
,
360 struct vhost_vsock
*vsock
= container_of(vq
->dev
, struct vhost_vsock
,
362 struct virtio_vsock_pkt
*pkt
;
363 int head
, pkts
= 0, total_len
= 0;
364 unsigned int out
, in
;
367 mutex_lock(&vq
->mutex
);
369 if (!vq
->private_data
)
372 vhost_disable_notify(&vsock
->dev
, vq
);
376 if (!vhost_vsock_more_replies(vsock
)) {
377 /* Stop tx until the device processes already
378 * pending replies. Leave tx virtqueue
379 * callbacks disabled.
381 goto no_more_replies
;
384 head
= vhost_get_vq_desc(vq
, vq
->iov
, ARRAY_SIZE(vq
->iov
),
385 &out
, &in
, NULL
, NULL
);
389 if (head
== vq
->num
) {
390 if (unlikely(vhost_enable_notify(&vsock
->dev
, vq
))) {
391 vhost_disable_notify(&vsock
->dev
, vq
);
397 pkt
= vhost_vsock_alloc_pkt(vq
, out
, in
);
399 vq_err(vq
, "Faulted on pkt\n");
405 /* Deliver to monitoring devices all received packets */
406 virtio_transport_deliver_tap_pkt(pkt
);
408 /* Only accept correctly addressed packets */
409 if (le64_to_cpu(pkt
->hdr
.src_cid
) == vsock
->guest_cid
)
410 virtio_transport_recv_pkt(pkt
);
412 virtio_transport_free_pkt(pkt
);
414 len
+= sizeof(pkt
->hdr
);
415 vhost_add_used(vq
, head
, len
);
418 } while(likely(!vhost_exceeds_weight(vq
, ++pkts
, total_len
)));
422 vhost_signal(&vsock
->dev
, vq
);
425 mutex_unlock(&vq
->mutex
);
428 static void vhost_vsock_handle_rx_kick(struct vhost_work
*work
)
430 struct vhost_virtqueue
*vq
= container_of(work
, struct vhost_virtqueue
,
432 struct vhost_vsock
*vsock
= container_of(vq
->dev
, struct vhost_vsock
,
435 vhost_transport_do_send_pkt(vsock
, vq
);
438 static int vhost_vsock_start(struct vhost_vsock
*vsock
)
440 struct vhost_virtqueue
*vq
;
444 mutex_lock(&vsock
->dev
.mutex
);
446 ret
= vhost_dev_check_owner(&vsock
->dev
);
450 for (i
= 0; i
< ARRAY_SIZE(vsock
->vqs
); i
++) {
453 mutex_lock(&vq
->mutex
);
455 if (!vhost_vq_access_ok(vq
)) {
460 if (!vq
->private_data
) {
461 vq
->private_data
= vsock
;
462 ret
= vhost_vq_init_access(vq
);
467 mutex_unlock(&vq
->mutex
);
470 mutex_unlock(&vsock
->dev
.mutex
);
474 vq
->private_data
= NULL
;
475 mutex_unlock(&vq
->mutex
);
477 for (i
= 0; i
< ARRAY_SIZE(vsock
->vqs
); i
++) {
480 mutex_lock(&vq
->mutex
);
481 vq
->private_data
= NULL
;
482 mutex_unlock(&vq
->mutex
);
485 mutex_unlock(&vsock
->dev
.mutex
);
489 static int vhost_vsock_stop(struct vhost_vsock
*vsock
)
494 mutex_lock(&vsock
->dev
.mutex
);
496 ret
= vhost_dev_check_owner(&vsock
->dev
);
500 for (i
= 0; i
< ARRAY_SIZE(vsock
->vqs
); i
++) {
501 struct vhost_virtqueue
*vq
= &vsock
->vqs
[i
];
503 mutex_lock(&vq
->mutex
);
504 vq
->private_data
= NULL
;
505 mutex_unlock(&vq
->mutex
);
509 mutex_unlock(&vsock
->dev
.mutex
);
513 static void vhost_vsock_free(struct vhost_vsock
*vsock
)
518 static int vhost_vsock_dev_open(struct inode
*inode
, struct file
*file
)
520 struct vhost_virtqueue
**vqs
;
521 struct vhost_vsock
*vsock
;
524 /* This struct is large and allocation could fail, fall back to vmalloc
525 * if there is no other way.
527 vsock
= kvmalloc(sizeof(*vsock
), GFP_KERNEL
| __GFP_RETRY_MAYFAIL
);
531 vqs
= kmalloc_array(ARRAY_SIZE(vsock
->vqs
), sizeof(*vqs
), GFP_KERNEL
);
537 vsock
->guest_cid
= 0; /* no CID assigned yet */
539 atomic_set(&vsock
->queued_replies
, 0);
541 vqs
[VSOCK_VQ_TX
] = &vsock
->vqs
[VSOCK_VQ_TX
];
542 vqs
[VSOCK_VQ_RX
] = &vsock
->vqs
[VSOCK_VQ_RX
];
543 vsock
->vqs
[VSOCK_VQ_TX
].handle_kick
= vhost_vsock_handle_tx_kick
;
544 vsock
->vqs
[VSOCK_VQ_RX
].handle_kick
= vhost_vsock_handle_rx_kick
;
546 vhost_dev_init(&vsock
->dev
, vqs
, ARRAY_SIZE(vsock
->vqs
),
547 VHOST_VSOCK_PKT_WEIGHT
, VHOST_VSOCK_WEIGHT
);
549 file
->private_data
= vsock
;
550 spin_lock_init(&vsock
->send_pkt_list_lock
);
551 INIT_LIST_HEAD(&vsock
->send_pkt_list
);
552 vhost_work_init(&vsock
->send_pkt_work
, vhost_transport_send_pkt_work
);
556 vhost_vsock_free(vsock
);
560 static void vhost_vsock_flush(struct vhost_vsock
*vsock
)
564 for (i
= 0; i
< ARRAY_SIZE(vsock
->vqs
); i
++)
565 if (vsock
->vqs
[i
].handle_kick
)
566 vhost_poll_flush(&vsock
->vqs
[i
].poll
);
567 vhost_work_flush(&vsock
->dev
, &vsock
->send_pkt_work
);
570 static void vhost_vsock_reset_orphans(struct sock
*sk
)
572 struct vsock_sock
*vsk
= vsock_sk(sk
);
574 /* vmci_transport.c doesn't take sk_lock here either. At least we're
575 * under vsock_table_lock so the sock cannot disappear while we're
579 /* If the peer is still valid, no need to reset connection */
580 if (vhost_vsock_get(vsk
->remote_addr
.svm_cid
))
583 /* If the close timeout is pending, let it expire. This avoids races
584 * with the timeout callback.
586 if (vsk
->close_work_scheduled
)
589 sock_set_flag(sk
, SOCK_DONE
);
590 vsk
->peer_shutdown
= SHUTDOWN_MASK
;
591 sk
->sk_state
= SS_UNCONNECTED
;
592 sk
->sk_err
= ECONNRESET
;
593 sk
->sk_error_report(sk
);
596 static int vhost_vsock_dev_release(struct inode
*inode
, struct file
*file
)
598 struct vhost_vsock
*vsock
= file
->private_data
;
600 spin_lock_bh(&vhost_vsock_lock
);
601 if (vsock
->guest_cid
)
602 hash_del_rcu(&vsock
->hash
);
603 spin_unlock_bh(&vhost_vsock_lock
);
605 /* Wait for other CPUs to finish using vsock */
608 /* Iterating over all connections for all CIDs to find orphans is
609 * inefficient. Room for improvement here. */
610 vsock_for_each_connected_socket(vhost_vsock_reset_orphans
);
612 vhost_vsock_stop(vsock
);
613 vhost_vsock_flush(vsock
);
614 vhost_dev_stop(&vsock
->dev
);
616 spin_lock_bh(&vsock
->send_pkt_list_lock
);
617 while (!list_empty(&vsock
->send_pkt_list
)) {
618 struct virtio_vsock_pkt
*pkt
;
620 pkt
= list_first_entry(&vsock
->send_pkt_list
,
621 struct virtio_vsock_pkt
, list
);
622 list_del_init(&pkt
->list
);
623 virtio_transport_free_pkt(pkt
);
625 spin_unlock_bh(&vsock
->send_pkt_list_lock
);
627 vhost_dev_cleanup(&vsock
->dev
, false);
628 kfree(vsock
->dev
.vqs
);
629 vhost_vsock_free(vsock
);
633 static int vhost_vsock_set_cid(struct vhost_vsock
*vsock
, u64 guest_cid
)
635 struct vhost_vsock
*other
;
637 /* Refuse reserved CIDs */
638 if (guest_cid
<= VMADDR_CID_HOST
||
639 guest_cid
== U32_MAX
)
642 /* 64-bit CIDs are not yet supported */
643 if (guest_cid
> U32_MAX
)
646 /* Refuse if CID is already in use */
647 spin_lock_bh(&vhost_vsock_lock
);
648 other
= vhost_vsock_get(guest_cid
);
649 if (other
&& other
!= vsock
) {
650 spin_unlock_bh(&vhost_vsock_lock
);
654 if (vsock
->guest_cid
)
655 hash_del_rcu(&vsock
->hash
);
657 vsock
->guest_cid
= guest_cid
;
658 hash_add_rcu(vhost_vsock_hash
, &vsock
->hash
, vsock
->guest_cid
);
659 spin_unlock_bh(&vhost_vsock_lock
);
664 static int vhost_vsock_set_features(struct vhost_vsock
*vsock
, u64 features
)
666 struct vhost_virtqueue
*vq
;
669 if (features
& ~VHOST_VSOCK_FEATURES
)
672 mutex_lock(&vsock
->dev
.mutex
);
673 if ((features
& (1 << VHOST_F_LOG_ALL
)) &&
674 !vhost_log_access_ok(&vsock
->dev
)) {
675 mutex_unlock(&vsock
->dev
.mutex
);
679 for (i
= 0; i
< ARRAY_SIZE(vsock
->vqs
); i
++) {
681 mutex_lock(&vq
->mutex
);
682 vq
->acked_features
= features
;
683 mutex_unlock(&vq
->mutex
);
685 mutex_unlock(&vsock
->dev
.mutex
);
689 static long vhost_vsock_dev_ioctl(struct file
*f
, unsigned int ioctl
,
692 struct vhost_vsock
*vsock
= f
->private_data
;
693 void __user
*argp
= (void __user
*)arg
;
700 case VHOST_VSOCK_SET_GUEST_CID
:
701 if (copy_from_user(&guest_cid
, argp
, sizeof(guest_cid
)))
703 return vhost_vsock_set_cid(vsock
, guest_cid
);
704 case VHOST_VSOCK_SET_RUNNING
:
705 if (copy_from_user(&start
, argp
, sizeof(start
)))
708 return vhost_vsock_start(vsock
);
710 return vhost_vsock_stop(vsock
);
711 case VHOST_GET_FEATURES
:
712 features
= VHOST_VSOCK_FEATURES
;
713 if (copy_to_user(argp
, &features
, sizeof(features
)))
716 case VHOST_SET_FEATURES
:
717 if (copy_from_user(&features
, argp
, sizeof(features
)))
719 return vhost_vsock_set_features(vsock
, features
);
721 mutex_lock(&vsock
->dev
.mutex
);
722 r
= vhost_dev_ioctl(&vsock
->dev
, ioctl
, argp
);
723 if (r
== -ENOIOCTLCMD
)
724 r
= vhost_vring_ioctl(&vsock
->dev
, ioctl
, argp
);
726 vhost_vsock_flush(vsock
);
727 mutex_unlock(&vsock
->dev
.mutex
);
732 static const struct file_operations vhost_vsock_fops
= {
733 .owner
= THIS_MODULE
,
734 .open
= vhost_vsock_dev_open
,
735 .release
= vhost_vsock_dev_release
,
736 .llseek
= noop_llseek
,
737 .unlocked_ioctl
= vhost_vsock_dev_ioctl
,
740 static struct miscdevice vhost_vsock_misc
= {
741 .minor
= VHOST_VSOCK_MINOR
,
742 .name
= "vhost-vsock",
743 .fops
= &vhost_vsock_fops
,
746 static struct virtio_transport vhost_transport
= {
748 .get_local_cid
= vhost_transport_get_local_cid
,
750 .init
= virtio_transport_do_socket_init
,
751 .destruct
= virtio_transport_destruct
,
752 .release
= virtio_transport_release
,
753 .connect
= virtio_transport_connect
,
754 .shutdown
= virtio_transport_shutdown
,
755 .cancel_pkt
= vhost_transport_cancel_pkt
,
757 .dgram_enqueue
= virtio_transport_dgram_enqueue
,
758 .dgram_dequeue
= virtio_transport_dgram_dequeue
,
759 .dgram_bind
= virtio_transport_dgram_bind
,
760 .dgram_allow
= virtio_transport_dgram_allow
,
762 .stream_enqueue
= virtio_transport_stream_enqueue
,
763 .stream_dequeue
= virtio_transport_stream_dequeue
,
764 .stream_has_data
= virtio_transport_stream_has_data
,
765 .stream_has_space
= virtio_transport_stream_has_space
,
766 .stream_rcvhiwat
= virtio_transport_stream_rcvhiwat
,
767 .stream_is_active
= virtio_transport_stream_is_active
,
768 .stream_allow
= virtio_transport_stream_allow
,
770 .notify_poll_in
= virtio_transport_notify_poll_in
,
771 .notify_poll_out
= virtio_transport_notify_poll_out
,
772 .notify_recv_init
= virtio_transport_notify_recv_init
,
773 .notify_recv_pre_block
= virtio_transport_notify_recv_pre_block
,
774 .notify_recv_pre_dequeue
= virtio_transport_notify_recv_pre_dequeue
,
775 .notify_recv_post_dequeue
= virtio_transport_notify_recv_post_dequeue
,
776 .notify_send_init
= virtio_transport_notify_send_init
,
777 .notify_send_pre_block
= virtio_transport_notify_send_pre_block
,
778 .notify_send_pre_enqueue
= virtio_transport_notify_send_pre_enqueue
,
779 .notify_send_post_enqueue
= virtio_transport_notify_send_post_enqueue
,
781 .set_buffer_size
= virtio_transport_set_buffer_size
,
782 .set_min_buffer_size
= virtio_transport_set_min_buffer_size
,
783 .set_max_buffer_size
= virtio_transport_set_max_buffer_size
,
784 .get_buffer_size
= virtio_transport_get_buffer_size
,
785 .get_min_buffer_size
= virtio_transport_get_min_buffer_size
,
786 .get_max_buffer_size
= virtio_transport_get_max_buffer_size
,
789 .send_pkt
= vhost_transport_send_pkt
,
792 static int __init
vhost_vsock_init(void)
796 ret
= vsock_core_init(&vhost_transport
.transport
);
799 return misc_register(&vhost_vsock_misc
);
802 static void __exit
vhost_vsock_exit(void)
804 misc_deregister(&vhost_vsock_misc
);
808 module_init(vhost_vsock_init
);
809 module_exit(vhost_vsock_exit
);
810 MODULE_LICENSE("GPL v2");
811 MODULE_AUTHOR("Asias He");
812 MODULE_DESCRIPTION("vhost transport for vsock ");
813 MODULE_ALIAS_MISCDEV(VHOST_VSOCK_MINOR
);
814 MODULE_ALIAS("devname:vhost-vsock");