* [Qemu-devel] [PATCH 1/3] virtio-9p-coth: add release function and fix init error path
2015-10-05 9:07 [Qemu-devel] [PATCH 0/3] virtio-9p: hotplug and migration support Greg Kurz
@ 2015-10-05 9:07 ` Greg Kurz
2015-10-06 9:16 ` Greg Kurz
2015-10-05 9:07 ` [Qemu-devel] [PATCH 2/3] virtio-9p: add unrealize handler Greg Kurz
2015-10-05 9:07 ` [Qemu-devel] [PATCH 3/3] virtio-9p: add savem handlers Greg Kurz
2 siblings, 1 reply; 11+ messages in thread
From: Greg Kurz @ 2015-10-05 9:07 UTC (permalink / raw)
To: aneesh.kumar; +Cc: qemu-devel, Michael S. Tsirkin
This is preliminary work to support hotplug/unplug of virtio-9p-device.
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
---
hw/9pfs/virtio-9p-coth.c | 13 +++++++++----
hw/9pfs/virtio-9p-coth.h | 1 +
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/hw/9pfs/virtio-9p-coth.c b/hw/9pfs/virtio-9p-coth.c
index 8185c533c013..a4392586c9a2 100644
--- a/hw/9pfs/virtio-9p-coth.c
+++ b/hw/9pfs/virtio-9p-coth.c
@@ -66,10 +66,7 @@ int v9fs_init_worker_threads(void)
}
p->completed = g_async_queue_new();
if (!p->completed) {
- /*
- * We are going to terminate.
- * So don't worry about cleanup
- */
+ g_thread_pool_free(p->pool, true, true);
ret = -1;
goto err_out;
}
@@ -80,3 +77,11 @@ err_out:
pthread_sigmask(SIG_SETMASK, &oldset, NULL);
return ret;
}
+
+int v9fs_release_worker_threads(void)
+{
+ V9fsThPool *p = &v9fs_pool;
+
+ g_thread_pool_free(p->pool, TRUE, TRUE);
+ g_async_queue_unref(p->completed);
+}
diff --git a/hw/9pfs/virtio-9p-coth.h b/hw/9pfs/virtio-9p-coth.h
index 4f51b250d1d4..6502e422cea8 100644
--- a/hw/9pfs/virtio-9p-coth.h
+++ b/hw/9pfs/virtio-9p-coth.h
@@ -56,6 +56,7 @@ typedef struct V9fsThPool {
extern void co_run_in_worker_bh(void *);
extern int v9fs_init_worker_threads(void);
+extern int v9fs_release_worker_threads(void);
extern int v9fs_co_readlink(V9fsPDU *, V9fsPath *, V9fsString *);
extern int v9fs_co_readdir_r(V9fsPDU *, V9fsFidState *,
struct dirent *, struct dirent **result);
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 1/3] virtio-9p-coth: add release function and fix init error path
2015-10-05 9:07 ` [Qemu-devel] [PATCH 1/3] virtio-9p-coth: add release function and fix init error path Greg Kurz
@ 2015-10-06 9:16 ` Greg Kurz
0 siblings, 0 replies; 11+ messages in thread
From: Greg Kurz @ 2015-10-06 9:16 UTC (permalink / raw)
To: aneesh.kumar; +Cc: qemu-devel, Michael S. Tsirkin
On Mon, 05 Oct 2015 11:07:16 +0200
Greg Kurz <gkurz@linux.vnet.ibm.com> wrote:
> This is preliminary work to support hotplug/unplug of virtio-9p-device.
>
> Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
> ---
Hmm... still not good. Since this is shared by all virtio-9p devices, we need
at least a refcount.
> hw/9pfs/virtio-9p-coth.c | 13 +++++++++----
> hw/9pfs/virtio-9p-coth.h | 1 +
> 2 files changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/hw/9pfs/virtio-9p-coth.c b/hw/9pfs/virtio-9p-coth.c
> index 8185c533c013..a4392586c9a2 100644
> --- a/hw/9pfs/virtio-9p-coth.c
> +++ b/hw/9pfs/virtio-9p-coth.c
> @@ -66,10 +66,7 @@ int v9fs_init_worker_threads(void)
> }
> p->completed = g_async_queue_new();
> if (!p->completed) {
> - /*
> - * We are going to terminate.
> - * So don't worry about cleanup
> - */
> + g_thread_pool_free(p->pool, true, true);
> ret = -1;
> goto err_out;
> }
> @@ -80,3 +77,11 @@ err_out:
> pthread_sigmask(SIG_SETMASK, &oldset, NULL);
> return ret;
> }
> +
> +int v9fs_release_worker_threads(void)
> +{
> + V9fsThPool *p = &v9fs_pool;
> +
> + g_thread_pool_free(p->pool, TRUE, TRUE);
> + g_async_queue_unref(p->completed);
> +}
> diff --git a/hw/9pfs/virtio-9p-coth.h b/hw/9pfs/virtio-9p-coth.h
> index 4f51b250d1d4..6502e422cea8 100644
> --- a/hw/9pfs/virtio-9p-coth.h
> +++ b/hw/9pfs/virtio-9p-coth.h
> @@ -56,6 +56,7 @@ typedef struct V9fsThPool {
>
> extern void co_run_in_worker_bh(void *);
> extern int v9fs_init_worker_threads(void);
> +extern int v9fs_release_worker_threads(void);
> extern int v9fs_co_readlink(V9fsPDU *, V9fsPath *, V9fsString *);
> extern int v9fs_co_readdir_r(V9fsPDU *, V9fsFidState *,
> struct dirent *, struct dirent **result);
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH 2/3] virtio-9p: add unrealize handler
2015-10-05 9:07 [Qemu-devel] [PATCH 0/3] virtio-9p: hotplug and migration support Greg Kurz
2015-10-05 9:07 ` [Qemu-devel] [PATCH 1/3] virtio-9p-coth: add release function and fix init error path Greg Kurz
@ 2015-10-05 9:07 ` Greg Kurz
2015-10-06 8:09 ` Stefan Hajnoczi
2015-10-05 9:07 ` [Qemu-devel] [PATCH 3/3] virtio-9p: add savem handlers Greg Kurz
2 siblings, 1 reply; 11+ messages in thread
From: Greg Kurz @ 2015-10-05 9:07 UTC (permalink / raw)
To: aneesh.kumar; +Cc: qemu-devel, Michael S. Tsirkin
If the user tries to hot unplug a virtio-9p device, it seems to succeed but
in fact:
- virtio-9p coroutines thread pool and async queue are leaked
- QEMU crashes in virtio_vmstate_change() if the user tries to live migrate
This patch brings hot unplug support to virtio-9p-device. It fixes both
above issues.
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
---
hw/9pfs/virtio-9p-device.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
index 93a407c45926..ed133c40493a 100644
--- a/hw/9pfs/virtio-9p-device.c
+++ b/hw/9pfs/virtio-9p-device.c
@@ -138,6 +138,17 @@ out:
v9fs_path_free(&path);
}
+static void virtio_9p_device_unrealize(DeviceState *dev, Error **errp)
+{
+ VirtIODevice *vdev = VIRTIO_DEVICE(dev);
+ V9fsState *s = VIRTIO_9P(dev);
+
+ v9fs_release_worker_threads();
+ g_free(s->ctx.fs_root);
+ g_free(s->tag);
+ virtio_cleanup(vdev);
+}
+
/* virtio-9p device */
static Property virtio_9p_properties[] = {
@@ -154,6 +165,7 @@ static void virtio_9p_class_init(ObjectClass *klass, void *data)
dc->props = virtio_9p_properties;
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
vdc->realize = virtio_9p_device_realize;
+ vdc->unrealize = virtio_9p_device_unrealize;
vdc->get_features = virtio_9p_get_features;
vdc->get_config = virtio_9p_get_config;
}
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 2/3] virtio-9p: add unrealize handler
2015-10-05 9:07 ` [Qemu-devel] [PATCH 2/3] virtio-9p: add unrealize handler Greg Kurz
@ 2015-10-06 8:09 ` Stefan Hajnoczi
2015-10-06 9:13 ` Greg Kurz
2015-10-07 8:50 ` Aneesh Kumar K.V
0 siblings, 2 replies; 11+ messages in thread
From: Stefan Hajnoczi @ 2015-10-06 8:09 UTC (permalink / raw)
To: Greg Kurz; +Cc: Michael S. Tsirkin, aneesh.kumar, qemu-devel
On Mon, Oct 05, 2015 at 11:07:23AM +0200, Greg Kurz wrote:
> If the user tries to hot unplug a virtio-9p device, it seems to succeed but
> in fact:
> - virtio-9p coroutines thread pool and async queue are leaked
> - QEMU crashes in virtio_vmstate_change() if the user tries to live migrate
>
> This patch brings hot unplug support to virtio-9p-device. It fixes both
> above issues.
>
> Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
> ---
> hw/9pfs/virtio-9p-device.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
What happens to in-flight I/O requests? We cannot assume that the guest
driver quiesces the device.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 2/3] virtio-9p: add unrealize handler
2015-10-06 8:09 ` Stefan Hajnoczi
@ 2015-10-06 9:13 ` Greg Kurz
2015-10-07 8:50 ` Aneesh Kumar K.V
1 sibling, 0 replies; 11+ messages in thread
From: Greg Kurz @ 2015-10-06 9:13 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: Michael S. Tsirkin, aneesh.kumar, qemu-devel
On Tue, 6 Oct 2015 09:09:14 +0100
Stefan Hajnoczi <stefanha@gmail.com> wrote:
> On Mon, Oct 05, 2015 at 11:07:23AM +0200, Greg Kurz wrote:
> > If the user tries to hot unplug a virtio-9p device, it seems to succeed but
> > in fact:
> > - virtio-9p coroutines thread pool and async queue are leaked
> > - QEMU crashes in virtio_vmstate_change() if the user tries to live migrate
> >
> > This patch brings hot unplug support to virtio-9p-device. It fixes both
> > above issues.
> >
> > Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
> > ---
> > hw/9pfs/virtio-9p-device.c | 12 ++++++++++++
> > 1 file changed, 12 insertions(+)
>
> What happens to in-flight I/O requests? We cannot assume that the guest
> driver quiesces the device.
>
We can assume that the guest has unmounted the 9p share otherwise migration
is blocked... is it possible we still have in-flight I/O requests in this
scenario ?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 2/3] virtio-9p: add unrealize handler
2015-10-06 8:09 ` Stefan Hajnoczi
2015-10-06 9:13 ` Greg Kurz
@ 2015-10-07 8:50 ` Aneesh Kumar K.V
2015-10-09 7:23 ` Greg Kurz
1 sibling, 1 reply; 11+ messages in thread
From: Aneesh Kumar K.V @ 2015-10-07 8:50 UTC (permalink / raw)
To: Stefan Hajnoczi, Greg Kurz; +Cc: qemu-devel, Michael S. Tsirkin
Stefan Hajnoczi <stefanha@gmail.com> writes:
> On Mon, Oct 05, 2015 at 11:07:23AM +0200, Greg Kurz wrote:
>> If the user tries to hot unplug a virtio-9p device, it seems to succeed but
>> in fact:
>> - virtio-9p coroutines thread pool and async queue are leaked
>> - QEMU crashes in virtio_vmstate_change() if the user tries to live migrate
>>
>> This patch brings hot unplug support to virtio-9p-device. It fixes both
>> above issues.
>>
>> Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
>> ---
>> hw/9pfs/virtio-9p-device.c | 12 ++++++++++++
>> 1 file changed, 12 insertions(+)
>
> What happens to in-flight I/O requests? We cannot assume that the guest
> driver quiesces the device.
We enable migration blocker when we have an active mount. So if we get
here, that should indicate no active 9p mounts.
-aneesh
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 2/3] virtio-9p: add unrealize handler
2015-10-07 8:50 ` Aneesh Kumar K.V
@ 2015-10-09 7:23 ` Greg Kurz
2015-10-09 7:36 ` Michael S. Tsirkin
0 siblings, 1 reply; 11+ messages in thread
From: Greg Kurz @ 2015-10-09 7:23 UTC (permalink / raw)
To: Aneesh Kumar K.V; +Cc: Stefan Hajnoczi, qemu-devel, Michael S. Tsirkin
On Wed, 07 Oct 2015 14:20:28 +0530
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> wrote:
> Stefan Hajnoczi <stefanha@gmail.com> writes:
>
> > On Mon, Oct 05, 2015 at 11:07:23AM +0200, Greg Kurz wrote:
> >> If the user tries to hot unplug a virtio-9p device, it seems to succeed but
> >> in fact:
> >> - virtio-9p coroutines thread pool and async queue are leaked
> >> - QEMU crashes in virtio_vmstate_change() if the user tries to live migrate
> >>
> >> This patch brings hot unplug support to virtio-9p-device. It fixes both
> >> above issues.
> >>
> >> Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
> >> ---
> >> hw/9pfs/virtio-9p-device.c | 12 ++++++++++++
> >> 1 file changed, 12 insertions(+)
> >
> > What happens to in-flight I/O requests? We cannot assume that the guest
> > driver quiesces the device.
>
> We enable migration blocker when we have an active mount. So if we get
> here, that should indicate no active 9p mounts.
>
> -aneesh
Oops.. Stefan is talking about hot-unplug versus in-flight requests... not
about migration. And there is no such thing as a hot-unplug blocker...
--
Greg
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 2/3] virtio-9p: add unrealize handler
2015-10-09 7:23 ` Greg Kurz
@ 2015-10-09 7:36 ` Michael S. Tsirkin
2015-10-09 10:54 ` Greg Kurz
0 siblings, 1 reply; 11+ messages in thread
From: Michael S. Tsirkin @ 2015-10-09 7:36 UTC (permalink / raw)
To: Greg Kurz; +Cc: Stefan Hajnoczi, Aneesh Kumar K.V, qemu-devel
On Fri, Oct 09, 2015 at 09:23:49AM +0200, Greg Kurz wrote:
> On Wed, 07 Oct 2015 14:20:28 +0530
> "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> wrote:
>
> > Stefan Hajnoczi <stefanha@gmail.com> writes:
> >
> > > On Mon, Oct 05, 2015 at 11:07:23AM +0200, Greg Kurz wrote:
> > >> If the user tries to hot unplug a virtio-9p device, it seems to succeed but
> > >> in fact:
> > >> - virtio-9p coroutines thread pool and async queue are leaked
> > >> - QEMU crashes in virtio_vmstate_change() if the user tries to live migrate
> > >>
> > >> This patch brings hot unplug support to virtio-9p-device. It fixes both
> > >> above issues.
> > >>
> > >> Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
> > >> ---
> > >> hw/9pfs/virtio-9p-device.c | 12 ++++++++++++
> > >> 1 file changed, 12 insertions(+)
> > >
> > > What happens to in-flight I/O requests? We cannot assume that the guest
> > > driver quiesces the device.
> >
> > We enable migration blocker when we have an active mount. So if we get
> > here, that should indicate no active 9p mounts.
> >
> > -aneesh
>
> Oops.. Stefan is talking about hot-unplug versus in-flight requests... not
> about migration. And there is no such thing as a hot-unplug blocker...
If unplug request fails, that should be enough.
> --
> Greg
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 2/3] virtio-9p: add unrealize handler
2015-10-09 7:36 ` Michael S. Tsirkin
@ 2015-10-09 10:54 ` Greg Kurz
0 siblings, 0 replies; 11+ messages in thread
From: Greg Kurz @ 2015-10-09 10:54 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: Stefan Hajnoczi, Aneesh Kumar K.V, qemu-devel
On Fri, 9 Oct 2015 10:36:56 +0300
"Michael S. Tsirkin" <mst@redhat.com> wrote:
> On Fri, Oct 09, 2015 at 09:23:49AM +0200, Greg Kurz wrote:
> > On Wed, 07 Oct 2015 14:20:28 +0530
> > "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> wrote:
> >
> > > Stefan Hajnoczi <stefanha@gmail.com> writes:
> > >
> > > > On Mon, Oct 05, 2015 at 11:07:23AM +0200, Greg Kurz wrote:
> > > >> If the user tries to hot unplug a virtio-9p device, it seems to succeed but
> > > >> in fact:
> > > >> - virtio-9p coroutines thread pool and async queue are leaked
> > > >> - QEMU crashes in virtio_vmstate_change() if the user tries to live migrate
> > > >>
> > > >> This patch brings hot unplug support to virtio-9p-device. It fixes both
> > > >> above issues.
> > > >>
> > > >> Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
> > > >> ---
> > > >> hw/9pfs/virtio-9p-device.c | 12 ++++++++++++
> > > >> 1 file changed, 12 insertions(+)
> > > >
> > > > What happens to in-flight I/O requests? We cannot assume that the guest
> > > > driver quiesces the device.
> > >
> > > We enable migration blocker when we have an active mount. So if we get
> > > here, that should indicate no active 9p mounts.
> > >
> > > -aneesh
> >
> > Oops.. Stefan is talking about hot-unplug versus in-flight requests... not
> > about migration. And there is no such thing as a hot-unplug blocker...
>
> If unplug request fails, that should be enough.
>
Like setting @hotpluggable to false for the virtio-9p-pci class ? I see no
other way for the unplug request to fail... but I will happily accept all
suggestions :)
--
Greg
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH 3/3] virtio-9p: add savem handlers
2015-10-05 9:07 [Qemu-devel] [PATCH 0/3] virtio-9p: hotplug and migration support Greg Kurz
2015-10-05 9:07 ` [Qemu-devel] [PATCH 1/3] virtio-9p-coth: add release function and fix init error path Greg Kurz
2015-10-05 9:07 ` [Qemu-devel] [PATCH 2/3] virtio-9p: add unrealize handler Greg Kurz
@ 2015-10-05 9:07 ` Greg Kurz
2 siblings, 0 replies; 11+ messages in thread
From: Greg Kurz @ 2015-10-05 9:07 UTC (permalink / raw)
To: aneesh.kumar; +Cc: qemu-devel, Michael S. Tsirkin
We don't support migration of mounted 9p shares. This is handled by a
migration blocker.
One would expect, however, to be able to migrate if the share is unmounted.
Unfortunately virtio-9p-device does not register savevm handlers at all !
Migration succeeds and leaves the guest with a dangling device...
This patch simply registers migration handlers for virtio-9p-device. Whether
migration is possible or not still depends on the migration blocker.
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
---
hw/9pfs/virtio-9p-device.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
index ed133c40493a..bd7f10a0a902 100644
--- a/hw/9pfs/virtio-9p-device.c
+++ b/hw/9pfs/virtio-9p-device.c
@@ -43,6 +43,16 @@ static void virtio_9p_get_config(VirtIODevice *vdev, uint8_t *config)
g_free(cfg);
}
+static void virtio_9p_save(QEMUFile *f, void *opaque)
+{
+ virtio_save(VIRTIO_DEVICE(opaque), f);
+}
+
+static int virtio_9p_load(QEMUFile *f, void *opaque, int version_id)
+{
+ return virtio_load(VIRTIO_DEVICE(opaque), f, version_id);
+}
+
static void virtio_9p_device_realize(DeviceState *dev, Error **errp)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
@@ -130,6 +140,7 @@ static void virtio_9p_device_realize(DeviceState *dev, Error **errp)
}
v9fs_path_free(&path);
+ register_savevm(dev, "virtio-9p", -1, 1, virtio_9p_save, virtio_9p_load, s);
return;
out:
g_free(s->ctx.fs_root);
@@ -146,6 +157,7 @@ static void virtio_9p_device_unrealize(DeviceState *dev, Error **errp)
v9fs_release_worker_threads();
g_free(s->ctx.fs_root);
g_free(s->tag);
+ unregister_savevm(dev, "virtio-9p", s);
virtio_cleanup(vdev);
}
^ permalink raw reply related [flat|nested] 11+ messages in thread