]> git.proxmox.com Git - qemu-server.git/blame - test/snapshot-test.pm
don't use cirrus by default for sane OS'
[qemu-server.git] / test / snapshot-test.pm
CommitLineData
a157d0fd
FG
1package PVE::QemuServer;
2
3use strict;
4use warnings;
5
6use lib qw(..);
7
8use PVE::Storage;
9use PVE::Storage::Plugin;
10use PVE::QemuServer;
ffda963f 11use PVE::QemuConfig;
a157d0fd
FG
12use PVE::Tools;
13
14use Test::MockModule;
15use Test::More;
16
17my $nodename;
18my $snapshot_possible;
19my $vol_snapshot_possible = {};
20my $vol_snapshot_delete_possible = {};
21my $vol_snapshot_rollback_possible = {};
22my $vol_snapshot_rollback_enabled = {};
23my $vol_snapshot = {};
24my $vol_snapshot_delete = {};
25my $vol_snapshot_rollback = {};
26my $running;
27my $freeze_possible;
28my $stop_possible;
29my $save_vmstate_works;
30my $vm_mon = {};
31
32# Mocked methods
33
34sub mocked_volume_snapshot {
35 my ($storecfg, $volid, $snapname) = @_;
36 die "Storage config not mocked! aborting\n"
37 if defined($storecfg);
38 die "volid undefined\n"
39 if !defined($volid);
40 die "snapname undefined\n"
41 if !defined($snapname);
42 if ($vol_snapshot_possible->{$volid}) {
43 if (defined($vol_snapshot->{$volid})) {
44 $vol_snapshot->{$volid} .= ",$snapname";
45 } else {
46 $vol_snapshot->{$volid} = $snapname;
47 }
48 return 1;
49 } else {
50 die "volume snapshot disabled\n";
51 }
52}
53
54sub mocked_volume_snapshot_delete {
55 my ($storecfg, $volid, $snapname) = @_;
56 die "Storage config not mocked! aborting\n"
57 if defined($storecfg);
58 die "volid undefined\n"
59 if !defined($volid);
60 die "snapname undefined\n"
61 if !defined($snapname);
62 if ($vol_snapshot_delete_possible->{$volid}) {
63 if (defined($vol_snapshot_delete->{$volid})) {
64 $vol_snapshot_delete->{$volid} .= ",$snapname";
65 } else {
66 $vol_snapshot_delete->{$volid} = $snapname;
67 }
68 return 1;
69 } else {
70 die "volume snapshot delete disabled\n";
71 }
72}
73
74sub mocked_volume_snapshot_rollback {
75 my ($storecfg, $volid, $snapname) = @_;
76 die "Storage config not mocked! aborting\n"
77 if defined($storecfg);
78 die "volid undefined\n"
79 if !defined($volid);
80 die "snapname undefined\n"
81 if !defined($snapname);
82 if ($vol_snapshot_rollback_enabled->{$volid}) {
83 if (defined($vol_snapshot_rollback->{$volid})) {
84 $vol_snapshot_rollback->{$volid} .= ",$snapname";
85 } else {
86 $vol_snapshot_rollback->{$volid} = $snapname;
87 }
88 return 1;
89 } else {
90 die "volume snapshot rollback disabled\n";
91 }
92}
93
94sub mocked_volume_rollback_is_possible {
95 my ($storecfg, $volid, $snapname) = @_;
96 die "Storage config not mocked! aborting\n"
97 if defined($storecfg);
98 die "volid undefined\n"
99 if !defined($volid);
100 die "snapname undefined\n"
101 if !defined($snapname);
102 return $vol_snapshot_rollback_possible->{$volid}
103 if ($vol_snapshot_rollback_possible->{$volid});
104 die "volume_rollback_is_possible failed\n";
105}
106
101a1b3f
FG
107sub mocked_activate_volumes {
108 my ($storecfg, $volumes) = @_;
109 die "Storage config not mocked! aborting\n"
110 if defined($storecfg);
111 die "wrong volume - fake vmstate expected!\n"
112 if ((scalar @$volumes != 1) || @$volumes[0] ne "somestorage:state-volume");
113 return;
114}
115
116sub mocked_deactivate_volumes {
117 my ($storecfg, $volumes) = @_;
118 die "Storage config not mocked! aborting\n"
119 if defined($storecfg);
120 die "wrong volume - fake vmstate expected!\n"
121 if ((scalar @$volumes != 1) || @$volumes[0] ne "somestorage:state-volume");
122 return;
123}
124
a157d0fd
FG
125sub mocked_vdisk_free {
126 my ($storecfg, $vmstate) = @_;
127 die "Storage config not mocked! aborting\n"
128 if defined($storecfg);
129 die "wrong vdisk - fake vmstate expected!\n"
130 if ($vmstate ne "somestorage:state-volume");
131 return;
132}
133
134sub mocked_run_command {
135 my ($cmd, %param) = @_;
136 my $cmdstring;
137 if (my $ref = ref($cmd)) {
138 $cmdstring = PVE::Tools::cmd2string($cmd);
139 if ($cmdstring =~ m/.*\/qemu-(un)?freeze.*/) {
140 return 1 if $freeze_possible;
141 die "qemu-[un]freeze disabled\n";
142 }
143 if ($cmdstring =~ m/.*\/qemu-stop.*--kill.*/) {
144 if ($stop_possible) {
145 $running = 0;
146 return 1;
147 } else {
148 return 0;
149 }
150 }
151 }
152 die "unexpected run_command call: '$cmdstring', aborting\n";
153}
154
155# Testing methods
156
157sub test_file {
158 my ($exp_fn, $real_fn) = @_;
159 my $ret;
160 eval {
161 $ret = system("diff -u '$exp_fn' '$real_fn'");
162 };
163 die if $@;
164 return !$ret;
165}
166
167sub testcase_prepare {
168 my ($vmid, $snapname, $save_vmstate, $comment, $exp_err) = @_;
169 subtest "Preparing snapshot '$snapname' for vm '$vmid'" => sub {
170 plan tests => 2;
171 $@ = undef;
172 eval {
b2c9558d 173 PVE::QemuConfig->__snapshot_prepare($vmid, $snapname, $save_vmstate, $comment);
a157d0fd
FG
174 };
175 is($@, $exp_err, "\$@ correct");
176 ok(test_file("snapshot-expected/prepare/qemu-server/$vmid.conf", "snapshot-working/prepare/qemu-server/$vmid.conf"), "config file correct");
177 };
178}
179
180sub testcase_commit {
181 my ($vmid, $snapname, $exp_err) = @_;
182 subtest "Committing snapshot '$snapname' for vm '$vmid'" => sub {
183 plan tests => 2;
184 $@ = undef;
185 eval {
b2c9558d 186 PVE::QemuConfig->__snapshot_commit($vmid, $snapname);
a157d0fd
FG
187 };
188 is($@, $exp_err, "\$@ correct");
189 ok(test_file("snapshot-expected/commit/qemu-server/$vmid.conf", "snapshot-working/commit/qemu-server/$vmid.conf"), "config file correct");
190 }
191}
192
193sub testcase_create {
194 my ($vmid, $snapname, $save_vmstate, $comment, $exp_err, $exp_vol_snap, $exp_vol_snap_delete) = @_;
195 subtest "Creating snapshot '$snapname' for vm '$vmid'" => sub {
196 plan tests => 4;
197 $vol_snapshot = {};
198 $vol_snapshot_delete = {};
199 $exp_vol_snap = {} if !defined($exp_vol_snap);
200 $exp_vol_snap_delete = {} if !defined($exp_vol_snap_delete);
201 $@ = undef;
202 eval {
b2c9558d 203 PVE::QemuConfig->snapshot_create($vmid, $snapname, $save_vmstate, $comment);
a157d0fd
FG
204 };
205 is($@, $exp_err, "\$@ correct");
206 is_deeply($vol_snapshot, $exp_vol_snap, "created correct volume snapshots");
207 is_deeply($vol_snapshot_delete, $exp_vol_snap_delete, "deleted correct volume snapshots");
208 ok(test_file("snapshot-expected/create/qemu-server/$vmid.conf", "snapshot-working/create/qemu-server/$vmid.conf"), "config file correct");
209 };
210}
211
212sub testcase_delete {
213 my ($vmid, $snapname, $force, $exp_err, $exp_vol_snap_delete) = @_;
214 subtest "Deleting snapshot '$snapname' of vm '$vmid'" => sub {
215 plan tests => 3;
216 $vol_snapshot_delete = {};
217 $exp_vol_snap_delete = {} if !defined($exp_vol_snap_delete);
218 $@ = undef;
219 eval {
b2c9558d 220 PVE::QemuConfig->snapshot_delete($vmid, $snapname, $force);
a157d0fd
FG
221 };
222 is($@, $exp_err, "\$@ correct");
223 is_deeply($vol_snapshot_delete, $exp_vol_snap_delete, "deleted correct volume snapshots");
224 ok(test_file("snapshot-expected/delete/qemu-server/$vmid.conf", "snapshot-working/delete/qemu-server/$vmid.conf"), "config file correct");
225 };
226}
227
228sub testcase_rollback {
229 my ($vmid, $snapname, $exp_err, $exp_vol_snap_rollback) = @_;
230 subtest "Rolling back to snapshot '$snapname' of vm '$vmid'" => sub {
231 plan tests => 3;
232 $vol_snapshot_rollback = {};
233 $running = 1;
234 $exp_vol_snap_rollback = {} if !defined($exp_vol_snap_rollback);
235 $@ = undef;
236 eval {
b2c9558d 237 PVE::QemuConfig->snapshot_rollback($vmid, $snapname);
a157d0fd
FG
238 };
239 is($@, $exp_err, "\$@ correct");
240 is_deeply($vol_snapshot_rollback, $exp_vol_snap_rollback, "rolled back to correct volume snapshots");
241 ok(test_file("snapshot-expected/rollback/qemu-server/$vmid.conf", "snapshot-working/rollback/qemu-server/$vmid.conf"), "config file correct");
242 };
243}
244
ffda963f 245# BEGIN mocked PVE::QemuConfig methods
a157d0fd
FG
246sub config_file_lock {
247 return "snapshot-working/pve-test.lock";
248}
249
250sub cfs_config_path {
ffda963f 251 my ($class, $vmid, $node) = @_;
a157d0fd
FG
252
253 $node = $nodename if !$node;
254 return "snapshot-working/$node/qemu-server/$vmid.conf";
255}
256
257sub load_config {
ffda963f 258 my ($class, $vmid, $node) = @_;
a157d0fd 259
ffda963f 260 my $filename = $class->cfs_config_path($vmid, $node);
a157d0fd
FG
261
262 my $raw = PVE::Tools::file_get_contents($filename);
263
264 my $conf = PVE::QemuServer::parse_vm_config($filename, $raw);
265 return $conf;
266}
267
268sub write_config {
ffda963f 269 my ($class, $vmid, $conf) = @_;
a157d0fd 270
ffda963f 271 my $filename = $class->cfs_config_path($vmid);
a157d0fd
FG
272
273 if ($conf->{snapshots}) {
274 foreach my $snapname (keys %{$conf->{snapshots}}) {
275 $conf->{snapshots}->{$snapname}->{snaptime} = "1234567890"
276 if $conf->{snapshots}->{$snapname}->{snaptime};
277 }
278 }
279
280 my $raw = PVE::QemuServer::write_vm_config($filename, $conf);
281
282 PVE::Tools::file_set_contents($filename, $raw);
283}
284
285sub has_feature {
b2c9558d 286 my ($class, $feature, $conf, $storecfg, $snapname, $running, $backup_only) = @_;
a157d0fd
FG
287 return $snapshot_possible;
288}
289
b2c9558d
FG
290sub __snapshot_save_vmstate {
291 my ($class, $vmid, $conf, $snapname, $storecfg) = @_;
a157d0fd
FG
292 die "save_vmstate failed\n"
293 if !$save_vmstate_works;
294
295 my $snap = $conf->{snapshots}->{$snapname};
296 $snap->{vmstate} = "somestorage:state-volume";
297 $snap->{machine} = "somemachine";
298}
b2c9558d
FG
299# END mocked PVE::QemuConfig methods
300
301# BEGIN redefine PVE::QemuServer methods
302
303sub check_running {
304 return $running;
305}
306
a157d0fd
FG
307
308sub do_snapshots_with_qemu {
309 return 0;
310}
311
312sub vm_qmp_command {
313 my ($vmid, $cmd, $nocheck) = @_;
314
315 my $exec = $cmd->{execute};
316 if ($exec eq "delete-drive-snapshot") {
317 return;
318 }
319 if ($exec eq "guest-ping") {
320 die "guest-ping disabled\n"
321 if !$vm_mon->{guest_ping};
322 return;
323 }
324 if ($exec eq "guest-fsfreeze-freeze" || $exec eq "guest-fsfreeze-thaw") {
325 die "freeze disabled\n"
326 if !$freeze_possible;
327 return;
328 }
329 if ($exec eq "savevm-start") {
330 die "savevm-start disabled\n"
331 if !$vm_mon->{savevm_start};
332 return;
333 }
334 if ($exec eq "savevm-end") {
335 die "savevm-end disabled\n"
336 if !$vm_mon->{savevm_end};
337 return;
338 }
339 if ($exec eq "query-savevm") {
340 return { "status" => "completed" };
341 }
342 die "unexpected vm_qmp_command!\n";
343}
344
345sub vm_start {
346 my ($storecfg, $vmid, $statefile, $skiplock, $migratedfrom, $paused, $forcemachine) = @_;
347
348 die "Storage config not mocked! aborting\n"
349 if defined($storecfg);
350
351 die "statefile and forcemachine must be both defined or undefined! aborting\n"
352 if defined($statefile) xor defined($forcemachine);
353
354 return;
355}
356
357sub vm_stop {
358 my ($storecfg, $vmid, $skiplock, $nocheck, $timeout, $shutdown, $force, $keepActive, $migratedfrom) = @_;
359
360 $running = 0
361 if $stop_possible;
362
363 return;
364}
365
366# END redefine PVE::QemuServer methods
367
368PVE::Tools::run_command("rm -rf snapshot-working");
369PVE::Tools::run_command("cp -a snapshot-input snapshot-working");
370
ffda963f
FG
371my $qemu_config_module = new Test::MockModule('PVE::QemuConfig');
372$qemu_config_module->mock('config_file_lock', \&config_file_lock);
373$qemu_config_module->mock('cfs_config_path', \&cfs_config_path);
374$qemu_config_module->mock('load_config', \&load_config);
375$qemu_config_module->mock('write_config', \&write_config);
b2c9558d
FG
376$qemu_config_module->mock('has_feature', \&has_feature);
377$qemu_config_module->mock('__snapshot_save_vmstate', \&__snapshot_save_vmstate);
ffda963f 378
a157d0fd
FG
379$running = 1;
380$freeze_possible = 1;
381$save_vmstate_works = 1;
382
383printf("\n");
384printf("Running prepare tests\n");
385printf("\n");
386$nodename = "prepare";
387
388printf("\n");
389printf("Setting has_feature to return true\n");
390printf("\n");
391$snapshot_possible = 1;
392
393printf("Successful snapshot_prepare with no existing snapshots\n");
394testcase_prepare("101", "test", 0, "test comment", '');
395
396printf("Successful snapshot_prepare with no existing snapshots, including vmstate\n");
397testcase_prepare("102", "test", 1, "test comment", '');
398
399printf("Successful snapshot_prepare with one existing snapshot\n");
400testcase_prepare("103", "test2", 0, "test comment", "");
401
402printf("Successful snapshot_prepare with one existing snapshot, including vmstate\n");
403testcase_prepare("104", "test2", 1, "test comment", "");
404
405printf("Expected error for snapshot_prepare on locked container\n");
406testcase_prepare("200", "test", 0, "test comment", "VM is locked (snapshot)\n");
407
408printf("Expected error for snapshot_prepare with duplicate snapshot name\n");
409testcase_prepare("201", "test", 0, "test comment", "snapshot name 'test' already used\n");
410
411$save_vmstate_works = 0;
412
413printf("Expected error for snapshot_prepare with failing save_vmstate\n");
414testcase_prepare("202", "test", 1, "test comment", "save_vmstate failed\n");
415
416$save_vmstate_works = 1;
417
418printf("\n");
419printf("Setting has_feature to return false\n");
420printf("\n");
421$snapshot_possible = 0;
422
423printf("Expected error for snapshot_prepare if snapshots not possible\n");
424testcase_prepare("300", "test", 0, "test comment", "snapshot feature is not available\n");
425
426printf("\n");
427printf("Running commit tests\n");
428printf("\n");
429$nodename = "commit";
430
431printf("\n");
432printf("Setting has_feature to return true\n");
433printf("\n");
434$snapshot_possible = 1;
435
436printf("Successful snapshot_commit with one prepared snapshot\n");
437testcase_commit("101", "test", "");
438
439printf("Successful snapshot_commit with one committed and one prepared snapshot\n");
440testcase_commit("102", "test2", "");
441
442printf("Expected error for snapshot_commit with no snapshot lock\n");
443testcase_commit("201", "test", "missing snapshot lock\n");
444
445printf("Expected error for snapshot_commit with invalid snapshot name\n");
446testcase_commit("202", "test", "snapshot 'test' does not exist\n");
447
448printf("Expected error for snapshot_commit with invalid snapshot state\n");
449testcase_commit("203", "test", "wrong snapshot state\n");
450
451$vol_snapshot_possible->{"local:snapshotable-disk-1"} = 1;
452$vol_snapshot_possible->{"local:snapshotable-disk-2"} = 1;
453$vol_snapshot_possible->{"local:snapshotable-disk-3"} = 1;
454$vol_snapshot_delete_possible->{"local:snapshotable-disk-1"} = 1;
455$vol_snapshot_delete_possible->{"local:snapshotable-disk-3"} = 1;
456$vol_snapshot_rollback_enabled->{"local:snapshotable-disk-1"} = 1;
457$vol_snapshot_rollback_enabled->{"local:snapshotable-disk-2"} = 1;
458$vol_snapshot_rollback_enabled->{"local:snapshotable-disk-3"} = 1;
459$vol_snapshot_rollback_possible->{"local:snapshotable-disk-1"} = 1;
460$vol_snapshot_rollback_possible->{"local:snapshotable-disk-2"} = 1;
461$vol_snapshot_rollback_possible->{"local:snapshotable-disk-3"} = 1;
462$vol_snapshot_rollback_possible->{"local:snapshotable-disk-4"} = 1;
463$vm_mon->{guest_ping} = 1;
464$vm_mon->{savevm_start} = 1;
465$vm_mon->{savevm_end} = 1;
466
467# possible, but fails
468$vol_snapshot_rollback_possible->{"local:snapshotable-disk-4"} = 1;
469
470printf("\n");
471printf("Setting up Mocking for PVE::Storage\n");
472my $storage_module = new Test::MockModule('PVE::Storage');
473$storage_module->mock('config', sub { return undef; });
474$storage_module->mock('path', sub { return "/some/store/statefile/path"; });
101a1b3f
FG
475$storage_module->mock('activate_volumes', \&mocked_activate_volumes);
476$storage_module->mock('deactivate_volumes', \&mocked_deactivate_volumes);
a157d0fd
FG
477$storage_module->mock('vdisk_free', \&mocked_vdisk_free);
478$storage_module->mock('volume_snapshot', \&mocked_volume_snapshot);
479$storage_module->mock('volume_snapshot_delete', \&mocked_volume_snapshot_delete);
480$storage_module->mock('volume_snapshot_rollback', \&mocked_volume_snapshot_rollback);
481$storage_module->mock('volume_rollback_is_possible', \&mocked_volume_rollback_is_possible);
482printf("\tconfig(), volume_snapshot(), volume_snapshot_delete(), volume_snapshot_rollback() and volume_rollback_is_possible() mocked\n");
483
484#printf("\n");
485#printf("Setting up Mocking for PVE::Tools\n");
486#my $tools_module = new Test::MockModule('PVE::Tools');
487#$tools_module->mock('run_command' => \&mocked_run_command);
488#printf("\trun_command() mocked\n");
489#
490$nodename = "create";
491printf("\n");
492printf("Running create tests\n");
493printf("\n");
494
495printf("Successful snapshot_create with no existing snapshots\n");
496testcase_create("101", "test", 0, "test comment", "", { "local:snapshotable-disk-1" => "test" });
497
498printf("Successful snapshot_create with no existing snapshots, including vmstate\n");
499testcase_create("102", "test", 1, "test comment", "", { "local:snapshotable-disk-1" => "test" });
500
501printf("Successful snapshot_create with one existing snapshots\n");
502testcase_create("103", "test2", 0, "test comment", "", { "local:snapshotable-disk-1" => "test2" });
503
504printf("Successful snapshot_create with one existing snapshots, including vmstate\n");
505testcase_create("104", "test2", 1, "test comment", "", { "local:snapshotable-disk-1" => "test2" });
506
507printf("Successful snapshot_create with multiple mps\n");
508testcase_create("105", "test", 0, "test comment", "", { "local:snapshotable-disk-1" => "test", "local:snapshotable-disk-2" => "test", "local:snapshotable-disk-3" => "test" });
509
510$freeze_possible = 0;
511printf("Successful snapshot_create with no existing snapshots and broken freeze\n");
512testcase_create("106", "test", 1, "test comment", "", { "local:snapshotable-disk-1" => "test" });
513$freeze_possible = 1;
514
515printf("Expected error for snapshot_create when volume snapshot is not possible\n");
b2c9558d 516testcase_create("201", "test", 0, "test comment", "volume snapshot disabled\n\n");
a157d0fd
FG
517
518printf("Expected error for snapshot_create when volume snapshot is not possible for one drive\n");
b2c9558d 519testcase_create("202", "test", 0, "test comment", "volume snapshot disabled\n\n", { "local:snapshotable-disk-1" => "test" }, { "local:snapshotable-disk-1" => "test" });
a157d0fd
FG
520
521$vm_mon->{savevm_start} = 0;
522printf("Expected error for snapshot_create when Qemu mon command 'savevm-start' fails\n");
b2c9558d 523testcase_create("203", "test", 0, "test comment", "savevm-start disabled\n\n");
a157d0fd
FG
524$vm_mon->{savevm_start} = 1;
525
526
527$nodename = "delete";
528printf("\n");
529printf("Running delete tests\n");
530printf("\n");
531
532printf("Successful snapshot_delete of only existing snapshot\n");
533testcase_delete("101", "test", 0, "", { "local:snapshotable-disk-1" => "test" });
534
535printf("Successful snapshot_delete of leaf snapshot\n");
536testcase_delete("102", "test2", 0, "", { "local:snapshotable-disk-1" => "test2" });
537
538printf("Successful snapshot_delete of root snapshot\n");
539testcase_delete("103", "test", 0, "", { "local:snapshotable-disk-1" => "test" });
540
541printf("Successful snapshot_delete of intermediate snapshot\n");
542testcase_delete("104", "test2", 0, "", { "local:snapshotable-disk-1" => "test2" });
543
544printf("Successful snapshot_delete with broken volume_snapshot_delete and force=1\n");
545testcase_delete("105", "test", 1, "");
546
547printf("Successful snapshot_delete with mp broken volume_snapshot_delete and force=1\n");
548testcase_delete("106", "test", 1, "", { "local:snapshotable-disk-1" => "test", "local:snapshotable-disk-3" => "test" });
549
550printf("Expected error when snapshot_delete fails with broken volume_snapshot_delete and force=0\n");
551testcase_delete("201", "test", 0, "volume snapshot delete disabled\n");
552
553printf("Expected error when snapshot_delete fails with broken mp volume_snapshot_delete and force=0\n");
554testcase_delete("202", "test", 0, "volume snapshot delete disabled\n", { "local:snapshotable-disk-1" => "test" });
555
556printf("Expected error for snapshot_delete with locked config\n");
557testcase_delete("203", "test", 0, "VM is locked (backup)\n");
558
559$nodename = "rollback";
560printf("\n");
561printf("Running rollback tests\n");
562printf("\n");
563
564$stop_possible = 1;
565
566printf("Successful snapshot_rollback to only existing snapshot\n");
567testcase_rollback("101", "test", "", { "local:snapshotable-disk-1" => "test" });
568
569printf("Successful snapshot_rollback to leaf snapshot\n");
570testcase_rollback("102", "test2", "", { "local:snapshotable-disk-1" => "test2" });
571
572printf("Successful snapshot_rollback to root snapshot\n");
573testcase_rollback("103", "test", "", { "local:snapshotable-disk-1" => "test" });
574
575printf("Successful snapshot_rollback to intermediate snapshot\n");
576testcase_rollback("104", "test2", "", { "local:snapshotable-disk-1" => "test2" });
577
578printf("Successful snapshot_rollback with multiple mp\n");
579testcase_rollback("105", "test", "", { "local:snapshotable-disk-1" => "test", "local:snapshotable-disk-2" => "test", "local:snapshotable-disk-3" => "test" });
580
581printf("Successful snapshot_rollback to only existing snapshot, with saved vmstate and machine config\n");
582testcase_rollback("106", "test", "", { "local:snapshotable-disk-1" => "test" });
583
584printf("Expected error for snapshot_rollback with non-existing snapshot\n");
585testcase_rollback("201", "test2", "snapshot 'test2' does not exist\n");
586
587printf("Expected error for snapshot_rollback if volume rollback not possible\n");
588testcase_rollback("202", "test", "volume_rollback_is_possible failed\n");
589
590printf("Expected error for snapshot_rollback with incomplete snapshot\n");
591testcase_rollback("203", "test", "unable to rollback to incomplete snapshot (snapstate = delete)\n");
592
593printf("Expected error for snapshot_rollback with lock\n");
594testcase_rollback("204", "test", "VM is locked (backup)\n");
595
596$stop_possible = 0;
597
598printf("Expected error for snapshot_rollback with unkillable container\n");
599testcase_rollback("205", "test", "unable to rollback vm 205: vm is running\n");
600
601$stop_possible = 1;
602
603printf("Expected error for snapshot_rollback with mp rollback_is_possible failure\n");
604testcase_rollback("206", "test", "volume_rollback_is_possible failed\n");
605
606printf("Expected error for snapshot_rollback with mp rollback failure (results in inconsistent state)\n");
607testcase_rollback("207", "test", "volume snapshot rollback disabled\n", { "local:snapshotable-disk-1" => "test", "local:snapshotable-disk-2" => "test" });
608
609done_testing();