QemuServer.patch 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. 6147a6148,6188
  2. > #BEGIN addition
  3. > my $src_storage_plugin = PVE::Storage::Plugin->lookup($src_scfg->{type});
  4. > my $dst_storage_plugin = PVE::Storage::Plugin->lookup($dst_scfg->{type});
  5. >
  6. > # in many cases the storage may have a better idea how to convert:
  7. > # if src and dst format is the same
  8. > # and src_storeid is dst_storeid
  9. > # and the storage has the feature
  10. > # and the feature is implemented as volume_copy / volume_snapshot_copy
  11. > # let the storage do the work as it quite sure is faster
  12. > if ( $src_format eq $dst_format ) {
  13. > if( $src_storeid eq $dst_storeid ) {
  14. > # this is the same storage
  15. > # and storage is capable of materializing snaps
  16. > if( $snapname ) {
  17. > my $canCopySnap = PVE::Storage::volume_has_feature($storecfg, 'copy', $src_volid, $snapname, undef) && $src_storage_plugin->can('volume_snapshot_copy');
  18. > if( $canCopySnap ) {
  19. > print "delegate to storage plugin volume_snapshot_copy (snap $snapname)\n";
  20. > $src_storage_plugin->volume_snapshot_copy($src_scfg, $src_volname, $snapname, $dst_volname);
  21. >
  22. > $src_storage_plugin->deactivate_volume($src_storeid, $src_scfg, $src_volname, $snapname);
  23. >
  24. > return 1;
  25. > }
  26. > }
  27. >
  28. > my $canCopyVolume = PVE::Storage::volume_has_feature($storecfg, 'copy', $src_volid, undef, undef) && $src_storage_plugin->can('volume_copy');
  29. > if ( $canCopyVolume ) {
  30. > print "delegate to storage plugin: volume_copy (base)\n";
  31. > $src_storage_plugin->volume_copy($src_scfg, $src_volname, $dst_volname);
  32. >
  33. > $src_storage_plugin->deactivate_volume($src_storeid, $src_scfg, $src_volname, $snapname);
  34. >
  35. > return 1;
  36. > }
  37. > }
  38. > # @todo: two zfs-storages might be able to receive stream from each other
  39. > }
  40. > #END addition
  41. >
  42. >
  43. 6173a6215,6219
  44. >
  45. > # added: deactivate the src-volume, even on failure
  46. > # this can be safely called as qemu_img_convert is never called on a running volume (that is not a snap)
  47. > $src_storage_plugin->deactivate_volume($src_storeid, $src_scfg, $src_volname, $snapname);
  48. >