qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] hostmem-file: add a property 'notrunc' to avoid


From: Eduardo Habkost
Subject: Re: [Qemu-devel] [PATCH] hostmem-file: add a property 'notrunc' to avoid data corruption
Date: Thu, 20 Oct 2016 11:34:19 -0200
User-agent: Mutt/1.7.0 (2016-08-17)

On Thu, Oct 20, 2016 at 09:11:38PM +0800, Haozhong Zhang wrote:
> On 10/20/16 14:34 +0200, Igor Mammedov wrote:
> > On Thu, 20 Oct 2016 14:13:01 +0800
> > Haozhong Zhang <address@hidden> wrote:
> > 
> > > If a file is used as the backend of memory-backend-file and its size is
> > > not identical to the property 'size', the file will be truncated. For a
> > > file used as the backend of vNVDIMM, its data is expected to be
> > > persistent and the truncation may corrupt the existing data.
> > I wonder if it's possible just skip 'size' property in your case instead
> > 'notrunc' property. That way if size is not present one'd get actual size
> > using get_file_size() and set 'size' to it?
> > And if 'size' is provided and 'size' != file_size then error out.
> > 
> 
> I don't know how this can be implemented in QEMU. Specially, how does
> the memory-backend-file know it's used for vNVDIMM, so that it can
> skip the 'size' property?
> 
> Besides, it cannot cover the case that only a part of file is used as
> the backend of vNVDIMM, which is allowed by the current implementation.

I see 3 possible cases:

* If desired RAM size is the same as file size, 'size' can be
  optional.
* If desired RAM size is smaller than file size, we don't need to
  truncate the file at all. In this case, we could even use the
  size specified in the frontend config options (-numa and/or
  -m), instead of requiring size to be specified on the backend
  object.
* If desired RAM size is larger than file size, the only option
  is to specify size explicitly on the backend object and extend
  it using ftruncate().

None of those cases would require a new option.

-- 
Eduardo



reply via email to

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