[virt-tools-list] [virt-install PATCH v2 7/7] installer: Set the network install resources when needed

Fabiano Fidêncio fidencio at redhat.com
Fri Mar 22 15:23:41 UTC 2019


Some distros (as Fedora, RHEL, and CentOS) require a bigger amount of
RAM during network installation than the recommended amount to run the
system.

In order to properly have it set, let's take advantages of the libosinfo
network-install resources API and change the guest amount of ram for the
installation.

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

diff --git a/virtinst/installer.py b/virtinst/installer.py
index 67cdfb29..b8c048f1 100644
--- a/virtinst/installer.py
+++ b/virtinst/installer.py
@@ -152,6 +152,23 @@ class Installer(object):
         else:
             guest.os.bootorder = []
 
+    def _alter_install_resources(self, guest, meter):
+        """
+        Sets the appropriate amount of ram needed when performing a "network"
+        based installation
+
+        :param guest: Guest instance we are installing
+        """
+        if not self._treemedia:
+            return
+        if not self._treemedia.requires_internet(guest, meter):
+            return
+
+        res = guest.osinfo.get_network_install_resources(guest)
+        if res and res.get("ram") > 0 and res["ram"] // 1024 > guest.memory:
+            logging.debug("Setting ram from libosinfo network-install "
+                          "resources: '%d'", res["ram"] // 1024)
+            guest.memory = res["ram"] // 1024
 
     ##########################
     # Internal API overrides #
@@ -290,27 +307,30 @@ class Installer(object):
         # set the install time properties but not permanently overwrite
         # any config the user explicitly requested.
         data = (guest.os.bootorder, guest.os.kernel, guest.os.initrd,
-                guest.os.kernel_args, guest.on_reboot)
+                guest.os.kernel_args, guest.on_reboot, guest.memory,
+                guest.maxmemory)
         return data
 
     def _finish_get_install_xml(self, guest, data):
         (guest.os.bootorder, guest.os.kernel, guest.os.initrd,
-                guest.os.kernel_args, guest.on_reboot) = data
+                guest.os.kernel_args, guest.on_reboot, guest.memory,
+                guest.maxmemory) = data
 
-    def _get_install_xml(self, guest):
+    def _get_install_xml(self, guest, meter):
         data = self._prepare_get_install_xml(guest)
         try:
             self._alter_bootconfig(guest)
+            self._alter_install_resources(guest, meter)
             ret = guest.get_xml()
             return ret
         finally:
             self._remove_install_cdrom_media(guest)
             self._finish_get_install_xml(guest, data)
 
-    def _build_xml(self, guest):
+    def _build_xml(self, guest, meter):
         install_xml = None
         if self.has_install_phase():
-            install_xml = self._get_install_xml(guest)
+            install_xml = self._get_install_xml(guest, meter)
         final_xml = guest.get_xml()
 
         logging.debug("Generated install XML: %s",
@@ -411,7 +431,7 @@ class Installer(object):
                 for dev in guest.devices.disk:
                     dev.build_storage(meter)
 
-            install_xml, final_xml = self._build_xml(guest)
+            install_xml, final_xml = self._build_xml(guest, meter)
             if return_xml:
                 return (install_xml, final_xml)
             if dry:
-- 
2.20.1




More information about the virt-tools-list mailing list