qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [xen-block] Return BLKIF_RSP_EOPNOTSUPP for unknown operation
@ 2025-08-27 16:08 Mark Syms via
  2025-08-28  7:39 ` Roger Pau Monné
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Syms via @ 2025-08-27 16:08 UTC (permalink / raw)
  To: qemu-devel, xen-devel; +Cc: sstabellini, anthony, paul, Mark Syms

Returning BLKIF_RSP_ERROR if an operation is not supoprted does not
allow the frontend to exercise any discretion on how to handle the
response and may lead to an operating system crash. As different
backends may support different feature sets and we might, during a
migration, switch backends, an in-flight request might be issued (or
reissued) which is then not supported by this backend.

Signed-off-by: Mark Syms <mark.syms@cloud.com>
---
 hw/block/dataplane/xen-block.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/block/dataplane/xen-block.c b/hw/block/dataplane/xen-block.c
index 48c2e315f3..32cf919a97 100644
--- a/hw/block/dataplane/xen-block.c
+++ b/hw/block/dataplane/xen-block.c
@@ -167,7 +167,8 @@ static int xen_block_parse_request(XenBlockRequest *request)
         return 0;
     default:
         error_report("error: unknown operation (%d)", request->req.operation);
-        goto err;
+        request->status = BLKIF_RSP_EOPNOTSUPP;
+        return -1;
     };
 
     if (request->req.operation != BLKIF_OP_READ &&
-- 
2.50.1



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

* Re: [PATCH] [xen-block] Return BLKIF_RSP_EOPNOTSUPP for unknown operation
  2025-08-27 16:08 [PATCH] [xen-block] Return BLKIF_RSP_EOPNOTSUPP for unknown operation Mark Syms via
@ 2025-08-28  7:39 ` Roger Pau Monné
  2025-08-28  9:28   ` Mark Syms
  0 siblings, 1 reply; 3+ messages in thread
From: Roger Pau Monné @ 2025-08-28  7:39 UTC (permalink / raw)
  To: Mark Syms; +Cc: qemu-devel, xen-devel, sstabellini, anthony, paul

On Wed, Aug 27, 2025 at 05:08:41PM +0100, Mark Syms via wrote:
> Returning BLKIF_RSP_ERROR if an operation is not supoprted does not
> allow the frontend to exercise any discretion on how to handle the
> response and may lead to an operating system crash. As different
> backends may support different feature sets and we might, during a
> migration, switch backends, an in-flight request might be issued (or
> reissued) which is then not supported by this backend.

Linux blkfront at least will empty the ring on resume, and re-process
and queue the requests after having negotiated the (possibly) new set
of features with the backend.  That however doesn't avoid finding
flush requests that might not longer be supported by the new backend,
in which case Linux blkfront will drop such requests.

I assume the fixes done here are not targeted at dealing with a Linux
blkfront?

> Signed-off-by: Mark Syms <mark.syms@cloud.com>
> ---
>  hw/block/dataplane/xen-block.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/block/dataplane/xen-block.c b/hw/block/dataplane/xen-block.c
> index 48c2e315f3..32cf919a97 100644
> --- a/hw/block/dataplane/xen-block.c
> +++ b/hw/block/dataplane/xen-block.c
> @@ -167,7 +167,8 @@ static int xen_block_parse_request(XenBlockRequest *request)
>          return 0;
>      default:
>          error_report("error: unknown operation (%d)", request->req.operation);
> -        goto err;
> +        request->status = BLKIF_RSP_EOPNOTSUPP;
> +        return -1;

The comment in blkif.h contains:

 /* Operation not supported (only happens on barrier writes). */
#define BLKIF_RSP_EOPNOTSUPP  -2

So in principle BLKIF_RSP_EOPNOTSUPP is only to be used as a response
for BLKIF_OP_WRITE_BARRIER or BLKIF_OP_FLUSH_DISKCACHE requests,
however blkback already uses it as a response to unknown request
types (like you propose here).

Would you mind also sending a patch to adjust blkif.h in Xen to remove
the "(only happens on barrier writes)" part of the comment?

Thanks Roger.


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

* Re: [PATCH] [xen-block] Return BLKIF_RSP_EOPNOTSUPP for unknown operation
  2025-08-28  7:39 ` Roger Pau Monné
@ 2025-08-28  9:28   ` Mark Syms
  0 siblings, 0 replies; 3+ messages in thread
From: Mark Syms @ 2025-08-28  9:28 UTC (permalink / raw)
  Cc: qemu-devel, xen-devel, sstabellini, anthony, paul

> The comment in blkif.h contains:
>
>  /* Operation not supported (only happens on barrier writes). */
> #define BLKIF_RSP_EOPNOTSUPP  -2
>
> So in principle BLKIF_RSP_EOPNOTSUPP is only to be used as a response
> for BLKIF_OP_WRITE_BARRIER or BLKIF_OP_FLUSH_DISKCACHE requests,
> however blkback already uses it as a response to unknown request
> types (like you propose here).
>
> Would you mind also sending a patch to adjust blkif.h in Xen to remove
> the "(only happens on barrier writes)" part of the comment?

Sure, no problem


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

end of thread, other threads:[~2025-08-28  9:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-27 16:08 [PATCH] [xen-block] Return BLKIF_RSP_EOPNOTSUPP for unknown operation Mark Syms via
2025-08-28  7:39 ` Roger Pau Monné
2025-08-28  9:28   ` Mark Syms

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).