Revision b7eb0c9f hw/scsi-disk.c
b/hw/scsi-disk.c | ||
---|---|---|
1737 | 1737 |
static int scsi_initfn(SCSIDevice *dev) |
1738 | 1738 |
{ |
1739 | 1739 |
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev); |
1740 |
DriveInfo *dinfo; |
|
1741 | 1740 |
|
1742 | 1741 |
if (!s->qdev.conf.bs) { |
1743 | 1742 |
error_report("drive property not set"); |
... | ... | |
1750 | 1749 |
return -1; |
1751 | 1750 |
} |
1752 | 1751 |
|
1753 |
if (!dev->conf.cyls && !dev->conf.heads && !dev->conf.secs) { |
|
1754 |
/* try to fall back to value set with legacy -drive cyls=... */ |
|
1755 |
dinfo = drive_get_by_blockdev(s->qdev.conf.bs); |
|
1756 |
dev->conf.cyls = dinfo->cyls; |
|
1757 |
dev->conf.heads = dinfo->heads; |
|
1758 |
dev->conf.secs = dinfo->secs; |
|
1759 |
} |
|
1760 |
if (!dev->conf.cyls && !dev->conf.heads && !dev->conf.secs) { |
|
1761 |
hd_geometry_guess(s->qdev.conf.bs, |
|
1762 |
&dev->conf.cyls, &dev->conf.heads, &dev->conf.secs, |
|
1763 |
NULL); |
|
1764 |
} |
|
1765 |
if (dev->conf.cyls || dev->conf.heads || dev->conf.secs) { |
|
1766 |
if (dev->conf.cyls < 1 || dev->conf.cyls > 65535) { |
|
1767 |
error_report("cyls must be between 1 and 65535"); |
|
1768 |
return -1; |
|
1769 |
} |
|
1770 |
if (dev->conf.heads < 1 || dev->conf.heads > 255) { |
|
1771 |
error_report("heads must be between 1 and 255"); |
|
1772 |
return -1; |
|
1773 |
} |
|
1774 |
if (dev->conf.secs < 1 || dev->conf.secs > 255) { |
|
1775 |
error_report("secs must be between 1 and 255"); |
|
1776 |
return -1; |
|
1777 |
} |
|
1778 |
} |
|
1779 |
|
|
1780 | 1752 |
blkconf_serial(&s->qdev.conf, &s->serial); |
1753 |
if (blkconf_geometry(&dev->conf, NULL, 65535, 255, 255) < 0) { |
|
1754 |
return -1; |
|
1755 |
} |
|
1781 | 1756 |
|
1782 | 1757 |
if (!s->version) { |
1783 | 1758 |
s->version = g_strdup(qemu_get_version()); |
Also available in: Unified diff