All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH qemu-xen 4.10 & 4.11] xen_disk: Disable file locking for the PV disk backend
@ 2019-05-22 14:51 ` Anthony PERARD
  0 siblings, 0 replies; 10+ messages in thread
From: Anthony PERARD @ 2019-05-22 14:51 UTC (permalink / raw)
  To: xen-devel; +Cc: Anthony PERARD, Olaf Hering, Wei Liu, Roger Pau Monné

Since QEMU 2.10 (or qemu-xen-4.10), qemu locks disk images to avoid
them been re-opened in a different qemu process.

With Xen, there are two issues:
- For HVM guests, a disk image can be open twice! One by the
  emulation driver, and one by the PV backend.
- During migration, the qemu process of the newly spawned domain may
  attempt to access the disk image before the domain been migrated
  and the qemu process are been completely destroyed.

Migration of HVM guest as been taken care of in libxl, but migration
of PV guest with qdisk and HVM guest attempting to access the PV disk
before unplugging the emulated disk are still an issue.

For these reasons, we don't want to have QEMU use a locking mechanism
with the PV backend.

This is already done by db9ff46eeb in QEMU upstream, or QEMU 4.0.

Affected version of QEMU are:
- qemu-xen of Xen 4.10 and 4.11
- QEMU 2.10, 2.11, 2.12, 3.0 and 3.1

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>

---

Hi Olaf, Roger, Wei,

Instead of a fix in libxl (with the reverted patch "libxl: fix
migration of PV and PVH domUs with and without qemu"), what do you
think of this QEMU patch?  It is much simpler that trying to work
around the issue in libxl, and it fix one more problem that still
exist.

This patch is only for stable branches as Xen unstable already have a
qemu with a similar patch.

Can you give it a try with one of the affected qemu? (qemu-xen-4.10 or
qemu-xen-4.11)

Thanks,
---
 hw/block/xen_disk.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
index e431bd89e8..cbff174a98 100644
--- a/hw/block/xen_disk.c
+++ b/hw/block/xen_disk.c
@@ -1084,11 +1084,18 @@ static int blk_connect(struct XenDevice *xendev)
         Error *local_err = NULL;
         QDict *options = NULL;
 
+        options = qdict_new();
+
         if (strcmp(blkdev->fileproto, "<unset>")) {
-            options = qdict_new();
             qdict_put_str(options, "driver", blkdev->fileproto);
         }
 
+        /*
+         * It is necessary to turn file locking off as an emulated device
+         * may have already opened the same image file.
+         */
+        qdict_put_str(options, "file.locking", "off");
+
         /* setup via xenbus -> create new block driver instance */
         xen_pv_printf(&blkdev->xendev, 2, "create new bdrv (xenbus setup)\n");
         blkdev->blk = blk_new_open(blkdev->filename, NULL, options,
-- 
Anthony PERARD


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Xen-devel] [PATCH qemu-xen 4.10 & 4.11] xen_disk: Disable file locking for the PV disk backend
@ 2019-05-22 14:51 ` Anthony PERARD
  0 siblings, 0 replies; 10+ messages in thread
From: Anthony PERARD @ 2019-05-22 14:51 UTC (permalink / raw)
  To: xen-devel; +Cc: Anthony PERARD, Olaf Hering, Wei Liu, Roger Pau Monné

Since QEMU 2.10 (or qemu-xen-4.10), qemu locks disk images to avoid
them been re-opened in a different qemu process.

With Xen, there are two issues:
- For HVM guests, a disk image can be open twice! One by the
  emulation driver, and one by the PV backend.
- During migration, the qemu process of the newly spawned domain may
  attempt to access the disk image before the domain been migrated
  and the qemu process are been completely destroyed.

Migration of HVM guest as been taken care of in libxl, but migration
of PV guest with qdisk and HVM guest attempting to access the PV disk
before unplugging the emulated disk are still an issue.

For these reasons, we don't want to have QEMU use a locking mechanism
with the PV backend.

This is already done by db9ff46eeb in QEMU upstream, or QEMU 4.0.

