ฉันกำลังพยายามจัดการเครื่องเสมือนบางเครื่องผ่าน vboxapi ที่มาพร้อมกับ SDK จนถึงตอนนี้ ฉันสามารถเปิด VM และปิดเครื่องได้ แต่ฉันไม่สามารถกู้คืนสแน็ปช็อตได้ ดูเหมือนว่าขั้นตอนการปิดเครื่องจะล็อกเครื่องเสมือนจนกว่าสคริปต์จะยุติลง ตามความเป็นจริง นี่เป็นข้อผิดพลาดที่ฉันได้รับ:
progress = self.session.console.restoreSnapshot(self.mach.currentSnapshot) File "", line 3, in restoreSnapshot xpcom.Exception: 0x80070005 (The object is not ready)
และต่อไปนี้เป็นฟังก์ชันเฉพาะที่ฉันเรียกใช้ตามลำดับเพื่อหยุด vm และกู้คืนสแน็ปช็อต
def stop(self): if self.mach: # Poweroff the virtual machine. progress = self.session.console.powerDown() # Wait for task to complete with a 60 seconds timeout. progress.waitForCompletion(VIRTUALBOX_TIMEOUT) # Check if poweroff was successful. if progress.resultCode != 0: log("[Virtual Machine] [PowerOff] [ERROR] Unable to poweroff virtual machine \"%s\"." % self.mach.name) return False else: log("[Virtual Machine] [PowerOff] Virtual machine \"%s\" powered off successfully." % self.mach.name) else: log("[Virtual Machine] [PowerOff] [ERROR] No virtual machine handle.") return False return True def restore_snapshot(self): if self.mach: # Restore virtual machine snapshot. progress = self.session.console.restoreSnapshot(self.mach.currentSnapshot) # Wait for task to complete with a 60 seconds timeout. progress.waitForCompletion(VIRTUALBOX_TIMEOUT) # Check if snapshot restoring was successful. if progress.resultCode != 0: log("[Virtual Machine] [Restore Snapshot] [ERROR] Unable to restore virtual machine \"%s\" snapshot." % self.mach.name) return False else: log("[Virtual Machine] [Restore Snapshot] Virtual machine \"%s\" successfully restored to current snashot." % self.mach.name) else: log("[Virtual Machine] [Restore Snapshot] [ERROR] No virtual machine handle.") return False return True
ฉันคิดว่าฉันอาจขาดอะไรบางอย่างไป มีเบาะแสว่ามันคืออะไร? ขอบคุณ C.