]> git.proxmox.com Git - qemu.git/commitdiff
fw_cfg: New fw_cfg_add_string()
authorMarkus Armbruster <armbru@redhat.com>
Wed, 16 Jan 2013 13:50:24 +0000 (14:50 +0100)
committerBlue Swirl <blauwirbel@gmail.com>
Sat, 19 Jan 2013 10:22:41 +0000 (10:22 +0000)
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
hw/fw_cfg.c
hw/fw_cfg.h

index 0361f684b475c38fbe0f5ae0a3aabe3cc4a36eb7..3d6dd5fb3a0392a80ab585169998661c7afcbc32 100644 (file)
@@ -385,6 +385,13 @@ void fw_cfg_add_bytes(FWCfgState *s, uint16_t key, uint8_t *data, uint32_t len)
     s->entries[arch][key].len = len;
 }
 
+void fw_cfg_add_string(FWCfgState *s, uint16_t key, const char *value)
+{
+    size_t sz = strlen(value) + 1;
+
+    return fw_cfg_add_bytes(s, key, (uint8_t *)g_memdup(value, sz), sz);
+}
+
 void fw_cfg_add_i16(FWCfgState *s, uint16_t key, uint16_t value)
 {
     uint16_t *copy;
index 7d32f285c6b1c27315538d104f7f4f48d3ca8cd6..c2c57cd2aad15765d3c90db40e076be20164f902 100644 (file)
@@ -55,6 +55,7 @@ typedef void (*FWCfgCallback)(void *opaque, uint8_t *data);
 
 typedef struct FWCfgState FWCfgState;
 void fw_cfg_add_bytes(FWCfgState *s, uint16_t key, uint8_t *data, uint32_t len);
+void fw_cfg_add_string(FWCfgState *s, uint16_t key, const char *value);
 void fw_cfg_add_i16(FWCfgState *s, uint16_t key, uint16_t value);
 void fw_cfg_add_i32(FWCfgState *s, uint16_t key, uint32_t value);
 void fw_cfg_add_i64(FWCfgState *s, uint16_t key, uint64_t value);