qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 26/50] blockdev: Check BB validity in drive-backup


From: Max Reitz
Subject: [Qemu-devel] [PATCH 26/50] blockdev: Check BB validity in drive-backup
Date: Mon, 26 Jan 2015 11:03:00 -0500

Call blk_is_available() before using blk_bs() to obtain the root
BlockDriverState behind the BlockBackend (instead of calling
bdrv_is_inserted() after bdrv_find()).

Signed-off-by: Max Reitz <address@hidden>
---
 blockdev.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/blockdev.c b/blockdev.c
index 431afcd..9476c72 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2323,6 +2323,7 @@ void qmp_drive_backup(const char *device, const char 
*target,
                       bool has_on_target_error, BlockdevOnError 
on_target_error,
                       Error **errp)
 {
+    BlockBackend *blk;
     BlockDriverState *bs;
     BlockDriverState *target_bs;
     BlockDriverState *source = NULL;
@@ -2346,21 +2347,22 @@ void qmp_drive_backup(const char *device, const char 
*target,
         mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
     }
 
-    bs = bdrv_find(device);
-    if (!bs) {
+    blk = blk_by_name(device);
+    if (!blk) {
         error_set(errp, QERR_DEVICE_NOT_FOUND, device);
         return;
     }
 
-    aio_context = bdrv_get_aio_context(bs);
+    aio_context = blk_get_aio_context(blk);
     aio_context_acquire(aio_context);
 
     /* Although backup_run has this check too, we need to use bs->drv below, so
      * do an early check redundantly. */
-    if (!bdrv_is_inserted(bs)) {
+    if (!blk_is_available(blk)) {
         error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device);
         goto out;
     }
+    bs = blk_bs(blk);
 
     if (!has_format) {
         format = mode == NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name;
-- 
2.1.0




reply via email to

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