qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 3/3] block: Fix blockdev-backup not to use funky error class
Date: Thu, 19 Mar 2015 16:16:14 +0100	[thread overview]
Message-ID: <1426778174-1170-4-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1426778174-1170-1-git-send-email-kwolf@redhat.com>

From: Markus Armbruster <armbru@redhat.com>

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 <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 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=[{
-- 
1.8.3.1

  parent reply	other threads:[~2015-03-19 15:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-19 15:16 [Qemu-devel] [PULL 0/3] Block patches for 2.3.0-rc1 Kevin Wolf
2015-03-19 15:16 ` [Qemu-devel] [PULL 1/3] raw-posix: Deprecate host floppy passthrough Kevin Wolf
2015-03-19 15:16 ` [Qemu-devel] [PULL 2/3] raw-posix: Deprecate aio=threads fallback without O_DIRECT Kevin Wolf
2015-03-19 15:16 ` Kevin Wolf [this message]
2015-03-19 18:44 ` [Qemu-devel] [PULL 0/3] Block patches for 2.3.0-rc1 Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1426778174-1170-4-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).