提交 6e6f61a6 编写于 作者: M Markus Armbruster 提交者: Kevin Wolf

ide: qdev property for BIOS CHS translation

This isn't quite orthodox.  CHS translation is firmware configuration,
communicated via the RTC's CMOS RAM, not a property of the disk.  But
it's best to treat it just like geometry anyway.

Maintain backward compatibility exactly like for geometry: fall back
to DriveInfo's translation, set with -drive trans=...

Bonus: info qtree now shows the translation.  Except when it shows
"auto": that's resolved by pc_cmos_init_late().  To be addressed
shortly.
Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 8cd41745
...@@ -474,6 +474,7 @@ struct IDEDevice { ...@@ -474,6 +474,7 @@ struct IDEDevice {
DeviceState qdev; DeviceState qdev;
uint32_t unit; uint32_t unit;
BlockConf conf; BlockConf conf;
int chs_trans;
char *version; char *version;
char *serial; char *serial;
char *model; char *model;
......
...@@ -144,7 +144,6 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind) ...@@ -144,7 +144,6 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
IDEState *s = bus->ifs + dev->unit; IDEState *s = bus->ifs + dev->unit;
const char *serial; const char *serial;
DriveInfo *dinfo; DriveInfo *dinfo;
int trans;
if (dev->conf.discard_granularity && dev->conf.discard_granularity != 512) { if (dev->conf.discard_granularity && dev->conf.discard_granularity != 512) {
error_report("discard_granularity must be 512 for ide"); error_report("discard_granularity must be 512 for ide");
...@@ -160,25 +159,24 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind) ...@@ -160,25 +159,24 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
} }
} }
trans = BIOS_ATA_TRANSLATION_AUTO;
if (!dev->conf.cyls && !dev->conf.heads && !dev->conf.secs) { if (!dev->conf.cyls && !dev->conf.heads && !dev->conf.secs) {
/* try to fall back to value set with legacy -drive cyls=... */ /* try to fall back to value set with legacy -drive cyls=... */
dinfo = drive_get_by_blockdev(dev->conf.bs); dinfo = drive_get_by_blockdev(dev->conf.bs);
dev->conf.cyls = dinfo->cyls; dev->conf.cyls = dinfo->cyls;
dev->conf.heads = dinfo->heads; dev->conf.heads = dinfo->heads;
dev->conf.secs = dinfo->secs; dev->conf.secs = dinfo->secs;
trans = dinfo->trans; dev->chs_trans = dinfo->trans;
} }
if (!dev->conf.cyls && !dev->conf.heads && !dev->conf.secs) { if (!dev->conf.cyls && !dev->conf.heads && !dev->conf.secs) {
hd_geometry_guess(dev->conf.bs, hd_geometry_guess(dev->conf.bs,
&dev->conf.cyls, &dev->conf.heads, &dev->conf.secs, &dev->conf.cyls, &dev->conf.heads, &dev->conf.secs,
&trans); &dev->chs_trans);
} }
if (ide_init_drive(s, dev->conf.bs, kind, if (ide_init_drive(s, dev->conf.bs, kind,
dev->version, serial, dev->model, dev->wwn, dev->version, serial, dev->model, dev->wwn,
dev->conf.cyls, dev->conf.heads, dev->conf.secs, dev->conf.cyls, dev->conf.heads, dev->conf.secs,
trans) < 0) { dev->chs_trans) < 0) {
return -1; return -1;
} }
...@@ -222,6 +220,8 @@ static int ide_drive_initfn(IDEDevice *dev) ...@@ -222,6 +220,8 @@ static int ide_drive_initfn(IDEDevice *dev)
static Property ide_hd_properties[] = { static Property ide_hd_properties[] = {
DEFINE_IDE_DEV_PROPERTIES(), DEFINE_IDE_DEV_PROPERTIES(),
DEFINE_BLOCK_CHS_PROPERTIES(IDEDrive, dev.conf), DEFINE_BLOCK_CHS_PROPERTIES(IDEDrive, dev.conf),
DEFINE_PROP_BIOS_CHS_TRANS("bios-chs-trans",
IDEDrive, dev.chs_trans, BIOS_ATA_TRANSLATION_AUTO),
DEFINE_PROP_END_OF_LIST(), DEFINE_PROP_END_OF_LIST(),
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册