aboutsummaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/monitor.c b/monitor.c
index 4f1ba2f666..301a143ffa 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4145,6 +4145,10 @@ int monitor_read_block_device_key(Monitor *mon, const char *device,
monitor_printf(mon, "Device not found %s\n", device);
return -1;
}
+ if (!blk_bs(blk)) {
+ monitor_printf(mon, "Device '%s' has no medium\n", device);
+ return -1;
+ }
bdrv_add_key(blk_bs(blk), NULL, &err);
if (err) {