Skip to content

Commit

Permalink
fw_cfg: fix boot order bug when dynamically modified via QOM
Browse files Browse the repository at this point in the history
When we dynamically modify boot order, the length of
boot order will be changed, but we don't update
s->files->f[i].size with new length. This casuse
seabios read a wrong vale of qemu cfg file about
bootorder.

Cc: Gerd Hoffmann <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Signed-off-by: Gonglei <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
gongleiarei authored and bonzini committed Nov 26, 2014
1 parent d1048be commit f3b3766
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions hw/nvram/fw_cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ void *fw_cfg_modify_file(FWCfgState *s, const char *filename,
void *data, size_t len)
{
int i, index;
void *ptr = NULL;

assert(s->files);

Expand All @@ -531,8 +532,10 @@ void *fw_cfg_modify_file(FWCfgState *s, const char *filename,

for (i = 0; i < index; i++) {
if (strcmp(filename, s->files->f[i].name) == 0) {
return fw_cfg_modify_bytes_read(s, FW_CFG_FILE_FIRST + i,
data, len);
ptr = fw_cfg_modify_bytes_read(s, FW_CFG_FILE_FIRST + i,
data, len);
s->files->f[i].size = cpu_to_be32(len);
return ptr;
}
}
/* add new one */
Expand Down

0 comments on commit f3b3766

Please sign in to comment.