diff -r d7b354eef058 virt-install --- a/virt-install Thu Mar 04 15:55:38 2010 -0500 +++ b/virt-install Thu Mar 25 08:01:16 2010 -0400 @@ -594,6 +594,9 @@ default="", help=_("Additional arguments to pass to the kernel " "booted from --location")) + insg.add_option("", "--initrd-inject", type="string", dest="initrd_injections", + default=[], action="append", + help=_("Add given file to root of initrd")) parser.add_option_group(insg) stog = OptionGroup(parser, _("Storage Configuration")) @@ -734,6 +737,7 @@ installer = instclass(type=hv_name, os_type=virt_type, conn=conn) installer.arch = capsguest.arch + installer.initrd_injections = options.initrd_injections # Get Guest instance from installer parameters. guest = installer.guest_from_installer() diff -r d7b354eef058 virtinst/DistroInstaller.py --- a/virtinst/DistroInstaller.py Thu Mar 04 15:55:38 2010 -0500 +++ b/virtinst/DistroInstaller.py Thu Mar 25 08:01:16 2010 -0400 @@ -19,6 +19,10 @@ import logging import os +import sys +import shutil +import subprocess +import tempfile import _util import Installer @@ -177,6 +181,36 @@ readOnly=True, transient=True) + def _perform_initrd_injections(self): + """Insert files into the root directory of the initial ram disk""" + tempdir = tempfile.mkdtemp(dir=self.scratchdir) + + gzip_proc = subprocess.Popen(['gzip', '-dc', self.install["initrd"]], + stdout=subprocess.PIPE, stderr=sys.stderr) + cpio_proc = subprocess.Popen(['cpio', '-i', '-d', '--quiet'], + stdin=gzip_proc.stdout, stderr=sys.stderr, cwd=tempdir) + cpio_proc.wait() + gzip_proc.wait() + + for filename in self._initrd_injections: + shutil.copy(filename, tempdir) + + find_proc = subprocess.Popen(['find', '.', '-depth', '-print0'], + stdout=subprocess.PIPE, stderr=sys.stderr, cwd=tempdir) + cpio_proc = subprocess.Popen(['cpio', '-o', '--null', '--quiet'], + stdin=find_proc.stdout, stdout=subprocess.PIPE, stderr=sys.stderr, cwd=tempdir) + new_initrd = self.install["initrd"] + '.new' + f = open(new_initrd, 'w') + gzip_proc = subprocess.Popen(['gzip'], stdin=cpio_proc.stdout, + stdout=f, stderr=sys.stderr) + f.close() + cpio_proc.wait() + find_proc.wait() + gzip_proc.wait() + sys.exit(1) + os.rename(new_initrd, self.install["initrd"]) + shutil.rmtree(tempdir) + def _prepare_kernel_and_initrd(self, guest, distro, meter): if self.boot is not None: # Got a local kernel/initrd already @@ -210,6 +244,9 @@ self._tmpfiles.append(kernelfn) if initrdfn: self._tmpfiles.append(initrdfn) + + if self._initrd_injections: + self._perform_initrd_injections() # If they're installing off a local file/device, we map it # through to a virtual CD or disk diff -r d7b354eef058 virtinst/Guest.py --- a/virtinst/Guest.py Thu Mar 04 15:55:38 2010 -0500 +++ b/virtinst/Guest.py Thu Mar 25 08:01:16 2010 -0400 @@ -145,6 +145,7 @@ self._os_type = None self._os_variant = None self._os_autodetect = False + # DEPRECATED: Public device lists unaltered by install process self.disks = [] diff -r d7b354eef058 virtinst/Installer.py --- a/virtinst/Installer.py Thu Mar 04 15:55:38 2010 -0500 +++ b/virtinst/Installer.py Thu Mar 25 08:01:16 2010 -0400 @@ -81,6 +81,7 @@ extraargs = None, os_type = None, conn = None): self._type = None self._location = None + self._initrd_injections = [] self._extraargs = None self._boot = None self._cdrom = False @@ -175,6 +176,12 @@ def set_location(self, val): self._location = val location = property(get_location, set_location) + + def get_initrd_injections(self): + return self._initrd_injections + def set_initrd_injections(self, val): + self._initrd_injections = val + initrd_injections = property(get_initrd_injections, set_initrd_injections) # kernel + initrd pair to use for installing as opposed to using a location def get_boot(self):