Message ID | 20190612115939.23825-8-shmuel.eiderman@oracle.com |
---|---|
State | New |
Headers | show |
Series | Add Qemu to SeaBIOS LCHS interface | expand |
Hi, > We serialize this information in a similar way to the "bootorder" > interface. > The fw_cfg entry is "bootdevices" and it serializes a struct. Why "bootdevices"? I'd suggest to use "geometry" or "lchs" instead. > At the moment the struct holds the values of logical CHS values but it > can be expanded easily due to the extendable ABI implemented. > > (In the future, we can pass the bootindex through "bootdevices" instead > "bootorder" - unifying all bootdevice information in one fw_cfg value) I don't think deprecating bootorder is useful. Nobody cares about the disk geometry, except some legacy x86 bios guests. So seabios will be the only firmware using this new interface. Switching all firmware to a new fw_cfg file is pointless churn. Why make this extendable? What possible extensions do you have in mind? Also note that with a possible extension you might end up in a situation where you have info A for device 1 and info B for device 2 and info A+B for device 3 while with your current patch there is no way to signal whenever info A or B is available for a given device. > +/* Serialized as: struct size (4) + (device name\0 + device struct) x devices */ > +char *get_boot_devices_info(size_t *size) > +{ > + FWLCHSEntry *i; > + BootDeviceEntrySerialized s; > + size_t total = 0; > + char *list = NULL; if (QTAILQ_EMPTY(&fw_lchs)) { return NULL; } > + if (!mc->legacy_fw_cfg_order) { ^^^^^^^^^^^^^^^^^^^ Hmm? cheers, Gerd
> On 17 Jun 2019, at 10:20, Gerd Hoffmann <kraxel@redhat.com> wrote: > > Hi, > >> We serialize this information in a similar way to the "bootorder" >> interface. >> The fw_cfg entry is "bootdevices" and it serializes a struct. > > Why "bootdevices"? I'd suggest to use "geometry" or "lchs" instead. True, if we don’t think an extension will be required in the future we might as well call it “lchs" or "bios-geometry”. > >> At the moment the struct holds the values of logical CHS values but it >> can be expanded easily due to the extendable ABI implemented. >> >> (In the future, we can pass the bootindex through "bootdevices" instead >> "bootorder" - unifying all bootdevice information in one fw_cfg value) > > I don't think deprecating bootorder is useful. Nobody cares about the > disk geometry, except some legacy x86 bios guests. So seabios will be > the only firmware using this new interface. Switching all firmware to a > new fw_cfg file is pointless churn. > > Why make this extendable? What possible extensions do you have in mind? I’m not sure about this but if “bootorder” was written in the first place using such an extension this could have been useful. I don’t have anything specific in mind. I don’t think deprecating bootorder is useful either, just mentioned that it will be possible if we would like to unify all disk values someday. > > Also note that with a possible extension you might end up in a situation > where you have info A for device 1 and info B for device 2 and info A+B > for device 3 while with your current patch there is no way to signal > whenever info A or B is available for a given device. Well for lchs (A) a non-existing value is 0, 0, 0 (uint32). So at the moment we’re good. We can signal other values with other magic numbers (such as -1 for bootorder) or prefix the value with an additional boolean value “is signaled”. > >> +/* Serialized as: struct size (4) + (device name\0 + device struct) x devices */ >> +char *get_boot_devices_info(size_t *size) >> +{ >> + FWLCHSEntry *i; >> + BootDeviceEntrySerialized s; >> + size_t total = 0; >> + char *list = NULL; > > if (QTAILQ_EMPTY(&fw_lchs)) { > return NULL; > } > >> + if (!mc->legacy_fw_cfg_order) { > ^^^^^^^^^^^^^^^^^^^ > Hmm? Only making this available in non-legacy mode. Qemu complains in get_fw_cfg_order() (fw_cfg.c): warn_report("Unknown firmware file in legacy mode: %s", name); Detected during qtests. So overall, WDYT? Keep it extendible for a low price of ABI + “bootdevices” name. Or go strict and rename to “bios-geometries”? (The ABI will not change too much anyway, the struct_size will disappear and sizeof(12) struct of LCHS will be assumed) Sam > > cheers, > Gerd >
Hi, > Keep it extendible for a low price of ABI + “bootdevices” name. > Or go strict and rename to “bios-geometries”? The name should reflect what is in there, so "bios-geometries" looks better to me. I'd also keep it strict, unless we have at least a vague idea what might be a useful future extension. I don't have any. cheers, Gerd
Ok, I’ll resubmit this patch series in v3, as well as v2 for SeaBIOS soon enough. * Change “bootdevices” to “bios-geometry”, and remove the struct size * Add cpu_to_le32 fix as Laszlo suggested or big endian hosts * Fix last qtest commit - automatic docker tester for some reason does not have qemu-img set Sam > On 17 Jun 2019, at 11:38, Gerd Hoffmann <kraxel@redhat.com> wrote: > > Hi, > >> Keep it extendible for a low price of ABI + “bootdevices” name. >> Or go strict and rename to “bios-geometries”? > > The name should reflect what is in there, so "bios-geometries" looks > better to me. I'd also keep it strict, unless we have at least a vague > idea what might be a useful future extension. I don't have any. > > cheers, > Gerd >
On Mon, Jun 17, 2019 at 10:36:54AM +0300, Sam Eiderman wrote: > So overall, WDYT? > Keep it extendible for a low price of ABI + “bootdevices” name. > Or go strict and rename to “bios-geometries”? If we add another qemu to firmware interface I think the interface should be documented. I also think that a mix of an ascii and binary interface is going to be difficult to describe and document. I'd prefer a pure ascii interface - for example a newline separated list of four space separted fields: <device name> <cylinders> <heads> <spt> -Kevin
> On 17 Jun 2019, at 17:48, Kevin O'Connor <kevin@koconnor.net> wrote: > > On Mon, Jun 17, 2019 at 10:36:54AM +0300, Sam Eiderman wrote: >> So overall, WDYT? >> Keep it extendible for a low price of ABI + “bootdevices” name. >> Or go strict and rename to “bios-geometries”? > > If we add another qemu to firmware interface I think the interface > should be documented. I also think that a mix of an ascii and binary > interface is going to be difficult to describe and document. I'd > prefer a pure ascii interface - for example a newline separated list > of four space separted fields: <device name> <cylinders> <heads> <spt> We can go pure ascii. I meanwhile sent a v3 QEMU and v2 SeaBIOS patches for more comments. Sam > > -Kevin
diff --git a/bootdevice.c b/bootdevice.c index 2b12fb85a4..84c2a83f25 100644 --- a/bootdevice.c +++ b/bootdevice.c @@ -405,3 +405,45 @@ void del_boot_device_lchs(DeviceState *dev, const char *suffix) } } } + +typedef struct QEMU_PACKED BootDeviceEntrySerialized { + /* Do not change field order - add new fields below */ + uint32_t lcyls; + uint32_t lheads; + uint32_t lsecs; +} BootDeviceEntrySerialized; + +/* Serialized as: struct size (4) + (device name\0 + device struct) x devices */ +char *get_boot_devices_info(size_t *size) +{ + FWLCHSEntry *i; + BootDeviceEntrySerialized s; + size_t total = 0; + char *list = NULL; + + list = g_malloc0(sizeof(uint32_t)); + *((uint32_t *)list) = (uint32_t)sizeof(s); + total = sizeof(uint32_t); + + QTAILQ_FOREACH(i, &fw_lchs, link) { + char *bootpath; + size_t len; + + bootpath = get_boot_device_path(i->dev, false, i->suffix); + s.lcyls = i->lcyls; + s.lheads = i->lheads; + s.lsecs = 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; +} diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 9f7b7789bc..008b21542f 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -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_info(&len); + ptr = fw_cfg_modify_file(s, "bootdevices", (uint8_t *)buf, len); + g_free(ptr); + } } static void fw_cfg_machine_ready(struct Notifier *n, void *data) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 173dfbb539..f0552006f4 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -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_info(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,