All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Cam Macdonell <cam@cs.ualberta.ca>
Cc: Avi Kivity <avi@redhat.com>, kvm@vger.kernel.org, qemu-devel@nongnu.org
Subject: Re: [PATCH v5 4/5] Inter-VM shared memory PCI device
Date: Mon, 10 May 2010 11:52:13 -0500	[thread overview]
Message-ID: <4BE839BD.1060502@codemonkey.ws> (raw)
In-Reply-To: <AANLkTilgxXDVCpnqmZL9KErsdfbgrjujvIStoSULirf3@mail.gmail.com>

On 05/10/2010 11:20 AM, Cam Macdonell wrote:
> On Mon, May 10, 2010 at 9:38 AM, Anthony Liguori<anthony@codemonkey.ws>  wrote:
>    
>> On 05/10/2010 10:28 AM, Avi Kivity wrote:
>>      
>>> On 05/10/2010 06:22 PM, Cam Macdonell wrote:
>>>        
>>>>          
>>>>>            
>>>>>> +
>>>>>> +    /* if the position is -1, then it's shared memory region fd */
>>>>>> +    if (incoming_posn == -1) {
>>>>>> +
>>>>>> +        s->num_eventfds = 0;
>>>>>> +
>>>>>> +        if (check_shm_size(s, incoming_fd) == -1) {
>>>>>> +            exit(-1);
>>>>>> +        }
>>>>>> +
>>>>>> +        /* creating a BAR in qemu_chr callback may be crazy */
>>>>>> +        create_shared_memory_BAR(s, incoming_fd);
>>>>>>
>>>>>>              
>>>>> It probably is... why can't you create it during initialization?
>>>>>            
>>>> This is for the shared memory server implementation, so the fd for the
>>>> shared memory has to be received (over the qemu char device) from the
>>>> server before the BAR can be created via qemu_ram_mmap() which adds
>>>> the necessary memory
>>>>
>>>>          
>>>
>>> We could do the handshake during initialization.  I'm worried that the
>>> device will appear without the BAR, and strange things will happen.  But the
>>> chardev API is probably not geared for passing data during init.
>>>
>>> Anthony, any ideas?
>>>        
>> Why can't we create the BAR with just normal RAM and then change it to a
>> mmap()'d fd after initialization?  This will be behavior would be important
>> for live migration as it would let you quickly migrate preserving the memory
>> contents without waiting for an external program to reconnect.
>>
>> Regards,
>>
>> Anthony Lioguori
>>
>>      
>>>> Otherwise, if the BAR is allocated during initialization, I would have
>>>> to use MAP_FIXED to mmap the memory.  This is what I did before the
>>>> qemu_ram_mmap() function was added.
>>>>          
>>> What would happen to any data written to the BAR before the the handshake
>>> completed?  I think it would disappear.
>>>        
>> You don't have to do MAP_FIXED.  You can allocate a ram area and map that in
>> when disconnected.  When you connect, you create another ram area and
>> memcpy() the previous ram area to the new one.  You then map the second ram
>> area in.
>>      
> the memcpy() would overwrite the contents of the shared memory each
> time a guest joins which would be dangerous.
>    

I think those are reasonable semantics and is really the only way to get 
guest-transparent reconnect.  The later is pretty critical for guest 
transparent live migration.

>>  From the guest's perspective, it's totally transparent.  For the backend,
>> I'd suggest having an explicit "initialized" ack or something so that it
>> knows that the data is now mapped to the guest.
>>      
> Yes, I think the ack is the way to go, so the guest has to be aware of
> it.  Would setting a flag in the driver-specific config space be an
> acceptable ack that the shared region is now mapped?
>    

You know it's mapped because it's mapped when the pci map function 
returns.  You don't need the guest to explicitly tell you.

Regards,

Anthony Liguori

> Cam
>    


WARNING: multiple messages have this Message-ID (diff)
From: Anthony Liguori <anthony@codemonkey.ws>
To: Cam Macdonell <cam@cs.ualberta.ca>
Cc: Avi Kivity <avi@redhat.com>, kvm@vger.kernel.org, qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH v5 4/5] Inter-VM shared memory PCI device
Date: Mon, 10 May 2010 11:52:13 -0500	[thread overview]
Message-ID: <4BE839BD.1060502@codemonkey.ws> (raw)
In-Reply-To: <AANLkTilgxXDVCpnqmZL9KErsdfbgrjujvIStoSULirf3@mail.gmail.com>

