aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
Diffstat (limited to 'hw')
-rw-r--r--hw/block/xen_disk.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
index a221d0bfca..2dcef07793 100644
--- a/hw/block/xen_disk.c
+++ b/hw/block/xen_disk.c
@@ -852,28 +852,25 @@ static int blk_connect(struct XenDevice *xendev)
blkdev->dinfo = drive_get(IF_XEN, 0, index);
if (!blkdev->dinfo) {
Error *local_err = NULL;
+ BlockDriver *drv;
+
/* setup via xenbus -> create new block driver instance */
xen_be_printf(&blkdev->xendev, 2, "create new bdrv (xenbus setup)\n");
- blkdev->bs = bdrv_new(blkdev->dev, &local_err);
- if (local_err) {
- blkdev->bs = NULL;
- }
- if (blkdev->bs) {
- BlockDriver *drv = bdrv_find_whitelisted_format(blkdev->fileproto,
- readonly);
- if (bdrv_open(&blkdev->bs, blkdev->filename, NULL, NULL, qflags,
- drv, &local_err) != 0)
- {
- xen_be_printf(&blkdev->xendev, 0, "error: %s\n",
- error_get_pretty(local_err));
- error_free(local_err);
- bdrv_unref(blkdev->bs);
- blkdev->bs = NULL;
- }
- }
+ blkdev->bs = bdrv_new(blkdev->dev, NULL);
if (!blkdev->bs) {
return -1;
}
+
+ drv = bdrv_find_whitelisted_format(blkdev->fileproto, readonly);
+ if (bdrv_open(&blkdev->bs, blkdev->filename, NULL, NULL, qflags,
+ drv, &local_err) != 0) {
+ xen_be_printf(&blkdev->xendev, 0, "error: %s\n",
+ error_get_pretty(local_err));
+ error_free(local_err);
+ bdrv_unref(blkdev->bs);
+ blkdev->bs = NULL;
+ return -1;
+ }
} else {
/* setup via qemu cmdline -> already setup for us */
xen_be_printf(&blkdev->xendev, 2, "get configured bdrv (cmdline setup)\n");