summaryrefslogtreecommitdiff
path: root/usr.sbin/vmd/vioscsi.c
diff options
context:
space:
mode:
authorccardenas <ccardenas@cvs.openbsd.org>2018-08-25 04:16:10 +0000
committerccardenas <ccardenas@cvs.openbsd.org>2018-08-25 04:16:10 +0000
commitdd9263b5dc3b32c9b3edaa5fb7015fdfe2cb5bd5 (patch)
tree44c7ae21c8198be7d3c913df97280eca0c57165e /usr.sbin/vmd/vioscsi.c
parentebe752276c8af29818c0c11ab6bab7284c003056 (diff)
Rework disks to have pluggable backends.
This is prep work for adding qcow2 image support. From Ori Bernstein. Many thanks! Tested by many. OK ccardenas@
Diffstat (limited to 'usr.sbin/vmd/vioscsi.c')
-rw-r--r--usr.sbin/vmd/vioscsi.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.sbin/vmd/vioscsi.c b/usr.sbin/vmd/vioscsi.c
index 93867887598..12fef2f4778 100644
--- a/usr.sbin/vmd/vioscsi.c
+++ b/usr.sbin/vmd/vioscsi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vioscsi.c,v 1.10 2018/07/15 20:25:52 ccardenas Exp $ */
+/* $OpenBSD: vioscsi.c,v 1.11 2018/08/25 04:16:09 ccardenas Exp $ */
/*
* Copyright (c) 2017 Carlos Cardenas <ccardenas@openbsd.org>
@@ -197,7 +197,7 @@ vioscsi_start_read(struct vioscsi_dev *dev, off_t block, ssize_t n_blocks)
goto nomem;
info->len = n_blocks * VIOSCSI_BLOCK_SIZE_CDROM;
info->offset = block * VIOSCSI_BLOCK_SIZE_CDROM;
- info->fd = dev->fd;
+ info->file = &dev->file;
return info;
@@ -210,7 +210,10 @@ nomem:
static const uint8_t *
vioscsi_finish_read(struct ioinfo *info)
{
- if (pread(info->fd, info->buf, info->len, info->offset) != info->len) {
+ struct virtio_backing *f;
+
+ f = info->file;
+ if (f->pread(f->p, info->buf, info->len, info->offset) != info->len) {
info->error = errno;
log_warn("vioscsi read error");
return NULL;