파이썬 스크립트로 문제를 해결했습니다.
VM_NAMES
목록을 사용하여 VirtualBox에 표시되는대로 VM 이름을 포함하도록 편집 한 다음 VM을 보내려는 날짜와 시간에 따라 RESET_TIME_VALUE를 설정하십시오.
기본값이 아닌 위치에 VirtualBox를 설치 한 경우 VIRTUAL_BOX_MANAGE_PATH
변수도 편집하십시오.
실행하려면 main
메서드를 호출하십시오.
import datetime
import subprocess
VIRTUAL_BOX_MANAGE_PATH = r"C:\Program Files\Oracle\VirtualBox\vboxmanage.exe"
SET_EXTRA_DATA_COMMAND = r"setextradata"
GET_HOST_TIME_DISABLE_COMMAND = "\"VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled\" \"1\""
MODIFY_VM_COMMAND = r"modifyvm"
BIOS_SYSTEM_TIME_OFFSET = r"--biossystemtimeoffset"
# Edit this list to add more Virtual Machines
VM_NAMES = ("xxx",
"yyy",
"zzz")
RESET_TIME_VALUE = datetime.datetime(2014, 6, 7, 13, 0, 0, 0)
def main():
for vm in VM_NAMES:
reset_time(vm)
disable_time_sync(vm)
def reset_time(vm_name):
"""
Resets the VM to the clean install time
"""
args = get_subprocess_args_set_bios_time(vm_name, RESET_TIME_VALUE)
print("Resetting time on VM [" + vm_name + "] to " + str(RESET_TIME_VALUE) + " ...")
subprocess.call(args)
print("\tDone.")
def disable_time_sync(vm_name):
"""
Disables the time synchronization of a VM with the BIOS
"""
args = [
VIRTUAL_BOX_MANAGE_PATH,
SET_EXTRA_DATA_COMMAND,
vm_name,
GET_HOST_TIME_DISABLE_COMMAND
]
print("Disabling time synchronization on VM [" + vm_name + "] ...")
subprocess.call(args)
print("\tDone.")
def get_subprocess_args_set_bios_time(vm_name, datetime_to_set):
"""
Returns a list containing the arguments to pass to the subprocess method
to start the Virtual Box Manage program and set the BIOS time to the supplied value
"""
return [
VIRTUAL_BOX_MANAGE_PATH,
MODIFY_VM_COMMAND,
vm_name,
BIOS_SYSTEM_TIME_OFFSET,
str(get_msec_time_difference(datetime.datetime.now(), datetime_to_set))
]
def get_msec_time_difference(reference_point, check_point):
"""
Computes the offset in msec from the reference point to the check point
"""
return int(round((check_point - reference_point).total_seconds() * 1000))
출처
2014-06-07 16:23:28
ose