From: Alexander Graf <agraf@suse.de>
To: virtualization@lists.linux-foundation.org
Cc: linux-s390@vger.kernel.org, KVM list <kvm@vger.kernel.org>,
borntraeger@de.ibm.com, Carsten Otte <carsteno@de.ibm.com>,
Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
Subject: [PATCH 2/3] S390: Add virtio hotplug add support
Date: Tue, 24 Aug 2010 15:48:51 +0200 [thread overview]
Message-ID: <1282657732-20902-2-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1282657732-20902-1-git-send-email-agraf@suse.de>
The one big missing feature in s390-virtio was hotplugging. This is no more.
This patch implements hotplug add support, so you can on the fly add new devices
in the guest.
Keep in mind that this needs a patch for qemu to actually leverage the
functionality.
Signed-off-by: Alexander Graf <agraf@suse.de>
---
v1 -> v2:
- move dev_add to kvm_virtio.h
---
arch/s390/include/asm/kvm_virtio.h | 1 +
drivers/s390/kvm/kvm_virtio.c | 47 ++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/arch/s390/include/asm/kvm_virtio.h b/arch/s390/include/asm/kvm_virtio.h
index 3f5d100..72f6141 100644
--- a/arch/s390/include/asm/kvm_virtio.h
+++ b/arch/s390/include/asm/kvm_virtio.h
@@ -59,5 +59,6 @@ struct kvm_vqconfig {
#define VIRTIO_PARAM_MASK 0xff
#define VIRTIO_PARAM_VRING_INTERRUPT 0x0
#define VIRTIO_PARAM_CONFIG_CHANGED 0x1
+#define VIRTIO_PARAM_DEV_ADD 0x2
#endif
diff --git a/drivers/s390/kvm/kvm_virtio.c b/drivers/s390/kvm/kvm_virtio.c
index 68cef4d..5a46b8c 100644
--- a/drivers/s390/kvm/kvm_virtio.c
+++ b/drivers/s390/kvm/kvm_virtio.c
@@ -32,6 +32,7 @@
* The pointer to our (page) of device descriptions.
*/
static void *kvm_devices;
+struct work_struct hotplug_work;
struct kvm_device {
struct virtio_device vdev;
@@ -328,6 +329,47 @@ static void scan_devices(void)
}
/*
+ * match for a kvm device with a specific desc pointer
+ */
+static int match_desc(struct device *dev, void *data)
+{
+ if ((ulong)to_kvmdev(dev_to_virtio(dev))->desc == (ulong)data)
+ return 1;
+
+ return 0;
+}
+
+/*
+ * hotplug_device tries to find changes in the device page.
+ */
+static void hotplug_devices(struct work_struct *dummy)
+{
+ unsigned int i;
+ struct kvm_device_desc *d;
+ struct device *dev;
+
+ for (i = 0; i < PAGE_SIZE; i += desc_size(d)) {
+ d = kvm_devices + i;
+
+ /* end of list */
+ if (d->type == 0)
+ break;
+
+ /* device already exists */
+ dev = device_find_child(kvm_root, d, match_desc);
+ if (dev) {
+ /* XXX check for hotplug remove */
+ put_device(dev);
+ continue;
+ }
+
+ /* new device */
+ printk(KERN_INFO "Adding new virtio device %p\n", d);
+ add_kvm_device(d, i);
+ }
+}
+
+/*
* we emulate the request_irq behaviour on top of s390 extints
*/
static void kvm_extint_handler(u16 code)
@@ -357,6 +399,9 @@ static void kvm_extint_handler(u16 code)
break;
}
+ case VIRTIO_PARAM_DEV_ADD:
+ schedule_work(&hotplug_work);
+ break;
case VIRTIO_PARAM_VRING_INTERRUPT:
default:
vring_interrupt(0, vq);
@@ -390,6 +435,8 @@ static int __init kvm_devices_init(void)
kvm_devices = (void *) real_memory_size;
+ INIT_WORK(&hotplug_work, hotplug_devices);
+
ctl_set_bit(0, 9);
register_external_interrupt(0x2603, kvm_extint_handler);
--
1.6.0.2
next prev parent reply other threads:[~2010-08-24 13:48 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-24 13:48 [PATCH 1/3] S390: take a full byte as ext_param indicator Alexander Graf
2010-08-24 13:48 ` Alexander Graf [this message]
2010-08-25 8:16 ` [PATCH 2/3] S390: Add virtio hotplug add support Heiko Carstens
2010-08-25 8:20 ` Alexander Graf
2010-08-25 8:35 ` Heiko Carstens
2010-08-25 8:34 ` Alexander Graf
2010-08-25 8:48 ` Heiko Carstens
2010-08-25 8:52 ` Alexander Graf
2010-09-12 0:42 ` Alexander Graf
2010-09-12 9:00 ` Avi Kivity
2010-09-13 3:35 ` Rusty Russell
2010-09-13 7:41 ` Martin Schwidefsky
2010-09-13 9:41 ` Avi Kivity
2010-08-24 13:48 ` [PATCH 3/3] S390: Export kvm_virtio.h Alexander Graf
2010-08-25 21:20 ` [PATCH 1/3] S390: take a full byte as ext_param indicator Marcelo Tosatti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1282657732-20902-2-git-send-email-agraf@suse.de \
--to=agraf@suse.de \
--cc=borntraeger@de.ibm.com \
--cc=carsteno@de.ibm.com \
--cc=ehrhardt@linux.vnet.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).