]> git.proxmox.com Git - mirror_qemu.git/blobdiff - blockdev.c
vmstate-static-checker: Recognize "num" field
[mirror_qemu.git] / blockdev.c
index fe9d8d89c07341bf11b4e4af3122866d5d0fd80c..d7b5c18f0af513a23b734deb02ebcb53b1742979 100644 (file)
@@ -1024,6 +1024,7 @@ fail:
 static BlockDriverState *qmp_get_root_bs(const char *name, Error **errp)
 {
     BlockDriverState *bs;
+    AioContext *aio_context;
 
     bs = bdrv_lookup_bs(name, name, errp);
     if (bs == NULL) {
@@ -1035,11 +1036,16 @@ static BlockDriverState *qmp_get_root_bs(const char *name, Error **errp)
         return NULL;
     }
 
+    aio_context = bdrv_get_aio_context(bs);
+    aio_context_acquire(aio_context);
+
     if (!bdrv_is_inserted(bs)) {
         error_setg(errp, "Device has no medium");
-        return NULL;
+        bs = NULL;
     }
 
+    aio_context_release(aio_context);
+
     return bs;
 }