From patchwork Sun Jul 17 00:57:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 105233 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4A3B3B6F90 for ; Mon, 18 Jul 2011 18:40:32 +1000 (EST) Received: from localhost ([::1]:45701 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QijNM-00050g-US for incoming@patchwork.ozlabs.org; Mon, 18 Jul 2011 04:40:28 -0400 Received: from eggs.gnu.org ([140.186.70.92]:51664) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qij5k-0000eU-Bg for qemu-devel@nongnu.org; Mon, 18 Jul 2011 04:22:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qij5g-0002Vh-R3 for qemu-devel@nongnu.org; Mon, 18 Jul 2011 04:22:15 -0400 Received: from cantor2.suse.de ([195.135.220.15]:49976 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qij5f-0002Uv-Mz for qemu-devel@nongnu.org; Mon, 18 Jul 2011 04:22:12 -0400 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id BBF3A89994; Mon, 18 Jul 2011 10:22:10 +0200 (CEST) From: Alexander Graf To: "qemu-devel@nongnu.org Developers" Date: Sun, 17 Jul 2011 02:57:18 +0200 Message-Id: <1310864241-27912-2-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1310864241-27912-1-git-send-email-agraf@suse.de> References: <1310864241-27912-1-git-send-email-agraf@suse.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 195.135.220.15 Cc: kwolf@redhat.com, armbru@redhat.com Subject: [Qemu-devel] [PATCH 1/4] [S390] Add hotplug support 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 I just submitted a few patches that enable the s390 virtio bus to receive a hotplug add event. This patch implements the qemu side of it, so that new hotplug events can be submitted to the guest. Signed-off-by: Alexander Graf --- v1 -> v2: - make s390 virtio hoplug code emulate-capable --- hw/s390-virtio-bus.c | 24 +++++++++++++++++++----- hw/s390-virtio-bus.h | 5 +++++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c index e2f3e32..0adbddb 100644 --- a/hw/s390-virtio-bus.c +++ b/hw/s390-virtio-bus.c @@ -82,12 +82,24 @@ VirtIOS390Bus *s390_virtio_bus_init(ram_addr_t *ram_size) bus->dev_offs = bus->dev_page; bus->next_ring = bus->dev_page + TARGET_PAGE_SIZE; + /* Enable hotplugging */ + _bus->allow_hotplug = 1; + /* Allocate RAM for VirtIO device pages (descriptors, queues, rings) */ *ram_size += S390_DEVICE_PAGES * TARGET_PAGE_SIZE; return bus; } +static void s390_virtio_irq(CPUState *env, int config_change, uint64_t token) +{ + if (kvm_enabled()) { + kvm_s390_virtio_irq(env, config_change, token); + } else { + cpu_inject_ext(env, VIRTIO_EXT_CODE, config_change, token); + } +} + static int s390_virtio_device_init(VirtIOS390Device *dev, VirtIODevice *vdev) { VirtIOS390Bus *bus; @@ -109,6 +121,11 @@ static int s390_virtio_device_init(VirtIOS390Device *dev, VirtIODevice *vdev) dev->host_features = vdev->get_features(vdev, dev->host_features); s390_virtio_device_sync(dev); + if (dev->qdev.hotplugged) { + CPUState *env = s390_cpu_addr2state(0); + s390_virtio_irq(env, VIRTIO_PARAM_DEV_ADD, dev->dev_offs); + } + return 0; } @@ -313,11 +330,7 @@ static void virtio_s390_notify(void *opaque, uint16_t vector) uint64_t token = s390_virtio_device_vq_token(dev, vector); CPUState *env = s390_cpu_addr2state(0); - if (kvm_enabled()) { - kvm_s390_virtio_irq(env, 0, token); - } else { - cpu_inject_ext(env, VIRTIO_EXT_CODE, 0, token); - } + s390_virtio_irq(env, 0, token); } static unsigned virtio_s390_get_features(void *opaque) @@ -385,6 +398,7 @@ static void s390_virtio_bus_register_withprop(VirtIOS390DeviceInfo *info) { info->qdev.init = s390_virtio_busdev_init; info->qdev.bus_info = &s390_virtio_bus_info; + info->qdev.unplug = qdev_simple_unplug_cb; assert(info->qdev.size >= sizeof(VirtIOS390Device)); qdev_register(&info->qdev); diff --git a/hw/s390-virtio-bus.h b/hw/s390-virtio-bus.h index f1bece7..d02a907 100644 --- a/hw/s390-virtio-bus.h +++ b/hw/s390-virtio-bus.h @@ -35,6 +35,11 @@ #define VIRTIO_RING_LEN (TARGET_PAGE_SIZE * 3) #define S390_DEVICE_PAGES 512 +#define VIRTIO_PARAM_MASK 0xff +#define VIRTIO_PARAM_VRING_INTERRUPT 0x0 +#define VIRTIO_PARAM_CONFIG_CHANGED 0x1 +#define VIRTIO_PARAM_DEV_ADD 0x2 + typedef struct VirtIOS390Device { DeviceState qdev; ram_addr_t dev_offs;