migration: Create migrate_tls_creds() function

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>

---

Moved the type to const char * (vladimir)
This commit is contained in:
Juan Quintela 2023-03-02 12:17:06 +01:00
parent b1a8795654
commit d5c3e1959c
3 changed files with 12 additions and 5 deletions

View File

@ -582,6 +582,13 @@ uint8_t migrate_throttle_trigger_threshold(void)
return s->parameters.throttle_trigger_threshold;
}
const char *migrate_tls_creds(void)
{
MigrationState *s = migrate_get_current();
return s->parameters.tls_creds;
}
uint64_t migrate_xbzrle_cache_size(void)
{
MigrationState *s = migrate_get_current();

View File

@ -80,6 +80,7 @@ MultiFDCompression migrate_multifd_compression(void);
int migrate_multifd_zlib_level(void);
int migrate_multifd_zstd_level(void);
uint8_t migrate_throttle_trigger_threshold(void);
const char *migrate_tls_creds(void);
uint64_t migrate_xbzrle_cache_size(void);
/* parameters setters */

View File

@ -34,20 +34,19 @@ migration_tls_get_creds(MigrationState *s,
Error **errp)
{
Object *creds;
const char *tls_creds = migrate_tls_creds();
QCryptoTLSCreds *ret;
creds = object_resolve_path_component(
object_get_objects_root(), s->parameters.tls_creds);
creds = object_resolve_path_component(object_get_objects_root(), tls_creds);
if (!creds) {
error_setg(errp, "No TLS credentials with id '%s'",
s->parameters.tls_creds);
error_setg(errp, "No TLS credentials with id '%s'", tls_creds);
return NULL;
}
ret = (QCryptoTLSCreds *)object_dynamic_cast(
creds, TYPE_QCRYPTO_TLS_CREDS);
if (!ret) {
error_setg(errp, "Object with id '%s' is not TLS credentials",
s->parameters.tls_creds);
tls_creds);
return NULL;
}
if (!qcrypto_tls_creds_check_endpoint(ret, endpoint, errp)) {