diff mbox

[for-2.9,1/3] 9pfs: clear migration blocker at session reset

Message ID 149095962044.26233.2156597686399438923.stgit@bahia.lan
State New
Headers show

Commit Message

Greg Kurz March 31, 2017, 11:27 a.m. UTC
The migration blocker survives a device reset: if the guest mounts a 9p
share and then gets rebooted with system_reset, it will be unmigratable
until it remounts and umounts the 9p share again.

This happens because the migration blocker is supposed to be cleared when
we put the last reference on the root fid, but virtfs_reset() wrongly calls
free_fid() instead of put_fid().

This patch fixes virtfs_reset() so that it honor the way fids are supposed
to be manipulated: first get a reference and later put it back when you're
done.

Signed-off-by: Greg Kurz <groug@kaod.org>
---
 hw/9pfs/9p.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

李强 April 1, 2017, 1:32 a.m. UTC | #1
> -----Original Message-----

> From: Greg Kurz [mailto:groug@kaod.org]

> Sent: Friday, March 31, 2017 7:27 PM

> To: qemu-devel@nongnu.org

> Cc: Eric Blake; 李强; Greg Kurz

> Subject: [for-2.9 PATCH 1/3] 9pfs: clear migration blocker at session reset

> 

> The migration blocker survives a device reset: if the guest mounts a 9p share

> and then gets rebooted with system_reset, it will be unmigratable until it

> remounts and umounts the 9p share again.

> 

> This happens because the migration blocker is supposed to be cleared when we

> put the last reference on the root fid, but virtfs_reset() wrongly calls

> free_fid() instead of put_fid().

> 

> This patch fixes virtfs_reset() so that it honor the way fids are supposed to be

> manipulated: first get a reference and later put it back when you're done.

> 

> Signed-off-by: Greg Kurz <groug@kaod.org>

> ---


Reviewed-by: Li Qiang <liqiang6-s@360.cn>


>  hw/9pfs/9p.c |   11 ++++++-----

>  1 file changed, 6 insertions(+), 5 deletions(-)

> 

> diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 48babce836b6..cc109367b030

> 100644

> --- a/hw/9pfs/9p.c

> +++ b/hw/9pfs/9p.c

> @@ -539,14 +539,15 @@ static void coroutine_fn virtfs_reset(V9fsPDU *pdu)

> 

>      /* Free all fids */

>      while (s->fid_list) {

> +        /* Get fid */

>          fidp = s->fid_list;

> +        fidp->ref++;

> +

> +        /* Clunk fid */

>          s->fid_list = fidp->next;

> +        fidp->clunked = 1;

> 

> -        if (fidp->ref) {

> -            fidp->clunked = 1;

> -        } else {

> -            free_fid(pdu, fidp);

> -        }

> +        put_fid(pdu, fidp);

>      }

>  }

>
diff mbox

Patch

diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index 48babce836b6..cc109367b030 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -539,14 +539,15 @@  static void coroutine_fn virtfs_reset(V9fsPDU *pdu)
 
     /* Free all fids */
     while (s->fid_list) {
+        /* Get fid */
         fidp = s->fid_list;
+        fidp->ref++;
+
+        /* Clunk fid */
         s->fid_list = fidp->next;
+        fidp->clunked = 1;
 
-        if (fidp->ref) {
-            fidp->clunked = 1;
-        } else {
-            free_fid(pdu, fidp);
-        }
+        put_fid(pdu, fidp);
     }
 }