summaryrefslogtreecommitdiff
path: root/virt-install
diff options
context:
space:
mode:
authorCole Robinson <crobinso@redhat.com>2019-06-10 19:31:37 -0400
committerCole Robinson <crobinso@redhat.com>2019-06-11 17:51:25 -0400
commit17d157820f001ba1ce36404e038bd72c70af8ad5 (patch)
treebcb9957e5af8a733de9e686ef10326bacc7de1ae /virt-install
parentdb4d348950ed149cbffe7ff251fff0bdc50d9b0c (diff)
downloadvirt-manager-17d157820f001ba1ce36404e038bd72c70af8ad5.tar.gz
guest: move libosinfo resource setting to virt-install
This puts all the default resource setting in one place, and the only place that was depending on it, as virt-manager explicitly sets the values on its own. This will be used in future patches to add more default setup and report the values to the user
Diffstat (limited to 'virt-install')
-rwxr-xr-xvirt-install24
1 files changed, 16 insertions, 8 deletions
diff --git a/virt-install b/virt-install
index 7c258519..bbd24d03 100755
--- a/virt-install
+++ b/virt-install
@@ -519,18 +519,26 @@ def build_installer(options, guest):
def set_resources_from_osinfo(options, guest):
if guest.os.is_container():
return
- if options.disk:
- return
+
+ # We need to do this upfront, so we don't incorrectly set guest.vcpus
+ guest.sync_vcpus_topology()
res = guest.osinfo.get_recommended_resources()
storage = res.get_recommended_storage(guest.os.arch)
- if not storage:
- return
+ ram = res.get_recommended_ram(guest.os.arch)
+ ncpus = res.get_recommended_ncpus(guest.os.arch)
+
+ if ram and not guest.currentMemory:
+ guest.currentMemory = ram // 1024
+
+ if ncpus and not guest.vcpus:
+ guest.vcpus = ncpus
- diskstr = 'size=%d' % (storage // (1024 ** 3))
- logging.debug("Generated default libosinfo '--disk %s'", diskstr)
- options.disk = [diskstr]
- cli.ParserDisk(diskstr, guest=guest).parse(None)
+ if storage and not options.disk:
+ diskstr = 'size=%d' % (storage // (1024 ** 3))
+ logging.debug("Generated default libosinfo '--disk %s'", diskstr)
+ options.disk = [diskstr]
+ cli.ParserDisk(diskstr, guest=guest).parse(None)
def build_guest_instance(conn, options):