[pve-devel] [PATCH qemu-server] implement is_shared_only check

Dominik Csapak d.csapak at proxmox.com
Thu Dec 1 17:21:39 CET 2016


here we check if every disk is on a storage marked as shared,
or the cdrom has the value 'none'

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 PVE/QemuConfig.pm | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/PVE/QemuConfig.pm b/PVE/QemuConfig.pm
index 692bba8..15df6ff 100644
--- a/PVE/QemuConfig.pm
+++ b/PVE/QemuConfig.pm
@@ -63,6 +63,27 @@ sub has_feature {
     return $err ? 0 : 1;
 }
 
+sub is_shared_only {
+    my ($class, $conf, $scfg) = @_;
+
+    my $issharedonly = 1;
+    PVE::QemuServer::foreach_drive($conf, sub {
+	my ($ds, $drive) = @_;
+
+	# exit early
+	return if !$issharedonly;
+
+	return if $drive->{file} eq 'none'; # cdrom with no file
+	my $sid = PVE::Storage::parse_volume_id($drive->{file});
+	my $storage = PVE::Storage::storage_config($scfg, $sid);
+	if (!$storage->{shared}) {
+	    $issharedonly = 0;
+	}
+   });
+
+    return $issharedonly;
+}
+
 sub __snapshot_save_vmstate {
     my ($class, $vmid, $conf, $snapname, $storecfg) = @_;
 
-- 
2.1.4





More information about the pve-devel mailing list