[libvirt] [PATCH] qemuDomainRemoveMemoryDevice: unlink() memory backing file

Michal Privoznik mprivozn at redhat.com
Thu Jan 11 12:39:05 UTC 2018


On 01/11/2018 01:32 PM, Daniel P. Berrange wrote:
> On Thu, Jan 11, 2018 at 01:24:57PM +0100, Michal Privoznik wrote:
>> https://bugzilla.redhat.com/show_bug.cgi?id=1461214
>>
>> Since fec8f9c49af we try to use predictable file names for
>> 'memory-backend-file' objects. But that made us provide full path
>> to qemu when hot plugging the object while previously we provided
>> merely a directory. But this makes qemu behave differently. If
>> qemu sees a path terminated with a directory it calls mkstemp()
>> and unlinks the file immediately. But if it sees full path it
>> just calls open(path, O_CREAT ..); and never unlinks the file.
>> Therefore it's up to libvirt to unlink the file and not leave it
>> behind.
> 
> IIUC, this unlinks the file when QEMU shuts down (or the mem device is
> unplugged).
> 
> Is there any benefit and/or downside to doing the same as QEMU and
> unlinking it immediately after QEMU has opened it ? I guess figuring
> out the right time might be hard todo race-free.

Yeah, I thought about that race too. Also, since we use
memory-backing-file whenever memoryBacking/access/@mode='shared' or
memoryBacking/source/@type='file' is used I figured that whoever set
those might want to do something with the files (e.g. read them?). But
if we unlink them right away we would be only making it harder for users
to get to the files. But I don't have strong preference either way.

Michal




More information about the libvir-list mailing list