From: Miguel Di Ciurcio Filho <miguel.filho@gmail.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>, qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH] savevm: Really verify if a drive supports snapshots
Date: Sat, 29 May 2010 15:54:44 -0300 [thread overview]
Message-ID: <AANLkTin2vBfH1UOMpC3dtkkDOSe1obWY07VeS6_LYBoL@mail.gmail.com> (raw)
In-Reply-To: <m3k4qnqm1h.fsf@blackfin.pond.sub.org>
On Sat, May 29, 2010 at 3:06 AM, Markus Armbruster <armbru@redhat.com> wrote:
>
>> I seem to remember that we came to the conclusion that
>> bdrv_has_snapshot() isn't needed at all and should be dropped. Any user
>> should be using bdrv_can_snapshot() instead as this is what they really
>> want.
>
> Our reasoning adapted to the patched code goes like this. The remaining
> uses of bdrv_has_snapshot() are of the form:
>
> if (bdrv_has_snapshot(bs)
> some_snapshot_op()
>
> where some_snapshot_op() fails when there are no snapshots, and the code
> can recognize that failure as "sorry, no snapshots" (that's what it does
> before your patch, when bdrv_has_snapshot() is really no more than a
> necessary, but not sufficient condition for "has snapshots").
>
> Therefore, we don't have to check for actual existence of snapshots with
> bdrv_has_snapshot(). bdrv_can_snapshot() suffices.
I had this feeling too, but I was conservative and kept
bdrv_has_snapshot(). I will remove it and replace by
bdrv_can_snapshot() where appropriate.
>>> +int bdrv_can_snapshot(BlockDriverState *bs)
>>> {
>>> BlockDriver *drv = bs->drv;
>>> - if (!drv)
>>> + if (!drv) {
>>> + return -ENOMEDIUM;
>>> + }
>>> +
>>> + if (!drv->bdrv_snapshot_create || bdrv_is_removable(bs) ||
>>> + bdrv_is_read_only(bs)) {
>>> + return -ENOTSUP;
>>> + }
>>> +
>>> + return 1;
>>> +}
>>
>> Returning either 1 or -errno is a strange interface. I'm not sure which
>
> Agree.
>
>> of 1/0 or 0/-errno is better in this case, but I'd suggest to take one
>> of these.
>
> Does any existing caller care for the error codes? If not, just go with
> 1/0.
When bdrv_can_snapshot() is called the specific reason for not
supporting snapshots does not matter. So, 1/0 is better. I will fix it
and resend.
Regards,
Miguel
prev parent reply other threads:[~2010-05-29 18:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-28 18:18 [Qemu-devel] [PATCH] savevm: Really verify if a drive supports snapshots Miguel Di Ciurcio Filho
2010-05-28 18:50 ` [Qemu-devel] " Kevin Wolf
2010-05-29 6:06 ` Markus Armbruster
2010-05-29 18:54 ` Miguel Di Ciurcio Filho [this message]
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=AANLkTin2vBfH1UOMpC3dtkkDOSe1obWY07VeS6_LYBoL@mail.gmail.com \
--to=miguel.filho@gmail.com \
--cc=armbru@redhat.com \
--cc=kwolf@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).