コード例 #1
0
ファイル: random-platform.c プロジェクト: 8tab/qemu
int qcrypto_random_init(Error **errp)
{
#ifndef _WIN32
    /* TBD perhaps also add support for BSD getentropy / Linux
     * getrandom syscalls directly */
    fd = open("/dev/urandom", O_RDONLY);
    if (fd == -1 && errno == ENOENT) {
        fd = open("/dev/random", O_RDONLY);
    }

    if (fd < 0) {
        error_setg(errp, "No /dev/urandom or /dev/random found");
        return -1;
    }
#else
    if (!CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL,
                             CRYPT_SILENT | CRYPT_VERIFYCONTEXT)) {
        error_setg_win32(errp, GetLastError(),
                         "Unable to create cryptographic provider");
        return -1;
    }
#endif

    return 0;
}
コード例 #2
0
ファイル: vss-win32.c プロジェクト: 32bitmicro/riscv-qemu
/* Call VSS requester and freeze/thaw filesystems and applications */
void qga_vss_fsfreeze(int *nr_volume, Error **errp, bool freeze)
{
    const char *func_name = freeze ? "requester_freeze" : "requester_thaw";
    QGAVSSRequesterFunc func;
    ErrorSet errset = {
        .error_setg_win32 = error_setg_win32_internal,
        .errp = errp,
    };

    g_assert(errp);             /* requester.cpp requires it */
    func = (QGAVSSRequesterFunc)GetProcAddress(provider_lib, func_name);
    if (!func) {
        error_setg_win32(errp, GetLastError(), "failed to load %s from %s",
                         func_name, QGA_VSS_DLL);
        return;
    }

    func(nr_volume, &errset);
}