Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit 79741d3

Browse files
committed
Fix previous nfs parsing patch. Rework virt-install cdrom validation to use non deprecated functions and accomodate all modes of installation.
1 parent c7a4f10 commit 79741d3

3 files changed

Lines changed: 20 additions & 13 deletions

File tree

virt-install

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,15 @@ def get_fullvirt_cdrom(cdpath, location, guest):
167167
while 1:
168168
cdpath = cli.prompt_for_input(_("What is the virtual CD image, CD device or install location?"), cdpath)
169169
try:
170-
# Build a throwaway disk to reuse its validation for local CDs only
171-
if os.path.exists(os.path.abspath(cdpath)):
172-
cddisk = virtinst.VirtualDisk(path=cdpath,
170+
# guest.cdrom is deprecated
171+
guest.location = cdpath
172+
if os.path.exists(guest.location):
173+
# Build a throwaway disk for validation for local CDs only
174+
cddisk = virtinst.VirtualDisk(path=guest.location,
173175
transient=True,
174176
device=virtinst.VirtualDisk.DEVICE_CDROM,
175177
readOnly=True)
176-
cdpath = os.path.abspath(cdpath)
177-
178-
guest.cdrom = cdpath
178+
guest.installer.cdrom = True
179179
break
180180
except ValueError, e:
181181
print _("ERROR: "), e

virtinst/DistroManager.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,19 @@ def __init__(self, type = "xen", location = None, boot = None, extraargs = None)
119119
def get_location(self):
120120
return self._location
121121
def set_location(self, val):
122-
# Canonicalize nfs: URIs to be RFC compliant
123-
if val.startswith("nfs:") and not val.startswith("nfs://"):
122+
# 'location' is kind of overloaded: it can be a local file or device
123+
# (for a boot.iso), local directory (for a tree), or an http, ftp, or
124+
# nfs for an iso or a tree
125+
if os.path.exists(os.path.abspath(val)):
126+
val = os.path.abspath(val)
127+
logging.debug("DistroInstaller location is a local file/path: %s"\
128+
% val)
129+
elif val.startswith("nfs:") and not val.startswith("nfs://"):
130+
# Canonicalize nfs: URIs to be RFC compliant
124131
val = "nfs://" + val[4:]
125-
if not (val.startswith("http://") or val.startswith("ftp://") or
126-
val.startswith("nfs://") or val.startswith("/")):
127-
raise ValueError(_("Install location must be an NFS, HTTP or FTP network install source, or local file/device"))
132+
elif not (val.startswith("http://") or val.startswith("ftp://") or
133+
val.startswith("nfs://")):
134+
raise ValueError(_("Install media location must be an NFS, HTTP or FTP network install source, or an existing local file/device"))
128135
if os.geteuid() != 0 and val.startswith("nfs://"):
129136
raise ValueError(_("NFS installations are only supported as root"))
130137
self._location = val

virtinst/ImageFetcher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ def prepareLocation(self, progresscb):
152152
self.srcdir = tempfile.mkdtemp(prefix="virtinstmnt.", dir=self.scratchdir)
153153
logging.debug("Preparing mount at " + self.srcdir)
154154
if self.location.startswith("nfs://"):
155-
cmd = ["mount", "-o", "ro", self.location[4:], self.srcdir]
156-
elif self.location.startswith("nfs:"):
157155
cmd = ["mount", "-o", "ro", self.location[6:], self.srcdir]
156+
elif self.location.startswith("nfs:"):
157+
cmd = ["mount", "-o", "ro", self.location[4:], self.srcdir]
158158
else:
159159
if stat.S_ISBLK(os.stat(self.location)[stat.ST_MODE]):
160160
cmd = ["mount", "-o", "ro", self.location, self.srcdir]

0 commit comments

Comments
 (0)