diff --git a/emhttp/plugins/dynamix.vm.manager/include/VMMachines.php b/emhttp/plugins/dynamix.vm.manager/include/VMMachines.php index 7c7ed0a4c..e585677d0 100644 --- a/emhttp/plugins/dynamix.vm.manager/include/VMMachines.php +++ b/emhttp/plugins/dynamix.vm.manager/include/VMMachines.php @@ -53,7 +53,7 @@ foreach ($vms as $vm) { $image = substr($icon,-4)=='.png' ? "" : (substr($icon,0,5)=='icon-' ? "" : ""); $arrConfig = domain_to_config($uuid); $snapshots = getvmsnapshots($vm) ; - $cdroms = $lv->get_cdrom_stats($res) ; + $cdroms = $lv->get_cdrom_stats($res,true,true) ; if ($state == 'running') { $mem = $dom['memory']/1024; } else { @@ -215,7 +215,7 @@ foreach ($vms as $vm) { $boot= $arrDisk["boot order"]; $serial = $arrDisk["serial"]; if ($boot < 1) $boot = _('Not set'); - $reallocation = trim(shell_exec("getfattr --absolute-names --only-values -n system.LOCATION ".escapeshellarg($disk)." 2>/dev/null")); + $reallocation = trim(get_realvolume($disk)); if (!empty($reallocation)) $reallocationstr = "($reallocation)"; else $reallocationstr = ""; echo "$disk $reallocationstr$serial$bus"; if ($state == 'shutoff') { @@ -237,8 +237,10 @@ foreach ($vms as $vm) { /* Display VM cdroms */ foreach ($cdroms as $arrCD) { + $tooltip = ""; $capacity = $lv->format_size($arrCD['capacity'], 0); $allocation = $lv->format_size($arrCD['allocation'], 0); + if ($arrCD['spundown']) {$capacity = $allocation = "*"; $tooltip = "Drive spun down ISO volume is ".$arrCD['reallocation'];} else $tooltip = "ISO volume is ".$arrCD['reallocation']; $disk = $arrCD['file'] ?? $arrCD['partition'] ?? "" ; $dev = $arrCD['device']; $bus = $arrValidDiskBuses[$arrCD['bus']] ?? 'VirtIO'; @@ -247,7 +249,7 @@ foreach ($vms as $vm) { if ($disk != "" ) { $title = _('Eject CD Drive'); $changemedia = "changemedia(\"{$uuid}\",\"{$dev}\",\"{$bus}\", \"--eject\")"; - echo "$disk $bus$capacity$allocation$boot"; + echo "$disk $bus$capacity$allocation$boot"; } else { $title = _('Insert CD'); $changemedia = "changemedia(\"{$uuid}\",\"{$dev}\",\"{$bus}\",\"--select\")"; diff --git a/emhttp/plugins/dynamix.vm.manager/include/libvirt.php b/emhttp/plugins/dynamix.vm.manager/include/libvirt.php index b5566a6b7..a17248bea 100644 --- a/emhttp/plugins/dynamix.vm.manager/include/libvirt.php +++ b/emhttp/plugins/dynamix.vm.manager/include/libvirt.php @@ -1250,33 +1250,44 @@ return $tmp; } - function get_cdrom_stats($domain, $sort=true) { + function get_cdrom_stats($domain, $sort=true,$spincheck = false) { + $unraiddisks = array_merge_recursive(@parse_ini_file('state/disks.ini',true)?:[], @parse_ini_file('state/devs.ini',true)?:[]); $dom = $this->get_domain_object($domain); - + $tmp = false; $buses = $this->get_xpath($dom, '//domain/devices/disk[@device="cdrom"]/target/@bus', false); - $disks = $this->get_xpath($dom, '//domain/devices/disk[@device="cdrom"]/target/@dev', false); + $cds = $this->get_xpath($dom, '//domain/devices/disk[@device="cdrom"]/target/@dev', false); $files = $this->get_xpath($dom, '//domain/devices/disk[@device="cdrom"]/source/@file', false); $boot = $this->get_xpath($dom, '//domain/devices/disk[@device="cdrom"]/boot/@*', false); $ret = []; - for ($i = 0; $i < $disks['num']; $i++) { - $tmp = libvirt_domain_get_block_info($dom, $disks[$i]); + for ($i = 0; $i < $cds['num']; $i++) { + $spundown = 0; + $reallocation = null; + if (isset($files[$i])) $reallocation = trim(get_realvolume($files[$i])); + if ($spincheck) { + if (isset($unraiddisks[$reallocation]['spundown']) && $unraiddisks[$reallocation]['spundown'] == 1) $spundown = 1; else $tmp = libvirt_domain_get_block_info($dom, $cds[$i]); + } else $tmp = libvirt_domain_get_block_info($dom, $cds[$i]); + if ($tmp) { $tmp['bus'] = $buses[$i]; $tmp["boot order"] = $boot[$i] ?? ""; + $tmp['reallocation'] = $reallocation; + $tmp['spundown'] = $spundown; $ret[] = $tmp; } else { $this->_set_last_error(); $ret[] = [ - 'device' => $disks[$i], + 'device' => $cds[$i], 'file' => $files[$i], 'type' => '-', 'capacity' => '-', 'allocation' => '-', 'physical' => '-', - 'bus' => $buses[$i] + 'bus' => $buses[$i], + 'reallocation' => $reallocation, + 'spundown' => $spundown ]; } } @@ -1294,7 +1305,7 @@ } unset($buses); - unset($disks); + unset($cds); unset($files); return $ret; diff --git a/emhttp/plugins/dynamix/include/Helpers.php b/emhttp/plugins/dynamix/include/Helpers.php index d2689c057..ec2280534 100644 --- a/emhttp/plugins/dynamix/include/Helpers.php +++ b/emhttp/plugins/dynamix/include/Helpers.php @@ -291,4 +291,13 @@ function my_mkdir($dirname,$permissions = 0777,$recursive = false) { break; } } +function get_realvolume($path) { + if (strpos($path,"/mnt/user/",0) === 0) + $reallocation = trim(shell_exec("getfattr --absolute-names --only-values -n system.LOCATION ".escapeshellarg($path)." 2>/dev/null")); + else { + $realexplode = explode("/",str_replace("/mnt/","",$path)); + $reallocation = $realexplode[0]; + } + return $reallocation; +} ?>