Message ID | 20210615172746.2212998-1-philmd@redhat.com (mailing list archive) |
---|---|
Headers | show |
Series | crypto: Make QCryptoTLSCreds* structures private | expand |
On 6/15/21 7:27 PM, Philippe Mathieu-Daudé wrote: > Code consuming the "crypto/tlscreds*.h" APIs doesn't need > to access its internals. Move the structure definitions to > the "tlscredspriv.h" private header (only accessible by > implementations). The public headers (in include/) still > forward-declare the structures typedef. > > This solves a bug introduced by commit 7de2e856533 which made > migration/qemu-file-channel.c include "io/channel-tls.h", > itself sometime depends on GNUTLS, leading to build failure > on OSX: > > [2/35] Compiling C object libmigration.fa.p/migration_qemu-file-channel.c.o > FAILED: libmigration.fa.p/migration_qemu-file-channel.c.o > cc -Ilibmigration.fa.p -I. -I.. -Iqapi [ ... ] -o libmigration.fa.p/migration_qemu-file-channel.c.o -c ../migration/qemu-file-channel.c > In file included from ../migration/qemu-file-channel.c:29: > In file included from include/io/channel-tls.h:26: > In file included from include/crypto/tlssession.h:24: > include/crypto/tlscreds.h:28:10: fatal error: 'gnutls/gnutls.h' file not found > #include <gnutls/gnutls.h> > ^~~~~~~~~~~~~~~~~ > 1 error generated. > > Reported-by: Stefan Weil <sw@weilnetz.de> > Suggested-by: Daniel P. Berrangé <berrange@redhat.com> > Resolves: https://gitlab.com/qemu-project/qemu/-/issues/407 > Fixes: 7de2e856533 ("yank: Unregister function when using TLS migration") > Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> > --- > crypto/tlscredspriv.h | 45 ++++++++++++++++++++++++++++++ > include/crypto/tls-cipher-suites.h | 6 ---- > include/crypto/tlscreds.h | 16 ----------- > include/crypto/tlscredsanon.h | 12 -------- > include/crypto/tlscredspsk.h | 12 -------- > include/crypto/tlscredsx509.h | 10 ------- > crypto/tls-cipher-suites.c | 7 +++++ > crypto/tlscredsanon.c | 3 +- > crypto/tlscredspsk.c | 3 +- > crypto/tlscredsx509.c | 4 +-- > crypto/tlssession.c | 1 + > 11 files changed, 58 insertions(+), 61 deletions(-) > index bea5f76c55d..2675b1af8f8 100644 > --- a/crypto/tlscredsanon.c > +++ b/crypto/tlscredsanon.c > @@ -26,9 +26,10 @@ > #include "qom/object_interfaces.h" > #include "trace.h" > > - Involuntary line removal :/ Can restore if v4 required. > #ifdef CONFIG_GNUTLS > > +#include <gnutls/gnutls.h> > + > > static int > qcrypto_tls_creds_anon_load(QCryptoTLSCredsAnon *creds, > diff --git a/crypto/tlscredspsk.c b/crypto/tlscredspsk.c > index f5a31108d15..820719c5e84 100644 > --- a/crypto/tlscredspsk.c > +++ b/crypto/tlscredspsk.c > @@ -26,9 +26,10 @@ > #include "qom/object_interfaces.h" > #include "trace.h" > > - > #ifdef CONFIG_GNUTLS > > +#include <gnutls/gnutls.h> > + > static int > lookup_key(const char *pskfile, const char *username, gnutls_datum_t *key, > Error **errp) > diff --git a/crypto/tlscredsx509.c b/crypto/tlscredsx509.c > index d9d6f4421e5..44dbe0dc819 100644 > --- a/crypto/tlscredsx509.c > +++ b/crypto/tlscredsx509.c > @@ -27,12 +27,10 @@ > #include "qom/object_interfaces.h" > #include "trace.h" > > - > #ifdef CONFIG_GNUTLS > - > +#include <gnutls/gnutls.h> > #include <gnutls/x509.h> > > - > static int > qcrypto_tls_creds_check_cert_times(gnutls_x509_crt_t cert, > const char *certFile,
On 6/15/21 7:27 PM, Philippe Mathieu-Daudé wrote: > Follow Daniel suggestion to simplify qcrypto TLS implementations, > aiming to solve the OSX build failure. > > Since v2: > - Add Error* argument (Daniel) > - Move structure definitions to "tlscredspriv.h" > > Philippe Mathieu-Daudé (7): > crypto/tlscreds: Introduce qcrypto_tls_creds_check_endpoint() helper > block/nbd: Use qcrypto_tls_creds_check_endpoint() > chardev/socket: Use qcrypto_tls_creds_check_endpoint() > migration/tls: Use qcrypto_tls_creds_check_endpoint() > crypto/tlssession: Introduce qcrypto_tls_creds_check_endpoint() helper > ui/vnc: Use qcrypto_tls_session_check_role() > crypto: Make QCryptoTLSCreds* structures private > > crypto/tlscredspriv.h | 45 ++++++++++++++++++++++++++++++ > include/crypto/tls-cipher-suites.h | 6 ---- > include/crypto/tlscreds.h | 29 +++++++++---------- > include/crypto/tlscredsanon.h | 12 -------- > include/crypto/tlscredspsk.h | 12 -------- > include/crypto/tlscredsx509.h | 10 ------- > include/crypto/tlssession.h | 14 ++++++++++ > block/nbd.c | 6 ++-- > blockdev-nbd.c | 6 ++-- > chardev/char-socket.c | 18 ++++-------- > crypto/tls-cipher-suites.c | 7 +++++ > crypto/tlscreds.c | 12 ++++++++ > crypto/tlscredsanon.c | 3 +- > crypto/tlscredspsk.c | 3 +- > crypto/tlscredsx509.c | 4 +-- > crypto/tlssession.c | 8 ++++++ > migration/tls.c | 6 +--- > ui/vnc.c | 6 ++-- > 18 files changed, 120 insertions(+), 87 deletions(-) Sorry Daniel, today it is too hot inside :S $ git checkout sev_builtin error: Your local changes to the following files would be overwritten by checkout: include/crypto/tlscreds.h include/crypto/tlssession.h Please commit your changes or stash them before you switch branches. Aborting $ git diff diff --git a/include/crypto/tlscreds.h b/include/crypto/tlscreds.h index 41b8939d417..2a8a8570109 100644 --- a/include/crypto/tlscreds.h +++ b/include/crypto/tlscreds.h @@ -53,6 +53,7 @@ struct QCryptoTLSCredsClass { * qcrypto_tls_creds_check_endpoint: * @creds: pointer to a TLS credentials object * @endpoint: type of network endpoint that will be using the credentials + * @errp: pointer to a NULL-initialized error object * * Check whether the credentials is setup according to * the type of @endpoint argument. diff --git a/include/crypto/tlssession.h b/include/crypto/tlssession.h index 657a2c05521..2fb0bb02d9f 100644 --- a/include/crypto/tlssession.h +++ b/include/crypto/tlssession.h @@ -166,6 +166,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(QCryptoTLSSession, qcrypto_tls_session_free) * qcrypto_tls_session_check_role: * @creds: pointer to a TLS credentials object * @endpoint: role of the TLS session, client or server + * @errp: pointer to a NULL-initialized error object * * Check whether the session object operates according to * the role of the @endpoint argument.