Commit 96b8f136f52ea2dc5948fe24f0bf4483251ac280

Authored by ths
1 parent bee8d684

Fix bdrv_get_geometry to return uint64_t, by Andre Przywara.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3825 c046a42c-6fe2-441c-8c8c-71466251a162
... ... @@ -717,7 +717,7 @@ int64_t bdrv_getlength(BlockDriverState *bs)
717 717 }
718 718  
719 719 /* return 0 as number of sectors if no device present or error */
720   -void bdrv_get_geometry(BlockDriverState *bs, int64_t *nb_sectors_ptr)
  720 +void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr)
721 721 {
722 722 int64_t length;
723 723 length = bdrv_getlength(bs);
... ...
... ... @@ -72,7 +72,7 @@ int bdrv_pwrite(BlockDriverState *bs, int64_t offset,
72 72 const void *buf, int count);
73 73 int bdrv_truncate(BlockDriverState *bs, int64_t offset);
74 74 int64_t bdrv_getlength(BlockDriverState *bs);
75   -void bdrv_get_geometry(BlockDriverState *bs, int64_t *nb_sectors_ptr);
  75 +void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr);
76 76 int bdrv_commit(BlockDriverState *bs);
77 77 void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size);
78 78 /* async block I/O */
... ...
hw/fdc.c
... ... @@ -234,7 +234,7 @@ static const fd_format_t fd_formats[] = {
234 234 static void fd_revalidate (fdrive_t *drv)
235 235 {
236 236 const fd_format_t *parse;
237   - int64_t nb_sectors, size;
  237 + uint64_t nb_sectors, size;
238 238 int i, first_match, match;
239 239 int nb_heads, max_track, last_sect, ro;
240 240  
... ...
hw/ide.c
... ... @@ -1465,12 +1465,12 @@ static void ide_atapi_cmd(IDEState *s)
1465 1465 break;
1466 1466 case GPCMD_SEEK:
1467 1467 {
1468   - int lba;
1469   - int64_t total_sectors;
  1468 + unsigned int lba;
  1469 + uint64_t total_sectors;
1470 1470  
1471 1471 bdrv_get_geometry(s->bs, &total_sectors);
1472 1472 total_sectors >>= 2;
1473   - if (total_sectors <= 0) {
  1473 + if (total_sectors == 0) {
1474 1474 ide_atapi_cmd_error(s, SENSE_NOT_READY,
1475 1475 ASC_MEDIUM_NOT_PRESENT);
1476 1476 break;
... ... @@ -1516,11 +1516,11 @@ static void ide_atapi_cmd(IDEState *s)
1516 1516 case GPCMD_READ_TOC_PMA_ATIP:
1517 1517 {
1518 1518 int format, msf, start_track, len;
1519   - int64_t total_sectors;
  1519 + uint64_t total_sectors;
1520 1520  
1521 1521 bdrv_get_geometry(s->bs, &total_sectors);
1522 1522 total_sectors >>= 2;
1523   - if (total_sectors <= 0) {
  1523 + if (total_sectors == 0) {
1524 1524 ide_atapi_cmd_error(s, SENSE_NOT_READY,
1525 1525 ASC_MEDIUM_NOT_PRESENT);
1526 1526 break;
... ... @@ -1560,11 +1560,11 @@ static void ide_atapi_cmd(IDEState *s)
1560 1560 break;
1561 1561 case GPCMD_READ_CDVD_CAPACITY:
1562 1562 {
1563   - int64_t total_sectors;
  1563 + uint64_t total_sectors;
1564 1564  
1565 1565 bdrv_get_geometry(s->bs, &total_sectors);
1566 1566 total_sectors >>= 2;
1567   - if (total_sectors <= 0) {
  1567 + if (total_sectors == 0) {
1568 1568 ide_atapi_cmd_error(s, SENSE_NOT_READY,
1569 1569 ASC_MEDIUM_NOT_PRESENT);
1570 1570 break;
... ... @@ -1580,7 +1580,7 @@ static void ide_atapi_cmd(IDEState *s)
1580 1580 int media = packet[1];
1581 1581 int layer = packet[6];
1582 1582 int format = packet[2];
1583   - int64_t total_sectors;
  1583 + uint64_t total_sectors;
1584 1584  
1585 1585 if (media != 0 || layer != 0)
1586 1586 {
... ... @@ -1592,6 +1592,11 @@ static void ide_atapi_cmd(IDEState *s)
1592 1592 case 0:
1593 1593 bdrv_get_geometry(s->bs, &total_sectors);
1594 1594 total_sectors >>= 2;
  1595 + if (total_sectors == 0) {
  1596 + ide_atapi_cmd_error(s, SENSE_NOT_READY,
  1597 + ASC_MEDIUM_NOT_PRESENT);
  1598 + break;
  1599 + }
1595 1600  
1596 1601 memset(buf, 0, 2052);
1597 1602  
... ... @@ -1636,7 +1641,7 @@ static void ide_atapi_cmd(IDEState *s)
1636 1641 break;
1637 1642 case GPCMD_GET_CONFIGURATION:
1638 1643 {
1639   - int64_t total_sectors;
  1644 + uint64_t total_sectors;
1640 1645  
1641 1646 /* only feature 0 is supported */
1642 1647 if (packet[2] != 0 || packet[3] != 0) {
... ... @@ -1721,7 +1726,7 @@ static void ide_cfata_metadata_write(IDEState *s)
1721 1726 static void cdrom_change_cb(void *opaque)
1722 1727 {
1723 1728 IDEState *s = opaque;
1724   - int64_t nb_sectors;
  1729 + uint64_t nb_sectors;
1725 1730  
1726 1731 /* XXX: send interrupt too */
1727 1732 bdrv_get_geometry(s->bs, &nb_sectors);
... ... @@ -2417,7 +2422,7 @@ static void ide_init2(IDEState *ide_state,
2417 2422 IDEState *s;
2418 2423 static int drive_serial = 1;
2419 2424 int i, cylinders, heads, secs, translation, lba_detected = 0;
2420   - int64_t nb_sectors;
  2425 + uint64_t nb_sectors;
2421 2426  
2422 2427 for(i = 0; i < 2; i++) {
2423 2428 s = ide_state + i;
... ...
hw/scsi-disk.c
... ... @@ -284,7 +284,7 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag,
284 284 uint8_t *buf, int lun)
285 285 {
286 286 SCSIDeviceState *s = d->state;
287   - int64_t nb_sectors;
  287 + uint64_t nb_sectors;
288 288 uint32_t lba;
289 289 uint32_t len;
290 290 int cmdlen;
... ...
qemu-img.c
... ... @@ -235,7 +235,7 @@ static int img_create(int argc, char **argv)
235 235 const char *fmt = "raw";
236 236 const char *filename;
237 237 const char *base_filename = NULL;
238   - int64_t size;
  238 + uint64_t size;
239 239 const char *p;
240 240 BlockDriver *drv;
241 241  
... ... @@ -300,7 +300,7 @@ static int img_create(int argc, char **argv)
300 300 printf(", backing_file=%s",
301 301 base_filename);
302 302 }
303   - printf(", size=%" PRId64 " kB\n", (int64_t) (size / 1024));
  303 + printf(", size=%" PRIu64 " kB\n", size / 1024);
304 304 ret = bdrv_create(drv, filename, size / 512, base_filename, flags);
305 305 if (ret < 0) {
306 306 if (ret == -ENOTSUP) {
... ... @@ -410,7 +410,8 @@ static int img_convert(int argc, char **argv)
410 410 const char *fmt, *out_fmt, *out_filename;
411 411 BlockDriver *drv;
412 412 BlockDriverState **bs, *out_bs;
413   - int64_t total_sectors, nb_sectors, sector_num, bs_offset, bs_sectors;
  413 + int64_t total_sectors, nb_sectors, sector_num, bs_offset;
  414 + uint64_t bs_sectors;
414 415 uint8_t buf[IO_BUF_SIZE];
415 416 const uint8_t *buf1;
416 417 BlockDriverInfo bdi;
... ... @@ -655,7 +656,8 @@ static int img_info(int argc, char **argv)
655 656 BlockDriver *drv;
656 657 BlockDriverState *bs;
657 658 char fmt_name[128], size_buf[128], dsize_buf[128];
658   - int64_t total_sectors, allocated_size;
  659 + uint64_t total_sectors;
  660 + int64_t allocated_size;
659 661 char backing_filename[1024];
660 662 char backing_filename2[1024];
661 663 BlockDriverInfo bdi;
... ...