Skip to content

Commit

Permalink
Partial support for raw devices
Browse files Browse the repository at this point in the history
Support for using virtual disk images.

Example:

```
hdiutil create -megabytes 20 -fs "MS-DOS" disk
hdiutil attach disk.dmg // Get disk number N
xhyve ... -s 4:0,ahci-hd,/dev/rdiskN ...
```

Signed-off-by: Johannes Würbach <[email protected]>
  • Loading branch information
johanneswuerbach committed Nov 4, 2016
1 parent 8975f80 commit fdda0f7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
7 changes: 4 additions & 3 deletions hyperkit.1
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,9 @@ hyperkit -s 0,hostbridge -s 1,lpc -s 2:0,virtio-net,tap0 \\
-A -H -P -m 24G -f fbsd,userboot.so,bootvolume.img,"" \\
.Ed
.Pp
Run an 8GB quad-CPU virtual machine with 8 AHCI SATA disks, an AHCI ATAPI
CD-ROM, a single virtio network port, an AMD hostbridge, and the console
port connected to an
Run an 8GB quad-CPU virtual machine with 8 AHCI SATA disks, a raw AHCI SATA volume,
an AHCI ATAPI CD-ROM, a single virtio network port, an AMD hostbridge,
and the console port connected to an
.Xr nmdm 4
null-modem device.
.Bd -literal -offset indent
Expand All @@ -347,6 +347,7 @@ hyperkit -c 4 \\
-s 1:5,ahci-hd,/images/disk.6 \\
-s 1:6,ahci-hd,/images/disk.7 \\
-s 1:7,ahci-hd,/images/disk.8 \\
-s 1:8,ahci-hd,/dev/rdisk2 \\
-s 2,ahci-cd,/images/install.iso \\
-s 3,virtio-net,tap0 \\
-l com1,/dev/nmdm0A \\
Expand Down
17 changes: 12 additions & 5 deletions src/lib/block_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ blockif_open(const char *optstr, const char *ident)
struct blockif_ctxt *bc;
struct stat sbuf;
// struct diocgattr_arg arg;
off_t size, psectsz, psectoff;
off_t size, psectsz, psectoff, blocks;
int extra, fd, i, sectsz;
int nocache, sync, ro, candelete, geom, ssopt, pssopt;
mirage_block_handle mbh;
Expand Down Expand Up @@ -653,8 +653,17 @@ blockif_open(const char *optstr, const char *ident)
if (ioctl(fd, DIOCGPROVIDERNAME, name) == 0)
geom = 1;
#else
perror("xhyve: raw device support unimplemented");
goto err;
blocks = 0;
if (ioctl(fd, DKIOCGETBLOCKCOUNT, &blocks) < 0 ||
ioctl(fd, DKIOCGETBLOCKSIZE, &sectsz)) {
perror("Could not fetch dev blk/sector size");
goto err;
}

assert(blocks != 0);
assert(sectsz != 0);

size = blocks * sectsz;
#endif
} else
psectsz = sbuf.st_blksize;
Expand All @@ -667,7 +676,6 @@ blockif_open(const char *optstr, const char *ident)
goto err;
}

#ifdef __FreeBSD__
/*
* Some backend drivers (e.g. cd0, ada0) require that the I/O
* size be a multiple of the device's sector size.
Expand All @@ -683,7 +691,6 @@ blockif_open(const char *optstr, const char *ident)
goto err;
}
}
#endif

sectsz = ssopt;
psectsz = pssopt;
Expand Down

0 comments on commit fdda0f7

Please sign in to comment.