[pve-devel] Snapshot questions

Dietmar Maurer dietmar at proxmox.com
Sat Sep 5 14:12:31 CEST 2015

> *) The first question is - how would these get called? "pvesm" shows no 
> matching arguments, and the GUI has no "snapshot" buttons either.

I guess it is best to test that with Qemu VMs. You can use the GUI to
create/delete snapshots (there is a 'Snaphots' panel),
or the command line tool:

# qm snapshot ...
# qm rollback ..
# qm delsnapshot

you can get help for all commands using:

# qm help <cmdname>


# qm help -v


# man qm

There is currently no snapshot support within 'pvesm', because snapshots
are usually managed by the 'qm' tool, or directly at storage level.

I usually simply write small perl test scripts like this:


use strict;
use warnings;
use Data::Dumper;
use PVE::Tools;

use PVE::Storage;

my $vmid = '999'; # for testing
my $storeid = 'mydrbdstorage';
my $size = 4096; # 4096K => 4M

my $cfg = PVE::Storage::config();

my $volid = PVE::Storage::vdisk_alloc($cfg, $storeid, $vmid, 'raw', undef,
print "created VOLID: $volid\n";

eval {
    # test code

    my $snapname = 'snapshot1';
    PVE::Storage::volume_snapshot($cfg, $volid, $snapname);
    print "created snapshot '$snapname'\n";

    # PVE::Storage::volume_snapshot_rollback(...)

    my $running = 0;
    PVE::Storage::volume_snapshot_delete($cfg, $volid, $snapname, $running);
    print "deleted snapshot '$snapname'\n";
my $err = $@;

# destroy disk
PVE::Storage::vdisk_free($cfg, $volid);

die $err if $err;

> Does that hide behind backup functionality or something like that?

Sorry, I do not understand that question. For Qemu VM, we do not use
storage snapshots to implement backup (we use qemu block backup code instead,
which also provides snapshot semantics).

> *) The second question is - recently the "filesystem_path" function got a new 
> line added:
>     die "drbd snapshot is not implemented\n" if defined($snapname);
> In what circumstances would that function get called? 

This is experimental code, and we want to use that to implement backup
functionality at the storage level. While we do not use that for KVM, we
want to use it with LXC containers:


Above container management toolkit 'pct' already supports drbd, and it would
be really cool to have snapshots, so that we can make snapshot and 
snapshot backups ;-)

But that code is quite new, so I would start with qemu, and implement those
advanced features later.

> While the Thin LVM 
> snapshots that DRBDmanage uses might be addressable locally[1], accessing 
> them is not recommended. Is that just for information purposes in the GUI?

We want to access them when making container backups. I think this should
work with dm-thin - why not? 

We can extend the storage API with 'activate_snapshot_volume()' and 
'deactivate_snapshot_volume()' if required?

> *) Thirdly, about restoring snapshots...
> There's the volume_snapshot_rollback() function that will destroy the 
> volume's data and replace it with the data in the snapshot 


- but using a snapshot for a new ("clean") VM isn't being done, right?

don't really understand that question?

> During volume_snapshot_rollback() there will no one be accessing the 
> original volume, 


> and after rollback it can have a new filesystem_path(),correct?

Yes, that should work.

Besides, we also have 'vdisk_clone', and some storage types supports
to clone directly from snapshot (zfs). But I am not really sure
if drbdmanage will support clone at all?

Normally, we only allow cloning from 'base' volumes, which are created
with vdisk_create_base(). If most cases, this just marks the volumes as
'read-only' and renames them. I guess dm-thin could
make a 'clone' by simply creating a writable snapshot of such read-only

More information about the pve-devel mailing list