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
This commit is contained in:
parent
db4d348950
commit
17d157820f
|
@ -8,7 +8,7 @@
|
||||||
</metadata>
|
</metadata>
|
||||||
<memory>65536</memory>
|
<memory>65536</memory>
|
||||||
<currentMemory>65536</currentMemory>
|
<currentMemory>65536</currentMemory>
|
||||||
<vcpu>2</vcpu>
|
<vcpu>1</vcpu>
|
||||||
<os>
|
<os>
|
||||||
<type arch="x86_64">exe</type>
|
<type arch="x86_64">exe</type>
|
||||||
<init>/bin/sh</init>
|
<init>/bin/sh</init>
|
||||||
|
|
24
virt-install
24
virt-install
|
@ -519,18 +519,26 @@ def build_installer(options, guest):
|
||||||
def set_resources_from_osinfo(options, guest):
|
def set_resources_from_osinfo(options, guest):
|
||||||
if guest.os.is_container():
|
if guest.os.is_container():
|
||||||
return
|
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()
|
res = guest.osinfo.get_recommended_resources()
|
||||||
storage = res.get_recommended_storage(guest.os.arch)
|
storage = res.get_recommended_storage(guest.os.arch)
|
||||||
if not storage:
|
ram = res.get_recommended_ram(guest.os.arch)
|
||||||
return
|
ncpus = res.get_recommended_ncpus(guest.os.arch)
|
||||||
|
|
||||||
diskstr = 'size=%d' % (storage // (1024 ** 3))
|
if ram and not guest.currentMemory:
|
||||||
logging.debug("Generated default libosinfo '--disk %s'", diskstr)
|
guest.currentMemory = ram // 1024
|
||||||
options.disk = [diskstr]
|
|
||||||
cli.ParserDisk(diskstr, guest=guest).parse(None)
|
if ncpus and not guest.vcpus:
|
||||||
|
guest.vcpus = ncpus
|
||||||
|
|
||||||
|
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):
|
def build_guest_instance(conn, options):
|
||||||
|
|
|
@ -676,7 +676,9 @@ class Guest(XMLBuilder):
|
||||||
self.uuid = Guest.generate_uuid(self.conn)
|
self.uuid = Guest.generate_uuid(self.conn)
|
||||||
|
|
||||||
self.sync_vcpus_topology()
|
self.sync_vcpus_topology()
|
||||||
self._set_default_resources()
|
if not self.vcpus:
|
||||||
|
self.vcpus = 1
|
||||||
|
|
||||||
self._set_default_machine()
|
self._set_default_machine()
|
||||||
self._set_default_uefi()
|
self._set_default_uefi()
|
||||||
|
|
||||||
|
@ -708,19 +710,6 @@ class Guest(XMLBuilder):
|
||||||
# Private xml routines #
|
# Private xml routines #
|
||||||
########################
|
########################
|
||||||
|
|
||||||
def _set_default_resources(self):
|
|
||||||
res = self.osinfo.get_recommended_resources()
|
|
||||||
|
|
||||||
if not self.currentMemory:
|
|
||||||
ram = res.get_recommended_ram(self.os.arch)
|
|
||||||
if ram:
|
|
||||||
self.currentMemory = ram // 1024
|
|
||||||
|
|
||||||
if not self.vcpus:
|
|
||||||
ncpus = res.get_recommended_ncpus(self.os.arch)
|
|
||||||
self.vcpus = ncpus or 1
|
|
||||||
|
|
||||||
|
|
||||||
def _set_default_machine(self):
|
def _set_default_machine(self):
|
||||||
if self.os.machine:
|
if self.os.machine:
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue