QemuServer.patch 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. 5936a5937,5976
  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. 5960a6001,6005
  43. >
  44. > # added: deactivate the src-volume, even on failure
  45. > # this can be safely called as qemu_img_convert is never called on a running volume (that is not a snap)
  46. > $src_storage_plugin->deactivate_volume($src_storeid, $src_scfg, $src_volname, $snapname);
  47. >