diff options
author | Max Reitz <mreitz@redhat.com> | 2015-10-19 17:53:29 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2015-10-23 18:18:23 +0200 |
commit | 5433c24f0f9306c82ad9bcc2b2b586e5f0ed8fa5 (patch) | |
tree | 8b2eb29767ef12bf28d528050a0463b3e9458f5b /monitor.c | |
parent | 0c3c36d651922ebe9244e68e6d9ed14cdfcac9fd (diff) |
block: Prepare for NULL BDS
blk_bs() will not necessarily return a non-NULL value any more (unless
blk_is_available() is true or it can be assumed to otherwise, e.g.
because it is called immediately after a successful blk_new_with_bs() or
blk_new_open()).
Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'monitor.c')
-rw-r--r-- | monitor.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -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) { |