Step 1: Fix kernel/5235.
http://article.gmane.org/gmane.os.openbsd.bugs/8586
has a suggestion.
Step 2: Add the diff below as
/usr/ports/emulators/qemu/patches/patch-block_c
Step 3: Install the port, then
qemu -cdrom /dev/cd0a -boot d -m 32
--- block.c.orig Mon Sep 11 21:36:19 2006
+++ block.c Mon Sep 11 22:02:11 2006
@@ -30,6 +30,7 @@
#include <sys/ioctl.h>
#include <sys/queue.h>
#include <sys/disk.h>
+#include <sys/disklabel.h>
#endif
#ifdef CONFIG_COCOA
@@ -671,6 +672,7 @@
int64_t size;
#ifdef _BSD
struct stat sb;
+ struct disklabel lab;
#endif
#ifdef __sun__
struct dk_minfo minfo;
@@ -685,36 +687,10 @@
bs->read_only = 1;
}
#ifdef _BSD
- if (!fstat(fd, &sb) && (S_IFCHR & sb.st_mode)) {
-#ifdef DIOCGMEDIASIZE
- if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size))
-#endif
-#ifdef CONFIG_COCOA
- size = LONG_LONG_MAX;
-#else
- size = lseek(fd, 0LL, SEEK_END);
-#endif
- } else
-#endif
-#ifdef __sun__
- /*
- * use the DKIOCGMEDIAINFO ioctl to read the size.
- */
- rv = ioctl ( fd, DKIOCGMEDIAINFO, &minfo );
- if ( rv != -1 ) {
- size = minfo.dki_lbsize * minfo.dki_capacity;
- } else /* there are reports that lseek on some devices
- fails, but irc discussion said that contingency
- on contingency was overkill */
-#endif
- {
- size = lseek(fd, 0, SEEK_END);
- }
-#ifdef _WIN32
- /* On Windows hosts it can happen that we're unable to get file size
- for CD-ROM raw device (it's inherent limitation of the CDFS driver). */
- if (size == -1)
- size = LONG_LONG_MAX;
+ if (0 == fstat(fd, &sb) && S_IFBLK == (S_IFBLK & sb.st_mode) && 1 !=
ioctl(fd, DIOCGDINFO, &lab))
+ size = lab.d_secsize * lab.d_secperunit;
+ else
+ size = lseek(fd, 0, SEEK_END);
#endif
bs->total_sectors = size / 512;
s->fd = fd;