On 05/10/2010 11:20 AM, Cam Macdonell wrote:
> On Mon, May 10, 2010 at 9:38 AM, Anthony Liguori<anthony@codemonkey.ws>  wrote:
>    
>> On 05/10/2010 10:28 AM, Avi Kivity wrote:
>>      
>>> On 05/10/2010 06:22 PM, Cam Macdonell wrote:
>>>        
>>>>          
>>>>>            
>>>>>> +
>>>>>> +    /* if the position is -1, then it's shared memory region fd */
>>>>>> +    if (incoming_posn == -1) {
>>>>>> +
>>>>>> +        s->num_eventfds = 0;
>>>>>> +
>>>>>> +        if (check_shm_size(s, incoming_fd) == -1) {
>>>>>> +            exit(-1);
>>>>>> +        }
>>>>>> +
>>>>>> +        /* creating a BAR in qemu_chr callback may be crazy */
>>>>>> +        create_shared_memory_BAR(s, incoming_fd);
>>>>>>
>>>>>>              
>>>>> It probably is... why can't you create it during initialization?
>>>>>            
>>>> This is for the shared memory server implementation, so the fd for the
>>>> shared memory has to be received (over the qemu char device) from the
>>>> server before the BAR can be created via qemu_ram_mmap() which adds
>>>> the necessary memory
>>>>
>>>>          
>>>
>>> We could do the handshake during initialization.  I'm worried that the
>>> device will appear without the BAR, and strange things will happen.  But the
>>> chardev API is probably not geared for passing data during init.
>>>
>>> Anthony, any ideas?
>>>        
>> Why can't we create the BAR with just normal RAM and then change it to a
>> mmap()'d fd after initialization?  This will be behavior would be important
>> for live migration as it would let you quickly migrate preserving the memory
>> contents without waiting for an external program to reconnect.
>>
>> Regards,
>>
>> Anthony Lioguori
>>
>>      
>>>> Otherwise, if the BAR is allocated during initialization, I would have
>>>> to use MAP_FIXED to mmap the memory.  This is what I did before the
>>>> qemu_ram_mmap() function was added.
>>>>          
>>> What would happen to any data written to the BAR before the the handshake
>>> completed?  I think it would disappear.
>>>        
>> You don't have to do MAP_FIXED.  You can allocate a ram area and map that in
>> when disconnected.  When you connect, you create another ram area and
>> memcpy() the previous ram area to the new one.  You then map the second ram
>> area in.
>>      
> the memcpy() would overwrite the contents of the shared memory each
> time a guest joins which would be dangerous.
>    

I think those are reasonable semantics and is really the only way to get 
guest-transparent reconnect.  The later is pretty critical for guest 
transparent live migration.

>>  From the guest's perspective, it's totally transparent.  For the backend,
>> I'd suggest having an explicit "initialized" ack or something so that it
>> knows that the data is now mapped to the guest.
>>      
> Yes, I think the ack is the way to go, so the guest has to be aware of
> it.  Would setting a flag in the driver-specific config space be an
> acceptable ack that the shared region is now mapped?
>    

You know it's mapped because it's mapped when the pci map function 
returns.  You don't need the guest to explicitly tell you.

Regards,

Anthony Liguori

> Cam
>    

  reply	other threads:[~2010-05-10 16:52 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-21 17:53 [PATCH v5 0/5] PCI Shared Memory device Cam Macdonell
2010-04-21 17:53 ` [Qemu-devel] " Cam Macdonell
2010-04-21 17:53 ` [PATCH v5 1/5] Device specification for shared memory PCI device Cam Macdonell
2010-04-21 17:53   ` [Qemu-devel] " Cam Macdonell
2010-04-21 17:53   ` [PATCH v5 2/5] Support adding a file to qemu's ram allocation Cam Macdonell
2010-04-21 17:53     ` [Qemu-devel] " Cam Macdonell
2010-04-21 17:53     ` [PATCH v5 3/5] Add functions for assigning ioeventfd and irqfds Cam Macdonell
2010-04-21 17:53       ` [Qemu-devel] " Cam Macdonell
2010-04-21 17:53       ` [PATCH v5 4/5] Inter-VM shared memory PCI device Cam Macdonell
2010-04-21 17:53         ` [Qemu-devel] " Cam Macdonell
2010-04-21 18:00         ` [PATCH v5 5/5] shared memory server for inter-VM shared memory Cam Macdonell
2010-04-21 18:00           ` [Qemu-devel] " Cam Macdonell
2010-05-05 16:57         ` [PATCH v5 4/5] RESEND: Inter-VM shared memory PCI device Cam Macdonell
2010-05-05 16:57           ` [Qemu-devel] " Cam Macdonell
2010-05-06 17:32         ` [PATCH v5 4/5] " Anthony Liguori
2010-05-06 17:32           ` [Qemu-devel] " Anthony Liguori
2010-05-06 17:59           ` Cam Macdonell
2010-05-06 17:59             ` [Qemu-devel] " Cam Macdonell
2010-05-10 11:59         ` Avi Kivity
2010-05-10 11:59           ` [Qemu-devel] " Avi Kivity
2010-05-10 15:22           ` Cam Macdonell
2010-05-10 15:22             ` [Qemu-devel] " Cam Macdonell
2010-05-10 15:28             ` Avi Kivity
2010-05-10 15:28               ` [Qemu-devel] " Avi Kivity
2010-05-10 15:38               ` Anthony Liguori
2010-05-10 15:38                 ` [Qemu-devel] " Anthony Liguori
2010-05-10 16:20                 ` Cam Macdonell
2010-05-10 16:20                   ` [Qemu-devel] " Cam Macdonell
2010-05-10 16:52                   ` Anthony Liguori [this message]
2010-05-10 16:52                     ` Anthony Liguori
2010-05-18 16:58                     ` Cam Macdonell
2010-05-18 16:58                       ` [Qemu-devel] " Cam Macdonell
2010-05-18 17:27                       ` Avi Kivity
2010-05-18 17:27                         ` [Qemu-devel] " Avi Kivity
2010-05-10 16:59                 ` Avi Kivity
2010-05-10 16:59                   ` [Qemu-devel] " Avi Kivity
2010-05-10 17:25                   ` Anthony Liguori
2010-05-10 17:25                     ` [Qemu-devel] " Anthony Liguori
2010-05-10 17:43                     ` Cam Macdonell
2010-05-10 17:43                       ` [Qemu-devel] " Cam Macdonell
2010-05-10 17:52                       ` Anthony Liguori
2010-05-10 17:52                         ` [Qemu-devel] " Anthony Liguori
2010-05-10 18:01                         ` Cam Macdonell
2010-05-10 18:01                           ` [Qemu-devel] " Cam Macdonell
2010-05-11  7:59                         ` Avi Kivity
2010-05-11  7:59                           ` [Qemu-devel] " Avi Kivity
2010-05-11 13:10                           ` Anthony Liguori
2010-05-11 13:10                             ` [Qemu-devel] " Anthony Liguori
2010-05-11 14:03                             ` Avi Kivity
2010-05-11 14:03                               ` [Qemu-devel] " Avi Kivity
2010-05-11 14:17                               ` Cam Macdonell
2010-05-11 14:17                                 ` [Qemu-devel] " Cam Macdonell
2010-05-11 14:53                                 ` Avi Kivity
2010-05-11 14:53                                   ` [Qemu-devel] " Avi Kivity
2010-05-11 15:51                                   ` Anthony Liguori
2010-05-11 15:51                                     ` [Qemu-devel] " Anthony Liguori
2010-05-11 16:39                                     ` Cam Macdonell
2010-05-11 16:39                                       ` [Qemu-devel] " Cam Macdonell
2010-05-11 17:05                                       ` Anthony Liguori
2010-05-11 17:05                                         ` [Qemu-devel] " Anthony Liguori
2010-05-11 17:50                                         ` Cam Macdonell
2010-05-11 17:50                                           ` [Qemu-devel] " Cam Macdonell
2010-05-11 18:13                                         ` Avi Kivity
2010-05-11 18:13                                           ` [Qemu-devel] " Avi Kivity
2010-05-12 15:32                                           ` Cam Macdonell
2010-05-12 15:32                                             ` [Qemu-devel] " Cam Macdonell
2010-05-12 15:48                                             ` Avi Kivity
2010-05-12 15:48                                               ` [Qemu-devel] " Avi Kivity
2010-05-11 18:09                                     ` Avi Kivity
2010-05-11 18:09                                       ` [Qemu-devel] " Avi Kivity
2010-05-11  7:55                     ` Avi Kivity
2010-05-11  7:55                       ` [Qemu-devel] " Avi Kivity
2010-05-10 15:41               ` Cam Macdonell
2010-05-10 15:41                 ` [Qemu-devel] " Cam Macdonell
2010-05-10 16:40                 ` Avi Kivity
2010-05-10 16:40                   ` [Qemu-devel] " Avi Kivity
2010-05-10 16:48                   ` Cam Macdonell
2010-05-10 16:48                     ` [Qemu-devel] " Cam Macdonell
2010-05-12 15:49                     ` Avi Kivity
2010-05-12 15:49                       ` [Qemu-devel] " Avi Kivity
2010-05-12 16:14                       ` Cam Macdonell
2010-05-12 16:14                         ` [Qemu-devel] " Cam Macdonell
2010-05-12 16:45                         ` Avi Kivity
2010-05-12 16:45                           ` [Qemu-devel] " Avi Kivity
2010-05-10 23:17           ` Cam Macdonell
2010-05-10 23:17             ` [Qemu-devel] " Cam Macdonell
2010-05-11  8:03             ` Avi Kivity
2010-05-11  8:03               ` [Qemu-devel] " Avi Kivity
2010-05-13 21:10           ` Cam Macdonell
2010-05-13 21:10             ` [Qemu-devel] " Cam Macdonell
2010-05-15  6:05             ` Avi Kivity
2010-05-15  6:05               ` [Qemu-devel] " Avi Kivity
2010-05-10 10:43       ` [PATCH v5 3/5] Add functions for assigning ioeventfd and irqfds Avi Kivity
2010-05-10 10:43         ` [Qemu-devel] " Avi Kivity
2010-05-10 15:13         ` Cam Macdonell
2010-05-10 15:13           ` [Qemu-devel] " Cam Macdonell
2010-05-10 15:17           ` Avi Kivity
2010-05-10 15:17             ` [Qemu-devel] " Avi Kivity
2010-05-10 10:39     ` [PATCH v5 2/5] Support adding a file to qemu's ram allocation Avi Kivity
2010-05-10 10:39       ` [Qemu-devel] " Avi Kivity
2010-05-10 15:32       ` Cam Macdonell
2010-05-10 15:32         ` [Qemu-devel] " Cam Macdonell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4BE839BD.1060502@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=avi@redhat.com \
    --cc=cam@cs.ualberta.ca \
    --cc=kvm@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.