[Qemu-devel] [PATCH v2] exec: make -mem-path filenames deterministic

2013-03-01 Thread peter
From: Peter Feiner pe...@gridcentric.ca

Adds ramblocks' names to their backing files when using -mem-path.  Eases
introspection and debugging.

Signed-off-by: Peter Feiner pe...@gridcentric.ca
---

On Tue, Jan 8, 2013 at 2:04 PM, Anthony Liguori aligu...@us.ibm.com wrote:

 Yes, please submit the oneliner.

Here it is :)

The commit should probably be called exec: add ramblocks' names to -mem-path
files since the paths aren't deterministic.

v1 - v2: Just add ramblock name to mkstemp template. 

Thanks,
Peter

 exec.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/exec.c b/exec.c
index a41bcb8..16a5452 100644
--- a/exec.c
+++ b/exec.c
@@ -865,7 +865,8 @@ static void *file_ram_alloc(RAMBlock *block,
 return NULL;
 }
 
-filename = g_strdup_printf(%s/qemu_back_mem.XX, path);
+filename = g_strdup_printf(%s/qemu_back_mem.%s.XX, path,
+   block-mr-name);
 
 fd = mkstemp(filename);
 if (fd  0) {
-- 
1.7.10.4




Re: [Qemu-devel] [PATCH v2] exec: make -mem-path filenames deterministic

2013-03-01 Thread Andreas Färber
Am 01.03.2013 18:21, schrieb pe...@gridcentric.ca:
 From: Peter Feiner pe...@gridcentric.ca
 
 Adds ramblocks' names to their backing files when using -mem-path.  Eases
 introspection and debugging.
 
 Signed-off-by: Peter Feiner pe...@gridcentric.ca
 ---
 
 On Tue, Jan 8, 2013 at 2:04 PM, Anthony Liguori aligu...@us.ibm.com wrote:

 Yes, please submit the oneliner.
 
 Here it is :)
 
 The commit should probably be called exec: add ramblocks' names to -mem-path
 files since the paths aren't deterministic.
 
 v1 - v2: Just add ramblock name to mkstemp template. 
 
 Thanks,
 Peter
 
  exec.c |3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
 
 diff --git a/exec.c b/exec.c
 index a41bcb8..16a5452 100644
 --- a/exec.c
 +++ b/exec.c
 @@ -865,7 +865,8 @@ static void *file_ram_alloc(RAMBlock *block,
  return NULL;
  }
  
 -filename = g_strdup_printf(%s/qemu_back_mem.XX, path);
 +filename = g_strdup_printf(%s/qemu_back_mem.%s.XX, path,
 +   block-mr-name);

Is it safe to use a MemoryRegion name as part of mkstemp()? /../ seems
rather unlikely but a / less so.

Also note that v2 is expected to be posted as a top-level patch since
the patches tool does not cope well with hidden reposts.

Andreas

  
  fd = mkstemp(filename);
  if (fd  0) {
 


-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] [PATCH v2] exec: make -mem-path filenames deterministic

2013-03-01 Thread Peter Feiner
On Fri, Mar 1, 2013 at 1:47 PM, Andreas Färber afaer...@suse.de wrote:
 Am 01.03.2013 18:21, schrieb pe...@gridcentric.ca:

 Is it safe to use a MemoryRegion name as part of mkstemp()? /../ seems
 rather unlikely but a / less so.

Since mkstemp essentially calls open, / does what you'd expect. So a
MemoryRegion name with / would cause problems. I can sanitize the
name by replacing / with _. I'll post this as v3.

 Also note that v2 is expected to be posted as a top-level patch since
 the patches tool does not cope well with hidden reposts.

Thanks for the tip. I'll post v3 without In-Reply-To.

Peter