@@ -405,3 +405,41 @@ void del_boot_device_lchs(DeviceState *dev, const char *suffix)
}
}
}
+
+typedef struct QEMU_PACKED FWLCHSEntrySerialized {
+ /* Little-endian. */
+ uint32_t lcyls;
+ uint32_t lheads;
+ uint32_t lsecs;
+} FWLCHSEntrySerialized;
+
+/* Serialized as: (device name\0 + lchs struct) x devices */
+char *get_boot_devices_lchs_list(size_t *size)
+{
+ FWLCHSEntry *i;
+ FWLCHSEntrySerialized s;
+ size_t total = 0;
+ char *list = NULL;
+
+ QTAILQ_FOREACH(i, &fw_lchs, link) {
+ char *bootpath;
+ size_t len;
+
+ bootpath = get_boot_device_path(i->dev, false, i->suffix);
+ s.lcyls = cpu_to_le32(i->lcyls);
+ s.lheads = cpu_to_le32(i->lheads);
+ s.lsecs = cpu_to_le32(i->lsecs);
+
+ len = strlen(bootpath) + 1;
+ list = g_realloc(list, total + len + sizeof(s));
+ memcpy(&list[total], bootpath, len);
+ memcpy(&list[total + len], &s, sizeof(s));
+ total += len + sizeof(s);
+
+ g_free(bootpath);
+ }
+
+ *size = total;
+
+ return list;
+}
@@ -916,13 +916,21 @@ void *fw_cfg_modify_file(FWCfgState *s, const char *filename,
static void fw_cfg_machine_reset(void *opaque)
{
+ MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
+ FWCfgState *s = opaque;
void *ptr;
size_t len;
- FWCfgState *s = opaque;
- char *bootindex = get_boot_devices_list(&len);
+ char *buf;
- ptr = fw_cfg_modify_file(s, "bootorder", (uint8_t *)bootindex, len);
+ buf = get_boot_devices_list(&len);
+ ptr = fw_cfg_modify_file(s, "bootorder", (uint8_t *)buf, len);
g_free(ptr);
+
+ if (!mc->legacy_fw_cfg_order) {
+ buf = get_boot_devices_lchs_list(&len);
+ ptr = fw_cfg_modify_file(s, "bios-geometry", (uint8_t *)buf, len);
+ g_free(ptr);
+ }
}
static void fw_cfg_machine_ready(struct Notifier *n, void *data)
@@ -174,6 +174,7 @@ void validate_bootdevices(const char *devices, Error **errp);
void add_boot_device_lchs(DeviceState *dev, const char *suffix,
uint32_t lcyls, uint32_t lheads, uint32_t lsecs);
void del_boot_device_lchs(DeviceState *dev, const char *suffix);
+char *get_boot_devices_lchs_list(size_t *size);
/* handler to set the boot_device order for a specific type of MachineClass */
typedef void QEMUBootSetHandler(void *opaque, const char *boot_order,