Virtuozzo Virtualization SDK C API Reference
ContentsIndex
Example
PrlVm_BeginEdit Function

The following example illustrates how to use PrlVm_BeginEdit and PrlVm_Commit functions.

PRL_HANDLE hJobBeginEdit;
PRL_HANDLE hJobCommit;
PRL_RESULT nJobRetCode;

// Timestamp the beginning of the configuration changes operation.
hJobBeginEdit = PrlVm_BeginEdit(hVm);

// Wait for the job to complete.
ret = PrlJob_Wait(hJobBeginEdit, 10000);

// Check for errors.
PrlJob_GetRetCode(hJobBeginEdit, &nJobRetCode);

if (PRL_FAILED(nJobRetCode))
{
    fprintf(stderr, "Error: %s\n", PRL_RESULT_TO_STRING(nJobRetCode));
    PrlHandle_Free(hJobBeginEdit);
    return nJobRetCode;
}

// The code modifying configuration parameters goes here...

// Commit the changes when done.
hJobCommit = PrlVm_Commit(hVm);

// Wait for the job to complete.
ret = PrlJob_Wait(hJobCommit, 10000);

// Check the results of the commit operation.
PrlJob_GetRetCode(hJobCommit, &nJobRetCode);

if (PRL_FAILED(nJobRetCode))
{
    fprintf(stderr, "Commit error: %s\n", PRL_RESULT_TO_STRING(nJobRetCode));
    PrlHandle_Free(hJobCommit);
    return nJobRetCode;
}
Copyright ©2016-2017 Parallels International GmbH. All rights reserved.