From patchwork Thu Feb 7 09:46:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 218881 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5C1612C0293 for ; Thu, 7 Feb 2013 21:20:46 +1100 (EST) Received: from localhost ([::1]:53176 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U3O0m-0000CZ-P7 for incoming@patchwork.ozlabs.org; Thu, 07 Feb 2013 04:43:20 -0500 Received: from eggs.gnu.org ([208.118.235.92]:57923) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U3O01-0007yF-3h for qemu-devel@nongnu.org; Thu, 07 Feb 2013 04:42:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U3Nzy-0000vw-QM for qemu-devel@nongnu.org; Thu, 07 Feb 2013 04:42:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:9629) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U3Nzy-0000vs-HW for qemu-devel@nongnu.org; Thu, 07 Feb 2013 04:42:30 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r179gTo9016790 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 7 Feb 2013 04:42:29 -0500 Received: from redhat.com (vpn1-6-18.ams2.redhat.com [10.36.6.18]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id r179gQZN024351; Thu, 7 Feb 2013 04:42:26 -0500 Date: Thu, 7 Feb 2013 11:46:51 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <55cc184302b3f8109daab6439859e7be9909fc68.1360229117.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Anthony Liguori , "Michael S. Tsirkin" , Jan Kiszka , Jason Wang , Gerd Hoffmann , Stefan Hajnoczi , Paolo Bonzini , Amos Kong Subject: [Qemu-devel] [PATCHv2 2/2] virtio-net: work around for windows driver bug X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Windows drivers from 22 Jan 2013 and older fail when config size != 32, which was the size before max_virtqueue_pairs was added. Force config size to a value these drivers expect to avoid breakage unless we really need max_virtqueue_pairs. Signed-off-by: Michael S. Tsirkin --- hw/virtio-net.c | 15 ++++++++++++--- hw/virtio-net.h | 6 +++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/hw/virtio-net.c b/hw/virtio-net.c index 510a0f6..2464cd5 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -1287,9 +1287,18 @@ VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf, { VirtIONet *n; int i; - - n = (VirtIONet *)virtio_common_init("virtio-net", VIRTIO_ID_NET, - sizeof(struct virtio_net_config), + size_t config_size; + + /* + * Windows drivers from 22 Jan 2013 and older fail when config size != 32, + * which was the size before max_virtqueue_pairs was added. + * Force config size to a value these drivers expect to avoid + * breakage unless we really need max_virtqueue_pairs. + */ + config_size = conf->queues > 1 ? sizeof(struct virtio_net_config) : + offsetof(struct virtio_net_config, max_virtqueue_pairs); + + n = (VirtIONet *)virtio_common_init("virtio-net", VIRTIO_ID_NET, config_size, sizeof(VirtIONet)); n->vdev.get_config = virtio_net_get_config; diff --git a/hw/virtio-net.h b/hw/virtio-net.h index 414365d..799b2ca 100644 --- a/hw/virtio-net.h +++ b/hw/virtio-net.h @@ -75,7 +75,11 @@ struct virtio_net_config uint8_t mac[ETH_ALEN]; /* See VIRTIO_NET_F_STATUS and VIRTIO_NET_S_* above */ uint16_t status; - /* Max virtqueue pairs supported by the device */ + /* + * Fields below need special handling because of driver bugs. + * See virtio_net_init. + * Max virtqueue pairs supported by the device. + */ uint16_t max_virtqueue_pairs; } QEMU_PACKED;