From: Pavel Hrdina <phrdina@redhat.com>
To: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Cc: armbru@redhat.com, qemu-devel@nongnu.org, lcapitulino@redhat.com
Subject: Re: [Qemu-devel] [PATCH 11/11] savevm: remove backward compatibility from bdrv_snapshot_find()
Date: Wed, 17 Apr 2013 12:51:29 +0200 [thread overview]
Message-ID: <516E7EB1.8060806@redhat.com> (raw)
In-Reply-To: <516E774D.8080809@linux.vnet.ibm.com>
On 17.4.2013 12:19, Wenchao Xia wrote:
> 于 2013-4-17 15:52, Pavel Hrdina 写道:
>> Hi Wenchao,
>>
>> unfortunately no. According to new design of savevm, loadvm and delvm I
>> need also search for snapshots that have the specified name and id.
>>
> It seems the logic in your function, is same with mine...
It is not the same.
Your logic:
if id is set:
if there is snapshot with that id:
end searching
if name set (search also if id is set but nothing found):
if there is snapshot with that name:
end searching
My logic:
if name is set and id is set:
if there is snapshot with than name and with that id:
end searching
else if name is set (means that only name is set):
if there is snapshot with that name:
end searching
else if id is set (means that only id is set):
if there is snapshot with that id:
end searching
>
>> I'm also touching bdrv_snapshot_list where I'm adding an Error parameter
> I looked it before, but it needs all call back in ./block support it,
> so is it really necessary?
I think it is better if this function internally set appropriate error
message based on used disk image format (qcow2, sheepdog, rbd).
Adding to CC Eric for his opinion.
>
>> and changing the return value to be used only for getting a number of
>> snapshots. So in case that there is some error, the return value will be 0.
>>
>> Pavel
>>
>> On 17.4.2013 04:53, Wenchao Xia wrote:
>>> Hi, Pavel
>>> I have implemented it at
>>> http://lists.nongnu.org/archive/html/qemu-devel/2013-04/msg02533.html
>>> in patch 1,2. Could u check if it satisfy your requirement, if yes maybe
>>> you can directly use them.
>>>
>>>> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
>>>> ---
>>>> savevm.c | 33 +++++++++++----------------------
>>>> 1 file changed, 11 insertions(+), 22 deletions(-)
>>>>
>>>> diff --git a/savevm.c b/savevm.c
>>>> index 66753da..bc829a5 100644
>>>> --- a/savevm.c
>>>> +++ b/savevm.c
>>>> @@ -2195,7 +2195,7 @@ out:
>>>> }
>>>>
>>>> static int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info,
>>>> - const char *name, const char *id, bool old_match)
>>>> + const char *name, const char *id)
>>>> {
>>>> QEMUSnapshotInfo *sn_tab, *sn;
>>>> int nb_sns, i, found = 0;
>>>> @@ -2218,20 +2218,10 @@ static int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info,
>>>> break;
>>>> }
>>>> } else if (name) {
>>>> - /* for compatibility for old bdrv_snapshot_find call
>>>> - * will be removed */
>>>> - if (old_match) {
>>>> - if (!strcmp(sn->id_str, id) || !strcmp(sn->name, name)) {
>>>> - *sn_info = *sn;
>>>> - found = 1;
>>>> - break;
>>>> - }
>>>> - } else {
>>>> - if (!strcmp(sn->name, name)) {
>>>> - *sn_info = *sn;
>>>> - found = 1;
>>>> - break;
>>>> - }
>>>> + if (!strcmp(sn->name, name)) {
>>>> + *sn_info = *sn;
>>>> + found = 1;
>>>> + break;
>>>> }
>>>> } else if (id) {
>>>> if (!strcmp(sn->id_str, id)) {
>>>> @@ -2290,7 +2280,7 @@ SnapshotInfo *qmp_vm_snapshot_save(const char *name, Error **errp)
>>>> sn->date_nsec = tv.tv_usec * 1000;
>>>> sn->vm_clock_nsec = qemu_get_clock_ns(vm_clock);
>>>>
>>>> - if (bdrv_snapshot_find(bs, old_sn, name, NULL, false)) {
>>>> + if (bdrv_snapshot_find(bs, old_sn, name, NULL)) {
>>>> error_setg(errp, "snapshot '%s' exists", name);
>>>> goto the_end;
>>>> } else {
>>>> @@ -2388,7 +2378,7 @@ SnapshotInfo *qmp_vm_snapshot_load(bool has_name, const char *name,
>>>> }
>>>>
>>>> /* Don't even try to load empty VM states */
>>>> - if (!bdrv_snapshot_find(bs_vm_state, &sn, name, id, false)) {
>>>> + if (!bdrv_snapshot_find(bs_vm_state, &sn, name, id)) {
>>>> return NULL;
>>>> }
>>>>
>>>> @@ -2413,7 +2403,7 @@ SnapshotInfo *qmp_vm_snapshot_load(bool has_name, const char *name,
>>>> return NULL;
>>>> }
>>>>
>>>> - if (!bdrv_snapshot_find(bs, &sn, name, id, false)) {
>>>> + if (!bdrv_snapshot_find(bs, &sn, name, id)) {
>>>> return NULL;
>>>> }
>>>> }
>>>> @@ -2484,7 +2474,7 @@ SnapshotInfo *qmp_vm_snapshot_delete(const bool has_name, const char *name,
>>>> return NULL;
>>>> }
>>>>
>>>> - if (!bdrv_snapshot_find(bs, &sn, name, id, false)) {
>>>> + if (!bdrv_snapshot_find(bs, &sn, name, id)) {
>>>> /* no need to set an error if snapshot doesn't exist */
>>>> return NULL;
>>>> }
>>>> @@ -2501,7 +2491,7 @@ SnapshotInfo *qmp_vm_snapshot_delete(const bool has_name, const char *name,
>>>> bs = NULL;
>>>> while ((bs = bdrv_next(bs))) {
>>>> if (bdrv_can_snapshot(bs)
>>>> - && bdrv_snapshot_find(bs, &sn, name, id, false)) {
>>>> + && bdrv_snapshot_find(bs, &sn, name, id)) {
>>>> bdrv_snapshot_delete(bs, sn.name, errp);
>>>> if (error_is_set(errp)) {
>>>> return NULL;
>>>> @@ -2549,8 +2539,7 @@ void do_info_snapshots(Monitor *mon, const QDict *qdict)
>>>>
>>>> while ((bs1 = bdrv_next(bs1))) {
>>>> if (bdrv_can_snapshot(bs1) && bs1 != bs) {
>>>> - if (!bdrv_snapshot_find(bs1, sn_info, sn->name, sn->id_str,
>>>> - true)) {
>>>> + if (!bdrv_snapshot_find(bs1, sn_info, sn->name, sn->id_str)) {
>>>> available = 0;
>>>> break;
>>>> }
>>>>
>>>
>>>
>>
>>
>
>
next prev parent reply other threads:[~2013-04-17 10:51 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-16 16:05 [Qemu-devel] [PATCH 00/11] covert savevm, loadvm and delvm into qapi Pavel Hrdina
2013-04-16 16:05 ` [Qemu-devel] [PATCH 01/11] qemu-img: introduce qemu_img_handle_error() Pavel Hrdina
2013-04-16 16:46 ` Eric Blake
2013-04-18 11:44 ` Kevin Wolf
2013-04-18 11:52 ` Pavel Hrdina
2013-04-18 12:59 ` Kevin Wolf
2013-04-18 13:09 ` Pavel Hrdina
2013-04-18 15:23 ` Luiz Capitulino
2013-04-16 16:05 ` [Qemu-devel] [PATCH 02/11] block: update error reporting for bdrv_snapshot_delete() and related functions Pavel Hrdina
2013-04-16 17:14 ` Eric Blake
2013-04-18 12:55 ` Kevin Wolf
2013-04-18 13:09 ` Eric Blake
2013-04-18 13:51 ` Kevin Wolf
2013-04-18 13:19 ` Pavel Hrdina
2013-04-18 13:41 ` Kevin Wolf
2013-04-16 16:05 ` [Qemu-devel] [PATCH 03/11] savevm: update bdrv_snapshot_find() to find snapshot by id or name Pavel Hrdina
2013-04-16 17:34 ` Eric Blake
2013-04-18 13:17 ` Kevin Wolf
2013-04-16 16:05 ` [Qemu-devel] [PATCH 04/11] qapi: Convert delvm Pavel Hrdina
2013-04-16 19:39 ` Eric Blake
2013-04-18 13:28 ` Kevin Wolf
2013-04-16 16:05 ` [Qemu-devel] [PATCH 05/11] block: update error reporting for bdrv_snapshot_goto() and related functions Pavel Hrdina
2013-04-16 20:48 ` Eric Blake
2013-04-23 14:08 ` Kevin Wolf
2013-04-16 16:05 ` [Qemu-devel] [PATCH 06/11] savevm: update error reporting for qemu_loadvm_state() Pavel Hrdina
2013-04-16 21:42 ` Eric Blake
2013-04-16 16:05 ` [Qemu-devel] [PATCH 07/11] qapi: Convert loadvm Pavel Hrdina
2013-04-16 23:43 ` Eric Blake
2013-04-18 10:34 ` Pavel Hrdina
2013-04-16 16:05 ` [Qemu-devel] [PATCH 08/11] block: update error reporting for bdrv_snapshot_create() and related functions Pavel Hrdina
2013-04-16 23:54 ` Eric Blake
2013-04-16 16:05 ` [Qemu-devel] [PATCH 09/11] savevm: update error reporting off qemu_savevm_state() " Pavel Hrdina
2013-04-17 0:02 ` Eric Blake
2013-04-16 16:05 ` [Qemu-devel] [PATCH 10/11] qapi: Convert savevm Pavel Hrdina
2013-04-16 16:05 ` [Qemu-devel] [PATCH 11/11] savevm: remove backward compatibility from bdrv_snapshot_find() Pavel Hrdina
2013-04-17 2:53 ` Wenchao Xia
2013-04-17 7:52 ` Pavel Hrdina
2013-04-17 10:19 ` Wenchao Xia
2013-04-17 10:51 ` Pavel Hrdina [this message]
2013-04-17 18:14 ` Eric Blake
2013-04-17 18:22 ` Eric Blake
2013-04-18 4:31 ` Wenchao Xia
2013-04-18 7:20 ` Wenchao Xia
2013-04-18 10:22 ` Pavel Hrdina
2013-04-19 0:28 ` Wenchao Xia
2013-04-24 3:51 ` Wenchao Xia
2013-04-24 9:37 ` Pavel Hrdina
2013-04-16 16:33 ` [Qemu-devel] [PATCH 00/11] covert savevm, loadvm and delvm into qapi Eric Blake
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=516E7EB1.8060806@redhat.com \
--to=phrdina@redhat.com \
--cc=armbru@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=xiawenc@linux.vnet.ibm.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.