From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>,
"Anthony Liguori" <aliguori@us.ibm.com>,
anthony@codemonkey.ws, jlarrew@linux.vnet.ibm.com,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Andreas Färber" <afaerber@suse.de>,
fred.konrad@greensocs.com
Subject: [Qemu-devel] [PATCH RFT 1/5] virtio-blk-dataplane: Improve error reporting
Date: Fri, 7 Jun 2013 20:18:56 +0200 [thread overview]
Message-ID: <1370629140-30841-2-git-send-email-afaerber@suse.de> (raw)
In-Reply-To: <1370629140-30841-1-git-send-email-afaerber@suse.de>
Return an Error so that it can be propagated later.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/block/dataplane/virtio-blk.c | 25 +++++++++++++------------
hw/block/dataplane/virtio-blk.h | 5 +++--
hw/block/virtio-blk.c | 8 +++++++-
3 files changed, 23 insertions(+), 15 deletions(-)
diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
index 0356665..5ae8d6e 100644
--- a/hw/block/dataplane/virtio-blk.c
+++ b/hw/block/dataplane/virtio-blk.c
@@ -395,8 +395,9 @@ static void start_data_plane_bh(void *opaque)
s, QEMU_THREAD_JOINABLE);
}
-bool virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *blk,
- VirtIOBlockDataPlane **dataplane)
+void virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *blk,
+ VirtIOBlockDataPlane **dataplane,
+ Error **errp)
{
VirtIOBlockDataPlane *s;
int fd;
@@ -404,25 +405,26 @@ bool virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *blk,
*dataplane = NULL;
if (!blk->data_plane) {
- return true;
+ return;
}
if (blk->scsi) {
- error_report("device is incompatible with x-data-plane, use scsi=off");
- return false;
+ error_setg(errp,
+ "device is incompatible with x-data-plane, use scsi=off");
+ return;
}
if (blk->config_wce) {
- error_report("device is incompatible with x-data-plane, "
- "use config-wce=off");
- return false;
+ error_setg(errp, "device is incompatible with x-data-plane, "
+ "use config-wce=off");
+ return;
}
fd = raw_get_aio_fd(blk->conf.bs);
if (fd < 0) {
- error_report("drive is incompatible with x-data-plane, "
- "use format=raw,cache=none,aio=native");
- return false;
+ error_setg(errp, "drive is incompatible with x-data-plane, "
+ "use format=raw,cache=none,aio=native");
+ return;
}
s = g_new0(VirtIOBlockDataPlane, 1);
@@ -438,7 +440,6 @@ bool virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *blk,
migrate_add_blocker(s->migration_blocker);
*dataplane = s;
- return true;
}
void virtio_blk_data_plane_destroy(VirtIOBlockDataPlane *s)
diff --git a/hw/block/dataplane/virtio-blk.h b/hw/block/dataplane/virtio-blk.h
index c90e99f..1750c99 100644
--- a/hw/block/dataplane/virtio-blk.h
+++ b/hw/block/dataplane/virtio-blk.h
@@ -19,8 +19,9 @@
typedef struct VirtIOBlockDataPlane VirtIOBlockDataPlane;
-bool virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *blk,
- VirtIOBlockDataPlane **dataplane);
+void virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *blk,
+ VirtIOBlockDataPlane **dataplane,
+ Error **errp);
void virtio_blk_data_plane_destroy(VirtIOBlockDataPlane *s);
void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s);
void virtio_blk_data_plane_stop(VirtIOBlockDataPlane *s);
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index cf12469..8ea1f03 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -633,6 +633,9 @@ static int virtio_blk_device_init(VirtIODevice *vdev)
DeviceState *qdev = DEVICE(vdev);
VirtIOBlock *s = VIRTIO_BLK(vdev);
VirtIOBlkConf *blk = &(s->blk);
+#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
+ Error *err = NULL;
+#endif
static int virtio_blk_id;
if (!blk->conf.bs) {
@@ -660,7 +663,10 @@ static int virtio_blk_device_init(VirtIODevice *vdev)
s->vq = virtio_add_queue(vdev, 128, virtio_blk_handle_output);
#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
- if (!virtio_blk_data_plane_create(vdev, blk, &s->dataplane)) {
+ virtio_blk_data_plane_create(vdev, blk, &s->dataplane, &err);
+ if (err != NULL) {
+ error_report("%s", error_get_pretty(err));
+ error_free(err);
virtio_cleanup(vdev);
return -1;
}
--
1.8.1.4
next prev parent reply other threads:[~2013-06-07 18:19 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-07 18:18 [Qemu-devel] [PATCH RFT 0/5] QOM realize for virtio Andreas Färber
2013-06-07 18:18 ` Andreas Färber [this message]
2013-06-10 11:39 ` [Qemu-devel] [PATCH RFT 1/5] virtio-blk-dataplane: Improve error reporting Stefan Hajnoczi
2013-07-29 20:19 ` Andreas Färber
2013-06-07 18:18 ` [Qemu-devel] [PATCH RFT 2/5] virtio: Convert VirtioDevice to QOM realize/unrealize Andreas Färber
2013-06-08 2:22 ` Peter Crosthwaite
2013-06-08 9:55 ` Andreas Färber
2013-06-08 12:32 ` Peter Crosthwaite
2013-06-10 2:08 ` Anthony Liguori
2013-06-10 6:30 ` Michael S. Tsirkin
2013-06-12 9:15 ` Andreas Färber
2013-06-13 1:48 ` Peter Crosthwaite
2013-06-18 9:57 ` Peter Crosthwaite
2013-06-09 10:36 ` Michael S. Tsirkin
2013-06-07 18:18 ` [Qemu-devel] [PATCH RFT 3/5] virtio-console: QOM'ify VirtConsole Andreas Färber
2013-06-07 18:18 ` [Qemu-devel] [PATCH RFT 4/5] virtio-console: Use exitfn for virtserialport, too Andreas Färber
2013-07-29 23:25 ` Andreas Färber
2013-06-07 18:19 ` [Qemu-devel] [PATCH RFT 5/5] virtio-serial-port: Convert to QOM realize/unrealize Andreas Färber
2013-06-09 10:39 ` [Qemu-devel] [PATCH RFT 0/5] QOM realize for virtio Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1370629140-30841-2-git-send-email-afaerber@suse.de \
--to=afaerber@suse.de \
--cc=aliguori@us.ibm.com \
--cc=anthony@codemonkey.ws \
--cc=fred.konrad@greensocs.com \
--cc=jlarrew@linux.vnet.ibm.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).