2020-10-30 21:18:46 +01:00
|
|
|
References:
|
|
|
|
When a particular firmware is selected, read the json file for a description.
|
|
|
|
Add a tooltip of the json description when the mouse move overs the selected firmware.
|
|
|
|
|
2022-08-05 20:49:45 +02:00
|
|
|
Index: virt-manager-4.1.0/virtManager/details/details.py
|
2022-03-03 05:17:21 +01:00
|
|
|
===================================================================
|
2022-08-05 20:49:45 +02:00
|
|
|
--- virt-manager-4.1.0.orig/virtManager/details/details.py
|
|
|
|
+++ virt-manager-4.1.0/virtManager/details/details.py
|
|
|
|
@@ -4,6 +4,10 @@
|
|
|
|
# This work is licensed under the GNU GPLv2 or later.
|
2020-10-30 21:18:46 +01:00
|
|
|
# See the COPYING file in the top-level directory.
|
|
|
|
|
|
|
|
+import os
|
|
|
|
+import json
|
|
|
|
+import textwrap
|
2022-08-05 20:49:45 +02:00
|
|
|
+
|
2020-10-30 21:18:46 +01:00
|
|
|
from gi.repository import Gtk
|
|
|
|
|
2022-08-05 20:49:45 +02:00
|
|
|
import libvirt
|
|
|
|
@@ -402,7 +406,7 @@ class vmmDetails(vmmGObjectUI):
|
2020-10-30 21:18:46 +01:00
|
|
|
"on_overview_name_changed": _e(EDIT_NAME),
|
|
|
|
"on_overview_title_changed": _e(EDIT_TITLE),
|
|
|
|
"on_machine_type_changed": _e(EDIT_MACHTYPE),
|
|
|
|
- "on_overview_firmware_changed": _e(EDIT_FIRMWARE),
|
|
|
|
+ "on_overview_firmware_changed": self._uefi_combobox_changed_cb,
|
|
|
|
"on_overview_chipset_changed": _e(EDIT_MACHTYPE),
|
|
|
|
|
|
|
|
"on_details_inspection_refresh_clicked": self._inspection_refresh_clicked_cb,
|
2022-08-05 20:49:45 +02:00
|
|
|
@@ -1098,6 +1102,52 @@ class vmmDetails(vmmGObjectUI):
|
2020-10-30 21:18:46 +01:00
|
|
|
self.storage_browser.set_browse_reason(reason)
|
|
|
|
self.storage_browser.show(self.topwin)
|
|
|
|
|
|
|
|
+ def _uefi_combobox_changed_cb(self, src):
|
|
|
|
+ def get_firmware_description(firmware_file):
|
|
|
|
+ json_description = ""
|
|
|
|
+ firmware_json_path = "/usr/share/qemu/firmware"
|
|
|
|
+ if os.path.isdir(firmware_json_path):
|
|
|
|
+ json_files = [f for f in os.listdir(firmware_json_path) if os.path.isfile(os.path.join(firmware_json_path, f))]
|
|
|
|
+ for jf in json_files:
|
|
|
|
+ full_path = firmware_json_path + '/' + jf
|
|
|
|
+ if not full_path.endswith(".json"):
|
|
|
|
+ continue
|
|
|
|
+ try:
|
|
|
|
+ if os.stat(full_path).st_size > 65536:
|
|
|
|
+ continue
|
|
|
|
+ except OSError:
|
|
|
|
+ continue
|
|
|
|
+ with open(full_path, 'r') as json_file:
|
|
|
|
+ data = json_file.read()
|
|
|
|
+ try:
|
|
|
|
+ json_obj = json.loads(data)
|
|
|
|
+ except Exception as e:
|
|
|
|
+ continue
|
|
|
|
+ if 'mapping' in json_obj and 'executable' in json_obj['mapping']:
|
|
|
|
+ json_exec = str(json_obj['mapping']['executable']['filename'])
|
|
|
|
+ if json_exec == firmware_file:
|
|
|
|
+ json_description = str(json_obj['description'])
|
2022-05-10 17:46:24 +02:00
|
|
|
+ json_features = str(json_obj['features'])
|
|
|
|
+ if len(json_features) > 0:
|
|
|
|
+ json_description = json_description + ". Firmware features: " + json_features
|
2020-10-30 21:18:46 +01:00
|
|
|
+ wrapper = textwrap.TextWrapper(width=60)
|
|
|
|
+ json_list = wrapper.wrap(text=json_description)
|
|
|
|
+ json_description = "\n".join(json_list)
|
|
|
|
+ break
|
|
|
|
+ return json_description
|
|
|
|
+
|
|
|
|
+ combo = self.widget("overview-firmware")
|
|
|
|
+ tree_iter = combo.get_active_iter()
|
|
|
|
+ if tree_iter is not None:
|
|
|
|
+ model = combo.get_model()
|
|
|
|
+ tooltip_text = ""
|
|
|
|
+ firmware = model[tree_iter][0]
|
|
|
|
+ if firmware != 'BIOS':
|
|
|
|
+ firmware_file = firmware.split()[-1]
|
|
|
|
+ tooltip_text = get_firmware_description(firmware_file)
|
|
|
|
+ combo.set_tooltip_text(tooltip_text)
|
|
|
|
+ self._enable_apply(EDIT_FIRMWARE)
|
|
|
|
+
|
|
|
|
def _inspection_refresh_clicked_cb(self, src):
|
|
|
|
from ..lib.inspection import vmmInspection
|
|
|
|
inspection = vmmInspection.get_instance()
|