On Fri, Feb 17, 2017 at 10:21:58PM -0800, ben@skyportsystems.com wrote:
From: Ben Warren ben@skyportsystems.com
When resuming from S3, only fw_cfg file keys are known.
Signed-off-by: Ben Warren ben@skyportsystems.com
src/fw/paravirt.c | 23 +++++++++++++++++++++++ src/fw/paravirt.h | 2 ++ 2 files changed, 25 insertions(+)
diff --git a/src/fw/paravirt.c b/src/fw/paravirt.c index 4618647..e513dd5 100644 --- a/src/fw/paravirt.c +++ b/src/fw/paravirt.c @@ -352,6 +352,17 @@ qemu_cfg_write_file(void *src, struct romfile_s *file, u32 offset, u32 len) return len; }
+// Bare-bones function for writing a file knowing only its unique +// identifying key (select) +int +qemu_cfg_write_file_simple(void *src, u16 key, u32 offset, u32 len) +{
- qemu_cfg_select(key);
- qemu_cfg_skip(offset);
- qemu_cfg_write(src, len);
- return len;
+}
static void qemu_romfile_add(char *name, int select, int skip, int size) { @@ -370,6 +381,18 @@ qemu_romfile_add(char *name, int select, int skip, int size) }
u16 +qemu_get_romfile_key(struct romfile_s *file) +{
- struct qemu_romfile_s *qfile;
- qfile = container_of(file, struct qemu_romfile_s, file);
- if (!qfile) {
warn_internalerror();
return 0;
- }
This should verify that file->copy==qemu_cfg_read_file before calling container_of. As Laszlo points out, there's no point in checking !qfile after container_of.
-Kevin