From patchwork Tue Dec 30 16:28:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 424655 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 314C4140119 for ; Wed, 31 Dec 2014 03:29:15 +1100 (AEDT) Received: from localhost ([::1]:37396 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y5zfV-0004zh-1Z for incoming@patchwork.ozlabs.org; Tue, 30 Dec 2014 11:29:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35519) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y5zf0-0003oE-Qg for qemu-devel@nongnu.org; Tue, 30 Dec 2014 11:28:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y5zez-0002ZP-Rt for qemu-devel@nongnu.org; Tue, 30 Dec 2014 11:28:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59970) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y5zez-0002ZI-Kl for qemu-devel@nongnu.org; Tue, 30 Dec 2014 11:28:41 -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 sBUGSbFQ003047 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 30 Dec 2014 11:28:37 -0500 Received: from redhat.com (dhcp-4-119.tlv.redhat.com [10.35.4.119]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id sBUGSZ2F007709; Tue, 30 Dec 2014 11:28:35 -0500 Date: Tue, 30 Dec 2014 18:28:34 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1419956898-25297-3-git-send-email-mst@redhat.com> References: <1419956898-25297-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1419956898-25297-1-git-send-email-mst@redhat.com> 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: cornelia.huck@de.ibm.com, Rusty Russell , Anthony Liguori Subject: [Qemu-devel] [PATCH RFC 2/3] virtio: misc fixes, include linux header 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 Tweak virtio core so we can use linux virtio pci header directly without duplicating code. Signed-off-by: Michael S. Tsirkin --- hw/net/virtio-net.c | 2 +- hw/virtio/virtio-pci.c | 3 +++ hw/virtio/virtio.c | 13 +++++++++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index b5dd356..5fff769 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1046,7 +1046,7 @@ static ssize_t virtio_net_receive(NetClientState *nc, const uint8_t *buf, size_t return -1; error_report("virtio-net unexpected empty queue: " "i %zd mergeable %d offset %zd, size %zd, " - "guest hdr len %zd, host hdr len %zd guest features 0x%lx", + "guest hdr len %zd, host hdr len %zd guest features 0x%"PRIx64, i, n->mergeable_rx_bufs, offset, size, n->guest_hdr_len, n->host_hdr_len, vdev->guest_features); exit(1); diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 7382705..bc11d3d 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -17,6 +17,7 @@ #include +#include "linux-headers/linux/virtio_pci.h" #include "hw/virtio/virtio.h" #include "hw/virtio/virtio-blk.h" #include "hw/virtio/virtio-net.h" @@ -76,6 +77,8 @@ VIRTIO_PCI_CONFIG_MSI : \ VIRTIO_PCI_CONFIG_NOMSI) +#undef VIRTIO_PCI_CONFIG + /* The remaining space is defined by each driver as the per-driver * configuration space */ #define VIRTIO_PCI_CONFIG(dev) (msix_enabled(dev) ? \ diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 90eedd3..301b83f 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1033,7 +1033,8 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id) int i, ret; int32_t config_len; uint32_t num; - uint32_t features; + uint32_t features_lo, features_hi; + uint64_t features; uint64_t supported_features; BusState *qbus = qdev_get_parent_bus(DEVICE(vdev)); VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); @@ -1057,12 +1058,16 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id) if (vdev->queue_sel >= VIRTIO_PCI_QUEUE_MAX) { return -1; } - qemu_get_be32s(f, &features); + qemu_get_be32s(f, &features_lo); + + //if (features_lo & (1UL << VIRTIO_F_VERSION_1)) { + qemu_get_be32s(f, &features_hi); + //} + features = (((uint64_t)features_hi) << 32) | features_lo; - /* XXX features >= 32 */ if (__virtio_set_features(vdev, features) < 0) { supported_features = k->get_features(qbus->parent); - error_report("Features 0x%x unsupported. Allowed features: 0x%lx", + error_report("Features 0x%"PRIx64" unsupported. Allowed features: 0x%"PRIx64, features, supported_features); return -1; }