From nobody Mon Feb 9 19:52:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636696071; cv=none; d=zohomail.com; s=zohoarc; b=blNPS402hKcKFeHVS2q0gqTxDkrd3kPm82Q/Boz47nFqXNlvfmD9GMZcEnjjAHx8spEvCWIApR6R5tKhxSTFfl6rqBMQEldMt+sS1pPdDk2xe71ZGrdeMUYcbDWxOf+EyoCFM9sCGSxksoDeFHAoo5qr5dFDI6xBahWvWW33d0g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636696071; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4OkdTiv3J2pePe4KSIQPKnUIrz83JJ+uC2UUHOjg05k=; b=Gtd5jj+RKRW4Xbn4Hh283OelZ2M1bKo7VFZjQeMzgaUHqFWjRp3i4Fuvxj1JhADlXS0LdGVLEWEWLHWlY11Td6JnfpKjzKj4AXs4GaXYnc16ZEpjRykjASu5bxI/nVN3WibGrndjDvl+julRiq8oOoZQnJd1d+WGE5et3uZl0W4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1636696071610505.48530729909226; Thu, 11 Nov 2021 21:47:51 -0800 (PST) Received: from localhost ([::1]:59600 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mlPPi-0008GI-KK for importer@patchew.org; Fri, 12 Nov 2021 00:47:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58030) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlPHg-0006JT-Mx for qemu-devel@nongnu.org; Fri, 12 Nov 2021 00:39:34 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:31203) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlPHe-0005PB-R9 for qemu-devel@nongnu.org; Fri, 12 Nov 2021 00:39:32 -0500 Received: from mail-ua1-f71.google.com (mail-ua1-f71.google.com [209.85.222.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-8-MRNyESCHM2a421lrb8JJZA-1; Fri, 12 Nov 2021 00:39:28 -0500 Received: by mail-ua1-f71.google.com with SMTP id 43-20020a9f25ae000000b002cf28d7afd2so4183118uaf.3 for ; Thu, 11 Nov 2021 21:39:28 -0800 (PST) Received: from LeoBras.redhat.com ([2804:431:c7f0:7e14:3b94:fb27:f0ad:a824]) by smtp.gmail.com with ESMTPSA id r2sm1465280vsk.28.2021.11.11.21.39.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Nov 2021 21:39:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636695570; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4OkdTiv3J2pePe4KSIQPKnUIrz83JJ+uC2UUHOjg05k=; b=ZmlBTHdkL/v2Vxb6iaGwwgi4jPyXYJMv/zqacJlvJpgge0NyvuBK07NL5sRr4gEShyGJ+8 i6FzCHLKu2+VHzasay4ssX9fypzgcOa/JW4mH+HcK10ty6n+lY4IQswiaCwrCQY/wO+LvR fkxbsqWAsEQve6YZkShA/GOlYbffiJo= X-MC-Unique: MRNyESCHM2a421lrb8JJZA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4OkdTiv3J2pePe4KSIQPKnUIrz83JJ+uC2UUHOjg05k=; b=nb158R0dI1Gb1g3zy1FRaI7U7NU6A9AYIw+Aa+6eO8Zob4DcloqtcprqYBHXzd6e6S liZUKLC4sxzKla1eH/nIAXJ8Af77BH1/jtgq7XfQLqcFjYYif0aX+6LPw5bHX/cCdecq q4suLaveUoDShi0Zgynzsb9v8PwGOCaDkumFXIixc5UXsBJx4ytwIMlP/RefgNxsrKgR 3/72Y8vfViK1pmpAJwPRkL75WNxstRVmk8X5SrFrIB3/EEjtIbeIi9RZ2J/AQLwA0m3O 834m8mN8owZYXxW2ot2qtuicP/xy2N8NGpq7GUMI45nP6J5MuQ4oQABeGtAdoWl/BWPE 2rhg== X-Gm-Message-State: AOAM533gVqMcRPP4b4pRaR5F17atAh93fJ8B+RqqZVZvZU13FT4aqOE7 ky2jpLzmlVnDVfokA/wOXkNGCnQrq8ojTjCdZuFOz2z+x6KWnDDMgJPBucnziZTztEhjDlqhLBC 1HsmF9V+jliKGeGs= X-Received: by 2002:a05:6122:786:: with SMTP id k6mr19107150vkr.26.1636695568229; Thu, 11 Nov 2021 21:39:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJy8Jq0LncCxfT3WHoaFZKob17ghs9HYBjcql7gnurGZwyif0CGjOpFr05eK+kTkuk3KHRzg3w== X-Received: by 2002:a05:6122:786:: with SMTP id k6mr19107121vkr.26.1636695568074; Thu, 11 Nov 2021 21:39:28 -0800 (PST) From: Leonardo Bras To: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster Subject: [PATCH v5 5/6] migration: Add migrate_use_tls() helper Date: Fri, 12 Nov 2021 02:10:40 -0300 Message-Id: <20211112051040.923746-6-leobras@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211112051040.923746-1-leobras@redhat.com> References: <20211112051040.923746-1-leobras@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=leobras@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=leobras@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Leonardo Bras , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636696072533100001 Content-Type: text/plain; charset="utf-8" A lot of places check parameters.tls_creds in order to evaluate if TLS is in use, and sometimes call migrate_get_current() just for that test. Add new helper function migrate_use_tls() in order to simplify testing for TLS usage. Signed-off-by: Leonardo Bras Reviewed-by: Juan Quintela --- migration/migration.h | 1 + migration/channel.c | 6 +++--- migration/migration.c | 9 +++++++++ migration/multifd.c | 5 +---- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/migration/migration.h b/migration/migration.h index e61ef81f26..9f38419312 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -344,6 +344,7 @@ int migrate_use_zerocopy(void); #else #define migrate_use_zerocopy() (0) #endif +int migrate_use_tls(void); int migrate_use_xbzrle(void); uint64_t migrate_xbzrle_cache_size(void); bool migrate_colo_enabled(void); diff --git a/migration/channel.c b/migration/channel.c index c4fc000a1a..1a45b75d29 100644 --- a/migration/channel.c +++ b/migration/channel.c @@ -32,16 +32,16 @@ */ void migration_channel_process_incoming(QIOChannel *ioc) { - MigrationState *s =3D migrate_get_current(); Error *local_err =3D NULL; =20 trace_migration_set_incoming_channel( ioc, object_get_typename(OBJECT(ioc))); =20 - if (s->parameters.tls_creds && - *s->parameters.tls_creds && + if (migrate_use_tls() && !object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_TLS)) { + MigrationState *s =3D migrate_get_current(); + migration_tls_channel_process_incoming(s, ioc, &local_err); } else { migration_ioc_register_yank(ioc); diff --git a/migration/migration.c b/migration/migration.c index add3dabc56..20ca99d726 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2565,6 +2565,15 @@ int migrate_use_zerocopy(void) } #endif =20 +int migrate_use_tls(void) +{ + MigrationState *s; + + s =3D migrate_get_current(); + + return s->parameters.tls_creds && *s->parameters.tls_creds; +} + int migrate_use_xbzrle(void) { MigrationState *s; diff --git a/migration/multifd.c b/migration/multifd.c index ab8f0f97be..3d9dc8cb58 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -794,14 +794,11 @@ static bool multifd_channel_connect(MultiFDSendParams= *p, QIOChannel *ioc, Error *error) { - MigrationState *s =3D migrate_get_current(); - trace_multifd_set_outgoing_channel( ioc, object_get_typename(OBJECT(ioc)), p->tls_hostname, error); =20 if (!error) { - if (s->parameters.tls_creds && - *s->parameters.tls_creds && + if (migrate_use_tls() && !object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_TLS)) { multifd_tls_channel_connect(p, ioc, &error); --=20 2.33.1