示例#1
0
 def _getTimezone(self):
     if FvmUtil.getWinLang(self.osName) == "en_US":
         return "85"
     elif FvmUtil.getWinLang(self.osName) == "zh_CN":
         return "85"
     elif FvmUtil.getWinLang(self.osName) == "zh_TW":
         return "85"
     else:
         assert False
示例#2
0
    def injectTo(self, mainDiskImage):

        # write to tmp file
        tmpf = os.path.join(self.param.tmpDir, "startup.bat")
        FvmUtil.writeFile(tmpf, self.buf)

        # inject operation
        mptObj = WinDiskMountPoint(self.param, mainDiskImage, FvmUtil.getWinLang(self.osName))
        try:
            startupDir = FvmUtil.getWinDir("startup", FvmUtil.getWinLang(self.osName), FvmUtil.getWinUser())
            mptObj.addFile(tmpf, startupDir, False)
        finally:
            mptObj.umount()

        os.remove(tmpf)
示例#3
0
    def doWork(self, param, vmObj, infoPrinter):
        """do driver install operation"""

        # prepare parameter
        self.param = param
        self.vmObj = vmObj

        mptObj = WinDiskMountPoint(self.param, self.vmObj.getMainDiskImage(), FvmUtil.getWinLang(self.osName))
        try:
            winreg = WinRegistry(self.param, mptObj.getMountDir())

            # Add drivers
            mptObj.mkdir("Drivers")
            self._addParaDriver(mptObj, "Drivers")
            self._addQxlDriver(mptObj, "Drivers")
            self._addVdagent(mptObj, "Drivers")

            # Configure driver installation options
            winreg.addOrModify("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion",
                               "DevicePath", "REG_EXPAND_SZ", "%SystemRoot%\\inf;C:\\Drivers")
            winreg.addOrModify("HKEY_LOCAL_MACHINE\\SOFTWARE\\Policies\\Microsoft\\Windows\\DriverSearching",
                               "DontPromptForWindowsUpdate", "REG_DWORD", 1)
            winreg.addOrModify("HKEY_LOCAL_MACHINE\\SOFTWARE\\Policies\\Microsoft\\Windows\\DriverSearching",
                               "DontSearchWindowsUpdate", "REG_DWORD", 1)
            winreg.addOrModify("HKEY_LOCAL_MACHINE\\SOFTWARE\\Policies\\Microsoft\\Windows\\DriverSearching",
                               "DontSearchFloppies", "REG_DWORD", 1)
            winreg.addOrModify("HKEY_LOCAL_MACHINE\\SOFTWARE\\Policies\\Microsoft\\Windows\\DriverSearching",
                               "DontSearchCD", "REG_DWORD", 1)
        finally:
            mptObj.umount()
 def _getWinLang(self):
     for o in self.vmObj.getVmInfo().vmCfgWin.os.setupOptList:
         if o.startswith("os="):
             osName = o[3:]
             return FvmUtil.getWinLang(osName)
     assert False
示例#5
0
 def _getWinLang(self):
     for o in self.vmObj.getVmInfo().vmCfgWin.os.setupOptList:
         if o.startswith("os="):
             osName = o[3:]
             return FvmUtil.getWinLang(osName)
     assert False
示例#6
0
    def doWork(self, param, vmObj, infoPrinter):
        """do driver update operation"""

        # prepare parameter
        self.param = param
        self.vmObj = vmObj

        # create assistant usb disk
        usbFile = os.path.join(self.param.tmpDir, "usb.img")
        if True:
            FvmUtil.createWinUsbImg(usbFile, 300, "ntfs")

            mptObj = WinDiskMountPoint(self.param, usbFile, FvmUtil.getWinLang(self.osName))
            try:
                mptObj.addAutoIt()
                mptObj.addFile(os.path.join(self.dataDir, "autocfg-update-driver.au3"), "", False)
                mptObj.addFile(os.path.join(self.dataDir, "autocfg-enable-vdagent.au3"), "", False)
            finally:
                mptObj.umount()
        self.vmObj.setLocalUsbImage(usbFile)

        # update virtio harddisk driver
        if self.vmObj.getVmInfo().vmCfgHw.mainDiskInterface != "ide":
            # create and inject startup file
            sFileList = ["autocfg-update-driver.au3",
                         "autocfg-enable-vdagent.au3"]
            msf = MyStartupFile(self.param, self.osName, sFileList)
            msf.injectTo(self.vmObj.getMainDiskImage())

            # run virtual machine
            self.vmObj.setLocalFakeHarddisk(self.vmObj.getVmInfo().vmCfgHw.mainDiskInterface)
            self.vmObj.run()
            self.vmObj.setLocalFakeHarddisk("")

        # update drivers
        if True:
            # create and inject startup.bat to disk-main.img
            sFileList = ["autocfg-update-driver.au3",            # VirtIO SCSI driver
                         "autocfg-update-driver.au3",            # VirtIO Balloon driver
                         "autocfg-update-driver.au3",            # VirtIO Serial driver
                         "autocfg-update-driver.au3"]            # Red Hat QXL GPU driver
            msf = MyStartupFile(self.param, self.osName, sFileList)
            msf.injectTo(self.vmObj.getMainDiskImage())

            # run virtual machine
            self.vmObj.setSetupMode(False)
            self.vmObj.setNetworkStatus("isolate")
            self.vmObj.run()
            self.vmObj.setNetworkStatus("")

        # update virtio network driver
        if self.vmObj.getVmInfo().vmCfgHw.networkAdapterInterface != "user":
            # create and inject startup.bat to disk-main.img
            sFileList = ["autocfg-update-driver.au3"]            # VirtIO Network driver
            msf = MyStartupFile(self.param, self.osName, sFileList)
            msf.injectTo(self.vmObj.getMainDiskImage())

            # run virtual machine
            self.vmObj.setNetworkStatus("virtio-dummy")
            self.vmObj.run()
            self.vmObj.setNetworkStatus("")
