From nobody Sun Feb 8 17:47:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1583771061; cv=none; d=zohomail.com; s=zohoarc; b=YqvvnQwgp7IiF3LBZsfwS1kwDJAIyjZ8ZoMeIlluyInPgAeYIYVukbnZQaT1VonWcLc/kIzuVmSc5yyGr4glOjXjWh43ly72luvz8M7WunT/bh5aV3efGZUrfaA8MqDWo+FWG0vEmwwsND9zauZnewsGMZKkKy09G3ptPNQykrA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583771061; 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=uEFEvItGDMUflTjohp8Fvl3cVCQQAPDC/enskYYaEy0=; b=hjovZUolRqEEiiXKc+pcApFZevntZydMszUjt65taXtOKNiiidmD3C8WaQreFGaLVn+6tAaBVrDdYTSsSdyRkkOS9mK2vtMInWb+OjNZinVzOtn45JJ3nmm2onCO5Wwe5rvYtqlXDkUyBjvq2mhe78tlyOFu777g4MEspwxwvT8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1583771061469125.16012370782198; Mon, 9 Mar 2020 09:24:21 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-421-uj8J7skMOQuQHowgpD2upQ-1; Mon, 09 Mar 2020 12:24:17 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 087B7800D5A; Mon, 9 Mar 2020 16:24:10 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D2C4C5DA83; Mon, 9 Mar 2020 16:24:09 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 7A3A786A29; Mon, 9 Mar 2020 16:24:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 029GNj0A020975 for ; Mon, 9 Mar 2020 12:23:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id 71AC690A03; Mon, 9 Mar 2020 16:23:45 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id ECCE390779 for ; Mon, 9 Mar 2020 16:23:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583771060; 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=uEFEvItGDMUflTjohp8Fvl3cVCQQAPDC/enskYYaEy0=; b=GJNLygZkuPPFt4vxGLu/cy8EEVO5hQ5s/if26U56Df0jZpezTroqC0rBKqiQdGzc5fR7dB FeQJd4rcTukRKJKAL6sgwYIXTuuQEpHlYmLPfF5kIe99t4hS4tWYwpTi3d2Tt+9BprIhis kBLJhJWOk0K4p76I8gkGzL4M1AcggI4= X-MC-Unique: uj8J7skMOQuQHowgpD2upQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 30/30] qemu: Pass through arguments of 'ssh' block driver used by libguestfs Date: Mon, 9 Mar 2020 17:23:10 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" We currently don't model the 'ssh' protocol properties properly and since it seems impossible for now (agent path passed via environment variable). To allow libguestfs to work as it used in pre-blockdev era we must carry the properties over to the command line. For this instance we just store it internally and format it back. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_block.c | 10 ++++++++++ src/util/virstoragefile.c | 13 +++++++++++++ src/util/virstoragefile.h | 5 +++++ tests/qemublocktest.c | 1 + .../jsontojson/ssh-passthrough-libguestfs-in.json | 1 + .../jsontojson/ssh-passthrough-libguestfs-out.json | 14 ++++++++++++++ 6 files changed, 44 insertions(+) create mode 100644 tests/qemublocktestdata/jsontojson/ssh-passthrough-libg= uestfs-in.json create mode 100644 tests/qemublocktestdata/jsontojson/ssh-passthrough-libg= uestfs-out.json diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index f64bd8254b..5ddf7f1f7c 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -911,6 +911,7 @@ qemuBlockStorageSourceGetSshProps(virStorageSourcePtr s= rc) g_autoptr(virJSONValue) serverprops =3D NULL; virJSONValuePtr ret =3D NULL; const char *username =3D NULL; + g_autoptr(virJSONValue) host_key_check =3D NULL; if (src->nhosts !=3D 1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -924,11 +925,20 @@ qemuBlockStorageSourceGetSshProps(virStorageSourcePtr= src) if (src->auth) username =3D src->auth->username; + else if (src->ssh_user) + username =3D src->ssh_user; + + if (src->ssh_host_key_check_disabled && + virJSONValueObjectCreate(&host_key_check, + "s:mode", "none", + NULL) < 0) + return NULL; if (virJSONValueObjectCreate(&ret, "s:path", src->path, "a:server", &serverprops, "S:user", username, + "A:host-key-check", &host_key_check, NULL) < 0) return NULL; diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index a85b95fd09..e4235316d8 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2464,6 +2464,10 @@ virStorageSourceCopy(const virStorageSource *src, return NULL; } + /* ssh config passthrough for libguestfs */ + def->ssh_host_key_check_disabled =3D src->ssh_host_key_check_disabled; + def->ssh_user =3D g_strdup(src->ssh_user); + return g_steal_pointer(&def); } @@ -2705,6 +2709,8 @@ virStorageSourceClear(virStorageSourcePtr def) VIR_FREE(def->tlsAlias); VIR_FREE(def->tlsCertdir); + VIR_FREE(def->ssh_user); + virStorageSourceInitiatorClear(&def->initiator); /* clear everything except the class header as the object APIs @@ -3635,6 +3641,8 @@ virStorageSourceParseBackingJSONSSH(virStorageSourceP= tr src, const char *path =3D virJSONValueObjectGetString(json, "path"); const char *host =3D virJSONValueObjectGetString(json, "host"); const char *port =3D virJSONValueObjectGetString(json, "port"); + const char *user =3D virJSONValueObjectGetString(json, "user"); + const char *host_key_check =3D virJSONValueObjectGetString(json, "host= _key_check"); virJSONValuePtr server =3D virJSONValueObjectGetObject(json, "server"); if (!(host || server) || !path) { @@ -3665,6 +3673,11 @@ virStorageSourceParseBackingJSONSSH(virStorageSource= Ptr src, return -1; } + /* these two are parsed just to be passed back as we don't model them = yet */ + src->ssh_user =3D g_strdup(user); + if (STREQ_NULLABLE(host_key_check, "no")) + src->ssh_host_key_check_disabled =3D true; + return 0; } diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index dd2186c4ff..f2a73feb6a 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -384,6 +384,11 @@ struct _virStorageSource { as a source for floppy drive */ bool hostcdrom; /* backing device is a cdrom */ + + /* passthrough variables for the ssh driver which we don't handle prop= erly */ + /* these must not be used apart from formatting the output JSON in the= qemu driver */ + char *ssh_user; + bool ssh_host_key_check_disabled; }; G_DEFINE_AUTOPTR_CLEANUP_FUNC(virStorageSource, virObjectUnref); diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index ec32d28188..7a2204787e 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -1136,6 +1136,7 @@ mymain(void) jsontojsondata.schemaroot =3D qmp_schemaroot_x86_64_blockdev_add; TEST_JSON_TO_JSON("curl-libguestfs"); + TEST_JSON_TO_JSON("ssh-passthrough-libguestfs"); #define TEST_IMAGE_CREATE(testname, testbacking) \ do { \ diff --git a/tests/qemublocktestdata/jsontojson/ssh-passthrough-libguestfs-= in.json b/tests/qemublocktestdata/jsontojson/ssh-passthrough-libguestfs-in.= json new file mode 100644 index 0000000000..da8fedef07 --- /dev/null +++ b/tests/qemublocktestdata/jsontojson/ssh-passthrough-libguestfs-in.json @@ -0,0 +1 @@ +json:{"file.driver":"ssh","file.user":"testuser","file.host":"random.host"= ,"file.port":1234,"file.path":"somewhere/something","file.host_key_check":"= no"} diff --git a/tests/qemublocktestdata/jsontojson/ssh-passthrough-libguestfs-= out.json b/tests/qemublocktestdata/jsontojson/ssh-passthrough-libguestfs-ou= t.json new file mode 100644 index 0000000000..1f6032deb4 --- /dev/null +++ b/tests/qemublocktestdata/jsontojson/ssh-passthrough-libguestfs-out.json @@ -0,0 +1,14 @@ +{ + "driver": "ssh", + "path": "somewhere/something", + "server": { + "host": "random.host", + "port": "22" + }, + "user": "testuser", + "host-key-check": { + "mode": "none" + }, + "auto-read-only": true, + "discard": "unmap" +} --=20 2.24.1