qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2] crypto_gen_random() now also works on window


From: Daniel P. Berrange
Subject: Re: [Qemu-devel] [PATCH v2] crypto_gen_random() now also works on windows
Date: Tue, 25 Apr 2017 14:54:52 +0100
User-agent: Mutt/1.7.1 (2016-10-04)

On Tue, Apr 25, 2017 at 08:52:58AM -0500, Eric Blake wrote:
> On 04/25/2017 08:42 AM, Daniel P. Berrange wrote:
> > On Mon, Apr 24, 2017 at 07:51:49PM +0200, Geert Martin Ijewski wrote:
> >> If no crypto library is included in the build QEMU uses
> >> qcrypto_random_bytes() to generate random data. That function tried to open
> >> /dev/urandom or /dev/random and if openeing neither file worked it errored
> >> out.
> >>
> 
> >> +int qcrypto_random_init(Error **errp)
> >> +{
> >> +#ifdef _WIN32
> >> +    if (!CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL,
> >> +                             CRYPT_SILENT | CRYPT_VERIFYCONTEXT)) {
> >> +        error_setg_errno(errp, GetLastError(),
> >> +                         "Unable to create cryptographic provider");
> > 
> > Unfortunately the return value of 'GetLastError()' isn't an errno
> > so we can't use error_setg_errno here.
> > 
> > Just use error_setg, and report the error value with a '(code=%u)'
> > substitution at the end of the error message.
> > 
> 
> Or, use error_setg_win32(), which is designed for this purpose.

Oh nice, didn't know that existed !

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



reply via email to

[Prev in Thread] Current Thread [Next in Thread]