Commit Graph

302 Commits

Author SHA1 Message Date
Jarek Kobus
44c7020651 ProcessInterface: Get rid of state() method
This is fully controlled by QtcProcess itself, so provide
general implementation of state() inside QtcProcess.

Task-number: QTCREATORBUG-27358
Change-Id: Id6f0b771ed933f870b80d6856c6d94896f946516
Reviewed-by: hjk <hjk@qt.io>
2022-04-14 13:49:25 +00:00
Jarek Kobus
936c44f367 Introduce ProcessResultData
It should be useful when reimplementing ProcessInterface.
It replaces 4 virtual methods with just 1.

Task-number: QTCREATORBUG-27358
Change-Id: I2dafbfbc25f8f016ff2aa19c1a176335a4a7498c
Reviewed-by: hjk <hjk@qt.io>
2022-04-11 06:51:51 +00:00
Jarek Kobus
a6fc7727a1 Get rid of SftpSession
Should be substituted by FilePath actions using remote paths.

Change-Id: Ib1e3913cc94d417045cbe6b922284a2f8ab6d71f
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2022-04-08 15:12:22 +00:00
Jarek Kobus
5715d433f4 Get rid of SftpFileSystemModel
It's being replaced with DeviceFileSystemModel.

Change-Id: I062f2a873ecede9755527e8ee7b8b4d578289c4b
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2022-04-08 11:50:15 +00:00
Jarek Kobus
484ea3ecc9 QtcSsh: Connect to QtcProcess::done() signal
Instead of connecting to errorOccurred() and finished() signals.

Change-Id: I113f51564501a67725afee77ab4d20e5d954a7c0
Reviewed-by: hjk <hjk@qt.io>
2022-04-05 14:20:38 +00:00
Jarek Kobus
4093fbe826 Don't delete process directly from process' finished handler
AbstractProcessStep::slotProcessFinished() slot is connected
to m_process finished() signal. We call there
AbstractProcessStep::Private::cleanUp(), and that calls
m_process.reset(), so it invokes m_process d'tor directly.

SshRemoteProcessRunner::handleProcessFinished() slot is
connected to d->m_process finished() signal. We call there
SshRemoteProcessRunner::setState(), and that calls
d->m_process.reset(), so it invokes m_process d'tor directly.

Delete later m_process instead in both cases.

Change-Id: I4a0f2a631b676b57e8bcc3a7878620bc76dc74de
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-04-05 12:41:26 +00:00
Jarek Kobus
ab11c4373b QtcProcess: Introduce done() signal
Introduce QtcProcess::done() signal. It's similar to
QtcProcess::finished() signal, but also emitted when
process failed to start (so after QProcess::FailedToStart
error occurred).

SshRemoteProcess::finished() signal was already behaving
like this. So, we remove special handling of
FailedToStart error in this class and connect all clients
of SshRemoteProcess to done() signal, instead of finished().

Task-number: QTCREATORBUG-27232
Change-Id: If4240e2172f3f706e812bca669a1d5b24bdc3285
Reviewed-by: hjk <hjk@qt.io>
2022-04-04 13:28:12 +00:00
Jarek Kobus
365a05640b QtcProcess: Get rid of setErrorString() method
It's internal method, not meant to be used outside.
It's only used in case of FailedToStart error.
Remove it also from ProcessInterface.
Leave it inside DefaultImpl and its subclasses only.

Remove m_errorString field from ProcessSetupData.

Change-Id: Ie605b95c2ff605ab1259045f1a5b16049207c1d3
Reviewed-by: hjk <hjk@qt.io>
2022-04-04 10:20:34 +00:00
Jarek Kobus
a3c531c2a3 SshRemoteProcessRunner: Get rid of no-op call to QtcProcess::terminate()
Calling QtcProcess::terminate() after disconecting from
process signals is a task for implicit ProcessReaper.
Delete the process instead.

Change-Id: I02d9b892125b1a1053aefe8edbc7bc96bac41381
Reviewed-by: hjk <hjk@qt.io>
2022-03-31 10:30:00 +00:00
Eike Ziller
b6f679d777 Merge remote-tracking branch 'origin/7.0'
Conflicts:
	src/plugins/webassembly/webassemblytoolchain.cpp

Change-Id: Ia75c783e3ecab1f97de2b5c73a0979c49da82009
2022-03-18 16:07:51 +01:00
Jarek Kobus
7c39617324 Make the setup info visually more noticeable
By adding two leading newlines we separate it nicely
from the other part of the test log.

