+sub __snapshot_rollback_hook {
+ my ($class, $vmid, $conf, $snap, $prepare, $data) = @_;
+
+ if ($prepare) {
+ # we save the machine of the current config
+ $data->{oldmachine} = $conf->{machine};
+ } else {
+ # if we have a 'runningmachine' entry in the snapshot we use that
+ # for the forcemachine parameter, else we use the old logic
+ if (defined($conf->{runningmachine})) {
+ $data->{forcemachine} = $conf->{runningmachine};
+ delete $conf->{runningmachine};
+ } else {
+ # Note: old code did not store 'machine', so we try to be smart
+ # and guess the snapshot was generated with kvm 1.4 (pc-i440fx-1.4).
+ $data->{forcemachine} = $conf->{machine} || 'pc-i440fx-1.4';
+
+ # we remove the 'machine' configuration if not explicitly specified
+ # in the original config.
+ delete $conf->{machine} if $snap->{vmstate} && !defined($data->{oldmachine});
+ }
+
+ if ($conf->{vmgenid}) {
+ # tell the VM that it's another generation, so it can react
+ # appropriately, e.g. dirty-mark copies of distributed databases or
+ # re-initializing its random number generator
+ $conf->{vmgenid} = PVE::QemuServer::generate_uuid();
+ }
+ }
+
+ return;
+}
+