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

Alexandre Derumier aderumier at odiso.com
Thu Oct 20 02:35:15 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 2dcab7b..ce6c20f 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -5870,16 +5870,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