VM manager: fix increasing vdisk size

This commit is contained in:
Eric Schultz
2018-03-21 13:50:02 -05:00
parent 2a0216ac49
commit dd91923acd
2 changed files with 7 additions and 3 deletions
+1 -1
View File
@@ -56,7 +56,7 @@ if ($_GET['refresh']) {
if ($subaction) {
$vm = $lv->domain_get_name_by_uuid($uuid);
if ($subaction == 'disk-resize') {
$capacity = str_replace(["KB","MB","GB","TB","PB"," ",","], ["K","M","G","T","P","",""], strtoupper($_POST['cap']));
$capacity = str_replace(["KB","MB","GB","TB","PB"," ",","], ["K","M","G","T","P","",""], strtoupper($_GET['cap']));
$oldcap = str_replace(["KB","MB","GB","TB","PB"," ",","], ["K","M","G","T","P","",""], strtoupper($_GET['oldcap']));
if (substr($oldcap,0,-1) < substr($capacity,0,-1)){
shell_exec("qemu-img resize -q ".escapeshellarg($_GET['disk'])." ".escapeshellarg($capacity));
@@ -108,9 +108,13 @@ foreach ($vms as $vm) {
echo "<tr><td>$disk</td><td>{$arrValidDiskBuses[$bus]}</td>";
if ($state == 'shutoff') {
echo "<td title='Click to increase Disk Size'>";
echo "<form method='post' action='?subaction=disk-resize&amp;uuid={$uuid}&amp;disk={$disk}&amp;oldcap={$capacity}'>";
echo "<form method='get' action=''>";
echo "<input type='hidden' name='subaction' value='disk-resize'>";
echo "<input type='hidden' name='uuid' value='".$uuid."'>";
echo "<input type='hidden' name='disk' value='".htmlspecialchars($disk)."'>";
echo "<input type='hidden' name='oldcap' value='".$capacity."'>";
echo "<span class='diskresize' style='width:30px'>";
echo "<span class='text'><a href='#'>$capacity</a></span>";
echo "<span class='text'><a href='#' onclick='return false'>$capacity</a></span>";
echo "<input class='input' type='text' style='width:46px' name='cap' value='$capacity' val='diskresize' hidden>";
echo "</span></form></td>";
echo "<td>$allocation</td>";