What does VZError code=12 mean when restoring VM state?

Hi,

I'm trying save and restore features of VZ Framework with saveMachineStateTo and restoreMachineStateFrom(vzvmsaveFilePath) with completionHandler.

Saving feature works well without any errors, .vzvmsave file created on my local mac, but the problem occurs on restore.

After creating VM with the same volume mounts I used to make .vzvmsave, restoreMachineStateFrom method sends error.

Failed to load VM from .vzvmsave file with Error Domain=VZErrorDomain Code=12 UserInfo={NSLocalizedFailure=<private>, NSLocalizedFailureReason=<private>}

Because Localized Failure and its reason are both 'private', I cannot get what exactly happened to this VM app. Only thing I know here is the Code of VZError but nobody summarized what exactly the error code means.

Could anyone give me the list of VZError code list please?

Additional information for onset:

This VZError only occurs when the VM started up from SSH. If I try restoring VM directly on the mac or via VNC, both save and restore succeeds.

Could anyone give me the list of VZError code list please?

There’s a list in <Virtualization/VZError.h>. Code 12 is VZErrorRestore, which is not very helpful )-:

I’m not 100% sure what’s going on here but my best guess is that there was an error actually opened your .vzvmsave file. If you run fs_usage while reproducing the problem, does it reveal anything about the failure?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thanks for the quick reply.

I finally found what exactly reproduces the problem and what doesn't.

If I do this with GUI on (VNC or local) restore works from whichever the restore process executed. (The screen should be turned on and logon should have been done by the user using VM before restore command starts)

If I close the VNC, restore fails. Should restoreMachineState be executed with screen always on and logged on? Impossible with no-screen SSH only?

  • As you suggested, I turned on fs_usage and checked when the error reproduced, seemed nothing special around the timing of error. Sorry that I cannot post it on here because I'm using VM on my company's mac.

If I close the VNC, restore fails. Should restoreMachineState be executed with screen always on and logged on? Impossible with no-screen SSH only?

The saved state is protected by the keychain. The Mac needs to be unlocked for the keychain to unlock.

Hi,

I'm getting the same error with my code when running it with my GUI app (no VNC or similar) and trying to restore a snapshot with VZVirtualMachine.restoreMachineStateFrom(url)

Failed to restore with error: Error Domain=VZErrorDomain Code=12 "The virtual machine failed to restore with error “invalid argument”." UserInfo={NSLocalizedFailure=An error occurred while restoring the virtual machine., NSLocalizedFailureReason=The virtual machine failed to restore with error “invalid argument”.}

Snapshot was written successfully without errors using VZVirtualMachine.saveMachineStateTo(ur) and also prio check with VZVirtualMachineConfiguration.validateSaveRestoreSupport() does't fail.

Any other ideas what could cause this error?

The header file for VZVirtualMachine contains some more information and hints regarding this error, that I can't see in the official doc and that helped me to resolve my issue.

This is the info from the header file for VZVirtualMachine.restoreMachineStateFrom(url):

The virtual machine must also be configured compatibly with the state contained in the file.

If the VZVirtualMachineConfiguration is not compatible with the content of the file, this operation will fail with a VZErrorRestore error indicating an invalid argument failure reason.

Files generated with saveMachineStateToURL:completionHandler: on a software version that is newer than the current version will also be rejected with an invalid argument failure reason.

In some cases, restoreMachineStateFromURL:completionHandler: can fail if a software update has changed the host in a way that would be incompatible with the previous format. In this case, an invalid argument error will be surfaced.

In most cases, the virtual machine should be restarted with startWithCompletionHandler:.

In my code I ran into the "If the VZVirtualMachineConfiguration is not compatible with the content of the file" case as the macAddress property of VZVirtioNetworkDeviceConfiguration the network device that my VM config used changed between the time the VM state was saved using VZVirtualMachine.saveMachineStateTo(url) and the attempt to restore the VM from the saved state.

The fix was to ensure that the macAddress remains the same. Afterwards restoring worked.

What does VZError code=12 mean when restoring VM state?
 
 
Q