virtinst: quickfix ubuntu net-preseed insert cdrom error

the proper kernel/initrd pair for booting from an http server is found in install/netboot/... on a mounted ubuntu iso.
this last worked in v1.4.2

Discussion: https://github.com/virt-manager/virt-manager/pull/34

(crobinso: add the fetcher.is_iso handling and add a comment)
This commit is contained in:
Johannes Tiefenbacher 2018-10-09 15:52:23 +02:00 committed by Cole Robinson
parent 943f1d4bc2
commit b8aff28087
2 changed files with 23 additions and 2 deletions

View File

@ -30,7 +30,6 @@ class _DistroCache(object):
self.suse_content = None
self.debian_media_type = None
def acquire_file_content(self, path):
if path not in self._filecache:
try:
@ -133,6 +132,9 @@ class _DistroCache(object):
verstr, version, update)
return version, update
def fetcher_is_iso(self):
return self._fetcher.is_iso()
class _SUSEContent(object):
"""
@ -664,7 +666,16 @@ class DebianDistro(Distro):
media_type = "daily"
elif cache.content_regex(".disk/info",
"%s.*" % cls._debname.capitalize()):
media_type = "disk"
# There's two cases here:
# 1) Direct access ISO, attached as CDROM afterwards. We
# use one set of kernels in that case which seem to
# assume the prescence of CDROM media
# 2) ISO mounted and exported over URL. We use a different
# set of kernels that expect to boot from the network
if cache.fetcher_is_iso():
media_type = "disk"
else:
media_type = "mounted_iso_url"
if media_type:
cache.debian_media_type = media_type
@ -710,6 +721,8 @@ class DebianDistro(Distro):
url_prefix = "current/images"
if self.cache.debian_media_type == "daily":
url_prefix = "daily"
elif self.cache.debian_media_type == "mounted_iso_url":
url_prefix = "install"
tree_arch = self._find_treearch()
hvmroot = "%s/netboot/%s-installer/%s/" % (url_prefix,

View File

@ -26,6 +26,7 @@ class _URLFetcher(object):
a media source, such as CD ISO, or HTTP/HTTPS/FTP server
"""
_block_size = 16384
_is_iso = False
def __init__(self, location, scratchdir, meter):
self.location = location
@ -101,6 +102,12 @@ class _URLFetcher(object):
# Public API #
##############
def is_iso(self):
"""
If this is a fetcher for local CDROM/ISO
"""
return self._is_iso
def prepareLocation(self):
"""
Perform any necessary setup
@ -288,6 +295,7 @@ class _LocalURLFetcher(_URLFetcher):
class _ISOURLFetcher(_URLFetcher):
_cache_file_list = None
_is_iso = True
def _make_full_url(self, filename):
return "/" + filename