qemu-devel
[Top][All Lists]
Advanced

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

Re: [External] [PATCH] hostmem: Add clear option to file backend


From: Feiran Zheng
Subject: Re: [External] [PATCH] hostmem: Add clear option to file backend
Date: Thu, 2 Mar 2023 13:31:17 +0000


> On 2 Mar 2023, at 11:54, David Hildenbrand <david@redhat.com> wrote:
> 
> On 02.03.23 12:48, Feiran Zheng wrote:
>>> On 2 Mar 2023, at 11:39, David Hildenbrand <david@redhat.com> wrote:
>>> 
>>> On 02.03.23 12:37, Feiran Zheng wrote:
>>>>> On 2 Mar 2023, at 11:31, David Hildenbrand <david@redhat.com> wrote:
>>>>> 
>>>>> On 02.03.23 12:09, Fam Zheng wrote:
>>>>>> This adds a memset to clear the backing memory. This is useful in the
>>>>>> case of PMEM DAX to drop dirty data, if the backing memory is handed
>>>>>> over from a previous application or firmware which didn't clean up
>>>>>> before exiting.
>>>>> 
>>>>> Why can't the VM manager do that instead? If you have a file that's 
>>>>> certainly easily possible.
>>>> Hi David,
>>>> Technically yes, but I have a simple VM manager here which wants to avoid 
>>>> replicating the same mmap code, such as handling the flags depending on 
>>>> share=on|off,hugepages=on|off. All in all this approach requires the least 
>>>> additional code to achieve it.
>>> 
>>> so ... we're supposed to maintain that code in QEMU instead to make your 
>>> life easier ? :)
>>> 
>>> Sorry, for this particular use case I don't see the big benefit of moving 
>>> that code into QEMU.
>>> 
>> I am posting because this does not only makes my life easier, supposedly it 
>> also make other developers life easier, because the file here can be a char 
>> file and there is no easy way to clear it (/dev/dax1.0) from command line if 
>> you want to invoke a QEMU command directly.
>> Maybe I’m missing a convenient command to clear a DAX char file?
> 
> Can't you simply use dd and read from /dev/zero?
> 

I don’t think it works for dax because the fs driver only implemented mmap, not 
read/write:

# strace -e write dd if=/dev/zero of=/dev/dax1.0 bs=1G count=1
write(1, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 
1073741824) = -1 EINVAL (Invalid argument)
write(2, "dd: error writing '/dev/dax1.0':"..., 50dd: error writing 
'/dev/dax1.0': Invalid argument

Fam


reply via email to

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