Error handling and debugging
All functions except the ones for freeing context objects return an integer value, where 0 indicates success and a value greater than 0 indicates a failure.
See the following sample error handling routine:
rc = zpc_foo();
if (rc) {
/* Handle specific error codes. */
fprintf(stderr, "Error: %d (%s).\n", rc, zpc_error_string(rc));
}
You find a description of the error strings in Error API - zpc/error.h.
In case of multiple errors, the precedence of error codes is undefined. Therefore, applications should always check for a non-zero return value before handling specific errors.
Debugging
Setting the environment variable ZPC_DEBUG=1 lets the library print debug information to stderr.
Live guest relocation
Do not use libzpc earlier than version 1.5 if the Linux® system may be subject to live guest relocation or migration. This restriction is removed with libzpc version 1.5. Versions of libzpc earlier than 1.5 can not support a live guest relocation and operations may fail if such an action is performed.
During live guest relocation or migration, protected keys become invalid and their use will result in a verification pattern mismatch. The code of libzpc version 1.5 is instrumented to react to this error by re-creating the protected key from the key material it was derived from.