[1/2] hmp: block qemu-io command for device without media
diff mbox

Message ID 20171128121055.6954-2-den@openvz.org
State New
Headers show

Commit Message

Denis V. Lunev Nov. 28, 2017, 12:10 p.m. UTC
In this case blk->bs == NULL and the code will just crash. Emulate error
on that path.

Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
CC: Kevin Wolf <kwolf@redhat.com>
CC: Stefan Hajnoczi <stefanha@redhat.com>
---
 hmp.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Stefan Hajnoczi Nov. 30, 2017, 4:22 p.m. UTC | #1
On Tue, Nov 28, 2017 at 03:10:54PM +0300, Denis V. Lunev wrote:
> In this case blk->bs == NULL and the code will just crash. Emulate error
> on that path.
> 
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> CC: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> CC: Kevin Wolf <kwolf@redhat.com>
> CC: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  hmp.c | 3 +++
>  1 file changed, 3 insertions(+)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

Patch
diff mbox

diff --git a/hmp.c b/hmp.c
index 35a7041824..cfd1d9ab29 100644
--- a/hmp.c
+++ b/hmp.c
@@ -2336,6 +2336,9 @@  void hmp_qemu_io(Monitor *mon, const QDict *qdict)
         } else {
             goto fail;
         }
+    } else if (!blk_is_available(blk)) {
+        error_setg(&err, "No media in the device '%s'", device);
+        goto fail;
     }
 
     aio_context = blk_get_aio_context(blk);