Re: [et-mgmt-tools] [patch 3/8] Move post install check into DistroInstaller

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, May 02, 2007 at 01:16:11PM +0100, Mark McLoughlin wrote:
> The existing heuristic we use in virt-install to detect whether
> an install has completed successfully is dependant on the type
> of installer being used - i.e. if you create a VM with a livecd
> or a raw ext3 image, there may be no disk with an MBR at the end.
> 
> This patch moves that logic into a new DistroInstaller method.
> 
> Signed-off-by: Mark McLoughlin <markmc@xxxxxxxxxx>
> 
> Index: virtinst--devel/virtinst/DistroManager.py
> ===================================================================
> --- virtinst--devel.orig/virtinst/DistroManager.py
> +++ virtinst--devel/virtinst/DistroManager.py
> @@ -18,6 +18,7 @@ import os
>  import gzip
>  import re
>  import stat
> +import struct
>  import subprocess
>  import urlgrabber.grabber as grabber
>  import urlgrabber.progress as progress
> @@ -698,3 +699,10 @@ class DistroInstaller(Guest.Installer):
>              osblob += "    <bootloader>/usr/bin/pygrub</bootloader>"
>  
>          return osblob
> +
> +    def post_install_check(self, guest):
> +        # Check for the 0xaa55 signature at the end of the MBR
> +        fd = os.open(guest.disks[0].path, os.O_RDONLY)
> +        buf = os.read(fd, 512)
> +        os.close(fd)
> +        return len(buf) == 512 and struct.unpack("H", buf[0x1fe: 0x200]) == (0xaa55,)

We should really create a convenience method in virtinst/util.py for
this stuff. This is definitely broken on ia64 which uses EFI / GPT
instead of BIOS/MBR.

We could have an 

  def has_boot_record()
     if has_boot_record_mbr()
        return True
     if has_boot_record_gpt()
        return True
     return Fale

  def has_boot_record_mbr()
    ...existing code from above...

  def has_boot_record_gpt()
    ...figure something out :-) ...


Dan
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 


[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux