[pve-devel] [PATCH] Make qm clone working with devices.

Jasmin Jessich jasmin at anw.at
Sat Oct 25 20:07:03 CEST 2014


Signed-off-by: Jasmin Jessich <jasmin at anw.at>
---
 PVE/API2/Qemu.pm  | 5 ++++-
 PVE/QemuServer.pm | 8 ++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index a0fcd28..32ee6de 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -71,6 +71,7 @@ my $check_storage_access_clone = sub {
 	my ($ds, $drive) = @_;
 
 	my $isCDROM = PVE::QemuServer::drive_is_cdrom($drive);
+	my $isDEVICE = PVE::QemuServer::drive_is_device($drive);
 
 	my $volid = $drive->{file};
 
@@ -86,7 +87,7 @@ my $check_storage_access_clone = sub {
 		$sharedvm = 0 if !$scfg->{shared};
 
 	    }
-	} else {
+	} elsif	(!$isDEVICE) {
 	    my ($sid, $volname) = PVE::Storage::parse_volume_id($volid);
 	    my $scfg = PVE::Storage::storage_config($storecfg, $sid);
 	    $sharedvm = 0 if !$scfg->{shared};
@@ -2260,6 +2261,8 @@ __PACKAGE__->register_method({
 		    die "unable to parse drive options for '$opt'\n" if !$drive;
 		    if (PVE::QemuServer::drive_is_cdrom($drive)) {
 			$newconf->{$opt} = $value; # simply copy configuration
+		    } elsif (PVE::QemuServer::drive_is_device($drive)) {
+			$newconf->{$opt} = $value; # simply copy configuration
 		    } else {
 			if ($param->{full}) {
 			    die "Full clone feature is not available"
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 98264d1..49fbffa 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -1272,6 +1272,14 @@ sub drive_is_cdrom {
 
 }
 
+sub drive_is_device {
+    my ($drive) = @_;
+
+    my $volid = $drive->{file};
+
+    return $volid && $volid =~ m/^\/dev\//;
+}
+
 sub parse_hostpci {
     my ($value) = @_;
 
-- 
1.8.3.2




More information about the pve-devel mailing list