Affected version of QEMU are:
- qemu-xen of Xen 4.10 and 4.11
- QEMU 2.10, 2.11, 2.12, 3.0 and 3.1

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>

---

Hi Olaf, Roger, Wei,

Instead of a fix in libxl (with the reverted patch "libxl: fix
migration of PV and PVH domUs with and without qemu"), what do you
think of this QEMU patch?  It is much simpler that trying to work
around the issue in libxl, and it fix one more problem that still
exist.

This patch is only for stable branches as Xen unstable already have a
qemu with a similar patch.

Can you give it a try with one of the affected qemu? (qemu-xen-4.10 or
qemu-xen-4.11)

Thanks,
---
 hw/block/xen_disk.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
index e431bd89e8..cbff174a98 100644
--- a/hw/block/xen_disk.c
+++ b/hw/block/xen_disk.c
@@ -1084,11 +1084,18 @@ static int blk_connect(struct XenDevice *xendev)
         Error *local_err = NULL;
         QDict *options = NULL;
 
+        options = qdict_new();
+
         if (strcmp(blkdev->fileproto, "<unset>")) {
-            options = qdict_new();
             qdict_put_str(options, "driver", blkdev->fileproto);
         }
 
+        /*
+         * It is necessary to turn file locking off as an emulated device
+         * may have already opened the same image file.
+         */
+        qdict_put_str(options, "file.locking", "off");
+
         /* setup via xenbus -> create new block driver instance */
         xen_pv_printf(&blkdev->xendev, 2, "create new bdrv (xenbus setup)\n");
         blkdev->blk = blk_new_open(blkdev->filename, NULL, options,
-- 
Anthony PERARD


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH qemu-xen 4.10 & 4.11] xen_disk: Disable file locking for the PV disk backend
@ 2019-05-22 14:54   ` Wei Liu
  0 siblings, 0 replies; 10+ messages in thread
From: Wei Liu @ 2019-05-22 14:54 UTC (permalink / raw)
  To: Anthony PERARD; +Cc: xen-devel, Olaf Hering, Wei Liu, Roger Pau Monné

On Wed, May 22, 2019 at 03:51:40PM +0100, Anthony PERARD wrote:
> Since QEMU 2.10 (or qemu-xen-4.10), qemu locks disk images to avoid
> them been re-opened in a different qemu process.
> 
> With Xen, there are two issues:
> - For HVM guests, a disk image can be open twice! One by the
>   emulation driver, and one by the PV backend.
> - During migration, the qemu process of the newly spawned domain may
>   attempt to access the disk image before the domain been migrated
>   and the qemu process are been completely destroyed.
> 
> Migration of HVM guest as been taken care of in libxl, but migration
> of PV guest with qdisk and HVM guest attempting to access the PV disk
> before unplugging the emulated disk are still an issue.
> 
> For these reasons, we don't want to have QEMU use a locking mechanism
> with the PV backend.
> 
> This is already done by db9ff46eeb in QEMU upstream, or QEMU 4.0.
> 
> Affected version of QEMU are:
> - qemu-xen of Xen 4.10 and 4.11
> - QEMU 2.10, 2.11, 2.12, 3.0 and 3.1
> 
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
> 
> ---
> 
> Hi Olaf, Roger, Wei,
> 
> Instead of a fix in libxl (with the reverted patch "libxl: fix
> migration of PV and PVH domUs with and without qemu"), what do you
> think of this QEMU patch?  It is much simpler that trying to work
> around the issue in libxl, and it fix one more problem that still
> exist.
> 
> This patch is only for stable branches as Xen unstable already have a
> qemu with a similar patch.
> 
> Can you give it a try with one of the affected qemu? (qemu-xen-4.10 or
> qemu-xen-4.11)
> 
> Thanks,

Thanks for stepping up. :-)

> ---
>  hw/block/xen_disk.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
> index e431bd89e8..cbff174a98 100644
> --- a/hw/block/xen_disk.c
> +++ b/hw/block/xen_disk.c
> @@ -1084,11 +1084,18 @@ static int blk_connect(struct XenDevice *xendev)
>          Error *local_err = NULL;
>          QDict *options = NULL;
>  
> +        options = qdict_new();
> +
>          if (strcmp(blkdev->fileproto, "<unset>")) {
> -            options = qdict_new();
>              qdict_put_str(options, "driver", blkdev->fileproto);
>          }
>  
> +        /*
> +         * It is necessary to turn file locking off as an emulated device
> +         * may have already opened the same image file.
> +         */
> +        qdict_put_str(options, "file.locking", "off");
> +
>          /* setup via xenbus -> create new block driver instance */
>          xen_pv_printf(&blkdev->xendev, 2, "create new bdrv (xenbus setup)\n");
>          blkdev->blk = blk_new_open(blkdev->filename, NULL, options,
> -- 
> Anthony PERARD
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Xen-devel] [PATCH qemu-xen 4.10 & 4.11] xen_disk: Disable file locking for the PV disk backend
@ 2019-05-22 14:54   ` Wei Liu
  0 siblings, 0 replies; 10+ messages in thread
From: Wei Liu @ 2019-05-22 14:54 UTC (permalink / raw)
  To: Anthony PERARD; +Cc: xen-devel, Olaf Hering, Wei Liu, Roger Pau Monné

On Wed, May 22, 2019 at 03:51:40PM +0100, Anthony PERARD wrote:
> Since QEMU 2.10 (or qemu-xen-4.10), qemu locks disk images to avoid
> them been re-opened in a different qemu process.
> 
> With Xen, there are two issues:
> - For HVM guests, a disk image can be open twice! One by the
>   emulation driver, and one by the PV backend.
> - During migration, the qemu process of the newly spawned domain may
>   attempt to access the disk image before the domain been migrated
>   and the qemu process are been completely destroyed.
> 
> Migration of HVM guest as been taken care of in libxl, but migration
> of PV guest with qdisk and HVM guest attempting to access the PV disk
> before unplugging the emulated disk are still an issue.
> 
> For these reasons, we don't want to have QEMU use a locking mechanism
> with the PV backend.
> 
> This is already done by db9ff46eeb in QEMU upstream, or QEMU 4.0.
> 
> Affected version of QEMU are:
> - qemu-xen of Xen 4.10 and 4.11
> - QEMU 2.10, 2.11, 2.12, 3.0 and 3.1
> 
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
> 
> ---
> 
> Hi Olaf, Roger, Wei,
> 
> Instead of a fix in libxl (with the reverted patch "libxl: fix
> migration of PV and PVH domUs with and without qemu"), what do you
> think of this QEMU patch?  It is much simpler that trying to work
> around the issue in libxl, and it fix one more problem that still
> exist.
> 
> This patch is only for stable branches as Xen unstable already have a
> qemu with a similar patch.
> 
> Can you give it a try with one of the affected qemu? (qemu-xen-4.10 or
> qemu-xen-4.11)
> 
> Thanks,

Thanks for stepping up. :-)

> ---
>  hw/block/xen_disk.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
> index e431bd89e8..cbff174a98 100644
> --- a/hw/block/xen_disk.c
> +++ b/hw/block/xen_disk.c
> @@ -1084,11 +1084,18 @@ static int blk_connect(struct XenDevice *xendev)
>          Error *local_err = NULL;
>          QDict *options = NULL;
>  
> +        options = qdict_new();
> +
>          if (strcmp(blkdev->fileproto, "<unset>")) {
> -            options = qdict_new();
>              qdict_put_str(options, "driver", blkdev->fileproto);
>          }
>  
> +        /*
> +         * It is necessary to turn file locking off as an emulated device
> +         * may have already opened the same image file.
> +         */
> +        qdict_put_str(options, "file.locking", "off");
> +
>          /* setup via xenbus -> create new block driver instance */
>          xen_pv_printf(&blkdev->xendev, 2, "create new bdrv (xenbus setup)\n");
>          blkdev->blk = blk_new_open(blkdev->filename, NULL, options,
> -- 
> Anthony PERARD
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH qemu-xen 4.10 & 4.11] xen_disk: Disable file locking for the PV disk backend
@ 2019-05-22 17:54   ` Olaf Hering
  0 siblings, 0 replies; 10+ messages in thread
From: Olaf Hering @ 2019-05-22 17:54 UTC (permalink / raw)
  To: Anthony PERARD; +Cc: xen-devel, Wei Liu, Roger Pau Monné


[-- Attachment #1.1: Type: text/plain, Size: 327 bytes --]

Am Wed, 22 May 2019 15:51:40 +0100
schrieb Anthony PERARD <anthony.perard@citrix.com>:

> Can you give it a try with one of the affected qemu? (qemu-xen-4.10 or
> qemu-xen-4.11)

Thanks for the patch. Unfortunately there is no easy way to trigger the race.
Is the changed code path also exercised for PV domUs?

Olaf

[-- Attachment #1.2: Digitale Signatur von OpenPGP --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 157 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Xen-devel] [PATCH qemu-xen 4.10 & 4.11] xen_disk: Disable file locking for the PV disk backend
@ 2019-05-22 17:54   ` Olaf Hering
  0 siblings, 0 replies; 10+ messages in thread
From: Olaf Hering @ 2019-05-22 17:54 UTC (permalink / raw)
  To: Anthony PERARD; +Cc: xen-devel, Wei Liu, Roger Pau Monné


[-- Attachment #1.1: Type: text/plain, Size: 327 bytes --]

Am Wed, 22 May 2019 15:51:40 +0100
schrieb Anthony PERARD <anthony.perard@citrix.com>:

> Can you give it a try with one of the affected qemu? (qemu-xen-4.10 or
> qemu-xen-4.11)

Thanks for the patch. Unfortunately there is no easy way to trigger the race.
Is the changed code path also exercised for PV domUs?

Olaf

[-- Attachment #1.2: Digitale Signatur von OpenPGP --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 157 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH qemu-xen 4.10 & 4.11] xen_disk: Disable file locking for the PV disk backend
@ 2019-05-23  9:41     ` Anthony PERARD
  0 siblings, 0 replies; 10+ messages in thread
From: Anthony PERARD @ 2019-05-23  9:41 UTC (permalink / raw)
  To: Olaf Hering; +Cc: xen-devel, Wei Liu, Roger Pau Monné

On Wed, May 22, 2019 at 07:54:42PM +0200, Olaf Hering wrote:
> Am Wed, 22 May 2019 15:51:40 +0100
> schrieb Anthony PERARD <anthony.perard@citrix.com>:
> 
> > Can you give it a try with one of the affected qemu? (qemu-xen-4.10 or
> > qemu-xen-4.11)
> 
> Thanks for the patch. Unfortunately there is no easy way to trigger the race.
> Is the changed code path also exercised for PV domUs?

Yes! The code path is executed every time a disk is attached via the
qdisk backend. So as long as guest can access the pv disk, then it's
fine (for both HVM and PV domUs, and PVH).

Another way to make sure that the locking is disable is to attach a disk
to a second guest, qemu should not complain anymore. I've tested both
"raw" disk and "qcow2" disk but I'm not sure if other kind of disk needs
to be tested.

Thanks,

-- 
Anthony PERARD

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Xen-devel] [PATCH qemu-xen 4.10 & 4.11] xen_disk: Disable file locking for the PV disk backend
@ 2019-05-23  9:41     ` Anthony PERARD
  0 siblings, 0 replies; 10+ messages in thread
From: Anthony PERARD @ 2019-05-23  9:41 UTC (permalink / raw)
  To: Olaf Hering; +Cc: xen-devel, Wei Liu, Roger Pau Monné

On Wed, May 22, 2019 at 07:54:42PM +0200, Olaf Hering wrote:
> Am Wed, 22 May 2019 15:51:40 +0100
> schrieb Anthony PERARD <anthony.perard@citrix.com>:
> 
> > Can you give it a try with one of the affected qemu? (qemu-xen-4.10 or
> > qemu-xen-4.11)
> 
> Thanks for the patch. Unfortunately there is no easy way to trigger the race.
> Is the changed code path also exercised for PV domUs?

Yes! The code path is executed every time a disk is attached via the
qdisk backend. So as long as guest can access the pv disk, then it's
fine (for both HVM and PV domUs, and PVH).

Another way to make sure that the locking is disable is to attach a disk
to a second guest, qemu should not complain anymore. I've tested both
"raw" disk and "qcow2" disk but I'm not sure if other kind of disk needs
to be tested.

Thanks,

-- 
Anthony PERARD

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Xen-devel] [PATCH qemu-xen 4.10 & 4.11] xen_disk: Disable file locking for the PV disk backend
  2019-05-23  9:41     ` [Xen-devel] " Anthony PERARD
  (?)
@ 2019-06-05 10:53     ` Anthony PERARD
  2019-06-14 13:23       ` Olaf Hering
  -1 siblings, 1 reply; 10+ messages in thread
From: Anthony PERARD @ 2019-06-05 10:53 UTC (permalink / raw)
  To: Olaf Hering; +Cc: xen-devel, Wei Liu, Roger Pau Monné

On Thu, May 23, 2019 at 10:41:48AM +0100, Anthony PERARD wrote:
> On Wed, May 22, 2019 at 07:54:42PM +0200, Olaf Hering wrote:
> > Am Wed, 22 May 2019 15:51:40 +0100
> > schrieb Anthony PERARD <anthony.perard@citrix.com>:
> > 
> > > Can you give it a try with one of the affected qemu? (qemu-xen-4.10 or
> > > qemu-xen-4.11)
> > 
> > Thanks for the patch. Unfortunately there is no easy way to trigger the race.
> > Is the changed code path also exercised for PV domUs?
> 
> Yes! The code path is executed every time a disk is attached via the
> qdisk backend. So as long as guest can access the pv disk, then it's
> fine (for both HVM and PV domUs, and PVH).
> 
> Another way to make sure that the locking is disable is to attach a disk
> to a second guest, qemu should not complain anymore. I've tested both
> "raw" disk and "qcow2" disk but I'm not sure if other kind of disk needs
> to be tested.

Olaf, did you apply this patch and run some guest? Do they still boot?
It doesn't matter if you can't trigger the race with or without this
patch, I just want to know if there are any regression.
So, may have I your "Tested-by" ? And I will try to apply it to our
qemu-xen branches.

Thanks,

-- 
Anthony PERARD

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Xen-devel] [PATCH qemu-xen 4.10 & 4.11] xen_disk: Disable file locking for the PV disk backend
  2019-06-05 10:53     ` Anthony PERARD
@ 2019-06-14 13:23       ` Olaf Hering
  0 siblings, 0 replies; 10+ messages in thread
From: Olaf Hering @ 2019-06-14 13:23 UTC (permalink / raw)
  To: Anthony PERARD; +Cc: xen-devel, Wei Liu, Roger Pau Monné


[-- Attachment #1.1: Type: text/plain, Size: 517 bytes --]

Am Wed, 5 Jun 2019 11:53:38 +0100
schrieb Anthony PERARD <anthony.perard@citrix.com>:

> Olaf, did you apply this patch and run some guest? Do they still boot?
> It doesn't matter if you can't trigger the race with or without this
> patch, I just want to know if there are any regression.
> So, may have I your "Tested-by" ? And I will try to apply it to our
> qemu-xen branches.

I can not reproduce it myself on the systems I have available.
It seems that patch went already into qemu-xen.git.


Olaf

[-- Attachment #1.2: Digitale Signatur von OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 157 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-06-14 13:23 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-22 14:51 [PATCH qemu-xen 4.10 & 4.11] xen_disk: Disable file locking for the PV disk backend Anthony PERARD
2019-05-22 14:51 ` [Xen-devel] " Anthony PERARD
2019-05-22 14:54 ` Wei Liu
2019-05-22 14:54   ` [Xen-devel] " Wei Liu
2019-05-22 17:54 ` Olaf Hering
2019-05-22 17:54   ` [Xen-devel] " Olaf Hering
2019-05-23  9:41   ` Anthony PERARD
2019-05-23  9:41     ` [Xen-devel] " Anthony PERARD
2019-06-05 10:53     ` Anthony PERARD
2019-06-14 13:23       ` Olaf Hering

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.