[gnome-boxes] installer: More robust drivers selection
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] installer: More robust drivers selection
- Date: Wed, 27 Feb 2013 15:07:19 +0000 (UTC)
commit 87b0d6b24ccbac155ce8fa4ebb5ce2268c6b91b0
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Mon Feb 25 14:31:57 2013 +0100
installer: More robust drivers selection
This patch ensures that we:
1. Don't add/setup same driver more than once.
2. Prefer same arch over compatible ones.
https://bugzilla.gnome.org/show_bug.cgi?id=694211
src/unattended-installer.vala | 23 +++++++++++++++++------
1 files changed, 17 insertions(+), 6 deletions(-)
---
diff --git a/src/unattended-installer.vala b/src/unattended-installer.vala
index 191a7f0..98eaf8f 100644
--- a/src/unattended-installer.vala
+++ b/src/unattended-installer.vala
@@ -770,7 +770,7 @@ private class Boxes.UnattendedInstaller: InstallerMedia {
}
private GLib.List<DeviceDriver> get_drivers (DriverTestFunction test_func) {
- var drivers = new GLib.List<DeviceDriver> ();
+ var drivers = new GLib.HashTable<string,DeviceDriver> (str_hash, str_equal);
foreach (var d in os.get_device_drivers ().get_elements ()) {
var driver = d as DeviceDriver;
@@ -779,13 +779,24 @@ private class Boxes.UnattendedInstaller: InstallerMedia {
continue;
var compatibility = compare_cpu_architectures (os_media.architecture, driver.get_architecture
());
- if (compatibility == CPUArchCompatibity.IDENTICAL || compatibility ==
CPUArchCompatibity.COMPATIBLE)
- // We don't entertain compatiblity when word-size is different because 32-bit drivers
- // are not guaranteed to work on 64-bit architectures in all OSs.
- drivers.append (driver);
- }
-
- return drivers;
+ var location = driver.get_location ();
+ if (compatibility == CPUArchCompatibity.IDENTICAL)
+ drivers.replace (location, driver);
+ else if (compatibility == CPUArchCompatibity.COMPATIBLE && drivers.lookup (location) == null)
+ drivers.insert (location, driver);
+ // We don't entertain compatibility when word-size is different because 32-bit drivers
+ // are not guaranteed to work on 64-bit architectures in all OSs.
+ }
+
+ // We can't just return drivers.get_values () as we don't own the list returned by this call and
drivers
+ // hashtable is destroyed at the end of this function. Also we can't just use drivers.get_values
().copy ()
+ // as we need a deep copy of drivers.
+ var ret = new GLib.List<DeviceDriver> ();
+ foreach (var driver in drivers.get_values ())
+ ret.prepend (driver);
+ ret.reverse ();
+
+ return ret;
}
private delegate bool ScriptTestFunction (InstallScript script);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]