From: Eric Blake <eblake@redhat.com>
To: Pavel Hrdina <phrdina@redhat.com>
Cc: lcapitulino@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 01/12] block: add error parameter to bdrv_snapshot_create() and related functions
Date: Tue, 26 Mar 2013 08:22:50 -0600 [thread overview]
Message-ID: <5151AF3A.6070801@redhat.com> (raw)
In-Reply-To: <5752796f1573f8ccd8de9224a5ce15f71908ac2d.1363957855.git.phrdina@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3170 bytes --]
On 03/22/2013 07:16 AM, Pavel Hrdina wrote:
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
> block.c | 22 ++++++++++++++++------
> block/qcow2-snapshot.c | 9 ++++++++-
> block/qcow2.h | 4 +++-
> block/rbd.c | 8 ++++++--
> block/sheepdog.c | 17 +++++++++--------
> include/block/block.h | 3 ++-
> include/block/block_int.h | 3 ++-
> qemu-img.c | 2 +-
> savevm.c | 2 +-
> 9 files changed, 48 insertions(+), 22 deletions(-)
>
> int bdrv_snapshot_create(BlockDriverState *bs,
> - QEMUSnapshotInfo *sn_info)
> + QEMUSnapshotInfo *sn_info,
> + Error **errp)
> {
> BlockDriver *drv = bs->drv;
> - if (!drv)
> +
> + if (!drv) {
> + error_setg(errp, "Device '%s' has no medium.",
In general, error_setg() should not print a trailing '.' (only two
offenders to git grep 'error_setg.*\."'). I think we also tend to start
messages with lower case, although that's not as obvious (49 cases of
'error_setg[^"*"[A-Z]' vs. 121 of error_setg[^"]*"[a-z]').
> +
> + error_setg(errp, "Snapshot is not supported for '%s'.",
And again, and probably throughout your series (although I'll quit
pointing it out).
> @@ -830,16 +832,18 @@ static int qemu_rbd_snap_create(BlockDriverState *bs,
> */
> if (sn_info->id_str[0] != '\0' &&
> strcmp(sn_info->id_str, sn_info->name) != 0) {
> + error_setg(errp, "ID and name have to be equal.");
> return -EINVAL;
> }
>
> if (strlen(sn_info->name) >= sizeof(sn_info->id_str)) {
> + error_setg(errp, "Parameter 'name' has to be shorter that 127 chars.");
s/that/than/
> return -ERANGE;
> }
>
> r = rbd_snap_create(s->image, sn_info->name);
> if (r < 0) {
> - error_report("failed to create snap: %s", strerror(-r));
> + error_setg(errp, "Failed to create snapshot: '%s'.", strerror(-r));
Use error_setg_errno(errp, -r, "failed to create snapshot").
> @@ -1779,9 +1781,8 @@ static int sd_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
> s->name, sn_info->vm_state_size, s->is_snapshot);
>
> if (s->is_snapshot) {
> - error_report("You can't create a snapshot of a snapshot VDI, "
> - "%s (%" PRIu32 ").", s->name, s->inode.vdi_id);
> -
> + error_setg(errp, "You can't create a snapshot '%s' of a VDI snapshot.",
> + sn_info->name);
Why are you losing information from the previous version of this error
message?
> if (ret < 0) {
> - error_report("failed to create inode for snapshot. %s",
> - strerror(errno));
> + error_setg(errp, "Failed to create inode for snapshot.");
Another case of losing information; error_setg_errno would be better
here, and anywhere else the old message included a strerror() call.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 621 bytes --]
next prev parent reply other threads:[~2013-03-26 14:23 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-22 13:15 [Qemu-devel] [PATCH v2 00/12] convert savevm to use qapi and introduce qmp command Pavel Hrdina
2013-03-22 13:16 ` [Qemu-devel] [PATCH v2 01/12] block: add error parameter to bdrv_snapshot_create() and related functions Pavel Hrdina
2013-03-26 14:22 ` Eric Blake [this message]
2013-03-26 14:38 ` Pavel Hrdina
2013-03-22 13:16 ` [Qemu-devel] [PATCH v2 02/12] block: add error parameter to del_existing_snapshots() Pavel Hrdina
2013-03-26 16:44 ` Eric Blake
2013-03-22 13:16 ` [Qemu-devel] [PATCH v2 03/12] savevm: add error parameter to qemu_savevm_state_begin() Pavel Hrdina
2013-03-26 16:49 ` Eric Blake
2013-03-22 13:16 ` [Qemu-devel] [PATCH v2 04/12] savevm: add error parameter to qemu_savevm_state_iterate() Pavel Hrdina
2013-03-26 16:55 ` Eric Blake
2013-03-22 13:16 ` [Qemu-devel] [PATCH v2 05/12] savevm: add error parameter to qemu_savevm_state_complete() Pavel Hrdina
2013-03-26 19:41 ` Eric Blake
2013-03-22 13:16 ` [Qemu-devel] [PATCH v2 06/12] savevm: add error parameter to qemu_savevm_state() Pavel Hrdina
2013-03-26 19:41 ` Eric Blake
2013-03-22 13:16 ` [Qemu-devel] [PATCH v2 07/12] qapi: Convert savevm Pavel Hrdina
2013-03-26 19:56 ` Eric Blake
2013-03-27 18:23 ` Pavel Hrdina
2013-03-22 13:16 ` [Qemu-devel] [PATCH v2 08/12] qemu-img: introduce qemu_img_handle_error Pavel Hrdina
2013-03-26 21:26 ` Eric Blake
2013-03-22 13:16 ` [Qemu-devel] [PATCH v2 09/12] block: update return value from bdrv_snapshot_create Pavel Hrdina
2013-03-26 21:54 ` Eric Blake
2013-03-22 13:16 ` [Qemu-devel] [PATCH v2 10/12] savevm: update return value from qemu_savevm_state Pavel Hrdina
2013-03-26 21:57 ` Eric Blake
2013-03-22 13:16 ` [Qemu-devel] [PATCH v2 11/12] vm-snapshot-save: add force parameter Pavel Hrdina
2013-03-26 22:04 ` Eric Blake
2013-03-22 13:16 ` [Qemu-devel] [PATCH v2 12/12] savevm: icrease the IO_BUF_SIZE to improve the speed of savevm Pavel Hrdina
2013-03-26 22:05 ` Eric Blake
2013-03-27 17:42 ` Pavel Hrdina
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=5151AF3A.6070801@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=phrdina@redhat.com \
--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).