]> git.proxmox.com Git - mirror_qemu.git/commitdiff
ide: Check validity of logical block size
authorKevin Wolf <kwolf@redhat.com>
Wed, 3 Dec 2014 12:21:32 +0000 (13:21 +0100)
committerKevin Wolf <kwolf@redhat.com>
Wed, 10 Dec 2014 09:31:16 +0000 (10:31 +0100)
Our IDE emulation can't handle logical block sizes other than 512. Check
for it.

The original assumption was that other values would silently be ignored
(which is bad enough), but it's not quite true: The physical block size
is exposed in IDENTIFY DEVICE as a multiple of the logical block size.
Setting a logical block size therefore also corrupts the physical block
size (4096/4096 doesn't silently downgrade to 4096/512, but 512/512).

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
hw/ide/qdev.c

index b4f096e12e0a310b852125999e846f6d1d3f4c2b..1ebb58d36d22b70d04f9c2de8af3c6fb0c1d1dbc 100644 (file)
@@ -163,6 +163,11 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
         return -1;
     }
 
+    if (dev->conf.logical_block_size != 512) {
+        error_report("logical_block_size must be 512 for IDE");
+        return -1;
+    }
+
     blkconf_serial(&dev->conf, &dev->serial);
     if (kind != IDE_CD) {
         blkconf_geometry(&dev->conf, &dev->chs_trans, 65536, 16, 255, &err);