Thomas Gleixner | 7a33847 | 2019-06-04 10:11:15 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 2 | /* |
| 3 | * vhost transport for vsock |
| 4 | * |
| 5 | * Copyright (C) 2013-2015 Red Hat, Inc. |
| 6 | * Author: Asias He <asias@redhat.com> |
| 7 | * Stefan Hajnoczi <stefanha@redhat.com> |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 8 | */ |
| 9 | #include <linux/miscdevice.h> |
| 10 | #include <linux/atomic.h> |
| 11 | #include <linux/module.h> |
| 12 | #include <linux/mutex.h> |
| 13 | #include <linux/vmalloc.h> |
| 14 | #include <net/sock.h> |
| 15 | #include <linux/virtio_vsock.h> |
| 16 | #include <linux/vhost.h> |
Stefan Hajnoczi | 834e772 | 2018-11-05 10:35:47 +0000 | [diff] [blame] | 17 | #include <linux/hashtable.h> |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 18 | |
| 19 | #include <net/af_vsock.h> |
| 20 | #include "vhost.h" |
| 21 | |
| 22 | #define VHOST_VSOCK_DEFAULT_HOST_CID 2 |
Jason Wang | e82b9b0 | 2019-05-17 00:29:49 -0400 | [diff] [blame] | 23 | /* Max number of bytes transferred before requeueing the job. |
| 24 | * Using this limit prevents one virtqueue from starving others. */ |
| 25 | #define VHOST_VSOCK_WEIGHT 0x80000 |
| 26 | /* Max number of packets transferred before requeueing the job. |
| 27 | * Using this limit prevents one virtqueue from starving others with |
| 28 | * small pkts. |
| 29 | */ |
| 30 | #define VHOST_VSOCK_PKT_WEIGHT 256 |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 31 | |
| 32 | enum { |
| 33 | VHOST_VSOCK_FEATURES = VHOST_FEATURES, |
| 34 | }; |
| 35 | |
| 36 | /* Used to track all the vhost_vsock instances on the system. */ |
Stefan Hajnoczi | 6db3d8d | 2018-11-05 17:33:22 +0000 | [diff] [blame] | 37 | static DEFINE_MUTEX(vhost_vsock_mutex); |
Stefan Hajnoczi | 834e772 | 2018-11-05 10:35:47 +0000 | [diff] [blame] | 38 | static DEFINE_READ_MOSTLY_HASHTABLE(vhost_vsock_hash, 8); |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 39 | |
| 40 | struct vhost_vsock { |
| 41 | struct vhost_dev dev; |
| 42 | struct vhost_virtqueue vqs[2]; |
| 43 | |
Stefan Hajnoczi | 6db3d8d | 2018-11-05 17:33:22 +0000 | [diff] [blame] | 44 | /* Link to global vhost_vsock_hash, writes use vhost_vsock_mutex */ |
Stefan Hajnoczi | 834e772 | 2018-11-05 10:35:47 +0000 | [diff] [blame] | 45 | struct hlist_node hash; |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 46 | |
| 47 | struct vhost_work send_pkt_work; |
| 48 | spinlock_t send_pkt_list_lock; |
| 49 | struct list_head send_pkt_list; /* host->guest pending packets */ |
| 50 | |
| 51 | atomic_t queued_replies; |
| 52 | |
| 53 | u32 guest_cid; |
| 54 | }; |
| 55 | |
| 56 | static u32 vhost_transport_get_local_cid(void) |
| 57 | { |
| 58 | return VHOST_VSOCK_DEFAULT_HOST_CID; |
| 59 | } |
| 60 | |
Stefan Hajnoczi | 6db3d8d | 2018-11-05 17:33:22 +0000 | [diff] [blame] | 61 | /* Callers that dereference the return value must hold vhost_vsock_mutex or the |
Stefan Hajnoczi | 834e772 | 2018-11-05 10:35:47 +0000 | [diff] [blame] | 62 | * RCU read lock. |
| 63 | */ |
| 64 | static struct vhost_vsock *vhost_vsock_get(u32 guest_cid) |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 65 | { |
| 66 | struct vhost_vsock *vsock; |
| 67 | |
Stefan Hajnoczi | 834e772 | 2018-11-05 10:35:47 +0000 | [diff] [blame] | 68 | hash_for_each_possible_rcu(vhost_vsock_hash, vsock, hash, guest_cid) { |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 69 | u32 other_cid = vsock->guest_cid; |
| 70 | |
| 71 | /* Skip instances that have no CID yet */ |
| 72 | if (other_cid == 0) |
| 73 | continue; |
| 74 | |
Vaibhav Murkute | ff3c1b1 | 2018-03-09 08:26:03 +0530 | [diff] [blame] | 75 | if (other_cid == guest_cid) |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 76 | return vsock; |
Vaibhav Murkute | ff3c1b1 | 2018-03-09 08:26:03 +0530 | [diff] [blame] | 77 | |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 78 | } |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 79 | |
| 80 | return NULL; |
| 81 | } |
| 82 | |
| 83 | static void |
| 84 | vhost_transport_do_send_pkt(struct vhost_vsock *vsock, |
| 85 | struct vhost_virtqueue *vq) |
| 86 | { |
| 87 | struct vhost_virtqueue *tx_vq = &vsock->vqs[VSOCK_VQ_TX]; |
Jason Wang | e79b431 | 2019-05-17 00:29:51 -0400 | [diff] [blame] | 88 | int pkts = 0, total_len = 0; |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 89 | bool added = false; |
| 90 | bool restart_tx = false; |
| 91 | |
| 92 | mutex_lock(&vq->mutex); |
| 93 | |
| 94 | if (!vq->private_data) |
| 95 | goto out; |
| 96 | |
| 97 | /* Avoid further vmexits, we're already processing the virtqueue */ |
| 98 | vhost_disable_notify(&vsock->dev, vq); |
| 99 | |
Jason Wang | e79b431 | 2019-05-17 00:29:51 -0400 | [diff] [blame] | 100 | do { |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 101 | struct virtio_vsock_pkt *pkt; |
| 102 | struct iov_iter iov_iter; |
| 103 | unsigned out, in; |
| 104 | size_t nbytes; |
| 105 | size_t len; |
| 106 | int head; |
| 107 | |
| 108 | spin_lock_bh(&vsock->send_pkt_list_lock); |
| 109 | if (list_empty(&vsock->send_pkt_list)) { |
| 110 | spin_unlock_bh(&vsock->send_pkt_list_lock); |
| 111 | vhost_enable_notify(&vsock->dev, vq); |
| 112 | break; |
| 113 | } |
| 114 | |
| 115 | pkt = list_first_entry(&vsock->send_pkt_list, |
| 116 | struct virtio_vsock_pkt, list); |
| 117 | list_del_init(&pkt->list); |
| 118 | spin_unlock_bh(&vsock->send_pkt_list_lock); |
| 119 | |
| 120 | head = vhost_get_vq_desc(vq, vq->iov, ARRAY_SIZE(vq->iov), |
| 121 | &out, &in, NULL, NULL); |
| 122 | if (head < 0) { |
| 123 | spin_lock_bh(&vsock->send_pkt_list_lock); |
| 124 | list_add(&pkt->list, &vsock->send_pkt_list); |
| 125 | spin_unlock_bh(&vsock->send_pkt_list_lock); |
| 126 | break; |
| 127 | } |
| 128 | |
| 129 | if (head == vq->num) { |
| 130 | spin_lock_bh(&vsock->send_pkt_list_lock); |
| 131 | list_add(&pkt->list, &vsock->send_pkt_list); |
| 132 | spin_unlock_bh(&vsock->send_pkt_list_lock); |
| 133 | |
| 134 | /* We cannot finish yet if more buffers snuck in while |
| 135 | * re-enabling notify. |
| 136 | */ |
| 137 | if (unlikely(vhost_enable_notify(&vsock->dev, vq))) { |
| 138 | vhost_disable_notify(&vsock->dev, vq); |
| 139 | continue; |
| 140 | } |
| 141 | break; |
| 142 | } |
| 143 | |
| 144 | if (out) { |
| 145 | virtio_transport_free_pkt(pkt); |
| 146 | vq_err(vq, "Expected 0 output buffers, got %u\n", out); |
| 147 | break; |
| 148 | } |
| 149 | |
| 150 | len = iov_length(&vq->iov[out], in); |
| 151 | iov_iter_init(&iov_iter, READ, &vq->iov[out], in, len); |
| 152 | |
| 153 | nbytes = copy_to_iter(&pkt->hdr, sizeof(pkt->hdr), &iov_iter); |
| 154 | if (nbytes != sizeof(pkt->hdr)) { |
| 155 | virtio_transport_free_pkt(pkt); |
| 156 | vq_err(vq, "Faulted on copying pkt hdr\n"); |
| 157 | break; |
| 158 | } |
| 159 | |
| 160 | nbytes = copy_to_iter(pkt->buf, pkt->len, &iov_iter); |
| 161 | if (nbytes != pkt->len) { |
| 162 | virtio_transport_free_pkt(pkt); |
| 163 | vq_err(vq, "Faulted on copying pkt buf\n"); |
| 164 | break; |
| 165 | } |
| 166 | |
| 167 | vhost_add_used(vq, head, sizeof(pkt->hdr) + pkt->len); |
| 168 | added = true; |
| 169 | |
| 170 | if (pkt->reply) { |
| 171 | int val; |
| 172 | |
| 173 | val = atomic_dec_return(&vsock->queued_replies); |
| 174 | |
| 175 | /* Do we have resources to resume tx processing? */ |
| 176 | if (val + 1 == tx_vq->num) |
| 177 | restart_tx = true; |
| 178 | } |
| 179 | |
Gerard Garcia | 82dfb540 | 2017-04-21 10:10:46 +0100 | [diff] [blame] | 180 | /* Deliver to monitoring devices all correctly transmitted |
| 181 | * packets. |
| 182 | */ |
| 183 | virtio_transport_deliver_tap_pkt(pkt); |
| 184 | |
Jason Wang | e79b431 | 2019-05-17 00:29:51 -0400 | [diff] [blame] | 185 | total_len += pkt->len; |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 186 | virtio_transport_free_pkt(pkt); |
Jason Wang | e79b431 | 2019-05-17 00:29:51 -0400 | [diff] [blame] | 187 | } while(likely(!vhost_exceeds_weight(vq, ++pkts, total_len))); |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 188 | if (added) |
| 189 | vhost_signal(&vsock->dev, vq); |
| 190 | |
| 191 | out: |
| 192 | mutex_unlock(&vq->mutex); |
| 193 | |
| 194 | if (restart_tx) |
| 195 | vhost_poll_queue(&tx_vq->poll); |
| 196 | } |
| 197 | |
| 198 | static void vhost_transport_send_pkt_work(struct vhost_work *work) |
| 199 | { |
| 200 | struct vhost_virtqueue *vq; |
| 201 | struct vhost_vsock *vsock; |
| 202 | |
| 203 | vsock = container_of(work, struct vhost_vsock, send_pkt_work); |
| 204 | vq = &vsock->vqs[VSOCK_VQ_RX]; |
| 205 | |
| 206 | vhost_transport_do_send_pkt(vsock, vq); |
| 207 | } |
| 208 | |
| 209 | static int |
| 210 | vhost_transport_send_pkt(struct virtio_vsock_pkt *pkt) |
| 211 | { |
| 212 | struct vhost_vsock *vsock; |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 213 | int len = pkt->len; |
| 214 | |
Stefan Hajnoczi | 834e772 | 2018-11-05 10:35:47 +0000 | [diff] [blame] | 215 | rcu_read_lock(); |
| 216 | |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 217 | /* Find the vhost_vsock according to guest context id */ |
| 218 | vsock = vhost_vsock_get(le64_to_cpu(pkt->hdr.dst_cid)); |
| 219 | if (!vsock) { |
Stefan Hajnoczi | 834e772 | 2018-11-05 10:35:47 +0000 | [diff] [blame] | 220 | rcu_read_unlock(); |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 221 | virtio_transport_free_pkt(pkt); |
| 222 | return -ENODEV; |
| 223 | } |
| 224 | |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 225 | if (pkt->reply) |
| 226 | atomic_inc(&vsock->queued_replies); |
| 227 | |
| 228 | spin_lock_bh(&vsock->send_pkt_list_lock); |
| 229 | list_add_tail(&pkt->list, &vsock->send_pkt_list); |
| 230 | spin_unlock_bh(&vsock->send_pkt_list_lock); |
| 231 | |
| 232 | vhost_work_queue(&vsock->dev, &vsock->send_pkt_work); |
Stefan Hajnoczi | 834e772 | 2018-11-05 10:35:47 +0000 | [diff] [blame] | 233 | |
| 234 | rcu_read_unlock(); |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 235 | return len; |
| 236 | } |
| 237 | |
Peng Tao | 16320f3 | 2017-03-15 09:32:15 +0800 | [diff] [blame] | 238 | static int |
| 239 | vhost_transport_cancel_pkt(struct vsock_sock *vsk) |
| 240 | { |
| 241 | struct vhost_vsock *vsock; |
| 242 | struct virtio_vsock_pkt *pkt, *n; |
| 243 | int cnt = 0; |
Stefan Hajnoczi | 834e772 | 2018-11-05 10:35:47 +0000 | [diff] [blame] | 244 | int ret = -ENODEV; |
Peng Tao | 16320f3 | 2017-03-15 09:32:15 +0800 | [diff] [blame] | 245 | LIST_HEAD(freeme); |
| 246 | |
Stefan Hajnoczi | 834e772 | 2018-11-05 10:35:47 +0000 | [diff] [blame] | 247 | rcu_read_lock(); |
| 248 | |
Peng Tao | 16320f3 | 2017-03-15 09:32:15 +0800 | [diff] [blame] | 249 | /* Find the vhost_vsock according to guest context id */ |
| 250 | vsock = vhost_vsock_get(vsk->remote_addr.svm_cid); |
| 251 | if (!vsock) |
Stefan Hajnoczi | 834e772 | 2018-11-05 10:35:47 +0000 | [diff] [blame] | 252 | goto out; |
Peng Tao | 16320f3 | 2017-03-15 09:32:15 +0800 | [diff] [blame] | 253 | |
| 254 | spin_lock_bh(&vsock->send_pkt_list_lock); |
| 255 | list_for_each_entry_safe(pkt, n, &vsock->send_pkt_list, list) { |
| 256 | if (pkt->vsk != vsk) |
| 257 | continue; |
| 258 | list_move(&pkt->list, &freeme); |
| 259 | } |
| 260 | spin_unlock_bh(&vsock->send_pkt_list_lock); |
| 261 | |
| 262 | list_for_each_entry_safe(pkt, n, &freeme, list) { |
| 263 | if (pkt->reply) |
| 264 | cnt++; |
| 265 | list_del(&pkt->list); |
| 266 | virtio_transport_free_pkt(pkt); |
| 267 | } |
| 268 | |
| 269 | if (cnt) { |
| 270 | struct vhost_virtqueue *tx_vq = &vsock->vqs[VSOCK_VQ_TX]; |
| 271 | int new_cnt; |
| 272 | |
| 273 | new_cnt = atomic_sub_return(cnt, &vsock->queued_replies); |
| 274 | if (new_cnt + cnt >= tx_vq->num && new_cnt < tx_vq->num) |
| 275 | vhost_poll_queue(&tx_vq->poll); |
| 276 | } |
| 277 | |
Stefan Hajnoczi | 834e772 | 2018-11-05 10:35:47 +0000 | [diff] [blame] | 278 | ret = 0; |
| 279 | out: |
| 280 | rcu_read_unlock(); |
| 281 | return ret; |
Peng Tao | 16320f3 | 2017-03-15 09:32:15 +0800 | [diff] [blame] | 282 | } |
| 283 | |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 284 | static struct virtio_vsock_pkt * |
| 285 | vhost_vsock_alloc_pkt(struct vhost_virtqueue *vq, |
| 286 | unsigned int out, unsigned int in) |
| 287 | { |
| 288 | struct virtio_vsock_pkt *pkt; |
| 289 | struct iov_iter iov_iter; |
| 290 | size_t nbytes; |
| 291 | size_t len; |
| 292 | |
| 293 | if (in != 0) { |
| 294 | vq_err(vq, "Expected 0 input buffers, got %u\n", in); |
| 295 | return NULL; |
| 296 | } |
| 297 | |
| 298 | pkt = kzalloc(sizeof(*pkt), GFP_KERNEL); |
| 299 | if (!pkt) |
| 300 | return NULL; |
| 301 | |
| 302 | len = iov_length(vq->iov, out); |
| 303 | iov_iter_init(&iov_iter, WRITE, vq->iov, out, len); |
| 304 | |
| 305 | nbytes = copy_from_iter(&pkt->hdr, sizeof(pkt->hdr), &iov_iter); |
| 306 | if (nbytes != sizeof(pkt->hdr)) { |
| 307 | vq_err(vq, "Expected %zu bytes for pkt->hdr, got %zu bytes\n", |
| 308 | sizeof(pkt->hdr), nbytes); |
| 309 | kfree(pkt); |
| 310 | return NULL; |
| 311 | } |
| 312 | |
| 313 | if (le16_to_cpu(pkt->hdr.type) == VIRTIO_VSOCK_TYPE_STREAM) |
| 314 | pkt->len = le32_to_cpu(pkt->hdr.len); |
| 315 | |
| 316 | /* No payload */ |
| 317 | if (!pkt->len) |
| 318 | return pkt; |
| 319 | |
| 320 | /* The pkt is too big */ |
| 321 | if (pkt->len > VIRTIO_VSOCK_MAX_PKT_BUF_SIZE) { |
| 322 | kfree(pkt); |
| 323 | return NULL; |
| 324 | } |
| 325 | |
| 326 | pkt->buf = kmalloc(pkt->len, GFP_KERNEL); |
| 327 | if (!pkt->buf) { |
| 328 | kfree(pkt); |
| 329 | return NULL; |
| 330 | } |
| 331 | |
Stefano Garzarella | 473c739 | 2019-07-30 17:43:30 +0200 | [diff] [blame^] | 332 | pkt->buf_len = pkt->len; |
| 333 | |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 334 | nbytes = copy_from_iter(pkt->buf, pkt->len, &iov_iter); |
| 335 | if (nbytes != pkt->len) { |
| 336 | vq_err(vq, "Expected %u byte payload, got %zu bytes\n", |
| 337 | pkt->len, nbytes); |
| 338 | virtio_transport_free_pkt(pkt); |
| 339 | return NULL; |
| 340 | } |
| 341 | |
| 342 | return pkt; |
| 343 | } |
| 344 | |
| 345 | /* Is there space left for replies to rx packets? */ |
| 346 | static bool vhost_vsock_more_replies(struct vhost_vsock *vsock) |
| 347 | { |
| 348 | struct vhost_virtqueue *vq = &vsock->vqs[VSOCK_VQ_TX]; |
| 349 | int val; |
| 350 | |
| 351 | smp_rmb(); /* paired with atomic_inc() and atomic_dec_return() */ |
| 352 | val = atomic_read(&vsock->queued_replies); |
| 353 | |
| 354 | return val < vq->num; |
| 355 | } |
| 356 | |
| 357 | static void vhost_vsock_handle_tx_kick(struct vhost_work *work) |
| 358 | { |
| 359 | struct vhost_virtqueue *vq = container_of(work, struct vhost_virtqueue, |
| 360 | poll.work); |
| 361 | struct vhost_vsock *vsock = container_of(vq->dev, struct vhost_vsock, |
| 362 | dev); |
| 363 | struct virtio_vsock_pkt *pkt; |
Jason Wang | e79b431 | 2019-05-17 00:29:51 -0400 | [diff] [blame] | 364 | int head, pkts = 0, total_len = 0; |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 365 | unsigned int out, in; |
| 366 | bool added = false; |
| 367 | |
| 368 | mutex_lock(&vq->mutex); |
| 369 | |
| 370 | if (!vq->private_data) |
| 371 | goto out; |
| 372 | |
| 373 | vhost_disable_notify(&vsock->dev, vq); |
Jason Wang | e79b431 | 2019-05-17 00:29:51 -0400 | [diff] [blame] | 374 | do { |
Stefan Hajnoczi | 3fda5d6 | 2016-08-04 14:52:53 +0100 | [diff] [blame] | 375 | u32 len; |
| 376 | |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 377 | if (!vhost_vsock_more_replies(vsock)) { |
| 378 | /* Stop tx until the device processes already |
| 379 | * pending replies. Leave tx virtqueue |
| 380 | * callbacks disabled. |
| 381 | */ |
| 382 | goto no_more_replies; |
| 383 | } |
| 384 | |
| 385 | head = vhost_get_vq_desc(vq, vq->iov, ARRAY_SIZE(vq->iov), |
| 386 | &out, &in, NULL, NULL); |
| 387 | if (head < 0) |
| 388 | break; |
| 389 | |
| 390 | if (head == vq->num) { |
| 391 | if (unlikely(vhost_enable_notify(&vsock->dev, vq))) { |
| 392 | vhost_disable_notify(&vsock->dev, vq); |
| 393 | continue; |
| 394 | } |
| 395 | break; |
| 396 | } |
| 397 | |
| 398 | pkt = vhost_vsock_alloc_pkt(vq, out, in); |
| 399 | if (!pkt) { |
| 400 | vq_err(vq, "Faulted on pkt\n"); |
| 401 | continue; |
| 402 | } |
| 403 | |
Stefan Hajnoczi | 3fda5d6 | 2016-08-04 14:52:53 +0100 | [diff] [blame] | 404 | len = pkt->len; |
| 405 | |
Gerard Garcia | 82dfb540 | 2017-04-21 10:10:46 +0100 | [diff] [blame] | 406 | /* Deliver to monitoring devices all received packets */ |
| 407 | virtio_transport_deliver_tap_pkt(pkt); |
| 408 | |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 409 | /* Only accept correctly addressed packets */ |
| 410 | if (le64_to_cpu(pkt->hdr.src_cid) == vsock->guest_cid) |
| 411 | virtio_transport_recv_pkt(pkt); |
| 412 | else |
| 413 | virtio_transport_free_pkt(pkt); |
| 414 | |
Jason Wang | e79b431 | 2019-05-17 00:29:51 -0400 | [diff] [blame] | 415 | len += sizeof(pkt->hdr); |
| 416 | vhost_add_used(vq, head, len); |
| 417 | total_len += len; |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 418 | added = true; |
Jason Wang | e79b431 | 2019-05-17 00:29:51 -0400 | [diff] [blame] | 419 | } while(likely(!vhost_exceeds_weight(vq, ++pkts, total_len))); |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 420 | |
| 421 | no_more_replies: |
| 422 | if (added) |
| 423 | vhost_signal(&vsock->dev, vq); |
| 424 | |
| 425 | out: |
| 426 | mutex_unlock(&vq->mutex); |
| 427 | } |
| 428 | |
| 429 | static void vhost_vsock_handle_rx_kick(struct vhost_work *work) |
| 430 | { |
| 431 | struct vhost_virtqueue *vq = container_of(work, struct vhost_virtqueue, |
| 432 | poll.work); |
| 433 | struct vhost_vsock *vsock = container_of(vq->dev, struct vhost_vsock, |
| 434 | dev); |
| 435 | |
| 436 | vhost_transport_do_send_pkt(vsock, vq); |
| 437 | } |
| 438 | |
| 439 | static int vhost_vsock_start(struct vhost_vsock *vsock) |
| 440 | { |
Stefan Hajnoczi | 0516ffd | 2017-01-19 10:43:53 +0000 | [diff] [blame] | 441 | struct vhost_virtqueue *vq; |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 442 | size_t i; |
| 443 | int ret; |
| 444 | |
| 445 | mutex_lock(&vsock->dev.mutex); |
| 446 | |
| 447 | ret = vhost_dev_check_owner(&vsock->dev); |
| 448 | if (ret) |
| 449 | goto err; |
| 450 | |
| 451 | for (i = 0; i < ARRAY_SIZE(vsock->vqs); i++) { |
Stefan Hajnoczi | 0516ffd | 2017-01-19 10:43:53 +0000 | [diff] [blame] | 452 | vq = &vsock->vqs[i]; |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 453 | |
| 454 | mutex_lock(&vq->mutex); |
| 455 | |
| 456 | if (!vhost_vq_access_ok(vq)) { |
| 457 | ret = -EFAULT; |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 458 | goto err_vq; |
| 459 | } |
| 460 | |
| 461 | if (!vq->private_data) { |
| 462 | vq->private_data = vsock; |
Stefan Hajnoczi | 0516ffd | 2017-01-19 10:43:53 +0000 | [diff] [blame] | 463 | ret = vhost_vq_init_access(vq); |
| 464 | if (ret) |
| 465 | goto err_vq; |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 466 | } |
| 467 | |
| 468 | mutex_unlock(&vq->mutex); |
| 469 | } |
| 470 | |
| 471 | mutex_unlock(&vsock->dev.mutex); |
| 472 | return 0; |
| 473 | |
| 474 | err_vq: |
Stefan Hajnoczi | 0516ffd | 2017-01-19 10:43:53 +0000 | [diff] [blame] | 475 | vq->private_data = NULL; |
| 476 | mutex_unlock(&vq->mutex); |
| 477 | |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 478 | for (i = 0; i < ARRAY_SIZE(vsock->vqs); i++) { |
Stefan Hajnoczi | 0516ffd | 2017-01-19 10:43:53 +0000 | [diff] [blame] | 479 | vq = &vsock->vqs[i]; |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 480 | |
| 481 | mutex_lock(&vq->mutex); |
| 482 | vq->private_data = NULL; |
| 483 | mutex_unlock(&vq->mutex); |
| 484 | } |
| 485 | err: |
| 486 | mutex_unlock(&vsock->dev.mutex); |
| 487 | return ret; |
| 488 | } |
| 489 | |
| 490 | static int vhost_vsock_stop(struct vhost_vsock *vsock) |
| 491 | { |
| 492 | size_t i; |
| 493 | int ret; |
| 494 | |
| 495 | mutex_lock(&vsock->dev.mutex); |
| 496 | |
| 497 | ret = vhost_dev_check_owner(&vsock->dev); |
| 498 | if (ret) |
| 499 | goto err; |
| 500 | |
| 501 | for (i = 0; i < ARRAY_SIZE(vsock->vqs); i++) { |
| 502 | struct vhost_virtqueue *vq = &vsock->vqs[i]; |
| 503 | |
| 504 | mutex_lock(&vq->mutex); |
| 505 | vq->private_data = NULL; |
| 506 | mutex_unlock(&vq->mutex); |
| 507 | } |
| 508 | |
| 509 | err: |
| 510 | mutex_unlock(&vsock->dev.mutex); |
| 511 | return ret; |
| 512 | } |
| 513 | |
| 514 | static void vhost_vsock_free(struct vhost_vsock *vsock) |
| 515 | { |
Wei Yongjun | b226aca | 2016-08-02 13:50:42 +0000 | [diff] [blame] | 516 | kvfree(vsock); |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 517 | } |
| 518 | |
| 519 | static int vhost_vsock_dev_open(struct inode *inode, struct file *file) |
| 520 | { |
| 521 | struct vhost_virtqueue **vqs; |
| 522 | struct vhost_vsock *vsock; |
| 523 | int ret; |
| 524 | |
| 525 | /* This struct is large and allocation could fail, fall back to vmalloc |
| 526 | * if there is no other way. |
| 527 | */ |
Michal Hocko | dcda9b0 | 2017-07-12 14:36:45 -0700 | [diff] [blame] | 528 | vsock = kvmalloc(sizeof(*vsock), GFP_KERNEL | __GFP_RETRY_MAYFAIL); |
Michal Hocko | 6c5ab65 | 2017-05-08 15:57:15 -0700 | [diff] [blame] | 529 | if (!vsock) |
| 530 | return -ENOMEM; |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 531 | |
| 532 | vqs = kmalloc_array(ARRAY_SIZE(vsock->vqs), sizeof(*vqs), GFP_KERNEL); |
| 533 | if (!vqs) { |
| 534 | ret = -ENOMEM; |
| 535 | goto out; |
| 536 | } |
| 537 | |
Stefan Hajnoczi | a72b69d | 2017-11-09 13:29:10 +0000 | [diff] [blame] | 538 | vsock->guest_cid = 0; /* no CID assigned yet */ |
| 539 | |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 540 | atomic_set(&vsock->queued_replies, 0); |
| 541 | |
| 542 | vqs[VSOCK_VQ_TX] = &vsock->vqs[VSOCK_VQ_TX]; |
| 543 | vqs[VSOCK_VQ_RX] = &vsock->vqs[VSOCK_VQ_RX]; |
| 544 | vsock->vqs[VSOCK_VQ_TX].handle_kick = vhost_vsock_handle_tx_kick; |
| 545 | vsock->vqs[VSOCK_VQ_RX].handle_kick = vhost_vsock_handle_rx_kick; |
| 546 | |
Jason Wang | e82b9b0 | 2019-05-17 00:29:49 -0400 | [diff] [blame] | 547 | vhost_dev_init(&vsock->dev, vqs, ARRAY_SIZE(vsock->vqs), |
| 548 | UIO_MAXIOV, VHOST_VSOCK_PKT_WEIGHT, |
| 549 | VHOST_VSOCK_WEIGHT); |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 550 | |
| 551 | file->private_data = vsock; |
| 552 | spin_lock_init(&vsock->send_pkt_list_lock); |
| 553 | INIT_LIST_HEAD(&vsock->send_pkt_list); |
| 554 | vhost_work_init(&vsock->send_pkt_work, vhost_transport_send_pkt_work); |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 555 | return 0; |
| 556 | |
| 557 | out: |
| 558 | vhost_vsock_free(vsock); |
| 559 | return ret; |
| 560 | } |
| 561 | |
| 562 | static void vhost_vsock_flush(struct vhost_vsock *vsock) |
| 563 | { |
| 564 | int i; |
| 565 | |
| 566 | for (i = 0; i < ARRAY_SIZE(vsock->vqs); i++) |
| 567 | if (vsock->vqs[i].handle_kick) |
| 568 | vhost_poll_flush(&vsock->vqs[i].poll); |
| 569 | vhost_work_flush(&vsock->dev, &vsock->send_pkt_work); |
| 570 | } |
| 571 | |
| 572 | static void vhost_vsock_reset_orphans(struct sock *sk) |
| 573 | { |
| 574 | struct vsock_sock *vsk = vsock_sk(sk); |
| 575 | |
| 576 | /* vmci_transport.c doesn't take sk_lock here either. At least we're |
| 577 | * under vsock_table_lock so the sock cannot disappear while we're |
| 578 | * executing. |
| 579 | */ |
| 580 | |
Stefan Hajnoczi | c38f57d | 2018-12-06 19:14:34 +0000 | [diff] [blame] | 581 | /* If the peer is still valid, no need to reset connection */ |
| 582 | if (vhost_vsock_get(vsk->remote_addr.svm_cid)) |
| 583 | return; |
| 584 | |
| 585 | /* If the close timeout is pending, let it expire. This avoids races |
| 586 | * with the timeout callback. |
| 587 | */ |
| 588 | if (vsk->close_work_scheduled) |
| 589 | return; |
| 590 | |
| 591 | sock_set_flag(sk, SOCK_DONE); |
| 592 | vsk->peer_shutdown = SHUTDOWN_MASK; |
| 593 | sk->sk_state = SS_UNCONNECTED; |
| 594 | sk->sk_err = ECONNRESET; |
| 595 | sk->sk_error_report(sk); |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 596 | } |
| 597 | |
| 598 | static int vhost_vsock_dev_release(struct inode *inode, struct file *file) |
| 599 | { |
| 600 | struct vhost_vsock *vsock = file->private_data; |
| 601 | |
Stefan Hajnoczi | 6db3d8d | 2018-11-05 17:33:22 +0000 | [diff] [blame] | 602 | mutex_lock(&vhost_vsock_mutex); |
Stefan Hajnoczi | 834e772 | 2018-11-05 10:35:47 +0000 | [diff] [blame] | 603 | if (vsock->guest_cid) |
| 604 | hash_del_rcu(&vsock->hash); |
Stefan Hajnoczi | 6db3d8d | 2018-11-05 17:33:22 +0000 | [diff] [blame] | 605 | mutex_unlock(&vhost_vsock_mutex); |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 606 | |
Stefan Hajnoczi | 834e772 | 2018-11-05 10:35:47 +0000 | [diff] [blame] | 607 | /* Wait for other CPUs to finish using vsock */ |
| 608 | synchronize_rcu(); |
| 609 | |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 610 | /* Iterating over all connections for all CIDs to find orphans is |
| 611 | * inefficient. Room for improvement here. */ |
| 612 | vsock_for_each_connected_socket(vhost_vsock_reset_orphans); |
| 613 | |
| 614 | vhost_vsock_stop(vsock); |
| 615 | vhost_vsock_flush(vsock); |
| 616 | vhost_dev_stop(&vsock->dev); |
| 617 | |
| 618 | spin_lock_bh(&vsock->send_pkt_list_lock); |
| 619 | while (!list_empty(&vsock->send_pkt_list)) { |
| 620 | struct virtio_vsock_pkt *pkt; |
| 621 | |
| 622 | pkt = list_first_entry(&vsock->send_pkt_list, |
| 623 | struct virtio_vsock_pkt, list); |
| 624 | list_del_init(&pkt->list); |
| 625 | virtio_transport_free_pkt(pkt); |
| 626 | } |
| 627 | spin_unlock_bh(&vsock->send_pkt_list_lock); |
| 628 | |
夷则(Caspar) | f6f93f7 | 2017-12-25 00:08:58 +0800 | [diff] [blame] | 629 | vhost_dev_cleanup(&vsock->dev); |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 630 | kfree(vsock->dev.vqs); |
| 631 | vhost_vsock_free(vsock); |
| 632 | return 0; |
| 633 | } |
| 634 | |
| 635 | static int vhost_vsock_set_cid(struct vhost_vsock *vsock, u64 guest_cid) |
| 636 | { |
| 637 | struct vhost_vsock *other; |
| 638 | |
| 639 | /* Refuse reserved CIDs */ |
| 640 | if (guest_cid <= VMADDR_CID_HOST || |
| 641 | guest_cid == U32_MAX) |
| 642 | return -EINVAL; |
| 643 | |
| 644 | /* 64-bit CIDs are not yet supported */ |
| 645 | if (guest_cid > U32_MAX) |
| 646 | return -EINVAL; |
| 647 | |
| 648 | /* Refuse if CID is already in use */ |
Stefan Hajnoczi | 6db3d8d | 2018-11-05 17:33:22 +0000 | [diff] [blame] | 649 | mutex_lock(&vhost_vsock_mutex); |
Stefan Hajnoczi | 834e772 | 2018-11-05 10:35:47 +0000 | [diff] [blame] | 650 | other = vhost_vsock_get(guest_cid); |
Gao feng | 6c083c2 | 2016-12-14 19:24:36 +0800 | [diff] [blame] | 651 | if (other && other != vsock) { |
Stefan Hajnoczi | 6db3d8d | 2018-11-05 17:33:22 +0000 | [diff] [blame] | 652 | mutex_unlock(&vhost_vsock_mutex); |
Gao feng | 6c083c2 | 2016-12-14 19:24:36 +0800 | [diff] [blame] | 653 | return -EADDRINUSE; |
| 654 | } |
Stefan Hajnoczi | 834e772 | 2018-11-05 10:35:47 +0000 | [diff] [blame] | 655 | |
| 656 | if (vsock->guest_cid) |
| 657 | hash_del_rcu(&vsock->hash); |
| 658 | |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 659 | vsock->guest_cid = guest_cid; |
Zha Bin | 7fbe078 | 2019-01-08 16:07:03 +0800 | [diff] [blame] | 660 | hash_add_rcu(vhost_vsock_hash, &vsock->hash, vsock->guest_cid); |
Stefan Hajnoczi | 6db3d8d | 2018-11-05 17:33:22 +0000 | [diff] [blame] | 661 | mutex_unlock(&vhost_vsock_mutex); |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 662 | |
| 663 | return 0; |
| 664 | } |
| 665 | |
| 666 | static int vhost_vsock_set_features(struct vhost_vsock *vsock, u64 features) |
| 667 | { |
| 668 | struct vhost_virtqueue *vq; |
| 669 | int i; |
| 670 | |
| 671 | if (features & ~VHOST_VSOCK_FEATURES) |
| 672 | return -EOPNOTSUPP; |
| 673 | |
| 674 | mutex_lock(&vsock->dev.mutex); |
| 675 | if ((features & (1 << VHOST_F_LOG_ALL)) && |
| 676 | !vhost_log_access_ok(&vsock->dev)) { |
| 677 | mutex_unlock(&vsock->dev.mutex); |
| 678 | return -EFAULT; |
| 679 | } |
| 680 | |
| 681 | for (i = 0; i < ARRAY_SIZE(vsock->vqs); i++) { |
| 682 | vq = &vsock->vqs[i]; |
| 683 | mutex_lock(&vq->mutex); |
| 684 | vq->acked_features = features; |
| 685 | mutex_unlock(&vq->mutex); |
| 686 | } |
| 687 | mutex_unlock(&vsock->dev.mutex); |
| 688 | return 0; |
| 689 | } |
| 690 | |
| 691 | static long vhost_vsock_dev_ioctl(struct file *f, unsigned int ioctl, |
| 692 | unsigned long arg) |
| 693 | { |
| 694 | struct vhost_vsock *vsock = f->private_data; |
| 695 | void __user *argp = (void __user *)arg; |
| 696 | u64 guest_cid; |
| 697 | u64 features; |
| 698 | int start; |
| 699 | int r; |
| 700 | |
| 701 | switch (ioctl) { |
| 702 | case VHOST_VSOCK_SET_GUEST_CID: |
| 703 | if (copy_from_user(&guest_cid, argp, sizeof(guest_cid))) |
| 704 | return -EFAULT; |
| 705 | return vhost_vsock_set_cid(vsock, guest_cid); |
| 706 | case VHOST_VSOCK_SET_RUNNING: |
| 707 | if (copy_from_user(&start, argp, sizeof(start))) |
| 708 | return -EFAULT; |
| 709 | if (start) |
| 710 | return vhost_vsock_start(vsock); |
| 711 | else |
| 712 | return vhost_vsock_stop(vsock); |
| 713 | case VHOST_GET_FEATURES: |
| 714 | features = VHOST_VSOCK_FEATURES; |
| 715 | if (copy_to_user(argp, &features, sizeof(features))) |
| 716 | return -EFAULT; |
| 717 | return 0; |
| 718 | case VHOST_SET_FEATURES: |
| 719 | if (copy_from_user(&features, argp, sizeof(features))) |
| 720 | return -EFAULT; |
| 721 | return vhost_vsock_set_features(vsock, features); |
| 722 | default: |
| 723 | mutex_lock(&vsock->dev.mutex); |
| 724 | r = vhost_dev_ioctl(&vsock->dev, ioctl, argp); |
| 725 | if (r == -ENOIOCTLCMD) |
| 726 | r = vhost_vring_ioctl(&vsock->dev, ioctl, argp); |
| 727 | else |
| 728 | vhost_vsock_flush(vsock); |
| 729 | mutex_unlock(&vsock->dev.mutex); |
| 730 | return r; |
| 731 | } |
| 732 | } |
| 733 | |
Sonny Rao | dc32bb6 | 2018-03-14 14:36:25 -0700 | [diff] [blame] | 734 | #ifdef CONFIG_COMPAT |
| 735 | static long vhost_vsock_dev_compat_ioctl(struct file *f, unsigned int ioctl, |
| 736 | unsigned long arg) |
| 737 | { |
| 738 | return vhost_vsock_dev_ioctl(f, ioctl, (unsigned long)compat_ptr(arg)); |
| 739 | } |
| 740 | #endif |
| 741 | |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 742 | static const struct file_operations vhost_vsock_fops = { |
| 743 | .owner = THIS_MODULE, |
| 744 | .open = vhost_vsock_dev_open, |
| 745 | .release = vhost_vsock_dev_release, |
| 746 | .llseek = noop_llseek, |
| 747 | .unlocked_ioctl = vhost_vsock_dev_ioctl, |
Sonny Rao | dc32bb6 | 2018-03-14 14:36:25 -0700 | [diff] [blame] | 748 | #ifdef CONFIG_COMPAT |
| 749 | .compat_ioctl = vhost_vsock_dev_compat_ioctl, |
| 750 | #endif |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 751 | }; |
| 752 | |
| 753 | static struct miscdevice vhost_vsock_misc = { |
Stefan Hajnoczi | f4660cc | 2017-05-10 10:19:18 -0400 | [diff] [blame] | 754 | .minor = VHOST_VSOCK_MINOR, |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 755 | .name = "vhost-vsock", |
| 756 | .fops = &vhost_vsock_fops, |
| 757 | }; |
| 758 | |
| 759 | static struct virtio_transport vhost_transport = { |
| 760 | .transport = { |
| 761 | .get_local_cid = vhost_transport_get_local_cid, |
| 762 | |
| 763 | .init = virtio_transport_do_socket_init, |
| 764 | .destruct = virtio_transport_destruct, |
| 765 | .release = virtio_transport_release, |
| 766 | .connect = virtio_transport_connect, |
| 767 | .shutdown = virtio_transport_shutdown, |
Peng Tao | 16320f3 | 2017-03-15 09:32:15 +0800 | [diff] [blame] | 768 | .cancel_pkt = vhost_transport_cancel_pkt, |
Asias He | 433fc58 | 2016-07-28 15:36:34 +0100 | [diff] [blame] | 769 | |
| 770 | .dgram_enqueue = virtio_transport_dgram_enqueue, |
| 771 | .dgram_dequeue = virtio_transport_dgram_dequeue, |
| 772 | .dgram_bind = virtio_transport_dgram_bind, |
| 773 | .dgram_allow = virtio_transport_dgram_allow, |
| 774 | |
| 775 | .stream_enqueue = virtio_transport_stream_enqueue, |
| 776 | .stream_dequeue = virtio_transport_stream_dequeue, |
| 777 | .stream_has_data = virtio_transport_stream_has_data, |
| 778 | .stream_has_space = virtio_transport_stream_has_space, |
| 779 | .stream_rcvhiwat = virtio_transport_stream_rcvhiwat, |
| 780 | .stream_is_active = virtio_transport_stream_is_active, |
| 781 | .stream_allow = virtio_transport_stream_allow, |
| 782 | |
| 783 | .notify_poll_in = virtio_transport_notify_poll_in, |
| 784 | .notify_poll_out = virtio_transport_notify_poll_out, |
| 785 | .notify_recv_init = virtio_transport_notify_recv_init, |
| 786 | .notify_recv_pre_block = virtio_transport_notify_recv_pre_block, |
| 787 | .notify_recv_pre_dequeue = virtio_transport_notify_recv_pre_dequeue, |
| 788 | .notify_recv_post_dequeue = virtio_transport_notify_recv_post_dequeue, |
| 789 | .notify_send_init = virtio_transport_notify_send_init, |
| 790 | .notify_send_pre_block = virtio_transport_notify_send_pre_block, |
| 791 | .notify_send_pre_enqueue = virtio_transport_notify_send_pre_enqueue, |
| 792 | .notify_send_post_enqueue = virtio_transport_notify_send_post_enqueue, |
| 793 | |
| 794 | .set_buffer_size = virtio_transport_set_buffer_size, |
| 795 | .set_min_buffer_size = virtio_transport_set_min_buffer_size, |
| 796 | .set_max_buffer_size = virtio_transport_set_max_buffer_size, |
| 797 | .get_buffer_size = virtio_transport_get_buffer_size, |
| 798 | .get_min_buffer_size = virtio_transport_get_min_buffer_size, |
| 799 | .get_max_buffer_size = virtio_transport_get_max_buffer_size, |
| 800 | }, |
| 801 | |
| 802 | .send_pkt = vhost_transport_send_pkt, |
| 803 | }; |
| 804 | |
| 805 | static int __init vhost_vsock_init(void) |
| 806 | { |
| 807 | int ret; |
| 808 | |
| 809 | ret = vsock_core_init(&vhost_transport.transport); |
| 810 | if (ret < 0) |
| 811 | return ret; |
| 812 | return misc_register(&vhost_vsock_misc); |
| 813 | }; |
| 814 | |
| 815 | static void __exit vhost_vsock_exit(void) |
| 816 | { |
| 817 | misc_deregister(&vhost_vsock_misc); |
| 818 | vsock_core_exit(); |
| 819 | }; |
| 820 | |
| 821 | module_init(vhost_vsock_init); |
| 822 | module_exit(vhost_vsock_exit); |
| 823 | MODULE_LICENSE("GPL v2"); |
| 824 | MODULE_AUTHOR("Asias He"); |
| 825 | MODULE_DESCRIPTION("vhost transport for vsock "); |
Stefan Hajnoczi | f4660cc | 2017-05-10 10:19:18 -0400 | [diff] [blame] | 826 | MODULE_ALIAS_MISCDEV(VHOST_VSOCK_MINOR); |
| 827 | MODULE_ALIAS("devname:vhost-vsock"); |