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

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

 



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/virt-install
===================================================================
--- virtinst--devel.orig/virt-install
+++ virtinst--devel/virt-install
@@ -17,7 +17,6 @@
 import os, sys, string
 from optparse import OptionParser, OptionValueError
 import subprocess
-import struct
 import logging
 import libxml2
 import urlgrabber.progress as progress
@@ -582,11 +581,7 @@ def main():
     # the domain is no longer running
     # FIXME: this is just a hacky heuristic, but I'll take what I can get
     try:
-        fd = os.open(guest.disks[0].path, os.O_RDONLY)
-        buf = os.read(fd, 512)
-        os.close(fd)
-        if len(buf) == 512 and \
-               struct.unpack("H", buf[0x1fe: 0x200]) == (0xaa55,):
+        if guest.post_install_check():
             # things installed enough that we should be able to restart
             # the domain
             if continue_inst:
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,)
Index: virtinst--devel/virtinst/Guest.py
===================================================================
--- virtinst--devel.orig/virtinst/Guest.py
+++ virtinst--devel/virtinst/Guest.py
@@ -727,6 +727,9 @@ class Guest(object):
         # for inactive guest, or get the still running install..
         return self.conn.lookupByName(self.name)
 
+    def post_install_check(self):
+        return self.installer.post_install_check(self)
+
     def connect_console(self, consolecb):
         logging.debug("Restarted guest, looking to see if it is running")
         # sleep in .25 second increments until either a) we get running

-- 


[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