]> git.proxmox.com Git - qemu.git/blobdiff - exec.c
Merge remote-tracking branch 'afaerber/qom-cpu' into staging
[qemu.git] / exec.c
diff --git a/exec.c b/exec.c
index c5e65a9380a554faf98c4538faf2c420798d7224..8a6aac36e347399ffa448fac4cab1fae2c135110 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -846,6 +846,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
@@ -867,7 +869,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) {