Not all of the code duplicated from xen_disk.c is required as the basis for
the new dataplane implementation so this patch removes extraneous code,
along with the legacy #includes and calls to the legacy xen_pv_printf()
function. Error messages are changed to be reported using error_report().
NOTE: The code is still not yet built. Further transformations will be
required to make it correctly interface to the new XenBus/XenDevice
framework. They will be delivered in a subsequent patch.
Signed-off-by: Paul Durrant
Acked-by: Anthony Perard
---
Cc: Stefano Stabellini
Cc: Stefan Hajnoczi
Cc: Kevin Wolf
Cc: Max Reitz
v2:
- Leave existing boilerplate alone, other than removing the now-incorrect
description
---
hw/block/dataplane/xen-block.c | 409 ++---
1 file changed, 16 insertions(+), 393 deletions(-)
diff --git a/hw/block/dataplane/xen-block.c b/hw/block/dataplane/xen-block.c
index 9fae505..98f987d 100644
--- a/hw/block/dataplane/xen-block.c
+++ b/hw/block/dataplane/xen-block.c
@@ -1,6 +1,4 @@
/*
- * xen paravirt block device backend
- *
* (c) Gerd Hoffmann
*
* This program is free software; you can redistribute it and/or modify
@@ -19,26 +17,12 @@
* GNU GPL, version 2 or (at your option) any later version.
*/
-#include "qemu/osdep.h"
-#include "qemu/units.h"
-#include
-#include
-
-#include "hw/hw.h"
-#include "hw/xen/xen_backend.h"
-#include "xen_blkif.h"
-#include "sysemu/blockdev.h"
-#include "sysemu/iothread.h"
-#include "sysemu/block-backend.h"
-#include "qapi/error.h"
-#include "qapi/qmp/qdict.h"
-#include "qapi/qmp/qstring.h"
-#include "trace.h"
-
-/* - */
-
-#define BLOCK_SIZE 512
-#define IOCB_COUNT (BLKIF_MAX_SEGMENTS_PER_REQUEST + 2)
+/*
+ * Copyright (c) 2018 Citrix Systems Inc.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
struct ioreq {
blkif_request_t req;
@@ -101,8 +85,6 @@ struct XenBlkDev {
AioContext *ctx;
};
-/* - */
-
static void ioreq_reset(struct ioreq *ioreq)
{
memset(>req, 0, sizeof(ioreq->req));
@@ -183,11 +165,6 @@ static int ioreq_parse(struct ioreq *ioreq)
size_t len;
int i;
-xen_pv_printf(
-xendev, 3,
-"op %d, nr %d, handle %d, id %" PRId64 ", sector %" PRId64 "\n",
-ioreq->req.operation, ioreq->req.nr_segments,
-ioreq->req.handle, ioreq->req.id, ioreq->req.sector_number);
switch (ioreq->req.operation) {
case BLKIF_OP_READ:
break;
@@ -202,28 +179,27 @@ static int ioreq_parse(struct ioreq *ioreq)
case BLKIF_OP_DISCARD:
return 0;
default:
-xen_pv_printf(xendev, 0, "error: unknown operation (%d)\n",
- ioreq->req.operation);
+error_report("error: unknown operation (%d)", ioreq->req.operation);
goto err;
};
if (ioreq->req.operation != BLKIF_OP_READ && blkdev->mode[0] != 'w') {
-xen_pv_printf(xendev, 0, "error: write req for ro device\n");
+error_report("error: write req for ro device");
goto err;
}
ioreq->start = ioreq->req.sector_number * blkdev->file_blk;
for (i = 0; i < ioreq->req.nr_segments; i++) {
if (i == BLKIF_MAX_SEGMENTS_PER_REQUEST) {
-xen_pv_printf(xendev, 0, "error: nr_segments too big\n");
+error_report("error: nr_segments too big");
goto err;
}
if (ioreq->req.seg[i].first_sect > ioreq->req.seg[i].last_sect) {
-xen_pv_printf(xendev, 0, "error: first > last sector\n");
+error_report("error: first > last sector");
goto err;
}
if (ioreq->req.seg[i].last_sect * BLOCK_SIZE >= XC_PAGE_SIZE) {
-xen_pv_printf(xendev, 0, "error: page crossing\n");
+error_report("error: page crossing");
goto err;
}
@@ -232,7 +208,7 @@ static int ioreq_parse(struct ioreq *ioreq)
ioreq->size += len;
}
if (ioreq->start + ioreq->size > blkdev->file_size) {
-xen_pv_printf(xendev, 0, "error: access beyond end of file\n");
+error_report("error: access beyond end of file");
goto err;
}
return 0;
@@ -278,8 +254,7 @@ static int ioreq_grant_copy(struct ioreq *ioreq)
rc = xen_be_copy_grant_refs(xendev, to_domain, segs, count);
if (rc) {
-xen_pv_printf(xendev, 0,
- "failed to copy data %d\n", rc);
+error_report("failed to copy data %d", rc);
ioreq->aio_errors++;
return -1;
}
@@ -298,8 +273,9 @@ static void qemu_aio_complete(void *opaque, int ret)
aio_context_acquire(blkdev->ctx);
if (ret != 0) {
-xen_pv_printf(xendev, 0, "%s I/O error\n",
- ioreq->req.operation ==