Skip to content

Commit

Permalink
exec: make -mem-path filenames deterministic
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Peter Feiner authored and Anthony Liguori committed Mar 12, 2013
1 parent 4524051 commit 8ca761f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion exec.c
Expand Up @@ -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
Expand All @@ -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) {
Expand Down

0 comments on commit 8ca761f

Please sign in to comment.