From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HTqiV-0001PY-KU for qemu-devel@nongnu.org; Tue, 20 Mar 2007 22:38:23 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HTqiT-0001PJ-IC for qemu-devel@nongnu.org; Tue, 20 Mar 2007 22:38:22 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HTqiT-0001PG-Cr for qemu-devel@nongnu.org; Tue, 20 Mar 2007 21:38:21 -0500 Received: from pf.freedaemonhosting.com ([66.210.104.252] helo=FreeDaemonHosting.com) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HTqgp-0007pK-PY for qemu-devel@nongnu.org; Tue, 20 Mar 2007 22:36:40 -0400 Received: from blue.fries.net (blue.hse.fries.net [IPv6:2001:240:58a::1c]) by FreeDaemonHosting.com (8.13.8/8.13.3) with ESMTP id l2L2a4Fu018791 for ; Tue, 20 Mar 2007 21:36:04 -0500 (CDT) Received: from blue.fries.net (localhost.fries.net [IPv6:::1]) by blue.fries.net (8.14.0/8.13.6) with ESMTP id l2L2ZsL8016515 for ; Tue, 20 Mar 2007 21:35:54 -0500 (CDT) Received: (from todd@localhost) by blue.fries.net (8.14.0/8.13.6/Submit) id l2L2ZsLp011532 for qemu-devel@nongnu.org; Tue, 20 Mar 2007 21:35:54 -0500 (CDT) Date: Tue, 20 Mar 2007 21:35:54 -0500 From: "Todd T. Fries" Message-ID: <20070321023552.GA24325@fries.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] Patch: block-raw.c for OpenBSD Reply-To: todd@fries.net, qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is relative to the 20070319 snapshot, mostly from Enache Adrian, 3n4ch3 at gmail dot com .. --- block-raw.c.orig Mon Mar 12 16:16:47 2007 +++ block-raw.c Tue Mar 20 19:16:43 2007 @@ -25,7 +25,9 @@ #include "block_int.h" #include #ifndef _WIN32 +#ifndef CONFIG_NO_AIO #include +#endif #ifndef QEMU_TOOL #include "exec-all.h" @@ -53,10 +55,16 @@ #include #include #endif -#ifdef __FreeBSD__ +#ifdef __FreeBSD__ #include #endif +#ifdef __OpenBSD__ +#include +#include +#include +#endif + //#define DEBUG_FLOPPY #define FTYPE_FILE 0 @@ -158,6 +166,7 @@ static int raw_pwrite(BlockDriverState * } /***********************************************************/ +#ifndef CONFIG_NO_AIO /* Unix AIO using POSIX AIO */ typedef struct RawAIOCB { @@ -380,6 +389,37 @@ static void raw_aio_cancel(BlockDriverAI } } +# else /* !CONFIG_NO_AIO */ + +void qemu_aio_init(void) +{ +} + +void qemu_aio_poll(void) +{ +} + +void qemu_aio_flush(void) +{ +} + +void qemu_aio_wait_start(void) +{ +} + +void qemu_aio_wait(void) +{ +#ifndef QEMU_TOOL + qemu_bh_poll(); +#endif +} + +void qemu_aio_wait_end(void) +{ +} + +#endif /* !CONFIG_NO_AIO */ + static void raw_close(BlockDriverState *bs) { BDRVRawState *s = bs->opaque; @@ -399,8 +439,25 @@ static int raw_truncate(BlockDriverState return 0; } +#ifdef __OpenBSD__ static int64_t raw_getlength(BlockDriverState *bs) { + int fd = ((BDRVRawState*)bs->opaque)->fd; + struct stat st; + if(fstat(fd, &st)) + return -1; + if(S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)){ + struct disklabel dl; + if(ioctl(fd, DIOCGDINFO, &dl)) + return -1; + return (uint64_t)dl.d_secsize * + dl.d_partitions[DISKPART(st.st_rdev)].p_size; + }else + return st.st_size; +} +#else /* !__OpenBSD__ */ +static int64_t raw_getlength(BlockDriverState *bs) +{ BDRVRawState *s = bs->opaque; int fd = s->fd; int64_t size; @@ -445,6 +502,7 @@ static int64_t raw_getlength(BlockDrive } return size; } +#endif static int raw_create(const char *filename, int64_t total_size, const char *backing_file, int flags) @@ -479,11 +537,13 @@ BlockDriver bdrv_raw = { raw_close, raw_create, raw_flush, - + +#ifndef CONFIG_NO_AIO .bdrv_aio_read = raw_aio_read, .bdrv_aio_write = raw_aio_write, .bdrv_aio_cancel = raw_aio_cancel, .aiocb_size = sizeof(RawAIOCB), +#endif /* !CONFIG_NO_AIO */ .protocol_name = "file", .bdrv_pread = raw_pread, .bdrv_pwrite = raw_pwrite, @@ -815,11 +875,13 @@ BlockDriver bdrv_host_device = { raw_close, NULL, raw_flush, - + +#ifndef CONFIG_NO_AIO .bdrv_aio_read = raw_aio_read, .bdrv_aio_write = raw_aio_write, .bdrv_aio_cancel = raw_aio_cancel, .aiocb_size = sizeof(RawAIOCB), +#endif /* !CONFIG_NO_AIO */ .bdrv_pread = raw_pread, .bdrv_pwrite = raw_pwrite, .bdrv_getlength = raw_getlength, -- Todd Fries .. todd@fries.net _____________________________________________ | \ 1.636.410.0632 (voice) | Free Daemon Consulting, LLC \ 1.405.227.9094 (voice) | http://FreeDaemonConsulting.com \ 1.866.792.3418 (FAX) | "..in support of free software solutions." \ 250797 (FWD) | \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 37E7 D3EB 74D0 8D66 A68D B866 0326 204E 3F42 004A http://todd.fries.net/pgp.txt