Amends 66c5b1e11e

Change-Id: Ic260cdc4cc2421ddb04bc5027082521800b268e8
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-03-18 08:55:42 +00:00
Eike Ziller
9fd2a059f6 Merge remote-tracking branch 'origin/7.0'
Conflicts:
	src/plugins/android/androiddevice.cpp
	src/plugins/docker/dockerdevice.cpp

Change-Id: Id16ba0d9993c9f608242622aceae0a2a6691e05e
2022-03-17 08:48:28 +01:00
Christian Stenger
66c5b1e11e RemoteLinux: Avoid unexpected password dialog in tests
Make the test depend on environment variables and give some
hint how to run the test correctly.
Beside this make the test work on Windows and share the setup
with ssh unit test.

Change-Id: I6bbf1ec863449512646ca2c51d13fec537beedbc
Reviewed-by: hjk <hjk@qt.io>
2022-03-16 16:44:27 +00:00
Jarek Kobus
14d39b871d SshRemoteProcess: Add missing override
At some point QtcProcess::start() started to be virtual,
so the intention is that SshRemoteProcess overrides it.

Amends 95c9579c58

Change-Id: Iff0c0984f07440c58c5f89a0f5e188503756d6d0
Reviewed-by: hjk <hjk@qt.io>
2022-03-02 11:39:22 +00:00
Jarek Kobus
87154986d2 SshRemoteProcessRunner: Remove unimplemented method
Change-Id: I4c075da36bc4f50a35692fd1ae2a61504954a05d
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-03-02 09:52:57 +00:00
Jarek Kobus
53095f666f SshRemoteProcessRunner: Unify API
Make the API more similar to QtcProcess API.
Rename signals to started() and finished().

Change-Id: I01f3a148749b666b8f145d8769222a234ccc9bce
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-03-02 09:52:47 +00:00
Jarek Kobus
b5cf3186a3 SshRemoteProcessRunner: Drop error string from processClosed()
Change-Id: I3d05fb253944d6fa47854693aa4ee21d36b35a32
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-03-02 09:52:33 +00:00
Jarek Kobus
d3c1632a0f SshRemoteProcessRunner: Unify API
Make the API more similar to QtcProcess API.
Drop process prefix for getters.

Change-Id: I21b99bb5b11956d923c0e526c08bbea9686e5c95
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-02 09:52:09 +00:00
Jarek Kobus
0dfcc97a3e SshRemoteProcess: Rename done() -> finished()
Change-Id: I9c22d075f50b0a2a171cbda11c7579e4735f3f4e
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-02-28 16:12:27 +00:00
Jarek Kobus
7b5dfcd6cd SshRemoteProcess: Get rid of error arg from done() signal
Prepare for signal rename done() -> finished().

Change-Id: I81a7bd0a4826ce6200f4af47ba5868ceedb42206
Reviewed-by: hjk <hjk@qt.io>
2022-02-28 14:21:47 +00:00
Jarek Kobus
1cb4017e71 SshRemoteProcessRunner: Don't buffer stdOut and stdErr
It's already being buffered inside SshRemoteProcess.

Change-Id: Iaee7e9f04f93196a1016d0e2d55a17ee88d35530
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-02-25 18:35:30 +00:00
Jarek Kobus
098e3794db Get rid of SshProcess (one process class less)
Introduce static SshRemoteProcess::setupSshEnvironment()
method instead.

Change-Id: I9a49bc68bd96ddf0f58234d28b92a721f7d4bb56
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-21 16:17:31 +00:00
Jarek Kobus
97264e0591 Ssh: Drop ProcessMode from c'tors and creator methods
Change-Id: I2db51f26d9a841f60d5ab3722fa82b3a89d57146
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2022-02-18 10:49:29 +00:00
Jarek Kobus
7a45f7f01f Make SshSettings thread safe
Change-Id: Iac07ee51574c348a22c6a966eb2113c53402b88d
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-15 09:17:08 +00:00
hjk
e2cb64471a Utils: Move QtcProcess constructor setup data to shared setup data
This includes replacing DeviceProcess terminal handling with base
member.

Change-Id: Id1541bfce33c71dddc71b4816ad0b174dce3879c
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-02-11 17:33:48 +00:00
Eike Ziller
fcb8d3b2a4 Merge remote-tracking branch 'origin/7.0'
Conflicts:
	src/plugins/qmldesigner/components/itemlibrary/itemlibraryview.cpp

