On Tue, Mar 15, 2016 at 09:45:22AM +0100, Gerd Hoffmann wrote:
Depends on how you code it up. We have a list, we look each file
there and sort accordingly. Fine.
New devices will not be on this list, I guess you can just ignore them
and guests will not see them. OK but I think it is better to make old
machine types see them.
Not a new fw_cfg file.
It's existing smbios file which gets new records added by a new device.
So when initializing it early (old order) it doesn't (yet) contain the
new records. When initializing it late it has them, but also has a
different place in the fw_cfg directory.
So old machine types initialize smbios early (for compatibility).
I see. So in this model, we'd have to somehow keep track of
the old initialization order forever, and
add hacks whenever we change it.
IMHO That would just be too hard to maintain. I have an alternative
proposal.
New machine types initialize smbios late (so guests see the new
records).
So here is what I propose instead:
- always initialize it late
- sort late, a machine done, not when inserting entries
- figure out what the order of existing entries is currently,
and fill an array listing them in this order.
for old machine types, insert the existing entries
in this specific order by using a sorting function:
qsort(....., fw_cfg_cmp);
where:
fw_cfg_find(a) {
for (index = 0; index < fw_cfg_legacy_array_size; ++index)
if (!strcmp(a, ...))
break;
return index;
}
fw_cfg_cmp(a, b) {
in cmp;
if (legacy_fw_cfg_order) {
int list1 = find(a);
int list2 = find(b);
if (list1 < list2)
return -1;
if (list1 > list2)
return 1;
}
return strcmp(a, b);
}