qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for-2.2] fw_cfg: fix boot order bug when dynamically modified via QOM
@ 2014-11-25  4:38 arei.gonglei
  2014-11-25  9:53 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: arei.gonglei @ 2014-11-25  4:38 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Gonglei, peter.huangpeng, Gerd Hoffmann

From: Gonglei <arei.gonglei@huawei.com>

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>
---
 hw/nvram/fw_cfg.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index e7ed27e..a7122ee 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -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 */
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.2] fw_cfg: fix boot order bug when dynamically modified via QOM
  2014-11-25  4:38 [Qemu-devel] [PATCH for-2.2] fw_cfg: fix boot order bug when dynamically modified via QOM arei.gonglei
@ 2014-11-25  9:53 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2014-11-25  9:53 UTC (permalink / raw)
  To: arei.gonglei, qemu-devel; +Cc: peter.huangpeng, Gerd Hoffmann



On 25/11/2014 05:38, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
> 
> 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>
> ---
>  hw/nvram/fw_cfg.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
> index e7ed27e..a7122ee 100644
> --- a/hw/nvram/fw_cfg.c
> +++ b/hw/nvram/fw_cfg.c
> @@ -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 */
> 

Applied, thanks.

Paolo

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-11-25  9:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-25  4:38 [Qemu-devel] [PATCH for-2.2] fw_cfg: fix boot order bug when dynamically modified via QOM arei.gonglei
2014-11-25  9:53 ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).