mercredi 26 mai 2021

VirtualBox API - Unlocking Machine after Restore

I've got a problem with machine restoring. It says:

The session is not locked (session state: Unlocked)

When I try to compare the state of machine with SessionState_Unlocked, somehow both states are equal but it enters in IF condition.

What am I missing here?

Code:

    progress = session.machine.restoreSnapshot(snap)  # async call

    while progress.percent < 100:
        sleep(0.5)
    sleep(2)
    print("Machine restored")
    print(type(session.state), session.state, id(session.state), hex(id(session.state)))
    print(type(self.constants.SessionState_Unlocked), self.constants.SessionState_Unlocked,
          id(self.constants.SessionState_Unlocked), hex(id(self.constants.SessionState_Unlocked)))
    print(session.state is self.constants.SessionState_Unlocked)
    if session.state != self.constants.SessionState_Unlocked:
        print("Unlocking machine")
        session.unlockMachine()
        return progress

Error:

Machine restored
<class 'int'> 1 2413217278256 0x231def56930
<class 'int'> 1 2413217278256 0x231def56930
True
(-2147352567, 'Exception occurred.', (0, 'SessionWrap', 'The session is not locked (session state: 
Unlocked)', None, 0, -2147418113), None)

Screenshot with error

Aucun commentaire:

Enregistrer un commentaire