]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
fw_cfg: fix boot order bug when dynamically modified via QOM
authorGonglei <arei.gonglei@huawei.com>
Tue, 25 Nov 2014 04:38:19 +0000 (12:38 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 26 Nov 2014 11:11:27 +0000 (12:11 +0100)
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 <kraxel@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
hw/nvram/fw_cfg.c

index e7ed27e24289eb0f47ed778ce7fc7e5f5362eeaf..a7122ee56be24026301e4a8815d9566448eea42d 100644 (file)
@@ -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);
 
@@ -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 */