diff mbox

[v2] xen_disk: add discard support

Message ID 20140220182057.GB19843@aepfle.de
State New
Headers show

Commit Message

Olaf Hering Feb. 20, 2014, 6:20 p.m. UTC
On Thu, Feb 20, Stefano Stabellini wrote:

> On Thu, 6 Feb 2014, Olaf Hering wrote:
> > @@ -253,6 +254,8 @@ static int ioreq_parse(struct ioreq *ioreq)
> >      case BLKIF_OP_WRITE:
> >          ioreq->prot = PROT_READ; /* from memory */
> >          break;
> > +    case BLKIF_OP_DISCARD:
> > +        return 0;
> >      default:
> >          xen_be_printf(&blkdev->xendev, 0, "error: unknown operation (%d)\n",
> >                        ioreq->req.operation);
> 
> Unfortunately I didn't realize before that older Xen releases don't
> define BLKIF_OP_DISCARD, therefore this patch would cause QEMU build
> failures against Xen 4.1 for example.

Would that work for you?

Olaf

Comments

Stefano Stabellini Feb. 23, 2014, 3:30 p.m. UTC | #1
On Thu, 20 Feb 2014, Olaf Hering wrote:
> On Thu, Feb 20, Stefano Stabellini wrote:
> 
> > On Thu, 6 Feb 2014, Olaf Hering wrote:
> > > @@ -253,6 +254,8 @@ static int ioreq_parse(struct ioreq *ioreq)
> > >      case BLKIF_OP_WRITE:
> > >          ioreq->prot = PROT_READ; /* from memory */
> > >          break;
> > > +    case BLKIF_OP_DISCARD:
> > > +        return 0;
> > >      default:
> > >          xen_be_printf(&blkdev->xendev, 0, "error: unknown operation (%d)\n",
> > >                        ioreq->req.operation);
> > 
> > Unfortunately I didn't realize before that older Xen releases don't
> > define BLKIF_OP_DISCARD, therefore this patch would cause QEMU build
> > failures against Xen 4.1 for example.
> 
> Would that work for you?
> 
> Olaf
> 
> diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h
> index 2d5a25b..4ca03ff 100644
> --- a/include/hw/xen/xen_common.h
> +++ b/include/hw/xen/xen_common.h
> @@ -144,6 +144,9 @@ static inline int xen_xc_hvm_inject_msi(XenXC xen_xc, domid_t dom,
>  {
>      return -ENOSYS;
>  }
> +#ifndef BLKIF_OP_DISCARD
> +#define BLKIF_OP_DISCARD 5
> +#endif
>  #else
>  static inline int xen_xc_hvm_inject_msi(XenXC xen_xc, domid_t dom,
>          uint64_t addr, uint32_t data)

Given that 4.2 is the first Xen release to have BLKIF_OP_DISCARD, maybe
we could just #define BLKIF_OP_DISCARD 5 in that case?
Do we actually need to #ifndef BLKIF_OP_DISCARD?
Olaf Hering Feb. 24, 2014, 4:28 p.m. UTC | #2
On Sun, Feb 23, Stefano Stabellini wrote:

> Given that 4.2 is the first Xen release to have BLKIF_OP_DISCARD, maybe
> we could just #define BLKIF_OP_DISCARD 5 in that case?
> Do we actually need to #ifndef BLKIF_OP_DISCARD?

I will do just the #define and resend with that change.

Olaf
diff mbox

Patch

diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h
index 2d5a25b..4ca03ff 100644
--- a/include/hw/xen/xen_common.h
+++ b/include/hw/xen/xen_common.h
@@ -144,6 +144,9 @@  static inline int xen_xc_hvm_inject_msi(XenXC xen_xc, domid_t dom,
 {
     return -ENOSYS;
 }
+#ifndef BLKIF_OP_DISCARD
+#define BLKIF_OP_DISCARD 5
+#endif
 #else
 static inline int xen_xc_hvm_inject_msi(XenXC xen_xc, domid_t dom,
         uint64_t addr, uint32_t data)