From owner-freebsd-emulation@FreeBSD.ORG Sat Sep 27 22:53:36 2008 Return-Path: Delivered-To: freebsd-emulation@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C2441106568B for ; Sat, 27 Sep 2008 22:53:36 +0000 (UTC) (envelope-from nox@saturn.kn-bremen.de) Received: from gwyn.kn-bremen.de (gwyn.kn-bremen.de [212.63.36.242]) by mx1.freebsd.org (Postfix) with ESMTP id 4CA108FC16 for ; Sat, 27 Sep 2008 22:53:36 +0000 (UTC) (envelope-from nox@saturn.kn-bremen.de) Received: by gwyn.kn-bremen.de (Postfix, from userid 10) id 809B3191A39; Sun, 28 Sep 2008 00:53:34 +0200 (CEST) Received: from saturn.kn-bremen.de (noident@localhost [127.0.0.1]) by saturn.kn-bremen.de (8.14.2/8.13.8) with ESMTP id m8RMq6WD057050; Sun, 28 Sep 2008 00:52:06 +0200 (CEST) (envelope-from nox@saturn.kn-bremen.de) Received: (from nox@localhost) by saturn.kn-bremen.de (8.14.2/8.13.6/Submit) id m8RMq4fu057049; Sun, 28 Sep 2008 00:52:04 +0200 (CEST) (envelope-from nox) Date: Sun, 28 Sep 2008 00:52:04 +0200 (CEST) From: Juergen Lock Message-Id: <200809272252.m8RMq4fu057049@saturn.kn-bremen.de> To: anthony@codemonkey.ws X-Newsgroups: local.list.qemu In-Reply-To: <48DE5256.5000101@codemonkey.ws> References: <20080921204025.GA81055@saturn.kn-bremen.de> <200809242210.m8OMAcSZ021572@saturn.kn-bremen.de> <48DCF9FC.2070708@codemonkey.ws> <20080926220445.GA13099@saturn.kn-bremen.de> Organization: home Cc: freebsd-emulation@freebsd.org, qemu-devel@nongnu.org Subject: Re: [Qemu-devel] Re: qemu svn r5281 on FreeBSD - slow usb, vmwarevga, screen updates... (now updated to r5313) X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Sep 2008 22:53:36 -0000 In article <48DE5256.5000101@codemonkey.ws> you write: >[...] >>> The one thing that really tripped me up with the whole aio kld-module >>> thing. Perhaps we should detect the presence of the module at run time and >>> disable aio? I assume kldload can only be run as root? >>> >> >> Yes. Atm the ports print a warning when aio is not loaded: >> > >Yeah, I don't think this is enough. I'd rather see AIO be disabled when >modfind("aio") is not available (printing a warning along with that >would be fine). A non-privileged user cannot load the aio module so >it's not very useful to tell them to load it. OK so how about the following? (only tested with a raw image, but if the way its disabled for OpenBSD works for all of them this should as well.) Oh and am I right qemu-img doesn't use aio? If it actually does we may want to add the same check there instead of just disabling it. (I kept it enabled for qemu-nbd since thats not built on FreeBSD anyway.) Index: qemu/block.h @@ -50,10 +50,9 @@ #define BDRV_O_DIRECT 0x0020 #define BDRV_O_AUTOGROW 0x0040 /* Allow backing file to extend when writing past end of file */ -void bdrv_info(void); +void bdrv_init(int emulate_aio); void bdrv_info_stats(void); -void bdrv_init(void); BlockDriver *bdrv_find_format(const char *format_name); int bdrv_create(BlockDriver *drv, const char *filename, int64_t size_in_sectors, Index: qemu/block.c @@ -177,9 +177,9 @@ } -static void bdrv_register(BlockDriver *bdrv) +static void bdrv_register(BlockDriver *bdrv, int emulate_aio) { - if (!bdrv->bdrv_aio_read) { + if (!bdrv->bdrv_aio_read || emulate_aio) { /* add AIO emulation layer */ bdrv->bdrv_aio_read = bdrv_aio_read_em; bdrv->bdrv_aio_write = bdrv_aio_write_em; @@ -1374,23 +1374,23 @@ return async_ret; } -void bdrv_init(void) +void bdrv_init(int emulate_aio) { - bdrv_register(&bdrv_raw); - bdrv_register(&bdrv_host_device); + bdrv_register(&bdrv_raw, emulate_aio); + bdrv_register(&bdrv_host_device, 0); #ifndef _WIN32 - bdrv_register(&bdrv_cow); + bdrv_register(&bdrv_cow, 0); #endif - bdrv_register(&bdrv_qcow); - bdrv_register(&bdrv_vmdk); - bdrv_register(&bdrv_cloop); - bdrv_register(&bdrv_dmg); - bdrv_register(&bdrv_bochs); - bdrv_register(&bdrv_vpc); - bdrv_register(&bdrv_vvfat); - bdrv_register(&bdrv_qcow2); - bdrv_register(&bdrv_parallels); - bdrv_register(&bdrv_nbd); + bdrv_register(&bdrv_qcow, 0); + bdrv_register(&bdrv_vmdk, 0); + bdrv_register(&bdrv_cloop, 0); + bdrv_register(&bdrv_dmg, 0); + bdrv_register(&bdrv_bochs, 0); + bdrv_register(&bdrv_vpc, 0); + bdrv_register(&bdrv_vvfat, 0); + bdrv_register(&bdrv_qcow2, 0); + bdrv_register(&bdrv_parallels, 0); + bdrv_register(&bdrv_nbd, 0); } void *qemu_aio_get(BlockDriverState *bs, BlockDriverCompletionFunc *cb, Index: qemu/vl.c @@ -8609,6 +8609,7 @@ int tb_size; const char *pid_file = NULL; VLANState *vlan; + int emulate_aio = 0; LIST_INIT (&vm_change_state_head); #ifndef _WIN32 @@ -8681,6 +8682,13 @@ tb_size = 0; +#ifdef __FreeBSD__ + if (modfind("aio") == -1) { + emulate_aio = 1; + fprintf(stderr, "warning: aio not (kld)loaded, disabling (may slow down on disk IO\n"); + } +#endif + optind = 1; for(;;) { if (optind >= argc) @@ -9415,7 +9423,7 @@ /* init the dynamic translator */ cpu_exec_init_all(tb_size * 1024 * 1024); - bdrv_init(); + bdrv_init(emulate_aio); /* we always create the cdrom drive, even if no disk is there */ Index: qemu/qemu-img.c @@ -733,7 +733,7 @@ { const char *cmd; - bdrv_init(); + bdrv_init(1); if (argc < 2) help(); cmd = argv[1]; Index: qemu/qemu-nbd.c @@ -326,7 +326,7 @@ return 0; } - bdrv_init(); + bdrv_init(0); bs = bdrv_new("hda"); if (bs == NULL) Signed-off-by: Juergen Lock