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.csa...@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


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to