qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v4 3/3] blockdev: do not open block device if passwo


From: Pavel Hrdina
Subject: [Qemu-devel] [PATCH v4 3/3] blockdev: do not open block device if password is not required but user provides one
Date: Mon, 24 Jun 2013 14:12:52 +0200

This fixes the issue that block device is openned successfully with an error
as warning if password is provided but not required. Now the open fails with
the error message.

Signed-off-by: Pavel Hrdina <address@hidden>
---
 blockdev.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/blockdev.c b/blockdev.c
index 2dbd781..7fc8dcf 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1065,6 +1065,11 @@ static void qmp_bdrv_open_encrypted(BlockDriverState 
*bs, const char *filename,
 {
     int ret;
 
+    if (!bdrv_key_required(bs) && password) {
+        error_set(errp, QERR_DEVICE_NOT_ENCRYPTED, bdrv_get_device_name(bs));
+        return;
+    }
+
     ret = bdrv_open(bs, filename, NULL, bdrv_flags, drv);
     if (ret < 0) {
         error_setg_file_open(errp, -ret, filename);
@@ -1082,8 +1087,6 @@ static void qmp_bdrv_open_encrypted(BlockDriverState *bs, 
const char *filename,
                       bdrv_get_encrypted_filename(bs));
             return;
         }
-    } else if (password) {
-        error_set(errp, QERR_DEVICE_NOT_ENCRYPTED, bdrv_get_device_name(bs));
     }
 
     bdrv_dev_change_media_cb(bs, true);
-- 
1.8.1.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]