Skip to content

Commit

Permalink
block: Fix blockdev-backup not to use funky error class
Browse files Browse the repository at this point in the history
Error classes are a leftover from the days of "rich" error objects.
New code should always use ERROR_CLASS_GENERIC_ERROR.  Commit
b7b9d39..7c6a4ab added uses of ERROR_CLASS_DEVICE_NOT_FOUND.  Replace
them.

Signed-off-by: Markus Armbruster <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
  • Loading branch information
Markus Armbruster authored and kevmw committed Mar 19, 2015
1 parent 9651825 commit 5b347c5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions blockdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1574,14 +1574,14 @@ static void blockdev_backup_prepare(BlkTransactionState *common, Error **errp)

blk = blk_by_name(backup->device);
if (!blk) {
error_set(errp, QERR_DEVICE_NOT_FOUND, backup->device);
error_setg(errp, "Device '%s' not found", backup->device);
return;
}
bs = blk_bs(blk);

blk = blk_by_name(backup->target);
if (!blk) {
error_set(errp, QERR_DEVICE_NOT_FOUND, backup->target);
error_setg(errp, "Device '%s' not found", backup->target);
return;
}
target = blk_bs(blk);
Expand Down Expand Up @@ -2421,7 +2421,7 @@ void qmp_blockdev_backup(const char *device, const char *target,

blk = blk_by_name(device);
if (!blk) {
error_set(errp, QERR_DEVICE_NOT_FOUND, device);
error_setg(errp, "Device '%s' not found", device);
return;
}
bs = blk_bs(blk);
Expand All @@ -2431,7 +2431,7 @@ void qmp_blockdev_backup(const char *device, const char *target,

blk = blk_by_name(target);
if (!blk) {
error_set(errp, QERR_DEVICE_NOT_FOUND, target);
error_setg(errp, "Device '%s' not found", target);
goto out;
}
target_bs = blk_bs(blk);
Expand Down
3 changes: 0 additions & 3 deletions qapi/block-core.json
Original file line number Diff line number Diff line change
Expand Up @@ -882,9 +882,6 @@
#
# For the arguments, see the documentation of BlockdevBackup.
#
# Returns: Nothing on success.
# If @device or @target is not a valid block device, DeviceNotFound.
#
# Since 2.3
##
{ 'command': 'blockdev-backup', 'data': 'BlockdevBackup' }
Expand Down
11 changes: 7 additions & 4 deletions tests/qemu-iotests/055
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ class TestSingleDrive(iotests.QMPTestCase):

def do_test_device_not_found(self, cmd, **args):
result = self.vm.qmp(cmd, **args)
self.assert_qmp(result, 'error/class', 'DeviceNotFound')
if cmd == 'drive-backup':
self.assert_qmp(result, 'error/class', 'DeviceNotFound')
else:
self.assert_qmp(result, 'error/class', 'GenericError')

def test_device_not_found(self):
self.do_test_device_not_found('drive-backup', device='nonexistent',
Expand Down Expand Up @@ -364,7 +367,7 @@ class TestSingleTransaction(iotests.QMPTestCase):
'sync': 'full' },
}
])
self.assert_qmp(result, 'error/class', 'DeviceNotFound')
self.assert_qmp(result, 'error/class', 'GenericError')

result = self.vm.qmp('transaction', actions=[{
'type': 'blockdev-backup',
Expand All @@ -373,7 +376,7 @@ class TestSingleTransaction(iotests.QMPTestCase):
'sync': 'full' },
}
])
self.assert_qmp(result, 'error/class', 'DeviceNotFound')
self.assert_qmp(result, 'error/class', 'GenericError')

result = self.vm.qmp('transaction', actions=[{
'type': 'blockdev-backup',
Expand All @@ -382,7 +385,7 @@ class TestSingleTransaction(iotests.QMPTestCase):
'sync': 'full' },
}
])
self.assert_qmp(result, 'error/class', 'DeviceNotFound')
self.assert_qmp(result, 'error/class', 'GenericError')

def test_target_is_source(self):
result = self.vm.qmp('transaction', actions=[{
Expand Down

0 comments on commit 5b347c5

Please sign in to comment.