aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/lguest/lguest.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/Documentation/lguest/lguest.c b/Documentation/lguest/lguest.c
index f2668390e8f7..42008395534d 100644
--- a/Documentation/lguest/lguest.c
+++ b/Documentation/lguest/lguest.c
@@ -62,8 +62,8 @@ typedef uint8_t u8;
62#endif 62#endif
63/* We can have up to 256 pages for devices. */ 63/* We can have up to 256 pages for devices. */
64#define DEVICE_PAGES 256 64#define DEVICE_PAGES 256
65/* This fits nicely in a single 4096-byte page. */ 65/* This will occupy 2 pages: it must be a power of 2. */
66#define VIRTQUEUE_NUM 127 66#define VIRTQUEUE_NUM 128
67 67
68/*L:120 verbose is both a global flag and a macro. The C preprocessor allows 68/*L:120 verbose is both a global flag and a macro. The C preprocessor allows
69 * this, and although I wouldn't recommend it, it works quite nicely here. */ 69 * this, and although I wouldn't recommend it, it works quite nicely here. */
@@ -1036,7 +1036,8 @@ static void add_virtqueue(struct device *dev, unsigned int num_descs,
1036 void *p; 1036 void *p;
1037 1037
1038 /* First we need some pages for this virtqueue. */ 1038 /* First we need some pages for this virtqueue. */
1039 pages = (vring_size(num_descs) + getpagesize() - 1) / getpagesize(); 1039 pages = (vring_size(num_descs, getpagesize()) + getpagesize() - 1)
1040 / getpagesize();
1040 p = get_pages(pages); 1041 p = get_pages(pages);
1041 1042
1042 /* Initialize the configuration. */ 1043 /* Initialize the configuration. */
@@ -1045,7 +1046,7 @@ static void add_virtqueue(struct device *dev, unsigned int num_descs,
1045 vq->config.pfn = to_guest_phys(p) / getpagesize(); 1046 vq->config.pfn = to_guest_phys(p) / getpagesize();
1046 1047
1047 /* Initialize the vring. */ 1048 /* Initialize the vring. */
1048 vring_init(&vq->vring, num_descs, p); 1049 vring_init(&vq->vring, num_descs, p, getpagesize());
1049 1050
1050 /* Add the configuration information to this device's descriptor. */ 1051 /* Add the configuration information to this device's descriptor. */
1051 add_desc_field(dev, VIRTIO_CONFIG_F_VIRTQUEUE, 1052 add_desc_field(dev, VIRTIO_CONFIG_F_VIRTQUEUE,
@@ -1342,7 +1343,7 @@ static bool service_io(struct device *dev)
1342 if (out->type & VIRTIO_BLK_T_SCSI_CMD) { 1343 if (out->type & VIRTIO_BLK_T_SCSI_CMD) {
1343 fprintf(stderr, "Scsi commands unsupported\n"); 1344 fprintf(stderr, "Scsi commands unsupported\n");
1344 in->status = VIRTIO_BLK_S_UNSUPP; 1345 in->status = VIRTIO_BLK_S_UNSUPP;
1345 wlen = sizeof(in); 1346 wlen = sizeof(*in);
1346 } else if (out->type & VIRTIO_BLK_T_OUT) { 1347 } else if (out->type & VIRTIO_BLK_T_OUT) {
1347 /* Write */ 1348 /* Write */
1348 1349
@@ -1363,7 +1364,7 @@ static bool service_io(struct device *dev)
1363 /* Die, bad Guest, die. */ 1364 /* Die, bad Guest, die. */
1364 errx(1, "Write past end %llu+%u", off, ret); 1365 errx(1, "Write past end %llu+%u", off, ret);
1365 } 1366 }
1366 wlen = sizeof(in); 1367 wlen = sizeof(*in);
1367 in->status = (ret >= 0 ? VIRTIO_BLK_S_OK : VIRTIO_BLK_S_IOERR); 1368 in->status = (ret >= 0 ? VIRTIO_BLK_S_OK : VIRTIO_BLK_S_IOERR);
1368 } else { 1369 } else {
1369 /* Read */ 1370 /* Read */
@@ -1376,10 +1377,10 @@ static bool service_io(struct device *dev)
1376 ret = readv(vblk->fd, iov+1, in_num-1); 1377 ret = readv(vblk->fd, iov+1, in_num-1);
1377 verbose("READ from sector %llu: %i\n", out->sector, ret); 1378 verbose("READ from sector %llu: %i\n", out->sector, ret);
1378 if (ret >= 0) { 1379 if (ret >= 0) {
1379 wlen = sizeof(in) + ret; 1380 wlen = sizeof(*in) + ret;
1380 in->status = VIRTIO_BLK_S_OK; 1381 in->status = VIRTIO_BLK_S_OK;
1381 } else { 1382 } else {
1382 wlen = sizeof(in); 1383 wlen = sizeof(*in);
1383 in->status = VIRTIO_BLK_S_IOERR; 1384 in->status = VIRTIO_BLK_S_IOERR;
1384 } 1385 }
1385 } 1386 }