[virt-tools-list] [virt-manager PATCH 12/12] installer: pre/post install drivers

Fabiano Fidêncio fidencio at redhat.com
Thu Jun 6 14:11:43 UTC 2019


Let's download and pre/post install the drivers available. In order to
do so, we have to keep the cdrom containing the files as it'll be used
after the machine does its first reboot.

Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
 virtinst/installer.py | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/virtinst/installer.py b/virtinst/installer.py
index 7816b45e..e0a081cf 100644
--- a/virtinst/installer.py
+++ b/virtinst/installer.py
@@ -52,6 +52,7 @@ class Installer(object):
         self._install_initrd = None
         self._install_cdrom_device_added = False
         self._unattended_install_cdrom_device = None
+        self._keep_unattended_install_cdrom_device = False
         self._unattended_files = []
         self._defaults_are_set = False
         self._unattended_data = None
@@ -135,7 +136,8 @@ class Installer(object):
         dummy = guest
         if not self._unattended_install_cdrom_device:
             return
-
+        if self._keep_unattended_install_cdrom_device:
+            return
         guest.remove_device(self._unattended_install_cdrom_device)
         self._unattended_install_cdrom_device.path = None
         self._unattended_install_cdrom_device.sync_path_props()
@@ -148,6 +150,9 @@ class Installer(object):
             logging.debug("Removing %s", str(f))
             os.unlink(f)
 
+        if self._keep_unattended_install_cdrom_device:
+            return
+
         logging.debug("Removing %s", util.get_unattended_cache_dir())
         os.rmdir(util.get_unattended_cache_dir())
 
@@ -231,6 +236,16 @@ class Installer(object):
             osguess = OSDB.guess_os_by_iso(self.cdrom)
             osmedia = OsMedia(osguess[1])
             paths = []
+
+            drivers_func = [guest.osinfo.get_pre_installable_drivers_location,
+                            guest.osinfo.get_post_installable_drivers_location]
+            for func in drivers_func:
+                drivers_location = func(guest.os.arch)
+                drivers = unattended.download_drivers(drivers_location)
+                paths.extend(drivers)
+                if drivers:
+                    self._keep_unattended_install_cdrom_device = True
+
             scripts = unattended.prepare_install_script(
                     guest, self._unattended_data, self.cdrom, osmedia)
             for script in scripts:
@@ -244,7 +259,8 @@ class Installer(object):
             self._add_unattended_cdrom_device(guest, cdrom)
 
             self._unattended_files.extend(paths)
-            self._unattended_files.append(cdrom)
+            if not self._keep_unattended_install_cdrom_device:
+                self._unattended_files.append(cdrom)
 
     def _cleanup(self, guest):
         if self._treemedia:
-- 
2.21.0




More information about the virt-tools-list mailing list