diff options
author | Peter Feiner <peter@gridcentric.ca> | 2013-03-04 13:54:25 -0500 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2013-03-12 13:42:52 -0500 |
commit | 8ca761f661a7cc972bc6bcf938feca6c538100f0 (patch) | |
tree | 079981074ece32c2b8c61aa73e5246e55b4ab66a | |
parent | 4524051c32190c1dc13ec2ccd122fd120dbed736 (diff) | |
download | hqemu-8ca761f661a7cc972bc6bcf938feca6c538100f0.zip hqemu-8ca761f661a7cc972bc6bcf938feca6c538100f0.tar.gz |
exec: make -mem-path filenames deterministic
Adds ramblocks' names to their backing files when using -mem-path. Eases
introspection and debugging.
Signed-off-by: Peter Feiner <peter@gridcentric.ca>
Message-id: 1362423265-15855-1-git-send-email-peter@gridcentric.ca
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r-- | exec.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -844,6 +844,8 @@ static void *file_ram_alloc(RAMBlock *block, const char *path) { char *filename; + char *sanitized_name; + char *c; void *area; int fd; #ifdef MAP_POPULATE @@ -865,7 +867,16 @@ static void *file_ram_alloc(RAMBlock *block, return NULL; } - filename = g_strdup_printf("%s/qemu_back_mem.XXXXXX", path); + /* Make name safe to use with mkstemp by replacing '/' with '_'. */ + sanitized_name = g_strdup(block->mr->name); + for (c = sanitized_name; *c != '\0'; c++) { + if (*c == '/') + *c = '_'; + } + + filename = g_strdup_printf("%s/qemu_back_mem.%s.XXXXXX", path, + sanitized_name); + g_free(sanitized_name); fd = mkstemp(filename); if (fd < 0) { |