]> Git Repo - qemu.git/commitdiff
xen: fix qdisk BLKIF_OP_DISCARD for 32/64 word size mix
authorJuergen Gross <[email protected]>
Mon, 20 Jun 2016 07:55:43 +0000 (09:55 +0200)
committerStefano Stabellini <[email protected]>
Wed, 22 Jun 2016 10:28:17 +0000 (11:28 +0100)
In case the word size of the domU and qemu running the qdisk backend
differ BLKIF_OP_DISCARD will not work reliably, as the request
structure in the ring have different layouts for different word size.

Correct this by copying the request structure in case of different
word size element by element in the BLKIF_OP_DISCARD case, too.

Signed-off-by: Juergen Gross <[email protected]>
Acked-by: Stefano Stabellini <[email protected]>
Signed-off-by: Stefano Stabellini <[email protected]>
hw/block/xen_blkif.h

index 7ccf92ec2a7a47e4284980bf04dda5f7af79e866..07386844100110114a09d3aa51a0a02a53c5c5cb 100644 (file)
@@ -28,6 +28,14 @@ struct blkif_x86_32_request {
     blkif_sector_t sector_number;    /* start sector idx on disk (r/w only)  */
     struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
 };
+struct blkif_x86_32_request_discard {
+    uint8_t        operation;        /* BLKIF_OP_DISCARD                     */
+    uint8_t        flag;             /* nr_segments in request struct        */
+    blkif_vdev_t   handle;           /* only for read/write requests         */
+    uint64_t       id;               /* private guest value, echoed in resp  */
+    blkif_sector_t sector_number;    /* start sector idx on disk (r/w only)  */
+    uint64_t       nr_sectors;       /* # of contiguous sectors to discard   */
+};
 struct blkif_x86_32_response {
     uint64_t        id;              /* copied from request */
     uint8_t         operation;       /* copied from request */
@@ -46,6 +54,14 @@ struct blkif_x86_64_request {
     blkif_sector_t sector_number;    /* start sector idx on disk (r/w only)  */
     struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
 };
+struct blkif_x86_64_request_discard {
+    uint8_t        operation;        /* BLKIF_OP_DISCARD                     */
+    uint8_t        flag;             /* nr_segments in request struct        */
+    blkif_vdev_t   handle;           /* only for read/write requests         */
+    uint64_t       __attribute__((__aligned__(8))) id;
+    blkif_sector_t sector_number;    /* start sector idx on disk (r/w only)  */
+    uint64_t       nr_sectors;       /* # of contiguous sectors to discard   */
+};
 struct blkif_x86_64_response {
     uint64_t       __attribute__((__aligned__(8))) id;
     uint8_t         operation;       /* copied from request */
@@ -88,7 +104,7 @@ static inline void blkif_get_x86_32_req(blkif_request_t *dst,
     /* Prevent the compiler from using src->... instead. */
     barrier();
     if (dst->operation == BLKIF_OP_DISCARD) {
-        struct blkif_request_discard *s = (void *)src;
+        struct blkif_x86_32_request_discard *s = (void *)src;
         struct blkif_request_discard *d = (void *)dst;
         d->nr_sectors = s->nr_sectors;
         return;
@@ -114,7 +130,7 @@ static inline void blkif_get_x86_64_req(blkif_request_t *dst,
     /* Prevent the compiler from using src->... instead. */
     barrier();
     if (dst->operation == BLKIF_OP_DISCARD) {
-        struct blkif_request_discard *s = (void *)src;
+        struct blkif_x86_64_request_discard *s = (void *)src;
         struct blkif_request_discard *d = (void *)dst;
         d->nr_sectors = s->nr_sectors;
         return;
This page took 0.046372 seconds and 4 git commands to generate.