Change-Id: Icda34067bb89d066a3e7eb47f8cca1d62dc3ae0d
2022-02-11 11:20:13 +01:00
Jarek Kobus
072750a284 Fix crash reporting in output pane when remote run in terminal
Fixes: QTCREATORBUG-27007
Change-Id: I6e409eb6489530dc6c48c90d20e28ff019eff187
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-02-09 12:34:57 +00:00
Eike Ziller
68fd73713b Merge remote-tracking branch 'origin/7.0'
Change-Id: I967615c66a11bb4823a6b403ca59e63dd1971032
2022-02-07 16:34:41 +01:00
Jarek Kobus
f5b946abbe LinuxDevice: Implement runProcess()
Change-Id: I5300d36119ffb9fdd82a2ba7e02f76edc0fe2eda
Reviewed-by: hjk <hjk@qt.io>
2022-02-03 14:20:18 +00:00
Eike Ziller
116b498b34 Merge remote-tracking branch 'origin/7.0'
Conflicts:
	src/libs/ssh/sshremoteprocessrunner.h

Change-Id: I4ce088c68704845ec8ec6feaad10bf747e415bec
2022-01-28 14:59:08 +01:00
Jarek Kobus
dd527a3890 SshRemoteProcessRunner: Remove unused command() method
Change-Id: If45ea80b892cb683aa3737dd73244fa4b669abc4
Reviewed-by: hjk <hjk@qt.io>
2022-01-28 12:26:01 +00:00
Jarek Kobus
1d15a934cd QtcProcess: Get rid of useTerminal
Remove SshRemoteProcessRunner::runInTerminal() method,
it wasn't used anywhere (just in test).
Remove QtcProcess::useTerminal, as process should be
created in TerminalOn mode when there is a need for terminal.
Add a parameter to
SshRemoteProcess::fullLocalCommandLine(bool inTerminal)
as this may still be needed when running application
through ssh from terminal (ssh -tt option).

Change-Id: I71911082fcca190b82a1106a2ca1ca48dc5d4c79
Reviewed-by: hjk <hjk@qt.io>
(cherry picked from commit 95a9b22f6f)
2022-01-28 12:19:12 +00:00
Jarek Kobus
95a9b22f6f QtcProcess: Get rid of useTerminal
Remove SshRemoteProcessRunner::runInTerminal() method,
it wasn't used anywhere (just in test).
Remove QtcProcess::useTerminal, as process should be
created in TerminalOn mode when there is a need for terminal.
Add a parameter to
SshRemoteProcess::fullLocalCommandLine(bool inTerminal)
as this may still be needed when running application
through ssh from terminal (ssh -tt option).

Change-Id: I71911082fcca190b82a1106a2ca1ca48dc5d4c79
Reviewed-by: hjk <hjk@qt.io>
2022-01-28 11:56:30 +00:00
Alexander Drozdov
5c53dc5e13 Ssh: fix crash on freed memory access
At the cleanup() method we must remove connection from the m_connection
list to avoid access to the freed memory from the
removeInactiveConnections() that caused Qt Creator crash.

Change-Id: I8195f05e903819e3e3b48b2f72fd71047c5a1636
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-01-28 09:46:22 +00:00
Eike Ziller
9d8a419d10 Remove qmake build files
Removes qmake as a build system for building Qt Creator itself.
Keep them for some tests that are not completely moved to CMake yet.

Change-Id: I846c6ef65626b6dfae6375fdc85d00677aa8c2fb
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-01-20 12:18:15 +00:00
Jarek Kobus
37718e3874 Refactor SshConnectionManager internals
It makes it easier to manage just one hash of connections
instead of 3 lists.

Change-Id: Id6a3661d8dfdb0bd269e35ece36410bd2477e5c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-01-12 21:03:31 +00:00
Jarek Kobus
75df106c37 Remove unused method declaration
Amends 20d19aa5bf

Change-Id: I8231a331d1200a82f88b96fb703b9e2945efad1d
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-01-04 13:12:08 +00:00
hjk
20d19aa5bf RemoteLinux: Implement some of the remote file API
Implementation of remote file API for correct FilePath
work with RemoteLinux.
Added tests for this functionality

Run ssh shell in separate thread.
The linux device instance keeps its own thread for running
SshRemoteProcess. In this way all calls to filepath
interface of linux device coming from different threads
are executed in one thread (SshRemoteProcess is reentrant,
but not thread safe). The redirection to the device thread
is done by invoking SshRemoteProcess' methods through
BlockingQueuedConnection.

