From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41416) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1biPDu-0000mu-I6 for qemu-devel@nongnu.org; Fri, 09 Sep 2016 13:04:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1biPDq-0007SQ-B3 for qemu-devel@nongnu.org; Fri, 09 Sep 2016 13:04:17 -0400 References: <1473426607-10516-1-git-send-email-maxime.coquelin@redhat.com> <1473426607-10516-3-git-send-email-maxime.coquelin@redhat.com> From: Marcel Apfelbaum Message-ID: <5570da9e-f095-f81d-a179-2eb7b2b9645b@redhat.com> Date: Fri, 9 Sep 2016 20:04:08 +0300 MIME-Version: 1.0 In-Reply-To: <1473426607-10516-3-git-send-email-maxime.coquelin@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 2/2] virtio-pci: Disable modern interface if backend without VIRTIO_F_VERSION_1 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Maxime Coquelin , mst@redhat.com, qemu-devel@nongnu.org, cornelia.huck@de.ibm.com Cc: vkaplans@redhat.com, qemu-stable@nongnu.org On 09/09/2016 04:10 PM, Maxime Coquelin wrote: > This patch makes pci devices plugging more robust, by not confusing > guest with modern interface when the backend doesn't support > VIRTIO_F_VERSION_1. > > Cc: Cornelia Huck > Cc: Marcel Apfelbaum > Cc: Michael S. Tsirkin > Cc: qemu-stable@nongnu.org > Signed-off-by: Maxime Coquelin > --- > hw/virtio/virtio-pci.c | 15 +++++++++++++++ > hw/virtio/virtio-pci.h | 5 +++++ > 2 files changed, 20 insertions(+) > > diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c > index 755f921..9e88d7b 100644 > --- a/hw/virtio/virtio-pci.c > +++ b/hw/virtio/virtio-pci.c > @@ -1581,6 +1581,21 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp) > uint32_t size; > VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); > > + /* > + * Virtio capabilities present without > + * VIRTIO_F_VERSION_1 confuses guests > + */ > + if (!virtio_test_backend_virtio_1(vdev, errp)) { > + virtio_pci_disable_modern(proxy); > + } > + > + legacy = virtio_pci_legacy(proxy); > + modern = virtio_pci_modern(proxy); I think the first initialization of the legacy/modern variables is not necessary anymore. Other than that it looks good to me. Thanks, Marcel > + if (!legacy && !modern) { > + error_setg(errp, "PCI device is neither legacy nor modern."); > + return; > + } > + > config = proxy->pci_dev.config; > if (proxy->class_code) { > pci_config_set_class(config, proxy->class_code); > diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h > index 25fbf8a..4e976b3 100644 > --- a/hw/virtio/virtio-pci.h > +++ b/hw/virtio/virtio-pci.h > @@ -172,6 +172,11 @@ static inline void virtio_pci_force_virtio_1(VirtIOPCIProxy *proxy) > proxy->disable_legacy = ON_OFF_AUTO_ON; > } > > +static inline void virtio_pci_disable_modern(VirtIOPCIProxy *proxy) > +{ > + proxy->disable_modern = true; > +} > + > /* > * virtio-scsi-pci: This extends VirtioPCIProxy. > */ >