From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:54383) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QpKpC-0001ZW-GT for qemu-devel@nongnu.org; Fri, 05 Aug 2011 09:52:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QpKpB-0001a0-H8 for qemu-devel@nongnu.org; Fri, 05 Aug 2011 09:52:30 -0400 Received: from mail-yi0-f45.google.com ([209.85.218.45]:59999) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QpKpB-0001Zw-D9 for qemu-devel@nongnu.org; Fri, 05 Aug 2011 09:52:29 -0400 Received: by yih10 with SMTP id 10so383702yih.4 for ; Fri, 05 Aug 2011 06:52:28 -0700 (PDT) Message-ID: <4E3BF599.4050207@codemonkey.ws> Date: Fri, 05 Aug 2011 08:52:25 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <1312463195-13605-1-git-send-email-avi@redhat.com> <1312463195-13605-2-git-send-email-avi@redhat.com> In-Reply-To: <1312463195-13605-2-git-send-email-avi@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v3 01/39] virtio-pci: get config on init List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, "Michael S. Tsirkin" On 08/04/2011 08:05 AM, Avi Kivity wrote: > From: "Michael S. Tsirkin" > > We originally did get config on map, so that > following write accesses are done on an updated config. > New memory API doesn't give us a callback > on map, and arguably, devices don't know when > cpu really can access there. So updating on > init seems cleaner. > > Signed-off-by: Michael S. Tsirkin > Signed-off-by: Avi Kivity > --- > hw/virtio-pci.c | 7 ++++--- > 1 files changed, 4 insertions(+), 3 deletions(-) > > diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c > index d685243..ca1f12f 100644 > --- a/hw/virtio-pci.c > +++ b/hw/virtio-pci.c > @@ -506,9 +506,6 @@ static void virtio_map(PCIDevice *pci_dev, int region_num, > register_ioport_read(addr, config_len, 1, virtio_pci_config_readb, proxy); > register_ioport_read(addr, config_len, 2, virtio_pci_config_readw, proxy); > register_ioport_read(addr, config_len, 4, virtio_pci_config_readl, proxy); > - > - if (vdev->config_len) > - vdev->get_config(vdev, vdev->config); > } > > static void virtio_write_config(PCIDevice *pci_dev, uint32_t address, > @@ -689,6 +686,10 @@ void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev) > proxy->host_features |= 0x1<< VIRTIO_F_NOTIFY_ON_EMPTY; > proxy->host_features |= 0x1<< VIRTIO_F_BAD_FEATURE; > proxy->host_features = vdev->get_features(vdev, proxy->host_features); > + > + if (vdev->config_len) { > + vdev->get_config(vdev, vdev->config); > + } Thinking more closely, I don't think this right. Updating on map ensured that the config was refreshed after each time the bar was mapped. In the very least, the config needs to be refreshed during reset because the guest may write to the guest space which should get cleared after reset. Regards, Anthony Liguori > } > > static int virtio_blk_init_pci(PCIDevice *pci_dev)