Done-by: Artem Sokolovskii
Change-Id: Id8756738d3a4597f175c8ef000c148d0c8536eeb
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-01-04 11:16:14 +00:00
hjk
bf00252a34 Ssh: Simplify SshRemoteProcess interface a bit
Change-Id: I6871b16c05172d6b705f666c7962dd82320c6e8f
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-01-03 12:48:23 +00:00
hjk
a68f2b48ac Ssh: Drop unneeded #include in sshprocess.cpp
Change-Id: Ibea173e81dc515e55d2a15be3c794016b6a49b99
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-01-03 12:45:57 +00:00
Jarek Kobus
34ada7c1ff SshConnection: Remove unneeded includes
Change-Id: I03bc01ca1f9143bc0aa1574957bc30112d07a8dd
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2022-01-03 12:34:33 +00:00
Jarek Kobus
ee2960989e Remove unused SshConnection::dataAvailable() signal
Change-Id: I1e12965931a7623ed03d0e703b275eb02ddaf6c7
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-01-03 12:34:24 +00:00
Jarek Kobus
04362afed2 Make connParams a const member
Change-Id: I1dc75414766b9ec6c16a1c7080878da51310863c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2022-01-03 12:34:03 +00:00
Jarek Kobus
464e12f5e1 Get rid of Utils::FileSystemWatcher from SshConnection
When we are starting master process for ssh (-M option specified)
we don't know whether everything went fine, since the process
just starts and doesn't print anything to the output in case
all went fine. It may also happen that when there are issues
the master process finishes soon after it was started.
When everything went fine the master process should create
a socket (specified by ControlPath option). But when we
receive a started() signal from the process, the socket
isn't yet ready. So, in order to detect that connection was
established properly, the old implementation created a
FileSystemWatcher on the expected socket file to appear.

There are 2 issues with the approach above:
1. There might be a race condition inside the started()
   handler of the master process. After checking that
   the expected socket isn't created yet and before setting
   up the file system watcher, the socket file could have
   been created in meantime what wouldn't be noticed.
2. The use of Utils::FileSystemWatcher excludes the usage
   in non-main threads. Thus in general: usage of SshConnection
   outside of main thread is dangerous.

This patch implements it in a different way. Instead of
installing a file system watcher we make use of local command
of ssh master process. We enable it by "PermitLocalCommand=yes"
and specify a local command by "LocalCommand=echo". This means
that local command will be executed after successfully connecting
to the server. Our command is very simple - just empty echo,
which means that we should expect the "\n" on master process
output after successful run. So, instead of connecting to
started() signal we are connected to readyReadStandardOutput()
and detect successful connection after receiving newline char.

This eliminates both issues with the old approach and makes a
step towards thread safe shared ssh connections.

Change-Id: I2e20c82aeff09b297e3cad5644d4d2c956db82d0
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-12-15 20:03:14 +00:00
hjk
8cb5c3cfdd Ssh: Use base QtcProcess' useTerminal for SshRemoteProcess
Still trying to ramp down non-QtcProcess interfaces.

Change-Id: I6b4ae6788f5021959ff3eb35bbade2157a6d67fa
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2021-12-06 15:30:00 +00:00
hjk
e64ce914f9 Utils/Ssh: Move SshRemoteProces::isRunning() to QtcProcess base
... and use it on a few places.

Change-Id: Id2cea709e355a46821a720e593740ac032888ced
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2021-12-06 13:44:23 +00:00
Jarek Kobus
d4ddd6754d Remove unused SshRemoteProcessRunner::writeDataToProcess()
Change-Id: Ib07c7c9cd19b498f84382d2c9c11b927533e4d85
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-11-17 14:01:52 +00:00
Jarek Kobus
a5318cba79 Use QtcProcess in SshConnection::connectionInfo()
Change-Id: Ibc0966ee43266d5d0f5f4f71274f11a4150eab3b
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-11-05 10:39:09 +00:00
Jarek Kobus
9e8b838080 Use QtcProcess for ssh key gen
Change-Id: I5a1ddf7f6773467c57571fe385fc1969e347c582
Reviewed-by: hjk <hjk@qt.io>
2021-11-05 08:50:26 +00:00
Eike Ziller
050af56000 Merge remote-tracking branch 'origin/6.0'
Change-Id: If773f217a9708ce0ad0b8adeefe3266ba0371a32
2021-09-29 12:54:38 +02:00