From: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: kwolf@redhat.com, phrdina@redhat.com, armbru@redhat.com,
qemu-devel@nongnu.org, lcapitulino@redhat.com,
stefanha@redhat.com, pbonzini@redhat.com, dietmar@proxmox.com
Subject: Re: [Qemu-devel] [PATCH 06/11] snapshot: distinguish id and name in snapshot delete
Date: Thu, 13 Jun 2013 13:41:19 +0800 [thread overview]
Message-ID: <51B95B7F.3010601@linux.vnet.ibm.com> (raw)
In-Reply-To: <20130611092528.GG18312@stefanha-thinkpad.redhat.com>
于 2013-6-11 17:25, Stefan Hajnoczi 写道:
> On Sat, Jun 08, 2013 at 02:58:02PM +0800, Wenchao Xia wrote:
>> static int find_snapshot_by_id_or_name(BlockDriverState *bs, const char *name)
>
> I suggest renaming the argument to make it less confusing: const char *name_or_id
>
will rename it.
>> {
>> - BDRVQcowState *s = bs->opaque;
>> - int i, ret;
>> + int ret;
>>
>> - ret = find_snapshot_by_id(bs, name);
>> + ret = find_snapshot_by_id_and_name(bs, name, NULL);
>> if (ret >= 0)
>> return ret;
>
> Since you're touching the other lines in this function you could add {}.
>
OK.
>> - for(i = 0; i < s->nb_snapshots; i++) {
>> - if (!strcmp(s->snapshots[i].name, name))
>> - return i;
>> - }
>> - return -1;
>> + return find_snapshot_by_id_and_name(bs, NULL, name);
>> }
>>
>> /* if no id is provided, a new one is constructed */
>> @@ -333,7 +347,7 @@ int qcow2_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
>> }
>>
>> /* Check that the ID is unique */
>> - if (find_snapshot_by_id(bs, sn_info->id_str) >= 0) {
>> + if (find_snapshot_by_id_and_name(bs, sn_info->id_str, NULL) >= 0) {
>> return -EEXIST;
>> }
>>
>> @@ -530,15 +544,21 @@ fail:
>> return ret;
>> }
>>
>> -int qcow2_snapshot_delete(BlockDriverState *bs, const char *snapshot_id)
>> +int qcow2_snapshot_delete(BlockDriverState *bs,
>> + const char *snapshot_id,
>> + const char *name,
>> + Error **errp)
>
> This patch will fail to compile. You haven't changed the
> .bdrv_snapshot_delete() prototype.
>
> Please make sure every patch compiles.
>
shouldn't following line in this patch changed the prototype?
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -157,7 +157,10 @@ struct BlockDriver {
QEMUSnapshotInfo *sn_info);
int (*bdrv_snapshot_goto)(BlockDriverState *bs,
const char *snapshot_id);
- int (*bdrv_snapshot_delete)(BlockDriverState *bs, const char
*snapshot_id);
+ int (*bdrv_snapshot_delete)(BlockDriverState *bs,
+ const char *snapshot_id,
+ const char *name,
+ Error **errp);
let me retry.
>> {
>> BDRVQcowState *s = bs->opaque;
>> QCowSnapshot sn;
>> int snapshot_index, ret;
>>
>> /* Search the snapshot */
>> - snapshot_index = find_snapshot_by_id_or_name(bs, snapshot_id);
>> + snapshot_index = find_snapshot_by_id_and_name(bs, snapshot_id, name);
>> if (snapshot_index < 0) {
>> + error_setg(errp,
>> + "Can't find a snapshot with ID %s and name %s",
>> + snapshot_id, name);
>
> Are both snapshot_id and name guaranteed to be non-NULL here? It is
> dangerous to pass NULL strings to sprintf() functions. IIRC some libc
> implementations will crash, others will print "(null)" like Linux.
>
OK, will check it.
--
Best Regards
Wenchao Xia
next prev parent reply other threads:[~2013-06-13 5:41 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-08 6:57 [Qemu-devel] [PATCH 00/11] add internal snapshot support at block device level Wenchao Xia
2013-06-08 6:57 ` [Qemu-devel] [PATCH 01/11] blockdev: drop redundant proto_drv check Wenchao Xia
2013-06-08 6:57 ` [Qemu-devel] [PATCH 02/11] blockdev: rename BlkTransactionStates to singular Wenchao Xia
2013-06-08 6:57 ` [Qemu-devel] [PATCH 03/11] blockdev: allow BdrvActionOps->commit() to be NULL Wenchao Xia
2013-06-08 6:58 ` [Qemu-devel] [PATCH 04/11] snapshot: new function bdrv_snapshot_find_by_id_and_name() Wenchao Xia
2013-06-08 7:31 ` Fam Zheng
2013-06-08 7:58 ` Wenchao Xia
2013-06-08 8:35 ` Fam Zheng
2013-06-09 2:33 ` Wenchao Xia
2013-06-11 8:26 ` Stefan Hajnoczi
2013-06-13 3:34 ` Wenchao Xia
2013-06-08 6:58 ` [Qemu-devel] [PATCH 05/11] snapshot: add paired functions for internal snapshot id and name Wenchao Xia
2013-06-11 9:14 ` Stefan Hajnoczi
2013-06-13 5:33 ` Wenchao Xia
2013-06-13 8:30 ` Stefan Hajnoczi
2013-06-08 6:58 ` [Qemu-devel] [PATCH 06/11] snapshot: distinguish id and name in snapshot delete Wenchao Xia
2013-06-08 7:54 ` Fam Zheng
2013-06-11 9:25 ` Stefan Hajnoczi
2013-06-13 5:41 ` Wenchao Xia [this message]
2013-06-08 6:58 ` [Qemu-devel] [PATCH 07/11] qmp: add internal snapshot support in qmp_transaction Wenchao Xia
2013-06-08 6:58 ` [Qemu-devel] [PATCH 08/11] qmp: add interface blockdev-snapshot-internal-sync Wenchao Xia
2013-06-08 8:05 ` Fam Zheng
2013-06-09 2:35 ` Wenchao Xia
2013-06-08 6:58 ` [Qemu-devel] [PATCH 09/11] qmp: add interface blockdev-snapshot-delete-internal-sync Wenchao Xia
2013-06-08 6:58 ` [Qemu-devel] [PATCH 10/11] hmp: add interface hmp_snapshot_internal_blkdev Wenchao Xia
2013-06-08 8:21 ` Fam Zheng
2013-06-09 2:39 ` Wenchao Xia
2013-06-09 3:01 ` Fam Zheng
2013-06-08 6:58 ` [Qemu-devel] [PATCH 11/11] hmp: add interface hmp_snapshot_delete_internal_blkdev Wenchao Xia
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=51B95B7F.3010601@linux.vnet.ibm.com \
--to=xiawenc@linux.vnet.ibm.com \
--cc=armbru@redhat.com \
--cc=dietmar@proxmox.com \
--cc=kwolf@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=pbonzini@redhat.com \
--cc=phrdina@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
--cc=stefanha@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.