From a373e316a343f894b2c9282c0820a0e101958527 Mon Sep 17 00:00:00 2001
From: SimonFair <39065407+SimonFair@users.noreply.github.com>
Date: Wed, 27 Dec 2023 14:05:44 +0000
Subject: [PATCH] Fix SCSI controller update
Add Method to snapshots.
---
emhttp/plugins/dynamix.vm.manager/include/VMMachines.php | 4 ++--
.../plugins/dynamix.vm.manager/include/libvirt_helpers.php | 6 ++++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/emhttp/plugins/dynamix.vm.manager/include/VMMachines.php b/emhttp/plugins/dynamix.vm.manager/include/VMMachines.php
index b5f3a33ca..2577382bd 100644
--- a/emhttp/plugins/dynamix.vm.manager/include/VMMachines.php
+++ b/emhttp/plugins/dynamix.vm.manager/include/VMMachines.php
@@ -267,7 +267,7 @@ foreach ($vms as $vm) {
if ($snap['parent'] == "" || $snap['parent'] == "Base") $j++;
$steps[$j] .= $snap['name'].';';
}
- echo "| ",_('Snapshots')," | | ",_('Date/Time')," | ",_('Type')," | ",_('Parent')," | ",_('Memory')," |
";
+ echo "| ",_('Snapshots')," | | ",_('Date/Time')," | ",_('Type (Method)')," | ",_('Parent')," | ",_('Memory')," |
";
echo "
";
foreach ($steps as $stepsline) {
$snapshotlist = explode(";",$stepsline);
@@ -275,7 +275,7 @@ foreach ($vms as $vm) {
foreach ($snapshotlist as $snapshotitem) {
if ($snapshotitem == "") continue;
$snapshot = $snapshots[$snapshotitem] ;
- $snapshotstate = _(ucfirst($snapshot["state"]));
+ $snapshotstate = _(ucfirst($snapshot["state"]))." ({$snapshot["method"]})";
$snapshotdesc = $snapshot["desc"];
$snapshotmemory = _(ucfirst($snapshot["memory"]["@attributes"]["snapshot"]));
$snapshotparent = $snapshot["parent"] ? $snapshot["parent"] : "None";
diff --git a/emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php b/emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php
index 0f7dacf8b..21fb48052 100644
--- a/emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php
+++ b/emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php
@@ -1409,10 +1409,11 @@ private static $encoding = 'UTF-8';
if ($p2['bus'] && $p2['slot'] && $p2['function'] && $p2['bus']==$pci['bus'] && $p2['slot']==$pci['slot'] && $p2['function']==$function) unset($old['devices']['hostdev'][$k]);
}
}
- // remove and rebuild usb controllers
+ // remove and rebuild usb + scsi controllers
$devices = $old['devices']['controller'];
foreach ($devices as $key => $controller) {
if ($controller['@attributes']['type']=='usb') unset($old['devices']['controller'][$key]);
+ if ($controller['@attributes']['type']=='scsi') unset($old['devices']['controller'][$key]);
}
// preserve existing disk driver settings
foreach ($new['devices']['disk'] as $key => $disk) {
@@ -1731,7 +1732,7 @@ private static $encoding = 'UTF-8';
return $snaps ;
}
- function write_snapshots_database($vm,$name) {
+ function write_snapshots_database($vm,$name,$method="QEMU") {
global $lv ;
$dbpath = "/etc/libvirt/qemu/snapshot/$vm" ;
if (!is_dir($dbpath)) mkdir($dbpath) ;
@@ -1749,6 +1750,7 @@ private static $encoding = 'UTF-8';
$snaps[$vmsnap]["desc"]= $b["description"];
$snaps[$vmsnap]["memory"]= $b["memory"];
$snaps[$vmsnap]["creationtime"]= $b["creationTime"];
+ $snaps[$vmsnap]["method"]= $method;
$disks =$lv->get_disk_stats($vm) ;
foreach($disks as $disk) {