From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH v5 4/5] Inter-VM shared memory PCI device Date: Wed, 12 May 2010 19:45:12 +0300 Message-ID: <4BEADB18.4080704@redhat.com> References: <1271872408-22842-1-git-send-email-cam@cs.ualberta.ca> <1271872408-22842-4-git-send-email-cam@cs.ualberta.ca> <1271872408-22842-5-git-send-email-cam@cs.ualberta.ca> <4BE7F517.5010707@redhat.com> <4BE82623.4000905@redhat.com> <4BE836E5.9070106@redhat.com> <4BEACE16.9000206@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, qemu-devel@nongnu.org, Anthony Liguori To: Cam Macdonell Return-path: Received: from mx1.redhat.com ([209.132.183.28]:33515 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756528Ab0ELQpX (ORCPT ); Wed, 12 May 2010 12:45:23 -0400 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On 05/12/2010 07:14 PM, Cam Macdonell wrote: > >> Why can't we complete initialization before exposing the card and BAR? >> Seems to be the simplest solution. >> > Looking at it more closely, you're right, the fds for shared > memory/eventfds are received in a fraction of a second, so that's why > I haven't seen any problems since the memory is mapped before the BIOS > detects and configures the device. > > We can't block on a qemu char device (in anyway I can see) so we have > to handle mapping the memory BAR in the callback function. But, we > can make the semantics that the VM ID is not set until the memory is > mapped. So if the VM ID is -1, then the memory has not been mapped > yet, reads/writes work but don't do anything useful. So the user can > detect the mapping of the memory > and it does not invalidate PCI since the BAR is always present, but > just not mapped to the shared memory. > I don't like this very much. We expose an internal qemu implementation detail, the lack of ability to complete negotiation during init, and make the device more error prone to use. However, it does make some sense if we regard the device as an HBA accessing an external memory, so it's not unreasonable. But please be sure to document this. -- Do not meddle in the internals of kernels, for they are subtle and quick to panic.