]> Git Repo - qemu.git/commitdiff
hw/nvram/fw_cfg: Store 'reboot-timeout' as little endian
authorLi Qiang <[email protected]>
Wed, 24 Apr 2019 14:06:41 +0000 (07:06 -0700)
committerPhilippe Mathieu-Daudé <[email protected]>
Thu, 23 May 2019 12:10:31 +0000 (14:10 +0200)
The current codebase is not specific about the endianess of the
fw_cfg 'file' entry 'reboot-timeout'.

Per docs/specs/fw_cfg.txt:

  === All Other Data Items ===

  Please consult the QEMU source for the most up-to-date
  and authoritative list of selector keys and their respective
  items' purpose, format and writeability.

Checking the git history, this code was introduced in commit
ac05f3492421, very similar to commit 3d3b8303c6f8 for the
'boot-menu-wait' entry, which explicitely use little-endian.

OVMF consumes 'boot-menu-wait' as little-endian, however it does
not consume 'reboot-timeout'.

Regarding the git history and OVMF use, we choose to explicit
'reboot-timeout' endianess as little-endian.

Signed-off-by: Li Qiang <[email protected]>
Tested-by: Thomas Huth <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Tested-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <20190424140643[email protected]>
[PMD: Reword commit description based on review comments]
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
hw/nvram/fw_cfg.c

index b2dc0a80cbc2371858e67771c05a838dc70e1867..9f7b7789bc2c5a2d6cc4ca74220ad047e03134ce 100644 (file)
@@ -234,6 +234,7 @@ static void fw_cfg_reboot(FWCfgState *s)
 {
     const char *reboot_timeout = NULL;
     int64_t rt_val = -1;
+    uint32_t rt_le32;
 
     /* get user configuration */
     QemuOptsList *plist = qemu_find_opts("boot-opts");
@@ -250,7 +251,8 @@ static void fw_cfg_reboot(FWCfgState *s)
         }
     }
 
-    fw_cfg_add_file(s, "etc/boot-fail-wait", g_memdup(&rt_val, 4), 4);
+    rt_le32 = cpu_to_le32(rt_val);
+    fw_cfg_add_file(s, "etc/boot-fail-wait", g_memdup(&rt_le32, 4), 4);
 }
 
 static void fw_cfg_write(FWCfgState *s, uint8_t value)
This page took 0.028288 seconds and 4 git commands to generate.