[pve-devel] [PATCH 3/3] drive_mirror : add support for nbd uri target

Alexandre Derumier aderumier at odiso.com
Tue Oct 11 16:45:21 CEST 2016


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/QemuServer.pm | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index b80f8f1..bbee7cd 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -5800,16 +5800,25 @@ sub qemu_img_format {
 sub qemu_drive_mirror {
     my ($vmid, $drive, $dst_volid, $vmiddst, $is_zero_initialized) = @_;
 
-    my $storecfg = PVE::Storage::config();
-    my ($dst_storeid, $dst_volname) = PVE::Storage::parse_volume_id($dst_volid);
+    my $qemu_target;
+    my $format;
+
+    if($dst_volid =~ /^nbd:/) {
+	$qemu_target = $dst_volid;
+	$format = "nbd";
+    } else {
 
-    my $dst_scfg = PVE::Storage::storage_config($storecfg, $dst_storeid);
+	my $storecfg = PVE::Storage::config();
+	my ($dst_storeid, $dst_volname) = PVE::Storage::parse_volume_id($dst_volid);
 
-    my $format = qemu_img_format($dst_scfg, $dst_volname);
+	my $dst_scfg = PVE::Storage::storage_config($storecfg, $dst_storeid);
+
+	$format = qemu_img_format($dst_scfg, $dst_volname);
 
-    my $dst_path = PVE::Storage::path($storecfg, $dst_volid);
+	my $dst_path = PVE::Storage::path($storecfg, $dst_volid);
 
-    my $qemu_target = $is_zero_initialized ? "zeroinit:$dst_path" : $dst_path;
+	$qemu_target = $is_zero_initialized ? "zeroinit:$dst_path" : $dst_path;
+    }
 
     my $opts = { timeout => 10, device => "drive-$drive", mode => "existing", sync => "full", target => $qemu_target };
     $opts->{format} = $format if $format;
-- 
2.1.4




More information about the pve-devel mailing list