From patchwork Sun Dec 13 20:43:41 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 41047 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 13C15B7082 for ; Mon, 14 Dec 2009 07:47:14 +1100 (EST) Received: from localhost ([127.0.0.1]:35216 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NJvLT-00076m-1W for incoming@patchwork.ozlabs.org; Sun, 13 Dec 2009 15:47:11 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NJvKr-00075T-OO for qemu-devel@nongnu.org; Sun, 13 Dec 2009 15:46:33 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NJvKo-00071Q-5M for qemu-devel@nongnu.org; Sun, 13 Dec 2009 15:46:33 -0500 Received: from [199.232.76.173] (port=47264 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NJvKn-00071C-LV for qemu-devel@nongnu.org; Sun, 13 Dec 2009 15:46:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:17870) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NJvKm-0006vQ-T8 for qemu-devel@nongnu.org; Sun, 13 Dec 2009 15:46:29 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nBDKkQKY027351 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 13 Dec 2009 15:46:26 -0500 Received: from redhat.com (vpn-6-140.tlv.redhat.com [10.35.6.140]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id nBDKkMHu010825; Sun, 13 Dec 2009 15:46:23 -0500 Date: Sun, 13 Dec 2009 22:43:41 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org, Anthony Liguori , kraxel@redhat.com Message-ID: <20091213204341.GA25823@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Subject: [Qemu-devel] [PATCH RFC] virtio: add features qdev property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add features property to virtio. This makes it possible to e.g. define machine without indirect buffer support, which is required for 0.10 compatibility. or without hardware checksum support, which is required for 0.11 compatibility. Signed-off-by: Michael S. Tsirkin --- Here's what I came up with for solving the problem of differences between features in virtio between 0.12 and 0.11 (applies on to of guest_features patch). Comments? Gerd, what do you think? hw/virtio-pci.c | 29 +++++++++++++++++++++++++++-- hw/virtio.h | 1 + 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index 80bc645..43b02b6 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -90,6 +90,7 @@ typedef struct { uint32_t addr; uint32_t class_code; uint32_t nvectors; + uint32_t host_features; DriveInfo *dinfo; NICConf nic; } VirtIOPCIProxy; @@ -235,8 +236,7 @@ static uint32_t virtio_ioport_read(VirtIOPCIProxy *proxy, uint32_t addr) switch (addr) { case VIRTIO_PCI_HOST_FEATURES: - ret = vdev->get_features(vdev); - ret |= vdev->binding->get_features(proxy); + ret = vdev->host_features; break; case VIRTIO_PCI_GUEST_FEATURES: ret = vdev->guest_features; @@ -398,6 +398,8 @@ static const VirtIOBindings virtio_pci_bindings = { .get_features = virtio_pci_get_features, }; +#define VIRTIO_PCI_NO_FEATURES 0xffffffff + static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev, uint16_t vendor, uint16_t device, uint16_t class_code, uint8_t pif) @@ -442,6 +444,18 @@ static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev, virtio_map); virtio_bind_device(vdev, &virtio_pci_bindings, proxy); + if (proxy->host_features == VIRTIO_PCI_NO_FEATURES) + proxy->host_features = vdev->get_features(vdev) | + vdev->binding->get_features(proxy); + else if (proxy->host_features & ~vdev->get_features(vdev) & + ~vdev->binding->get_features(proxy)) { + fprintf(stderr, "Requested host features 0x%x, " + "but supported features are transport:0x%x device:0x%x\n", + proxy->host_features, + vdev->binding->get_features(proxy), + vdev->get_features(vdev)); + exit(1); + } } static int virtio_blk_init_pci(PCIDevice *pci_dev) @@ -561,6 +575,8 @@ static PCIDeviceInfo virtio_info[] = { DEFINE_PROP_HEX32("class", VirtIOPCIProxy, class_code, 0), DEFINE_PROP_DRIVE("drive", VirtIOPCIProxy, dinfo), DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2), + DEFINE_PROP_HEX32("features", VirtIOPCIProxy, host_features, + VIRTIO_PCI_NO_FEATURES), DEFINE_PROP_END_OF_LIST(), }, .qdev.reset = virtio_pci_reset, @@ -571,6 +587,8 @@ static PCIDeviceInfo virtio_info[] = { .exit = virtio_net_exit_pci, .qdev.props = (Property[]) { DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 3), + DEFINE_PROP_HEX32("features", VirtIOPCIProxy, host_features, + 0xffffffff), DEFINE_NIC_PROPERTIES(VirtIOPCIProxy, nic), DEFINE_PROP_END_OF_LIST(), }, @@ -582,6 +600,8 @@ static PCIDeviceInfo virtio_info[] = { .exit = virtio_exit_pci, .qdev.props = (Property[]) { DEFINE_PROP_HEX32("class", VirtIOPCIProxy, class_code, 0), + DEFINE_PROP_HEX32("features", VirtIOPCIProxy, host_features, + VIRTIO_PCI_NO_FEATURES), DEFINE_PROP_END_OF_LIST(), }, .qdev.reset = virtio_pci_reset, @@ -590,6 +610,11 @@ static PCIDeviceInfo virtio_info[] = { .qdev.size = sizeof(VirtIOPCIProxy), .init = virtio_balloon_init_pci, .exit = virtio_exit_pci, + .qdev.props = (Property[]) { + DEFINE_PROP_HEX32("features", VirtIOPCIProxy, host_features, + VIRTIO_PCI_NO_FEATURES), + DEFINE_PROP_END_OF_LIST(), + }, .qdev.reset = virtio_pci_reset, },{ /* end of list */ diff --git a/hw/virtio.h b/hw/virtio.h index 85ef171..73f784f 100644 --- a/hw/virtio.h +++ b/hw/virtio.h @@ -101,6 +101,7 @@ struct VirtIODevice uint8_t isr; uint16_t queue_sel; uint32_t guest_features; + uint32_t host_features; size_t config_len; void *config; uint16_t config_vector;