qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Re: qemu svn r5281 on FreeBSD - slow usb, vmwarevga, s


From: Juergen Lock
Subject: Re: [Qemu-devel] Re: qemu svn r5281 on FreeBSD - slow usb, vmwarevga, screen updates... (now updated to r5313)
Date: Sun, 28 Sep 2008 00:52:04 +0200 (CEST)

In article <address@hidden> 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 <address@hidden>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]