From 9f39b162d05f42f99204853ca607a0cd5878cb76 Mon Sep 17 00:00:00 2001 From: SimonFair <39065407+SimonFair@users.noreply.github.com> Date: Sat, 4 Nov 2023 11:31:46 +0000 Subject: [PATCH] Add QEMU arg Support --- .../dynamix.vm.manager/include/libvirt.php | 10 ++++++++- .../include/libvirt_helpers.php | 21 ++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/emhttp/plugins/dynamix.vm.manager/include/libvirt.php b/emhttp/plugins/dynamix.vm.manager/include/libvirt.php index c6379c458..f66fb2843 100644 --- a/emhttp/plugins/dynamix.vm.manager/include/libvirt.php +++ b/emhttp/plugins/dynamix.vm.manager/include/libvirt.php @@ -984,6 +984,12 @@ } + function appendqemucmdline($xml,$cmdline) { + $newxml = $xml ; + if ($cmdline != null) $newxml = str_replace("",$cmdline."\n",$xml) ; + return $newxml ; + } + function domain_new($config) { // attempt to create all disk images if needed @@ -1007,6 +1013,8 @@ // generate xml for this domain $strXML = $this->config_to_xml($config); + $qemucmdline = $config['qemucmdline']; + $strXML = $this->appendqemucmdline($strXML,$qemucmdline) ; // Start the VM now if requested @@ -1698,7 +1706,7 @@ if (strpos($xml,'')) { $tmp = explode("\n", $xml); for ($i = 0; $i < sizeof($tmp); $i++) - if (strpos('.'.$tmp[$i], " $arrOtherDevices, 'nic' => $arrNICs, 'usb' => $arrUSBDevs, - 'shares' => $lv->domain_get_mount_filesystems($res) + 'shares' => $lv->domain_get_mount_filesystems($res), + 'qemucmdline' => getQEMUCmdLine($strDOMXML), + 'clocks' => getClocks($strDOMXML) ]; } @@ -1447,6 +1449,23 @@ private static $encoding = 'UTF-8'; $memorybacking = $memoryBacking->memoryBacking ; return json_encode($memorybacking); ; } + function getClocks($xml) { + $clocks = new SimpleXMLElement($xml); + $clocks = $clocks->clock ; + return json_encode($clocks); ; + } + + function getQEMUCmdLine($xml) { + $x = strpos($xml,"", 0) ; + if ($x === false) return null ; + $y = strpos($xml,"", 0) ; + $z=$y ; + while ($y!=false) { + $y = strpos($xml,"", $z +19) ; + if ($y != false) $z =$y ; + } + return substr($xml,$x, ($z + 19) -$x) ; + } function getchannels($res) { global $lv ;