From db2097c1d4b3c0d46c6ac79aebe32621a4a8ced8 Mon Sep 17 00:00:00 2001 From: Eric Schultz Date: Tue, 27 Mar 2018 19:53:29 -0500 Subject: [PATCH] VMmachine update to use virsh for detaching disks --- plugins/dynamix.vm.manager/include/VMMachines.php | 10 ++++------ plugins/dynamix.vm.manager/include/VMajax.php | 6 ++++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/dynamix.vm.manager/include/VMMachines.php b/plugins/dynamix.vm.manager/include/VMMachines.php index da04c70eb..b5f80be34 100644 --- a/plugins/dynamix.vm.manager/include/VMMachines.php +++ b/plugins/dynamix.vm.manager/include/VMMachines.php @@ -119,10 +119,11 @@ foreach ($vms as $vm) { echo "$capacity"; echo ""; echo ""; + echo "$allocation locked"; } else { - echo "$capacity"; + echo "$capacity$allocation"; + echo "from VM: $vm',type:'warning',html:true,showCancelButton:true},function(){\$('div.spinner').show('slow');setTimeout(function(){ajaxVMDispatch({action:'disk-remove',uuid:'$uuid',dev:'$dev'},'loadlist');},100);})\" title='detach disk from VM'> detach"; } - echo "$allocation locked"; } /* end Display VM disks */ @@ -134,10 +135,7 @@ foreach ($vms as $vm) { $dev = $arrCD['device']; $bus = $arrValidDiskBuses[$arrCD['bus']] ?? 'VirtIO'; echo "$disk$bus$capacity$allocation"; - if ($state == 'shutoff') - echo " locked "; - else - echo "from VM: $vm',type:'warning',html:true,showCancelButton:true},function(){\$('div.spinner').show('slow');setTimeout(function(){ajaxVMDispatch({action:'disk-remove',uuid:'$uuid',dev:'$dev'},'loadlist');},100);})\" title='detach disk from VM'> detach"; + echo " locked "; echo ""; } diff --git a/plugins/dynamix.vm.manager/include/VMajax.php b/plugins/dynamix.vm.manager/include/VMajax.php index 84e67f88b..2e7409324 100644 --- a/plugins/dynamix.vm.manager/include/VMajax.php +++ b/plugins/dynamix.vm.manager/include/VMajax.php @@ -191,9 +191,11 @@ switch ($action) { case 'disk-remove': requireLibvirt(); - $arrResponse = ($lv->domain_disk_remove($domName, $_REQUEST['dev'])) ? + // libvirt-php has an issue with detaching a disk, use virsh tool instead + exec("virsh detach-disk " . escapeshellarg($uuid) . " " . escapeshellarg($_REQUEST['dev']) . " 2>&1", $arrOutput, $intReturnCode); + $arrResponse = ($intReturnCode == 0) ? ['success' => true] : - ['error' => $lv->get_last_error()]; + ['error' => str_replace('error: ', '', implode('. ', $arrOutput))]; break; case 'snap-create':