blockdev: use error_setg_file_open()
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Acked-by: Kevin Wolf <kwolf@redhat.com>
diff --git a/blockdev.c b/blockdev.c
index 9937311..5975dde 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -899,7 +899,7 @@
ret = bdrv_open(states->new_bs, new_image_file, NULL,
flags | BDRV_O_NO_BACKING, drv);
if (ret != 0) {
- error_set(errp, QERR_OPEN_FILE_FAILED, new_image_file);
+ error_setg_file_open(errp, -ret, new_image_file);
}
}
@@ -1062,8 +1062,11 @@
int bdrv_flags, BlockDriver *drv,
const char *password, Error **errp)
{
- if (bdrv_open(bs, filename, NULL, bdrv_flags, drv) < 0) {
- error_set(errp, QERR_OPEN_FILE_FAILED, filename);
+ int ret;
+
+ ret = bdrv_open(bs, filename, NULL, bdrv_flags, drv);
+ if (ret < 0) {
+ error_setg_file_open(errp, -ret, filename);
return;
}
@@ -1483,7 +1486,7 @@
if (ret < 0) {
bdrv_delete(target_bs);
- error_set(errp, QERR_OPEN_FILE_FAILED, target);
+ error_setg_file_open(errp, -ret, target);
return;
}