[pve-devel] [PATCH] Added methods to allocate and free storage for migration
Alexandre DERUMIER
aderumier at odiso.com
Wed Nov 12 07:45:12 CET 2014
I think we should add apis like
qm storage add storeid:xxx
qm storage del storeid:xxx
for this.
I have begin to do some block migration, seem to works fine.
I'm currently improving it to allow to migrate to different storageid/storagetype.
Also I'm doing some tests with ndb server to copy unused disk with qemu-img convert, seem to works fine too.
I'll try to send patchs in 1 or 2 weeks.
----- Mail original -----
De: "Kamil Trzcinski" <ayufan at ayufan.eu>
À: pve-devel at pve.proxmox.com
Envoyé: Lundi 3 Novembre 2014 12:12:56
Objet: [pve-devel] [PATCH] Added methods to allocate and free storage for migration
Signed-off-by: Kamil Trzcinski <ayufan at ayufan.eu>
---
PVE/Storage.pm | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
diff --git a/PVE/Storage.pm b/PVE/Storage.pm
index 3cc9581..2e3c1ec 100755
--- a/PVE/Storage.pm
+++ b/PVE/Storage.pm
@@ -477,6 +477,68 @@ sub storage_migrate {
}
}
+sub storage_migrate_alloc {
+ my ($self, $cfg, $volid, $target_host, $target_storeid, $target_volname) = @_;
+
+ my ($storeid, $volname) = parse_volume_id($volid);
+ $target_volname = $volname if !$target_volname;
+
+ my $scfg = storage_config($cfg, $storeid);
+
+ # no need to migrate shared content
+ return if $storeid eq $target_storeid && $scfg->{shared};
+
+ my $tcfg = storage_config($cfg, $target_storeid);
+
+ my $target_volid = "${target_storeid}:${target_volname}";
+
+ my $sshoptions = "-o 'BatchMode=yes'";
+ my $ssh = "/usr/bin/ssh $sshoptions";
+
+ my ($size, $format) = PVE::Storage::volume_size_info($cfg, $volid);
+
+ my ($vtype, $name, $vmid) = parse_volname($cfg, $target_volid);
+
+ my $remote_cmd = <<'END_MESSAGE';
+use PVE::Storage;
+$cfg = PVE::Storage::config();
+PVE::Storage::vdisk_alloc($cfg, $ARGV[0], $ARGV[1], $ARGV[2], $ARGV[3], $ARGV[4]);
+END_MESSAGE
+
+ ## start on remote node
+ my $cmd = [@{$self->{rem_ssh}}, 'perl', '-', $target_storeid, $vmid, $format, $name, ($size/1024)];
+ PVE::Tools::run_command($cmd, input => $remote_cmd);
+}
+
+sub storage_migrate_free {
+ my ($self, $cfg, $volid, $target_host, $target_storeid, $target_volname) = @_;
+
+ my ($storeid, $volname) = parse_volume_id($volid);
+ $target_volname = $volname if !$target_volname;
+
+ my $scfg = storage_config($cfg, $storeid);
+
+ # no need to migrate shared content
+ return if $storeid eq $target_storeid && $scfg->{shared};
+
+ my $tcfg = storage_config($cfg, $target_storeid);
+
+ my $target_volid = "${target_storeid}:${target_volname}";
+
+ my $sshoptions = "-o 'BatchMode=yes'";
+ my $ssh = "/usr/bin/ssh $sshoptions";
+
+ my $remote_cmd = <<'END_MESSAGE';
+use PVE::Storage;
+$cfg = PVE::Storage::config();
+PVE::Storage::vdisk_free($cfg, $ARGV[0]);
+END_MESSAGE
+
+ ## start on remote node
+ my $cmd = [@{$self->{rem_ssh}}, 'perl', '-', $target_volid];
+ PVE::Tools::run_command($cmd, input => $remote_cmd);
+}
+
sub vdisk_clone {
my ($cfg, $volid, $vmid, $snap) = @_;
--
1.9.3 (Apple Git-50)
_______________________________________________
pve-devel mailing list
pve-devel at pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
More information about the pve-devel
mailing list