eb5a2f
From 8e046eb446573101d92b41a88ebe1066a42d653c Mon Sep 17 00:00:00 2001
eb5a2f
From: Kevin Wolf <kwolf@redhat.com>
eb5a2f
Date: Mon, 2 Jun 2014 13:54:43 +0200
eb5a2f
Subject: [PATCH 22/30] qcow: correctly propagate errors
eb5a2f
eb5a2f
RH-Author: Kevin Wolf <kwolf@redhat.com>
eb5a2f
Message-id: <1401717288-3918-2-git-send-email-kwolf@redhat.com>
eb5a2f
Patchwork-id: 59096
eb5a2f
O-Subject: [RHEL-7.1/7.0.z qemu-kvm PATCH 1/6] qcow: correctly propagate errors
eb5a2f
Bugzilla: 1097229
eb5a2f
RH-Acked-by: Max Reitz <mreitz@redhat.com>
eb5a2f
RH-Acked-by: Fam Zheng <famz@redhat.com>
eb5a2f
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
eb5a2f
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
eb5a2f
eb5a2f
From: Paolo Bonzini <pbonzini@redhat.com>
eb5a2f
eb5a2f
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
eb5a2f
Reviewed-by: Fam Zheng <famz@redhat.com>
eb5a2f
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
eb5a2f
(cherry picked from commit b6d5066d32f9e6c3d7508c1af9ae78327a927120)
eb5a2f
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
eb5a2f
---
eb5a2f
 block/qcow.c | 12 ++++++------
eb5a2f
 1 file changed, 6 insertions(+), 6 deletions(-)
eb5a2f
eb5a2f
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
eb5a2f
---
eb5a2f
 block/qcow.c |   12 ++++++------
eb5a2f
 1 files changed, 6 insertions(+), 6 deletions(-)
eb5a2f
eb5a2f
diff --git a/block/qcow.c b/block/qcow.c
eb5a2f
index c470e05..b57b900 100644
eb5a2f
--- a/block/qcow.c
eb5a2f
+++ b/block/qcow.c
eb5a2f
@@ -119,17 +119,19 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
eb5a2f
     if (header.version != QCOW_VERSION) {
eb5a2f
         char version[64];
eb5a2f
         snprintf(version, sizeof(version), "QCOW version %d", header.version);
eb5a2f
-        qerror_report(QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
eb5a2f
-            bs->device_name, "qcow", version);
eb5a2f
+        error_set(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
eb5a2f
+                  bs->device_name, "qcow", version);
eb5a2f
         ret = -ENOTSUP;
eb5a2f
         goto fail;
eb5a2f
     }
eb5a2f
 
eb5a2f
     if (header.size <= 1 || header.cluster_bits < 9) {
eb5a2f
+        error_setg(errp, "invalid value in qcow header");
eb5a2f
         ret = -EINVAL;
eb5a2f
         goto fail;
eb5a2f
     }
eb5a2f
     if (header.crypt_method > QCOW_CRYPT_AES) {
eb5a2f
+        error_setg(errp, "invalid encryption method in qcow header");
eb5a2f
         ret = -EINVAL;
eb5a2f
         goto fail;
eb5a2f
     }
eb5a2f
@@ -686,15 +688,13 @@ static int qcow_create(const char *filename, QEMUOptionParameter *options,
eb5a2f
 
eb5a2f
     ret = bdrv_create_file(filename, options, &local_err);
eb5a2f
     if (ret < 0) {
eb5a2f
-        qerror_report_err(local_err);
eb5a2f
-        error_free(local_err);
eb5a2f
+        error_propagate(errp, local_err);
eb5a2f
         return ret;
eb5a2f
     }
eb5a2f
 
eb5a2f
     ret = bdrv_file_open(&qcow_bs, filename, NULL, BDRV_O_RDWR, &local_err);
eb5a2f
     if (ret < 0) {
eb5a2f
-        qerror_report_err(local_err);
eb5a2f
-        error_free(local_err);
eb5a2f
+        error_propagate(errp, local_err);
eb5a2f
         return ret;
eb5a2f
     }
eb5a2f
 
eb5a2f
-- 
eb5a2f
1.7.1
eb5a2f