qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v8 06/13] qemu.py: make sure we only remove file


From: Amador Pahim
Subject: Re: [Qemu-devel] [PATCH v8 06/13] qemu.py: make sure we only remove files we create
Date: Thu, 14 Sep 2017 22:21:11 +0200

On Thu, Sep 14, 2017 at 10:18 PM, Eduardo Habkost <address@hidden> wrote:
> On Thu, Sep 14, 2017 at 10:05:50PM +0200, Amador Pahim wrote:
>> On Thu, Sep 14, 2017 at 9:46 PM, Eduardo Habkost <address@hidden> wrote:
>> > On Thu, Sep 14, 2017 at 09:38:13PM +0200, Amador Pahim wrote:
>> >> On Tue, Sep 5, 2017 at 5:18 AM, Fam Zheng <address@hidden> wrote:
>> >> > On Fri, 09/01 13:28, Amador Pahim wrote:
> [...]
>> >> >> +        else:
>> >> >> +            if not isinstance(self._monitor_address, tuple):
>> >> >> +                self._created_files.append(self._monitor_address)
>> >> >> +
>> >> >> +        try:
>> >> >> +            flags = os.O_CREAT | os.O_EXCL | os.O_WRONLY
>> >> >> +            os.open(self._qemu_log_path, flags)
>> >> >
>> >> > Why change to os.open() instead of open()?
>> >>
>> >> I want to create the file only if it does not exist. The open() flag
>> >> 'x' is available only in python 3.3. For python <3.3, we need the
>> >> os.open() to have that feature.
>> >
>> > I'm not sure this extra complexity is really necessary.  We could
>> > fix all that by using mkdtemp() and deleting the temporary
>> > directory on shutdown.
>>
>> I thought about that, but I foresee the question: hat happens if
>> between the mkdtemp and the file creation (i.e. self._qemu_log_path)
>> someone goes in that directory and creates a file with the same name
>> of the self._qemu_log_path? Are we going to overwrite it? Ok, very
>> unlikely, but possible. This extra step takes care of that.
>
> If someone creates a file inside a directory we created using
> mkdtemp(), we will just delete it.  Why would that be a problem?

Ok then. That simplifies the control a lot.
Thanks.

>
> --
> Eduardo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]