aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--blockdev.c15
-rw-r--r--include/qapi/qmp/qerror.h2
-rwxr-xr-xtests/qemu-iotests/04012
3 files changed, 15 insertions, 14 deletions
diff --git a/blockdev.c b/blockdev.c
index fe6fb5d..d05a874 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2531,7 +2531,7 @@ void qmp_block_stream(bool has_job_id, const char *job_id, const char *device,
if (has_base) {
base_bs = bdrv_find_backing_image(bs, base);
if (base_bs == NULL) {
- error_setg(errp, QERR_BASE_NOT_FOUND, base);
+ error_setg(errp, "Can't find '%s' in the backing chain", base);
goto out;
}
assert(bdrv_get_aio_context(base_bs) == aio_context);
@@ -2703,13 +2703,16 @@ void qmp_block_commit(bool has_job_id, const char *job_id, const char *device,
}
} else if (has_base && base) {
base_bs = bdrv_find_backing_image(top_bs, base);
+ if (base_bs == NULL) {
+ error_setg(errp, "Can't find '%s' in the backing chain", base);
+ goto out;
+ }
} else {
base_bs = bdrv_find_base(top_bs);
- }
-
- if (base_bs == NULL) {
- error_setg(errp, QERR_BASE_NOT_FOUND, base ? base : "NULL");
- goto out;
+ if (base_bs == NULL) {
+ error_setg(errp, "There is no backimg image");
+ goto out;
+ }
}
assert(bdrv_get_aio_context(base_bs) == aio_context);
diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h
index c272e3f..5d7e69c 100644
--- a/include/qapi/qmp/qerror.h
+++ b/include/qapi/qmp/qerror.h
@@ -16,8 +16,6 @@
* These macros will go away, please don't use in new code, and do not
* add new ones!
*/
-#define QERR_BASE_NOT_FOUND \
- "Base '%s' not found"
#define QERR_BUS_NO_HOTPLUG \
"Bus '%s' does not support hotplugging"
diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040
index caf2865..dc6069e 100755
--- a/tests/qemu-iotests/040
+++ b/tests/qemu-iotests/040
@@ -156,7 +156,7 @@ class TestSingleDrive(ImageCommitTestCase):
self.assert_no_active_block_jobs()
result = self.vm.qmp('block-commit', device='drive0', top='%s' % backing_img, base='%s' % backing_img)
self.assert_qmp(result, 'error/class', 'GenericError')
- self.assert_qmp(result, 'error/desc', 'Base \'%s\' not found' % backing_img)
+ self.assert_qmp(result, 'error/desc', "Can't find '%s' in the backing chain" % backing_img)
def test_top_invalid(self):
self.assert_no_active_block_jobs()
@@ -168,7 +168,7 @@ class TestSingleDrive(ImageCommitTestCase):
self.assert_no_active_block_jobs()
result = self.vm.qmp('block-commit', device='drive0', top='%s' % mid_img, base='badfile')
self.assert_qmp(result, 'error/class', 'GenericError')
- self.assert_qmp(result, 'error/desc', 'Base \'badfile\' not found')
+ self.assert_qmp(result, 'error/desc', "Can't find 'badfile' in the backing chain")
def test_top_node_invalid(self):
self.assert_no_active_block_jobs()
@@ -208,7 +208,7 @@ class TestSingleDrive(ImageCommitTestCase):
self.assert_no_active_block_jobs()
result = self.vm.qmp('block-commit', device='drive0', top='%s' % backing_img, base='%s' % mid_img)
self.assert_qmp(result, 'error/class', 'GenericError')
- self.assert_qmp(result, 'error/desc', 'Base \'%s\' not found' % mid_img)
+ self.assert_qmp(result, 'error/desc', "Can't find '%s' in the backing chain" % mid_img)
def test_top_and_base_node_reversed(self):
self.assert_no_active_block_jobs()
@@ -349,7 +349,7 @@ class TestRelativePaths(ImageCommitTestCase):
self.assert_no_active_block_jobs()
result = self.vm.qmp('block-commit', device='drive0', top='%s' % self.mid_img, base='%s' % self.mid_img)
self.assert_qmp(result, 'error/class', 'GenericError')
- self.assert_qmp(result, 'error/desc', 'Base \'%s\' not found' % self.mid_img)
+ self.assert_qmp(result, 'error/desc', "Can't find '%s' in the backing chain" % self.mid_img)
def test_top_invalid(self):
self.assert_no_active_block_jobs()
@@ -361,7 +361,7 @@ class TestRelativePaths(ImageCommitTestCase):
self.assert_no_active_block_jobs()
result = self.vm.qmp('block-commit', device='drive0', top='%s' % self.mid_img, base='badfile')
self.assert_qmp(result, 'error/class', 'GenericError')
- self.assert_qmp(result, 'error/desc', 'Base \'badfile\' not found')
+ self.assert_qmp(result, 'error/desc', "Can't find 'badfile' in the backing chain")
def test_top_is_active(self):
self.run_commit_test(self.test_img, self.backing_img)
@@ -372,7 +372,7 @@ class TestRelativePaths(ImageCommitTestCase):
self.assert_no_active_block_jobs()
result = self.vm.qmp('block-commit', device='drive0', top='%s' % self.backing_img, base='%s' % self.mid_img)
self.assert_qmp(result, 'error/class', 'GenericError')
- self.assert_qmp(result, 'error/desc', 'Base \'%s\' not found' % self.mid_img)
+ self.assert_qmp(result, 'error/desc', "Can't find '%s' in the backing chain" % self.mid_img)
class TestSetSpeed(ImageCommitTestCase):