diff mbox

[1/1] block: use /var/tmp instead of /tmp for -snapshot

Message ID 155481d240779c5d25f8195a406d57db613507bc.1393407651.git.amit.shah@redhat.com
State New
Headers show

Commit Message

Amit Shah Feb. 26, 2014, 9:42 a.m. UTC
If TMPDIR is not specified, the default was to use /tmp for the working
copy of the block devices.  Update this to /var/tmp instead, so systems
using tmp-on-tmpfs don't end up inadvertently using RAM for the block
device.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 block.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Stefan Hajnoczi Feb. 27, 2014, 10:18 a.m. UTC | #1
On Wed, Feb 26, 2014 at 03:12:37PM +0530, Amit Shah wrote:
> If TMPDIR is not specified, the default was to use /tmp for the working
> copy of the block devices.  Update this to /var/tmp instead, so systems
> using tmp-on-tmpfs don't end up inadvertently using RAM for the block
> device.
> 
> Signed-off-by: Amit Shah <amit.shah@redhat.com>
> ---
>  block.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Was expecting someone to argue against this because a path change is
always controversial :-).  But I think this makes sense and no one is
protesting....

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan
Amit Shah Feb. 27, 2014, 11:33 a.m. UTC | #2
On (Thu) 27 Feb 2014 [11:18:15], Stefan Hajnoczi wrote:
> On Wed, Feb 26, 2014 at 03:12:37PM +0530, Amit Shah wrote:
> > If TMPDIR is not specified, the default was to use /tmp for the working
> > copy of the block devices.  Update this to /var/tmp instead, so systems
> > using tmp-on-tmpfs don't end up inadvertently using RAM for the block
> > device.
> > 
> > Signed-off-by: Amit Shah <amit.shah@redhat.com>
> > ---
> >  block.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> Was expecting someone to argue against this because a path change is
> always controversial :-).  But I think this makes sense and no one is
> protesting....

You mean I can relax my crossed fingers now?

> Thanks, applied to my block tree:
> https://github.com/stefanha/qemu/commits/block

Thanks!

		Amit
Eric Blake Feb. 27, 2014, 1:42 p.m. UTC | #3
On 02/27/2014 04:33 AM, Amit Shah wrote:
> On (Thu) 27 Feb 2014 [11:18:15], Stefan Hajnoczi wrote:
>> On Wed, Feb 26, 2014 at 03:12:37PM +0530, Amit Shah wrote:
>>> If TMPDIR is not specified, the default was to use /tmp for the working
>>> copy of the block devices.  Update this to /var/tmp instead, so systems
>>> using tmp-on-tmpfs don't end up inadvertently using RAM for the block
>>> device.
>>>
>>> Signed-off-by: Amit Shah <amit.shah@redhat.com>
>>> ---
>>>  block.c | 5 +++--
>>>  1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> Was expecting someone to argue against this because a path change is
>> always controversial :-).  But I think this makes sense and no one is
>> protesting....

No protests here.  Libvirt doesn't use -snapshot to trigger the behavior
in the first place, and even if it did, it is always possible to
explicitly set TMPDIR if you don't like the (changed) default.
diff mbox

Patch

diff --git a/block.c b/block.c
index 2fd5482..38bbdf3 100644
--- a/block.c
+++ b/block.c
@@ -547,8 +547,9 @@  int get_tmp_filename(char *filename, int size)
     int fd;
     const char *tmpdir;
     tmpdir = getenv("TMPDIR");
-    if (!tmpdir)
-        tmpdir = "/tmp";
+    if (!tmpdir) {
+        tmpdir = "/var/tmp";
+    }
     if (snprintf(filename, size, "%s/vl.XXXXXX", tmpdir) >= size) {
         return -EOVERFLOW;
     }