Hello,
I'm running a CentOS 5.2 xen dom0 with opensuse 10.3 paravirutalized
guests. I've been using my own installation script in the past, but have
decided to give virt-install a whirl with autoyast.
It got to the point where it downloads the ls-lR.gz file and looks for the
kernel RPM, and fails.
Looking at the code, I was a little puzzled as to why it's trying to
extract a kernel rpm and built an initrd when one already exists in the
opensuse 10.3 install tree.... so I wrote a quick patch that basically
just removed the wacky code and added the paths:
+ kernelpath = "boot/i386/vmlinuz-xenpae"
+ initrdpath = "boot/i386/initrd-xenpae"
(this is obviously just for i386, might want to do something a little more
elaborate to detect if arch is x86_64)
This patch is against the CentOS 5.2 distribution package:
python-virtinst-0.300.2-8.el5 and it works for me beautifully now.
Feedback is welcome.
Thanks!
--
Corey
--- OSDistro.py.old 2008-09-12 06:33:50.000000000 -0600
+++ OSDistro.py 2008-09-12 07:52:07.000000000 -0600
@@ -115,199 +115,25 @@ class CentOSDistro(RedHatDistro):
-# Suse image store is harder - we fetch the kernel RPM and a helper
-# RPM and then munge bits together to generate a initrd
+# Suse image store contains xen images, like redhat, under a different
+# path. We don't need to fetch the kernel RPM and a helper RPM and then
+# munge bits together to generate a initrd ... that's just wacky
class SuseDistro(Distro):
- def acquireBootDisk(self, fetcher, progresscb):
- return fetcher.acquireFile("boot/boot.iso", progresscb)
def acquireKernel(self, fetcher, progresscb):
- kernelrpm = None
- installinitrdrpm = None
- filelist = None
- try:
- # There is no predictable filename for kernel/install-initrd RPMs
- # so we have to grok the filelist and find them
- filelist = fetcher.acquireFile("ls-lR.gz", progresscb)
- (kernelrpmname, installinitrdrpmname) = self.extractRPMNames(filelist)
-
- # Now fetch the two RPMs we want
- kernelrpm = fetcher.acquireFile(kernelrpmname, progresscb)
- installinitrdrpm = fetcher.acquireFile(installinitrdrpmname, progresscb)
+ kernelpath = "boot/i386/vmlinuz-xenpae"
+ initrdpath = "boot/i386/initrd-xenpae"
- # Process the RPMs to extract the kernel & generate an initrd
- return self.buildKernelInitrd(fetcher, kernelrpm, installinitrdrpm, progresscb)
- finally:
- if filelist is not None:
- os.unlink(filelist)
- if kernelrpm is not None:
- os.unlink(kernelrpm)
- if installinitrdrpm is not None:
- os.unlink(installinitrdrpm)
-
- # We need to parse the ls-lR.gz file, looking for the kernel &
- # install-initrd RPM entries - capturing the directory they are
- # in and the version'd filename.
- def extractRPMNames(self, filelist):
- filelistData = gzip.GzipFile(filelist, mode = "r")
+ kernel = fetcher.acquireFile(kernelpath, progresscb)
try:
- arch = os.uname()[4]
- arches = [arch]
- # On i686 arch, we also look under i585 and i386 dirs
- # in case the RPM is built for a lesser arch. We also
- # need the PAE variant (for Fedora dom0 at least)
- #
- # XXX shouldn't hard code that dom0 is PAE
- if arch == "i686":
- arches.append("i586")
- arches.append("i386")
- kernelname = "kernel-xenpae"
-
- installinitrdrpm = None
- kernelrpm = None
- dir = None
- while 1:
- data = filelistData.readline()
- if not data:
- break
- if dir is None:
- for arch in arches:
- wantdir = "/suse/" + arch
- if data == "." + wantdir + ":\n":
- dir = wantdir
- break
- else:
- if data == "\n":
- dir = None
- else:
- if data[:5] != "total":
- filename = re.split("\s+", data)[8]
-
- if filename[:14] == "install-initrd":
- installinitrdrpm = dir + "/" + filename
- elif filename[:len(kernelname)] == kernelname:
- kernelrpm = dir + "/" + filename
-
- if kernelrpm is None:
- raise _("Unable to determine kernel RPM path")
- if installinitrdrpm is None:
- raise _("Unable to determine install-initrd RPM path")
- return (kernelrpm, installinitrdrpm)
- finally:
- filelistData.close()
-
- # We have a kernel RPM and a install-initrd RPM with a generic initrd in it
- # Now we have to munge the two together to build an initrd capable of
- # booting the installer.
- #
- # Yes, this is crazy ass stuff :-)
- def buildKernelInitrd(self, fetcher, kernelrpm, installinitrdrpm, progresscb):
- progresscb.start(text=_("Building initrd"), size=11)
- progresscb.update(1)
- cpiodir = tempfile.mkdtemp(prefix="virtinstcpio.", dir=self.scratchdir)
- try:
- # Extract the kernel RPM contents
- os.mkdir(cpiodir + "/kernel")
- cmd = "cd " + cpiodir + "/kernel && (rpm2cpio " + kernelrpm + " | cpio --quiet -idm)"
- logging.debug("Running " + cmd)
- os.system(cmd)
- progresscb.update(2)
-
- # Determine the raw kernel version
- kernelinfo = None
- for f in os.listdir(cpiodir + "/kernel/boot"):
- if f.startswith("System.map-"):
- kernelinfo = re.split("-", f)
- kernel_override = kernelinfo[1] + "-override-" + kernelinfo[3]
- kernel_version = kernelinfo[1] + "-" + kernelinfo[2] + "-" + kernelinfo[3]
- logging.debug("Got kernel version " + str(kernelinfo))
-
- # Build a list of all .ko files
- modpaths = {}
- for root, dirs, files in os.walk(cpiodir + "/kernel/lib/modules", topdown=False):
- for name in files:
- if name.endswith(".ko"):
- modpaths[name] = os.path.join(root, name)
- progresscb.update(3)
-
- # Extract the install-initrd RPM contents
- os.mkdir(cpiodir + "/installinitrd")
- cmd = "cd " + cpiodir + "/installinitrd && (rpm2cpio " + installinitrdrpm + " | cpio --quiet -idm)"
- logging.debug("Running " + cmd)
- os.system(cmd)
- progresscb.update(4)
-
- # Read in list of mods required for initrd
- modnames = []
- fn = open(cpiodir + "/installinitrd/usr/lib/install-initrd/" + kernelinfo[3] + "/module.list", "r")
- try:
- while 1:
- line = fn.readline()
- if not line:
- break
- line = line[:len(line)-1]
- modnames.append(line)
- finally:
- fn.close()
- progresscb.update(5)
-
- # Uncompress the basic initrd
- cmd = "gunzip -c " + cpiodir + "/installinitrd/usr/lib/install-initrd/initrd-base.gz > " + cpiodir + "/initrd.img"
- logging.debug("Running " + cmd)
- os.system(cmd)
- progresscb.update(6)
-
- # Create temp tree to hold stuff we're adding to initrd
- moddir = cpiodir + "/initrd/lib/modules/" + kernel_override + "/initrd/"
- moddepdir = cpiodir + "/initrd/lib/modules/" + kernel_version
- os.makedirs(moddir)
- os.makedirs(moddepdir)
- os.symlink("../" + kernel_override, moddepdir + "/updates")
- os.symlink("lib/modules/" + kernel_override + "/initrd", cpiodir + "/initrd/modules")
- cmd = "cp " + cpiodir + "/installinitrd/usr/lib/install-initrd/" + kernelinfo[3] + "/module.config" + " " + moddir
- logging.debug("Running " + cmd)
- os.system(cmd)
- progresscb.update(7)
-
- # Copy modules we need into initrd staging dir
- for modname in modnames:
- if modpaths.has_key(modname):
- src = modpaths[modname]
- dst = moddir + "/" + modname
- os.system("cp " + src + " " + dst)
- progresscb.update(8)
-
- # Run depmod across the staging area
- cmd = "depmod -a -b " + cpiodir + "/initrd -F " + cpiodir + "/kernel/boot/System.map-" + kernel_version + " " + kernel_version
- logging.debug("Running " + cmd)
- os.system(cmd)
- progresscb.update(9)
-
- # Add the extra modules to the basic initrd
- cmd = "cd " + cpiodir + "/initrd && ( find . | cpio --quiet -o -H newc -A -F " + cpiodir + "/initrd.img)"
- logging.debug("Running " + cmd)
- os.system(cmd)
- progresscb.update(10)
-
- # Compress the final initrd
- cmd = "gzip -f9N " + cpiodir + "/initrd.img"
- logging.debug("Running " + cmd)
- os.system(cmd)
- progresscb.end(11)
-
- # Save initrd & kernel to temp files for booting...
- initrdname = fetcher.saveTemp(open(cpiodir + "/initrd.img.gz", "r"), "initrd.img")
- logging.debug("Saved " + initrdname)
- try:
- kernelname = fetcher.saveTemp(open(cpiodir + "/kernel/boot/vmlinuz-" + kernel_version, "r"), "vmlinuz")
- logging.debug("Saved " + kernelname)
- return (kernelname, initrdname, "install=" + fetcher.location)
- except:
- os.unlink(initrdname)
- finally:
- #pass
- os.system("rm -rf " + cpiodir)
+ initrd = fetcher.acquireFile(initrdpath, progresscb)
+ # Local host path, so can't pass a location to guest for install method
+ return (kernel, initrd, "")
+ except:
+ os.unlink(kernel)
+ def acquireBootDisk(self, fetcher, progresscb):
+ return fetcher.acquireFile("boot/boot.iso", progresscb)
def isValidStore(self, fetcher, progresscb):
# Suse distros always have a 'directory.yast' file in the top
_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/et-mgmt-tools