Re: [ANNOUNCE] kvm-46 release

Anthony Liguori
2007-10-11T01:13:54Z

Jun Koi wrote:
> On 10/10/07, Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org> wrote:
>
>> Jun Koi wrote:
>>
>>> On 10/10/07, Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org> wrote:
>>>
>>>
>>>> Jun Koi wrote:
>>>>
>>>>
>>>>> Hi,
>>>>>
>>>>> On 10/10/07, Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org> wrote:
>>>>>
>>>>>
>>>>>
>>>>>> We've now switched to allocating guest memory in userspace rather than
>>>>>> in the kernel. This is important if you have a mainframe, but also if
>>>>>> you want to share memory between guests and implement nice features like
>>>>>> swapping.
>>>>>>
>>>>>>
>>>>>>
>>>>> This is interesting! But how can we do that now? (share memory between guests)
>>>>>
>>>>>
>>>>>
>>>>>
>>>> It's not exposed by qemu, but you can now mmap() some file (or use SysV
>>>> shared memory) and use that as guest memory.
>>>>
>>>>
>>>>
>>> OK, lets say we have 2 guest VMs share a memory, like mmap() a tmpfs
>>> file (which is actually in memory). Now one writes to the memory
>>> (shared file). Can we guarantee that the memory immediately updated,
>>> so other will see the change immediately? Or the data might be cached
>>> for a while, befere being flushed to the shared memory?
>>>
>>>
>> Changes are visible immediately.
>>
>>
>
> OK, that is about sharing memory file. How about a shared file in
> which a file is a real physical file on the host?
>
> As far as I remember, there is a caution about sharing a file using
> mmap() between 2 processes, that is: if the first process modifies the
> shared file, it might take a while for the changes to be flushed from
> cache to the file. That means the other process doesnt see the change
> immediately.
>

Changes to a mmap() file may not be flushed to the disk until an msync
or munmap but if you've got it opened with MAP_SHARED, then everyone
mapping will have access to the same physical memory IIUC. You still
need to use barriers to take into account SMP. There may be some weird
interactions if the area isn't mlocked but I'm not totally sure on that.

Regards,

Anthony Liguori

> I guess this problem affects us in this case, when we use a real
> (physical) file to share between 2 VMs, correct?
>
> Thanks,
> Jun
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> kvm-devel mailing list
> kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/kvm-devel