From nobody Fri May 17 07:47:21 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1713537036550488.12375660770897; Fri, 19 Apr 2024 07:30:36 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 491161D45; Fri, 19 Apr 2024 10:30:35 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 5FE1E1D40; Fri, 19 Apr 2024 10:29:55 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1C6E91D41; Fri, 19 Apr 2024 10:29:52 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 26D031D3F for ; Fri, 19 Apr 2024 10:29:51 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-689-_VQCd-5UM_a9hFGt4OQVoQ-1; Fri, 19 Apr 2024 10:29:49 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2ADE529AA38D for ; Fri, 19 Apr 2024 14:29:49 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 93BC02166B32 for ; Fri, 19 Apr 2024 14:29:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: _VQCd-5UM_a9hFGt4OQVoQ-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH] qemu: migration: Don't use empty string for 'tls-hostname' NBD blockdev Date: Fri, 19 Apr 2024 16:29:47 +0200 Message-ID: <1b7ec30b22fcd2aa31602309ef516cc047a2eb9b.1713536987.git.pkrempa@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: 5TJCIKYKXHZD3CDJ2L4NOTYNFVNV7J2Q X-Message-ID-Hash: 5TJCIKYKXHZD3CDJ2L4NOTYNFVNV7J2Q X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1713537037354100001 While QEMU accepts and interprets an empty string in the tls-hostname field in migration parametes as if it's unset, the same does not apply for the 'tls-hostname' field when 'blockdev-add'-ing a NBD backend for non-shared storage migration. When libvirt sets up migation with TLS in 'qemuMigrationParamsEnableTLS' the QEMU_MIGRATION_PARAM_TLS_HOSTNAME migration parameter will be set to empty string in case when the 'hostname' argument is passed as NULL. Later on when setting up the NBD connections for non-shared storage migration 'qemuMigrationParamsGetTLSHostname', which fetches the value of the aforementioned TLS parameter. This bug was mostly latent until recently as libvirt used MIGRATION_DEST_CONNECT_HOST mode in most cases which required the hostname to be passed, thus the parameter was set properly. This changed with 8d693d79c40 for post-copy migration, where libvirt now instructs qemu to connect and thus passes NULL hostname to qemuMigrationParamsEnableTLS, which in turn causes libvirt to try to add NBD connection with empty string as tls-hostname resulting in: error: internal error: unable to execute QEMU command 'blockdev-add': Cer= tificate does not match the hostname To address this modify 'qemuMigrationParamsGetTLSHostname' to undo the weird semantics the migration code uses to handle TLS hostname and make it return NULL if the hostname is an empty string. Fixes: e8fa09d66bc Resolves: https://issues.redhat.com/browse/RHEL-32880 Signed-off-by: Peter Krempa Reviewed-by: Jiri Denemark --- src/qemu/qemu_migration_params.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index e955822f68..48f8657f71 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -1158,6 +1158,7 @@ qemuMigrationParamsEnableTLS(virQEMUDriver *driver, *tlsAlias) < 0) return -1; + /* QEMU interprets an empty string for hostname as if it is not popula= ted */ if (!migParams->params[QEMU_MIGRATION_PARAM_TLS_HOSTNAME].set && qemuMigrationParamsSetString(migParams, QEMU_MIGRATION_PARAM_TLS_HOSTNAME, @@ -1659,13 +1660,23 @@ qemuMigrationCapsGet(virDomainObj *vm, * @migParams: Migration params object * * Fetches the value of the QEMU_MIGRATION_PARAM_TLS_HOSTNAME parameter wh= ich is - * passed from the user as VIR_MIGRATE_PARAM_TLS_DESTINATION + * passed from the user as VIR_MIGRATE_PARAM_TLS_DESTINATION. + * + * In contrast with the migration parameter semantics, where an empty stri= ng + * is considered as if the hostname was not provided, this function will r= eturn + * NULL instead of an empty string as other parts of QEMU expect that the + * hostname is not provided at all. */ const char * qemuMigrationParamsGetTLSHostname(qemuMigrationParams *migParams) { + const char *hostname =3D migParams->params[QEMU_MIGRATION_PARAM_TLS_HO= STNAME].value.s; + if (!migParams->params[QEMU_MIGRATION_PARAM_TLS_HOSTNAME].set) return NULL; - return migParams->params[QEMU_MIGRATION_PARAM_TLS_HOSTNAME].value.s; + if (STREQ(hostname, "")) + return NULL; + + return hostname; } --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org