g_autoptr(virJSONValue) serverprops = NULL;
virJSONValuePtr ret = NULL;
const char *username = NULL;
+ g_autoptr(virJSONValue) host_key_check = NULL;
if (src->nhosts != 1) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
if (src->auth)
username = src->auth->username;
+ else if (src->ssh_user)
+ username = 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;
return NULL;
}
+ /* ssh config passthrough for libguestfs */
+ def->ssh_host_key_check_disabled = src->ssh_host_key_check_disabled;
+ def->ssh_user = g_strdup(src->ssh_user);
+
return g_steal_pointer(&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
const char *path = virJSONValueObjectGetString(json, "path");
const char *host = virJSONValueObjectGetString(json, "host");
const char *port = virJSONValueObjectGetString(json, "port");
+ const char *user = virJSONValueObjectGetString(json, "user");
+ const char *host_key_check = virJSONValueObjectGetString(json, "host_key_check");
virJSONValuePtr server = virJSONValueObjectGetObject(json, "server");
if (!(host || server) || !path) {
return -1;
}
+ /* these two are parsed just to be passed back as we don't model them yet */
+ src->ssh_user = g_strdup(user);
+ if (STREQ_NULLABLE(host_key_check, "no"))
+ src->ssh_host_key_check_disabled = true;
+
return 0;
}
as a source for floppy drive */
bool hostcdrom; /* backing device is a cdrom */
+
+ /* passthrough variables for the ssh driver which we don't handle properly */
+ /* 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);
jsontojsondata.schemaroot = 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 { \
--- /dev/null
+json:{"file.driver":"ssh","file.user":"testuser","file.host":"random.host","file.port":1234,"file.path":"somewhere/something","file.host_key_check":"no"}
--- /dev/null
+{
+ "driver": "ssh",
+ "path": "somewhere/something",
+ "server": {
+ "host": "random.host",
+ "port": "22"
+ },
+ "user": "testuser",
+ "host-key-check": {
+ "mode": "none"
+ },
+ "auto-read-only": true,
+ "discard": "unmap"
+}