Commit 1200e646 authored by Anthony Liguori's avatar Anthony Liguori Committed by Rusty Russell

lguest: Fix lguest virtio-blk backend size computation

This seems like an obvious typo but it's worked in the past because the virtio
blk frontend just ignores the length field on completion.
Signed-off-by: default avatarAnthony Liguori <aliguori@us.ibm.com>
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent 1bc4953e
...@@ -1342,7 +1342,7 @@ static bool service_io(struct device *dev) ...@@ -1342,7 +1342,7 @@ static bool service_io(struct device *dev)
if (out->type & VIRTIO_BLK_T_SCSI_CMD) { if (out->type & VIRTIO_BLK_T_SCSI_CMD) {
fprintf(stderr, "Scsi commands unsupported\n"); fprintf(stderr, "Scsi commands unsupported\n");
in->status = VIRTIO_BLK_S_UNSUPP; in->status = VIRTIO_BLK_S_UNSUPP;
wlen = sizeof(in); wlen = sizeof(*in);
} else if (out->type & VIRTIO_BLK_T_OUT) { } else if (out->type & VIRTIO_BLK_T_OUT) {
/* Write */ /* Write */
...@@ -1363,7 +1363,7 @@ static bool service_io(struct device *dev) ...@@ -1363,7 +1363,7 @@ static bool service_io(struct device *dev)
/* Die, bad Guest, die. */ /* Die, bad Guest, die. */
errx(1, "Write past end %llu+%u", off, ret); errx(1, "Write past end %llu+%u", off, ret);
} }
wlen = sizeof(in); wlen = sizeof(*in);
in->status = (ret >= 0 ? VIRTIO_BLK_S_OK : VIRTIO_BLK_S_IOERR); in->status = (ret >= 0 ? VIRTIO_BLK_S_OK : VIRTIO_BLK_S_IOERR);
} else { } else {
/* Read */ /* Read */
...@@ -1376,10 +1376,10 @@ static bool service_io(struct device *dev) ...@@ -1376,10 +1376,10 @@ static bool service_io(struct device *dev)
ret = readv(vblk->fd, iov+1, in_num-1); ret = readv(vblk->fd, iov+1, in_num-1);
verbose("READ from sector %llu: %i\n", out->sector, ret); verbose("READ from sector %llu: %i\n", out->sector, ret);
if (ret >= 0) { if (ret >= 0) {
wlen = sizeof(in) + ret; wlen = sizeof(*in) + ret;
in->status = VIRTIO_BLK_S_OK; in->status = VIRTIO_BLK_S_OK;
} else { } else {
wlen = sizeof(in); wlen = sizeof(*in);
in->status = VIRTIO_BLK_S_IOERR; in->status = VIRTIO_BLK_S_IOERR;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment