kdumptool: Separate process spawning from pipe loop

This will allow to create multiple processes and handle their outputs
independently.

This commit alone does not change behaviour.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Include drm drivers in the kdump initrd

This is necessary to get a usable fbcon device in the kdump environment.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Rename Process -> ProcessFilter

Process-related actions should be split off this class, but then what
should be the name of that process-only class? I'd like to call it
Process, but then the original class must be renamed.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Implement a SubProcess class

This is a relatively low-level interface to creating a process,
optionally with input/output redirections.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Add a unit test for class SubProcess

Yes, everything needs testing, of course.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Add DEBUG and TRACE messages to class SubProcess

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Rewrite ProcessFilter using class SubProcess

Use a separate object to deal with subprocesses.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
cleanup: Fix exception message in SubProcess::spawn()

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
cleanup: teach SubProcess::PipeInfo to take care of itself

Give this object a constructor and destructor, which makes it easier
to make sure that all file descriptors are closed once and only once.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
cleanup: do not depend on *_FILENO constants

These standard constants are used in code, but the fd initialisation loop
in fact depended on their numeric values. This was suboptimal.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Implement a MultiplexIO class around the poll() syscall

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Rewrite ProcessFilter using generic IO class

This allows to extend the implementation and cover other types of IO.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Move ProcessFilter::IO definitions to the header file

This way, derivative classes can be created outside of process.cc and
meaningfully use the public method setIO().

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
SubProcess: Create pipes with O_CLOEXEC

This way the pipes are closed automatically on exec(), and only the
destination file descriptors are passed to the child process.

This change has implications when another child is spawned from the
same parent, as there would be no way for the user of SubProcess to
close the parent ends of the previous child's pipes in the forked
process, but leave them open in the parent.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
SubProcess: implement file descriptor redirection

Make it possible to redirect a file descriptor in the child from an
already open file in the parent.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Store the file descriptor in ProcessFilter::IO

This is necessary to give it even more flexibility in handling the
SubProcess instance, while avoiding too many special treatment from
ProcessFilter itself.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Maximum flexibility to ProcessFilter::IO

These objects are now fully responsible for dealing with the MultiplexIO
and SubProcess objects. This way ProcessFilter can make no assumptions
if they are implemented using pipes or something else.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
ProcessFilter::IO: add a method to get the file descriptor

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
clean up ProcessFilter::setIO

When overriding the IO for a given file descriptor, free the previous
IO object in that slot.

Also change the arguments (the file descriptor is superfluous, and it
can cause inconsistencies).
Implement SSH target as a pipe to the ssh command

Use SubProcess to pipe makedumpfile output via stdin to a remote "dd"
process.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>