From: Anthony Liguori <aligu...@us.ibm.com>

This code doesn't exist in upstream QEMU because it is not necessary to
provide an aligned buffer to bdrv_read.  The API has always worked this way
although at one point, the bouncing was broken which is what led to this
patch.

The places where qemu_memalign() is used in QEMU are only where performance is
sensitive.  guess_disk_lchs does not fall into this category.

Signed-off-by: Anthony Liguori <aligu...@us.ibm.com>
Signed-off-by: Avi Kivity <a...@redhat.com>

diff --git a/block.c b/block.c
index 8e08f32..8348cf2 100644
--- a/block.c
+++ b/block.c
@@ -30,7 +30,6 @@
 #include "qemu-common.h"
 #include "monitor.h"
 #include "block_int.h"
-#include "osdep.h"
 
 #ifdef HOST_BSD
 #include <sys/types.h>
@@ -772,26 +771,20 @@ struct partition {
 static int guess_disk_lchs(BlockDriverState *bs,
                            int *pcylinders, int *pheads, int *psectors)
 {
-    uint8_t *buf;
+    uint8_t buf[512];
     int ret, i, heads, sectors, cylinders;
     struct partition *p;
     uint32_t nr_sects;
     uint64_t nb_sectors;
 
-    buf = qemu_memalign(512, 512);
-    if (buf == NULL)
-        return -1;
-
     bdrv_get_geometry(bs, &nb_sectors);
 
     ret = bdrv_read(bs, 0, buf, 1);
     if (ret < 0)
         return -1;
     /* test msdos magic */
-    if (buf[510] != 0x55 || buf[511] != 0xaa) {
-        qemu_free(buf);
+    if (buf[510] != 0x55 || buf[511] != 0xaa)
         return -1;
-    }
     for(i = 0; i < 4; i++) {
         p = ((struct partition *)(buf + 0x1be)) + i;
         nr_sects = le32_to_cpu(p->nr_sects);
@@ -812,11 +805,9 @@ static int guess_disk_lchs(BlockDriverState *bs,
             printf("guessed geometry: LCHS=%d %d %d\n",
                    cylinders, heads, sectors);
 #endif
-            qemu_free(buf);
             return 0;
         }
     }
-    qemu_free(buf);
     return -1;
 }
 
--
To unsubscribe from this list: send the line "unsubscribe kvm-commits" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to