[PATCH 01/21] Remove memalign call for guess_disk_lchs

Anthony Liguori
2009-04-29T21:20:45Z

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 <aliguori@us.ibm.com>
---
block.c | 13 ++-----------
1 files changed, 2 insertions(+), 11 deletions(-)

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;
}

--
1.6.0.6