diff --git a/src/utils/qemu.c b/src/utils/qemu.c index 777ea997d..f2179c806 100644 --- a/src/utils/qemu.c +++ b/src/utils/qemu.c @@ -42,19 +42,26 @@ int pg_util_cmdloop(const char *cmd, int timeout_s) int pg_util_ssh(const char *host, int port, const char *key_path, - const char *cmd) + const char *cmd, ...) { gchar *ssh_cmd; gint status; + va_list args; + char *c; + + va_start(args, cmd); + c = g_strdup_vprintf(cmd, args); + va_end(args); ssh_cmd = g_strdup_printf("%s%s%s%s%s%s%u%s%s%s", "ssh ", host, " -l root -q", " -i ", key_path, " -p ", port, " -oConnectTimeout=1", - " -oStrictHostKeyChecking=no ", cmd); + " -oStrictHostKeyChecking=no ", c); g_spawn_command_line_sync(ssh_cmd, NULL, NULL, &status, NULL); g_free(ssh_cmd); + g_free(c); return g_spawn_check_exit_status(status, NULL) ? 0 : -1; } diff --git a/src/utils/qemu.h b/src/utils/qemu.h index 860e85e70..9783ca29c 100644 --- a/src/utils/qemu.h +++ b/src/utils/qemu.h @@ -25,7 +25,8 @@ int pg_util_cmdloop(const char *cmd, int timeout_s); int pg_util_ssh(const char *host, int port, const char *key_path, - const char *cmd); + const char *cmd, ...) +__attribute__((__format__(__printf__, 4, 5))); int pg_util_spawn_qemu(const char *socket_path_0, const char *socket_path_1,