From nobody Tue Feb 10 11:55:41 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1674252308; cv=none; d=zohomail.com; s=zohoarc; b=I5iDvYAva6SruPdI03mLXAOnl/OUULx1MmLNbtzoV/FFzEmC8MVMLmDURnD/8O08oV5v5xabALivpfTTboQawaPTarBdkqBdYBarHJdZGfLhyFE3a8FAjPNzZJAEsK8TyAarO5oTBZxRgfBN1JXRYc6D2skbEi11+ZQ7nG0c2QM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674252308; h=Content-Type:Content-Transfer-Encoding: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=ZtK2ZUwAUPNXJNeJI49DvlG896PlhOPgeA4nztWoQ5k=; b=NHa6K19OIzp7BkMHOSP9pVw5p9APmJJkH+ZtME3XLXf2II5yv4g5nL/ybQ5vevi8TBYwGzSN6mB0CMPEM+38ThsAPGBvDY5Lb5XQkMOo3QkYYNs6J6hnvUDwsFUs9M+BksVrnITva0ycy7NQYEFxNFsSfMHTghgPFAyTjix9YJ8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1674252308770715.9441992402508; Fri, 20 Jan 2023 14:05:08 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-512-9hMR7WYPNqCGKBMKTTHgNA-1; Fri, 20 Jan 2023 17:03:52 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AD49287A9EC; Fri, 20 Jan 2023 22:03:35 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8DF4439D92; Fri, 20 Jan 2023 22:03:35 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1483D1946A78; Fri, 20 Jan 2023 22:03:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9964D1947040 for ; Fri, 20 Jan 2023 22:03:32 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7F70B14171C1; Fri, 20 Jan 2023 22:03:32 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.18.185]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5B12614171C0 for ; Fri, 20 Jan 2023 22:03:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674252307; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ZtK2ZUwAUPNXJNeJI49DvlG896PlhOPgeA4nztWoQ5k=; b=PPT89mmpr1FB/2HoTbUWTHaJzNl9olzVUatIUcXvor3xEMjCPnx2Ly2NqKHm8WGvV/WgLF pgWETiw7iw/V/XVI8uG6j3jOT/AP8q47i5ilqb2aAnAo7uTKqeWAzYEavCe5PgxFhhVhxB DNdTNKPJgFQCNKd0zgi+YYx70P6WcfY= X-MC-Unique: 9hMR7WYPNqCGKBMKTTHgNA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH v4 29/31] qemu: implement knownHosts for ssh disks with nbdkit Date: Fri, 20 Jan 2023 16:03:23 -0600 Message-Id: <20230120220325.1015090-30-jjongsma@redhat.com> In-Reply-To: <20230120220325.1015090-1-jjongsma@redhat.com> References: <20230120220325.1015090-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1674252310124100001 Content-Type: text/plain; charset="utf-8"; x-default="true" For ssh disks that are served by nbdkit, use the configured value for knownHosts and pass it to the nbdkit process. Signed-off-by: Jonathon Jongsma --- src/conf/domain_conf.c | 8 ++++++++ src/conf/storage_source_conf.c | 1 + src/conf/storage_source_conf.h | 2 ++ src/qemu/qemu_nbdkit.c | 3 +++ tests/qemunbdkitdata/disk-network-ssh-password.args.disk0 | 3 ++- tests/qemunbdkitdata/disk-network-ssh.args.disk0 | 3 ++- tests/qemuxml2argvdata/disk-network-ssh-password.xml | 1 + tests/qemuxml2argvdata/disk-network-ssh.xml | 1 + 8 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 45965fa0fa..f383bb8aaa 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7143,6 +7143,11 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, return -1; } } + if (src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_SSH && + (tmpnode =3D virXPathNode("./knownHosts", ctxt))) { + if (!(src->ssh_known_hosts_file =3D virXMLPropStringRequired(tmpno= de, "path"))) + return -1; + } =20 return 0; } @@ -21940,6 +21945,9 @@ virDomainDiskSourceFormatNetwork(virBuffer *attrBuf, =20 if (src->timeout) virBufferAsprintf(childBuf, "\n", src->= timeout); + + if (src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_SSH && src->ssh_know= n_hosts_file) + virBufferAsprintf(childBuf, "\n", src->ss= h_known_hosts_file); } =20 =20 diff --git a/src/conf/storage_source_conf.c b/src/conf/storage_source_conf.c index cecd7e811e..5d60c46cfc 100644 --- a/src/conf/storage_source_conf.c +++ b/src/conf/storage_source_conf.c @@ -1167,6 +1167,7 @@ virStorageSourceClear(virStorageSource *def) VIR_FREE(def->tlsHostname); =20 VIR_FREE(def->ssh_user); + VIR_FREE(def->ssh_known_hosts_file); =20 VIR_FREE(def->nfs_user); VIR_FREE(def->nfs_group); diff --git a/src/conf/storage_source_conf.h b/src/conf/storage_source_conf.h index 14a6825d54..a2d8b1f8bd 100644 --- a/src/conf/storage_source_conf.h +++ b/src/conf/storage_source_conf.h @@ -405,6 +405,8 @@ struct _virStorageSource { /* these must not be used apart from formatting the output JSON in the= qemu driver */ char *ssh_user; bool ssh_host_key_check_disabled; + /* additional ssh variables */ + char *ssh_known_hosts_file; =20 /* nfs_user and nfs_group store the strings passed in by the user for = NFS params. * nfs_uid and nfs_gid represent the converted/looked up ID numbers wh= ich are used diff --git a/src/qemu/qemu_nbdkit.c b/src/qemu/qemu_nbdkit.c index 39afad106a..4b10df6b7c 100644 --- a/src/qemu/qemu_nbdkit.c +++ b/src/qemu/qemu_nbdkit.c @@ -1110,6 +1110,9 @@ qemuNbdkitProcessBuildCommandSSH(qemuNbdkitProcess *p= roc, if (proc->source->ssh_host_key_check_disabled) virCommandAddArgPair(cmd, "verify-remote-host", "false"); =20 + if (proc->source->ssh_known_hosts_file) + virCommandAddArgPair(cmd, "known-hosts", proc->source->ssh_known_h= osts_file); + return 0; } =20 diff --git a/tests/qemunbdkitdata/disk-network-ssh-password.args.disk0 b/te= sts/qemunbdkitdata/disk-network-ssh-password.args.disk0 index 30711f7f07..ee2d7c3343 100644 --- a/tests/qemunbdkitdata/disk-network-ssh-password.args.disk0 +++ b/tests/qemunbdkitdata/disk-network-ssh-password.args.disk0 @@ -5,4 +5,5 @@ host=3Dexample.org \ port=3D2222 \ path=3Dtest2.img \ user=3Dtestuser \ -password=3D-777 +password=3D-777 \ +known-hosts=3D/path/to/knownhosts diff --git a/tests/qemunbdkitdata/disk-network-ssh.args.disk0 b/tests/qemun= bdkitdata/disk-network-ssh.args.disk0 index c04dc8bb03..481b218936 100644 --- a/tests/qemunbdkitdata/disk-network-ssh.args.disk0 +++ b/tests/qemunbdkitdata/disk-network-ssh.args.disk0 @@ -3,4 +3,5 @@ nbdkit \ --foreground ssh \ host=3Dexample.org \ port=3D2222 \ -path=3Dtest.img +path=3Dtest.img \ +known-hosts=3D/path/to/ssh_known_hosts diff --git a/tests/qemuxml2argvdata/disk-network-ssh-password.xml b/tests/q= emuxml2argvdata/disk-network-ssh-password.xml index 266acb761f..bdb4cf6e35 100644 --- a/tests/qemuxml2argvdata/disk-network-ssh-password.xml +++ b/tests/qemuxml2argvdata/disk-network-ssh-password.xml @@ -22,6 +22,7 @@ + diff --git a/tests/qemuxml2argvdata/disk-network-ssh.xml b/tests/qemuxml2ar= gvdata/disk-network-ssh.xml index 355add4fea..a3aeca0c99 100644 --- a/tests/qemuxml2argvdata/disk-network-ssh.xml +++ b/tests/qemuxml2argvdata/disk-network-ssh.xml @@ -19,6 +19,7 @@ + --=20 2.39.0