From patchwork Thu Mar 19 15:16:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 452011 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8A4E11400B7 for ; Fri, 20 Mar 2015 02:18:25 +1100 (AEDT) Received: from localhost ([::1]:39725 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYcDH-00044X-IN for incoming@patchwork.ozlabs.org; Thu, 19 Mar 2015 11:18:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50762) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYcBd-000186-Bl for qemu-devel@nongnu.org; Thu, 19 Mar 2015 11:16:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YYcBX-000882-3E for qemu-devel@nongnu.org; Thu, 19 Mar 2015 11:16:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38024) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYcBT-00086P-UA; Thu, 19 Mar 2015 11:16:32 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id A00B5CC074; Thu, 19 Mar 2015 15:16:31 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-54.ams2.redhat.com [10.36.116.54]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2JFGPnV020966; Thu, 19 Mar 2015 11:16:30 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 19 Mar 2015 16:16:14 +0100 Message-Id: <1426778174-1170-4-git-send-email-kwolf@redhat.com> In-Reply-To: <1426778174-1170-1-git-send-email-kwolf@redhat.com> References: <1426778174-1170-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PULL 3/3] block: Fix blockdev-backup not to use funky error class X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Markus Armbruster 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 Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- blockdev.c | 8 ++++---- qapi/block-core.json | 3 --- tests/qemu-iotests/055 | 11 +++++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/blockdev.c b/blockdev.c index 0b50985..fbb3a79 100644 --- a/blockdev.c +++ b/blockdev.c @@ -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); @@ -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); @@ -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); diff --git a/qapi/block-core.json b/qapi/block-core.json index ac839af..f525b04 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -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' } diff --git a/tests/qemu-iotests/055 b/tests/qemu-iotests/055 index e81d4d0..017a609 100755 --- a/tests/qemu-iotests/055 +++ b/tests/qemu-iotests/055 @@ -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', @@ -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', @@ -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', @@ -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=[{