test.c (42249094f79422fbf5ed4b54eeb48ff096809b8f) | test.c (59566b6e8cc8f8a05022e0f01a1b90974003f092) |
---|---|
1/* Copyright (C) 2009 Red Hat, Inc. 2 * Author: Michael S. Tsirkin <mst@redhat.com> 3 * 4 * This work is licensed under the terms of the GNU GPL, version 2. 5 * 6 * test virtio server in host kernel. 7 */ 8 --- 90 unchanged lines hidden (view full) --- 99 handle_vq(n); 100} 101 102static int vhost_test_open(struct inode *inode, struct file *f) 103{ 104 struct vhost_test *n = kmalloc(sizeof *n, GFP_KERNEL); 105 struct vhost_dev *dev; 106 struct vhost_virtqueue **vqs; | 1/* Copyright (C) 2009 Red Hat, Inc. 2 * Author: Michael S. Tsirkin <mst@redhat.com> 3 * 4 * This work is licensed under the terms of the GNU GPL, version 2. 5 * 6 * test virtio server in host kernel. 7 */ 8 --- 90 unchanged lines hidden (view full) --- 99 handle_vq(n); 100} 101 102static int vhost_test_open(struct inode *inode, struct file *f) 103{ 104 struct vhost_test *n = kmalloc(sizeof *n, GFP_KERNEL); 105 struct vhost_dev *dev; 106 struct vhost_virtqueue **vqs; |
107 int r; | |
108 109 if (!n) 110 return -ENOMEM; 111 vqs = kmalloc(VHOST_TEST_VQ_MAX * sizeof(*vqs), GFP_KERNEL); 112 if (!vqs) { 113 kfree(n); 114 return -ENOMEM; 115 } 116 117 dev = &n->dev; 118 vqs[VHOST_TEST_VQ] = &n->vqs[VHOST_TEST_VQ]; 119 n->vqs[VHOST_TEST_VQ].handle_kick = handle_vq_kick; | 107 108 if (!n) 109 return -ENOMEM; 110 vqs = kmalloc(VHOST_TEST_VQ_MAX * sizeof(*vqs), GFP_KERNEL); 111 if (!vqs) { 112 kfree(n); 113 return -ENOMEM; 114 } 115 116 dev = &n->dev; 117 vqs[VHOST_TEST_VQ] = &n->vqs[VHOST_TEST_VQ]; 118 n->vqs[VHOST_TEST_VQ].handle_kick = handle_vq_kick; |
120 r = vhost_dev_init(dev, vqs, VHOST_TEST_VQ_MAX); 121 if (r < 0) { 122 kfree(vqs); 123 kfree(n); 124 return r; 125 } | 119 vhost_dev_init(dev, vqs, VHOST_TEST_VQ_MAX); |
126 127 f->private_data = n; 128 129 return 0; 130} 131 132static void *vhost_test_stop_vq(struct vhost_test *n, 133 struct vhost_virtqueue *vq) --- 208 unchanged lines hidden --- | 120 121 f->private_data = n; 122 123 return 0; 124} 125 126static void *vhost_test_stop_vq(struct vhost_test *n, 127 struct vhost_virtqueue *vq) --- 208 unchanged lines hidden --- |