From patchwork Mon Nov 2 22:23:30 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: 57152 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nA2MQX3D019196 for ; Mon, 2 Nov 2009 22:26:33 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757195AbZKBW00 (ORCPT ); Mon, 2 Nov 2009 17:26:26 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757185AbZKBW00 (ORCPT ); Mon, 2 Nov 2009 17:26:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:11936 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757193AbZKBW0Z (ORCPT ); Mon, 2 Nov 2009 17:26:25 -0500 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nA2MPwqQ002230; Mon, 2 Nov 2009 17:25:58 -0500 Received: from redhat.com (vpn-6-135.tlv.redhat.com [10.35.6.135]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id nA2MPsGA001773; Mon, 2 Nov 2009 17:25:55 -0500 Date: Tue, 3 Nov 2009 00:23:30 +0200 From: "Michael S. Tsirkin" To: avi@redhat.com, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org Cc: gregory.haskins@gmail.com Subject: [PATCHv4 1/6] qemu/virtio: move features to an inline function Message-ID: <20091102222329.GB15153@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c index 7ca783e..15b50bb 100644 --- a/hw/virtio-balloon.c +++ b/hw/virtio-balloon.c @@ -127,7 +127,7 @@ static void virtio_balloon_set_config(VirtIODevice *vdev, static uint32_t virtio_balloon_get_features(VirtIODevice *vdev) { - return 0; + return virtio_common_features(); } static ram_addr_t virtio_balloon_to_target(void *opaque, ram_addr_t target) diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index 2630b99..db727b9 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -445,7 +445,7 @@ static uint32_t virtio_blk_get_features(VirtIODevice *vdev) if (strcmp(s->serial_str, "0")) features |= 1 << VIRTIO_BLK_F_IDENTIFY; - return features; + return features | virtio_common_features(); } static void virtio_blk_save(QEMUFile *f, void *opaque) diff --git a/hw/virtio-console.c b/hw/virtio-console.c index 92c953c..79544bb 100644 --- a/hw/virtio-console.c +++ b/hw/virtio-console.c @@ -53,7 +53,7 @@ static void virtio_console_handle_input(VirtIODevice *vdev, VirtQueue *vq) static uint32_t virtio_console_get_features(VirtIODevice *vdev) { - return 0; + return virtio_common_features(); } static int vcon_can_read(void *opaque) diff --git a/hw/virtio-net.c b/hw/virtio-net.c index ce8e6cb..469c6e3 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -154,7 +154,7 @@ static uint32_t virtio_net_get_features(VirtIODevice *vdev) } #endif - return features; + return features | virtio_common_features(); } static uint32_t virtio_net_bad_features(VirtIODevice *vdev) diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index 01782e5..0716f6f 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -230,9 +230,6 @@ static uint32_t virtio_ioport_read(VirtIOPCIProxy *proxy, uint32_t addr) switch (addr) { case VIRTIO_PCI_HOST_FEATURES: ret = vdev->get_features(vdev); - ret |= (1 << VIRTIO_F_NOTIFY_ON_EMPTY); - ret |= (1 << VIRTIO_RING_F_INDIRECT_DESC); - ret |= (1 << VIRTIO_F_BAD_FEATURE); break; case VIRTIO_PCI_GUEST_FEATURES: ret = vdev->features; diff --git a/hw/virtio.h b/hw/virtio.h index 0f9be7d..799e608 100644 --- a/hw/virtio.h +++ b/hw/virtio.h @@ -167,4 +167,14 @@ VirtIODevice *virtio_net_init(DeviceState *dev); VirtIODevice *virtio_console_init(DeviceState *dev); VirtIODevice *virtio_balloon_init(DeviceState *dev); +static inline uint32_t virtio_common_features(void) +{ + uint32_t features = 0; + features |= (1 << VIRTIO_F_NOTIFY_ON_EMPTY); + features |= (1 << VIRTIO_RING_F_INDIRECT_DESC); + features |= (1 << VIRTIO_F_BAD_FEATURE); + + return features; +} + #endif