Patchwork [4/5] ide: add topology support

login
register
mail settings
Submitter Christoph Hellwig
Date Jan. 29, 2010, 7:05 p.m.
Message ID <20100129190514.GC25287@lst.de>
Download mbox | patch
Permalink /patch/44016/
State New
Headers show

Comments

Christoph Hellwig - Jan. 29, 2010, 7:05 p.m.
Export the physical block size in the ATA IDENTIFY command.  The
other topology values are not supported in ATA so skip them.

Add a new field to the savevm information which is initialized to
zero if migrating from an older qemu version.

Signed-off-by: Christoph Hellwig <hch@lst.de>

Patch

Index: qemu/hw/ide/core.c
===================================================================
--- qemu.orig/hw/ide/core.c	2010-01-29 11:07:50.103003910 +0100
+++ qemu/hw/ide/core.c	2010-01-29 11:08:32.943004637 +0100
@@ -164,6 +164,8 @@  static void ide_identify(IDEState *s)
     put_le16(p + 101, s->nb_sectors >> 16);
     put_le16(p + 102, s->nb_sectors >> 32);
     put_le16(p + 103, s->nb_sectors >> 48);
+    if (s->physical_block_exp)
+        put_le16(p + 106, 0x6000 | s->physical_block_exp);
 
     memcpy(s->identify_data, p, sizeof(s->identify_data));
     s->identify_set = 1;
@@ -2615,6 +2617,7 @@  void ide_init_drive(IDEState *s, DriveIn
         }
         strncpy(s->drive_serial_str, drive_get_serial(s->bs),
                 sizeof(s->drive_serial_str));
+        s->physical_block_exp = bdrv_get_physical_block_exp(s->bs);
     }
     if (strlen(s->drive_serial_str) == 0)
         snprintf(s->drive_serial_str, sizeof(s->drive_serial_str),
@@ -2684,12 +2687,17 @@  static int ide_drive_post_load(void *opa
             s->cdrom_changed = 1;
         }
     }
+
+    if (version_id < 4) {
+        s->physical_block_exp = 0;
+    }
+
     return 0;
 }
 
 const VMStateDescription vmstate_ide_drive = {
     .name = "ide_drive",
-    .version_id = 3,
+    .version_id = 4,
     .minimum_version_id = 0,
     .minimum_version_id_old = 0,
     .post_load = ide_drive_post_load,
@@ -2714,6 +2722,7 @@  const VMStateDescription vmstate_ide_dri
         VMSTATE_UINT8(sense_key, IDEState),
         VMSTATE_UINT8(asc, IDEState),
         VMSTATE_UINT8_V(cdrom_changed, IDEState, 3),
+        VMSTATE_UINT8_V(physical_block_exp, IDEState, 4),
         /* XXX: if a transfer is pending, we do not save it yet */
         VMSTATE_END_OF_LIST()
     }
Index: qemu/hw/ide/internal.h
===================================================================
--- qemu.orig/hw/ide/internal.h	2010-01-29 11:07:50.116004031 +0100
+++ qemu/hw/ide/internal.h	2010-01-29 11:08:32.948011699 +0100
@@ -433,6 +433,8 @@  struct IDEState {
     int smart_errors;
     uint8_t smart_selftest_count;
     uint8_t *smart_selftest_data;
+    /* topology information */
+    uint8_t physical_block_exp;
 };
 
 struct IDEBus {