Merge pull request #2021 from SimonFair/VM-Manager-PHP-Fixes

Fix: PHP fixes
This commit is contained in:
tom mortensen
2025-02-15 12:23:12 -08:00
committed by GitHub
4 changed files with 25 additions and 18 deletions

View File

@@ -196,7 +196,7 @@ foreach ($vms as $vm) {
$title = _('Select ISO image');
$cdstr = $cdromcount." / 2<a class='hand' title='$title' href='#' onclick='$changemedia'><i class='fa fa-dot-circle-o'></i></a>";
echo "<tr parent-id='$i' class='sortable'><td class='vm-name' style='width:220px;padding:8px'><i class='fa fa-arrows-v mover orange-text'></i>";
echo "<span class='outer'><span id='vm-$uuid' $menu class='hand'>$image</span><span class='inner'><a href='#' onclick='return toggle_id(\"name-$i\")' title='click for more VM info'>$vm</a><br><i class='fa fa-$shape $status $color'></i><span class='state'>"._($status)." $snapshotstcount</span></span></span></td>";
echo "<span class='outer'><span id='vm-$uuid' $menu class='hand'>$image</span><span class='inner'><a href='#' onclick='return toggle_id(\"name-$i\")' title='click for more VM info'>$vm</a><br><i class='fa fa-$shape $status $color'></i><span class='state'>"._($status)." </span></span></span></td>";
echo "<td>$desc</td>";
echo "<td><a class='vcpu-$uuid' style='cursor:pointer'>$vcpu</a></td>";
echo "<td>$mem</td>";

View File

@@ -2146,7 +2146,7 @@ class Array2XML {
# If Snapstate not running create new XML.
if ($snapstate != "running") {
if ($method == "ZFS") $xml = $snapslist[$snap]['xml']; else $xml = custom::createXML('domain',$xmlobj)->saveXML();
if (!strpos($xml,'<vmtemplate xmlns="unraid"')) $xml=str_replace('<vmtemplate','<vmtemplate xmlns="unraid"',$xml);
if (!strpos($xml,'<vmtemplate xmlns="unraid"') && !strpos($xml,'<vmtemplate xmlns="http://unraid"') ) $xml=str_replace('<vmtemplate','<vmtemplate xmlns="http://unraid"',$xml);
if (!$dryrun) $new = $lv->domain_define($xml);
if ($new) $arrResponse = ['success' => true]; else $arrResponse = ['error' => $lv->get_last_error()];
if ($logging) qemu_log($vm,"Create XML $new");
@@ -2239,7 +2239,7 @@ class Array2XML {
$xml = file_get_contents($xmlfile);
$xmlobj = custom::createArray('domain',$xml);
$xml = custom::createXML('domain',$xmlobj)->saveXML();
if (!strpos($xml,'<vmtemplate xmlns="unraid"')) $xml=str_replace('<vmtemplate','<vmtemplate xmlns="unraid"',$xml);
if (!strpos($xml,'<vmtemplate xmlns="unraid"') && !strpos($xml,'<vmtemplate xmlns="http://unraid"') ) $xml=str_replace('<vmtemplate','<vmtemplate xmlns="http://unraid"',$xml);
if (!$dryrun) $rtn = $lv->domain_define($xml);
if ($logging) qemu_log($vm,"Define XML");
@@ -2719,7 +2719,7 @@ function get_vm_usage_stats($collectcpustats = true,$collectdiskstats = true,$co
$currentmem = $data["balloon.current"];
$maximummem = $data["balloon.maximum"];
$meminuse = min($data["balloon.rss"],$data["balloon.current"]);
} else $currentmem = $meminuse = 0;
} else $maximummem = $currentmem = $meminuse = 0;
# Disk
if ($state == 1 && $collectdiskstats) {
@@ -2823,20 +2823,22 @@ function build_xml_templates($strXML) {
}
$xml2["devices"] = $devxml;
$xml2["devices"]["allusb"] = "";
foreach ($xml2['devices']["hostdev"] as $xmlhostdev) {
$xmlhostdevdoc = new SimpleXMLElement($xmlhostdev);
switch ($xmlhostdevdoc->attributes()->type) {
case 'pci' :
$pciaddr = $xmlhostdevdoc->source->address->attributes()->bus.":".$xmlhostdevdoc->source->address->attributes()->slot.".".$xmlhostdevdoc->source->address->attributes()->function;
$pciaddr = str_replace("0x","",$pciaddr);
$xml2["devices"][$arrValidPCIDevices[$pciaddr]["class"]][$pciaddr] = $xmlhostdev;
break;
case "usb":
$usbaddr = $xmlhostdevdoc->source->vendor->attributes()->id.":".$xmlhostdevdoc->source->product->attributes()->id;
$usbaddr = str_replace("0x","",$usbaddr);
$xml2["devices"]["usb"][$usbaddr] = $xmlhostdev;
$xml2["devices"]["allusb"] .= $xmlhostdev;
break;
if(isset($xml2['devices']["hostdev"])) {
foreach ($xml2['devices']["hostdev"] as $xmlhostdev) {
$xmlhostdevdoc = new SimpleXMLElement($xmlhostdev);
switch ($xmlhostdevdoc->attributes()->type) {
case 'pci' :
$pciaddr = $xmlhostdevdoc->source->address->attributes()->bus.":".$xmlhostdevdoc->source->address->attributes()->slot.".".$xmlhostdevdoc->source->address->attributes()->function;
$pciaddr = str_replace("0x","",$pciaddr);
$xml2["devices"][$arrValidPCIDevices[$pciaddr]["class"]][$pciaddr] = $xmlhostdev;
break;
case "usb":
$usbaddr = $xmlhostdevdoc->source->vendor->attributes()->id.":".$xmlhostdevdoc->source->product->attributes()->id;
$usbaddr = str_replace("0x","",$usbaddr);
$xml2["devices"]["usb"][$usbaddr] = $xmlhostdev;
$xml2["devices"]["allusb"] .= $xmlhostdev;
break;
}
}
}
foreach($xml2["devices"]["input"] as $input) $xml2["devices"]["allinput"] .= "$input\n";

View File

@@ -2632,6 +2632,7 @@ $(function() {
});
<?endif?>
$panel.find('input').prop('disabled', true);
var styleElement = $('<style>.sweet-alert fieldset input { display: inline-block !important; }</style>').appendTo('head');
$button.val($button.attr('busyvalue'));
swal({
title: "_(Template Name)_",
@@ -2665,6 +2666,7 @@ $(function() {
}
}, "json");
});
styleElement.remove();
});
$("#vmform .xmlview #btnSubmit").click(function frmSubmit() {
@@ -2699,6 +2701,7 @@ $(function() {
createVmInput.remove();
var postdata = $panel.closest('form').serialize().replace(/'/g,"%27");
$panel.find('input').prop('disabled', true);
var styleElement = $('<style>.sweet-alert fieldset input { display: inline-block !important; }</style>').appendTo('head');
$button.val($button.attr('busyvalue'));
swal({
title: "_(Template Name)_",
@@ -2723,6 +2726,7 @@ $(function() {
}
}, "json");
});
styleElement.remove();
});
// Fire events below once upon showing page

View File

@@ -224,6 +224,7 @@ libvirtd_start(){
fi
fi
done
sed -i 's|<vmtemplate xmlns="unraid|<vmtemplate xmlns="http://unraid|' $XML
done
# copy any new conf files we dont currently have