[virt-tools-list] perform_initrd_injections does not work

Claus Rosenberger claus.rosenberger at rocnet.de
Thu Dec 21 15:09:27 UTC 2017


Finally it seems the xen toolstack is not able to handle concaticated 
gzip files at all, is there any way to push the modified cpio archive 
unzipped to the VM?


Am 21.12.2017 um 15:32 schrieb Claus Rosenberger:
> Changing the code from
>
>    cpio_proc.wait()
>    find_proc.wait()
>    gzip_proc.wait()
>
> to
>
>    find_proc.wait()
>    cpio_proc.wait()
>    gzip_proc.wait()
>
> did it, the file is injected now. But the VM still prevents to start, 
> because of the concatted gzip files?
>
> Am 21.12.2017 um 12:09 schrieb Claus Rosenberger:
>> Hi,
>>
>> i figured out the function perform_initrd_injections does extend the
>> existing initrd with a few bytes, but the file to be injected is not 
>> inside
>> of the new generated initrd. Further it's not possible to boot the VM 
>> with
>> the new generated initrd. But both files are still a gzipped ASCII cpio
>> archive (SVR4 with no CRC). I can deflate the new generated file 
>> manually.
>>
>> Do you have any clue what could be the issue? virt-install is working
>> without injecting the preseed.cfg file.
>>
>> -rw-------  1 root root 133426176 Dec 19 18:29 initrd-new
>> -rw-------  1 root root 133425664 Dec 19 18:29 initrd-old
>>
>> root@ /tmp # hexdump -s 133425664 -C initrd-new
>> 07f3ea00  30 37 30 37 30 31 30 30  30 30 30 30 30 30 30 30 
>> |0707010000000000|
>> 07f3ea10  30 30 30 30 30 30 30 30  30 30 30 30 30 30 30 30 
>> |0000000000000000|
>> 07f3ea20  30 30 30 30 30 30 30 30  30 30 30 30 30 31 30 30 
>> |0000000000000100|
>> 07f3ea30  30 30 30 30 30 30 30 30  30 30 30 30 30 30 30 30 
>> |0000000000000000|
>> *
>> 07f3ea60  30 30 30 30 30 42 30 30  30 30 30 30 30 30 54 52 
>> |00000B00000000TR|
>> 07f3ea70  41 49 4c 45 52 21 21 21  00 00 00 00 00 00 00 00 
>> |AILER!!!........|
>> 07f3ea80  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00 
>> |................|
>> *
>> 07f3ec00
>>
>>
>> Kind regards
>> Claus
>>
>>
>> def perform_initrd_injections(initrd, injections, scratchdir):
>>     """
>>     Insert files into the root directory of the initial ram disk
>>     """
>>     if not injections:
>>         return
>>
>>     if _rhel4_initrd_inject(initrd, injections):
>>         return
>>
>>     tempdir = tempfile.mkdtemp(dir=scratchdir)
>>     os.chmod(tempdir, 0775)
>>     shutil.copy(initrd, '/tmp/initrd-old.gz')     # <------ this file 
>> works to boot the VM
>>
>>     for filename in injections:
>>         logging.debug("Copying %s to the initrd.", filename)
>>         shutil.copy(filename, tempdir)
>>
>>     logging.debug("Appending to the initrd.")
>>     find_proc = subprocess.Popen(['find', '.', '-print0'],
>>                                  stdout=subprocess.PIPE,
>>                                  stderr=subprocess.PIPE,
>>                                  cwd=tempdir)
>>     logging.debug("Found file %s with find_proc.", 
>> find_proc.stdout.read())
>>     cpio_proc = subprocess.Popen(['cpio', '-o', '--null', 
>> '-Hnewc','--quiet'],
>>                                  stdin=find_proc.stdout,
>>                                  stdout=subprocess.PIPE,
>>                                  stderr=subprocess.PIPE,
>>                                  cwd=tempdir)
>>     f = open(initrd, 'ab')
>>     gzip_proc = subprocess.Popen(['gzip'], stdin=cpio_proc.stdout,
>>                                  stdout=f, stderr=subprocess.PIPE)
>>     cpio_proc.wait()
>>     find_proc.wait()
>>     gzip_proc.wait()
>>     f.close()
>>     shutil.rmtree(tempdir)
>>     # copy injected initrd
>>     shutil.copy(initrd, '/tmp/initrd-new.gz')     # <------ this file 
>> doesn't work to boot the VM
>>
>>
>>     finderr = find_proc.stderr.read()
>>     cpioerr = cpio_proc.stderr.read()
>>     gziperr = gzip_proc.stderr.read()
>>     if finderr:
>>         logging.debug("find stderr=%s", finderr)
>>     if cpioerr:
>>         logging.debug("cpio stderr=%s", cpioerr)
>>     if gziperr:
>>         logging.debug("gzip stderr=%s", gziperr)
>>
>> _______________________________________________
>> virt-tools-list mailing list
>> virt-tools-list at redhat.com
>> https://www.redhat.com/mailman/listinfo/virt-tools-list
>
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list




More information about the virt-tools-list mailing list