* [Qemu-devel] [PATCH]: set up rbd snapshot handling
@ 2012-01-10 20:01 Gregory Farnum
2012-01-11 9:58 ` Stefan Hajnoczi
2012-01-11 10:00 ` Christoph Hellwig
0 siblings, 2 replies; 4+ messages in thread
From: Gregory Farnum @ 2012-01-10 20:01 UTC (permalink / raw)
To: qemu-devel; +Cc: ceph-devel
rbd: wire up snapshot removal and rollback functionality
Signed-off-by: Greg Farnum <gregory.farnum@dreamhost.com>
Reviewed-by: Josh Durgin <josh.durgin@dreamhost.com>
---
block/rbd.c | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/block/rbd.c b/block/rbd.c
index 7a2384c..f52c1ca 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -787,6 +787,36 @@ static int qemu_rbd_snap_create(BlockDriverState *bs,
return 0;
}
+static int qemu_rbd_snap_remove(BlockDriverState *bs,
+ const char *snapshot_name)
+{
+ BDRVRBDState *s = bs->opaque;
+ int r;
+
+ r = rbd_snap_remove(s->image, snapshot_name);
+ if (r < 0) {
+ error_report("failed to remove snap: %s", strerror(-r));
+ return r;
+ }
+
+ return 0;
+}
+
+static int qemu_rbd_snap_rollback(BlockDriverState *bs,
+ const char *snapshot_name)
+{
+ BDRVRBDState *s = bs->opaque;
+ int r;
+
+ r = rbd_snap_rollback(s->image, snapshot_name);
+ if (r < 0) {
+ error_report("failed to rollback to snap: %s", strerror(-r));
+ return r;
+ }
+
+ return 0;
+}
+
static int qemu_rbd_snap_list(BlockDriverState *bs,
QEMUSnapshotInfo **psn_tab)
{
@@ -860,7 +890,9 @@ static BlockDriver bdrv_rbd = {
.bdrv_co_flush_to_disk = qemu_rbd_co_flush,
.bdrv_snapshot_create = qemu_rbd_snap_create,
+ .bdrv_snapshot_delete = qemu_rbd_snap_remove,
.bdrv_snapshot_list = qemu_rbd_snap_list,
+ .bdrv_snapshot_goto = qemu_rbd_snap_rollback,
};
static void bdrv_rbd_init(void)
--
1.7.2.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH]: set up rbd snapshot handling
2012-01-10 20:01 [Qemu-devel] [PATCH]: set up rbd snapshot handling Gregory Farnum
@ 2012-01-11 9:58 ` Stefan Hajnoczi
2012-01-11 10:00 ` Christoph Hellwig
1 sibling, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2012-01-11 9:58 UTC (permalink / raw)
To: Gregory Farnum; +Cc: ceph-devel, qemu-devel
On Tue, Jan 10, 2012 at 8:01 PM, Gregory Farnum
<gregory.farnum@dreamhost.com> wrote:
> +static int qemu_rbd_snap_remove(BlockDriverState *bs,
> + const char *snapshot_name)
> +{
> + BDRVRBDState *s = bs->opaque;
> + int r;
> +
> + r = rbd_snap_remove(s->image, snapshot_name);
> + if (r < 0) {
> + error_report("failed to remove snap: %s", strerror(-r));
> + return r;
There's no need to report an error message here. This function should
return -errno and let the caller decide how to show the error to the
user. If you look at callers in the codebase they already print an
equivalent error message.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH]: set up rbd snapshot handling
2012-01-10 20:01 [Qemu-devel] [PATCH]: set up rbd snapshot handling Gregory Farnum
2012-01-11 9:58 ` Stefan Hajnoczi
@ 2012-01-11 10:00 ` Christoph Hellwig
2012-01-11 19:48 ` Gregory Farnum
1 sibling, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2012-01-11 10:00 UTC (permalink / raw)
To: Gregory Farnum; +Cc: ceph-devel, qemu-devel
> +static int qemu_rbd_snap_remove(BlockDriverState *bs,
> + const char *snapshot_name)
> +{
> + BDRVRBDState *s = bs->opaque;
> + int r;
> +
> + r = rbd_snap_remove(s->image, snapshot_name);
> + r = rbd_snap_rollback(s->image, snapshot_name);
Have these functions been available since day 1 in librbd or should they
get a version checks like the cache flush call?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH]: set up rbd snapshot handling
2012-01-11 10:00 ` Christoph Hellwig
@ 2012-01-11 19:48 ` Gregory Farnum
0 siblings, 0 replies; 4+ messages in thread
From: Gregory Farnum @ 2012-01-11 19:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Christoph Hellwig, stefanha, ceph-devel
On Wed, Jan 11, 2012 at 1:58 AM, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> On Tue, Jan 10, 2012 at 8:01 PM, Gregory Farnum
> <gregory.farnum@dreamhost.com> wrote:
>> +static int qemu_rbd_snap_remove(BlockDriverState *bs,
>> + const char *snapshot_name)
>> +{
>> + BDRVRBDState *s = bs->opaque;
>> + int r;
>> +
>> + r = rbd_snap_remove(s->image, snapshot_name);
>> + if (r < 0) {
>> + error_report("failed to remove snap: %s", strerror(-r));
>> + return r;
>
> There's no need to report an error message here. This function should
> return -errno and let the caller decide how to show the error to the
> user. If you look at callers in the codebase they already print an
> equivalent error message.
>
> Stefan
Oh yep, guess I was a little too formulaic. Resend in a moment...
On Wed, Jan 11, 2012 at 2:00 AM, Christoph Hellwig <hch@infradead.org> wrote:
>> +static int qemu_rbd_snap_remove(BlockDriverState *bs,
>> + const char *snapshot_name)
>> +{
>> + BDRVRBDState *s = bs->opaque;
>> + int r;
>> +
>> + r = rbd_snap_remove(s->image, snapshot_name);
>
>> + r = rbd_snap_rollback(s->image, snapshot_name);
>
> Have these functions been available since day 1 in librbd or should they
> get a version checks like the cache flush call?
Day 1. :)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-01-11 19:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-10 20:01 [Qemu-devel] [PATCH]: set up rbd snapshot handling Gregory Farnum
2012-01-11 9:58 ` Stefan Hajnoczi
2012-01-11 10:00 ` Christoph Hellwig
2012-01-11 19:48 ` Gregory Farnum
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).