示例#7
0
    def doWork(self, param, vmObj, infoPrinter):
        """do driver update operation"""

        # prepare parameter
        self.param = param
        self.vmObj = vmObj

        # do preparation configuration in main disk image
        mptObj = WinDiskMountPoint(self.param, self.vmObj.getMainDiskImage(), FvmUtil.getWinLang(self.osName))
        try:
            winreg = WinRegistry(self.param, mptObj.getMountDir())

            # add sleep.exe, needed by delay code in startup.bat
            mptObj.addFile(os.path.join(self.dataDir, "sleep.exe"), "WINDOWS/system32", True)

            # Dismiss screen check, so it won't disturb us
            winreg.addOrModify("HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\DontShowMeThisDialogAgain",
                               "ScreenCheck", "REG_SZ", "no")

            # Dismiss balloon tips, so it won't disturb us
            winreg.addOrModify("HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
                               "EnableBalloonTips", "REG_DWORD", 0)

            # Disable "AutoPlay & AutoRun", they will disturb some config's autoit script
            winreg.addOrModify("HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\policies\\Explorer",
                               "NoDriveTypeAutoRun", "REG_DWORD", 0xff)
        finally:
            mptObj.umount()

        # boot with usb disk, so it can be the first hardware device recognized
        usbFile = os.path.join(self.param.tmpDir, "usb.img")
        if True:
            FvmUtil.createWinUsbImg(usbFile, 300, "ntfs")

            mptObj = WinDiskMountPoint(self.param, usbFile, FvmUtil.getWinLang(self.osName))
            try:
                mptObj.addAutoIt()

                # dismiss start menu show, so it won't disturb us
                mptObj.addFile(os.path.join(self.dataDir, "autocfg-dismiss-start-menu-show.au3"), "", False)

                # disable swapfile and snapshot as early as possible
                mptObj.addFile(os.path.join(self.dataDir, "autocfg-disable-swapfile.au3"), "", False)
                mptObj.addFile(os.path.join(self.dataDir, "autocfg-disable-snapshot.au3"), "", False)

                # disable anti-virus check, so it won't disturb us
                mptObj.addFile(os.path.join(self.dataDir, "autocfg-disable-antivirues-check.au3"), "", False)

                # disable screen saver, so it won't disturb us in future
                mptObj.addFile(os.path.join(self.dataDir, "autocfg-disable-screensaver.au3"), "", False)

                # disable desktop cleanup wizard
                mptObj.addFile(os.path.join(self.dataDir, "autocfg-disable-desktop-cleanup-wizard.au3"), "", False)

                # dismiss explore xp, so it won't disturb us
                # it can't be dismissed by directly modify the registry, don't know why
                mptObj.addFile(os.path.join(self.dataDir, "autocfg-dismiss-explore-winxp.au3"), "", False)
            finally:
                mptObj.umount()
        self.vmObj.setLocalUsbImage(usbFile)

        # create and inject startup file
        sFileList = ["autocfg-dismiss-start-menu-show.au3",
                     "autocfg-disable-swapfile.au3",
                     "autocfg-disable-snapshot.au3",
                     "autocfg-disable-antivirues-check.au3",
                     "autocfg-disable-screensaver.au3",
                     "autocfg-disable-desktop-cleanup-wizard.au3",
                     "autocfg-dismiss-explore-winxp.au3"]
        msf = MyStartupFile(self.param, self.osName, sFileList)
        msf.injectTo(self.vmObj.getMainDiskImage())

        # run virtual machine
        # this boot will also dimiss the start menu show, so it won't disturb us in future
        self.vmObj.run()