event_type should come only with specific values but
this in theory can change in the future.
To prevent overflows (just for logging) check value size
against lookup array.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe de Dinechin <cdupontd@redhat.com>
This saves some stack memory not reducing any readability.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
Instead of having a long if statement with checks and assignment
split in two.
The conditions where used to compute 2 different path, this does
not help much with code readability.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
Avoid extra field that could be out of sync.
Having a valid process handle is enough.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
Use delete[] to free an array.
This could potentially lead to memory errors depending
on compiler/library implementation.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
vdagent terminates when the global event is set by vdservice. vdservice is also
responsible to reset the event in any case, without trusting vdagent to do so.
Otherwise, it may terminate the following vdagent instance immediately as well.
Regression was due to commit 2d03cc.
rhbz #868254
Terminate agent politely instead of ugly TerminateProcess(), so now
VD_AGENT_CLIPBOARD_RELEASE is sent (if guest owned the clipboard),
followed by cleanup.
rhbz #903379
The problem on XP was failing to terminate agent running on session>0,
since during agent process creation, a handle was not set, so it was NULL.
Therefore, the new agent created (at the session we switched to) was unable
to open vitio-serial which was still used by the other running agent instance.
rhbz#868254
read & write are async, and their completion is handled by handle_event(),
which returns status used by service execute loop.
previously an error in GetOverlappedResult caused vdservice hang.
rhbz#839564
When checking for ConnectNamedPipe status, the error check uses
if ( err = ERROR_IO_PENDING) instead of using == which causes this
error check to always trigger. This commit fixes this, however it
needs careful testing since the fact that it went unnoticed means
the code with the bug was working as expected. Maybe changing it
will cause unexpected regressions.
In case of agent launch failure: if connection state is not active(*), wait for
agent launch on the next session connection. Otherwise, the service is stopped.
(*) The failure was due to system startup timings and logon settings, causing
the first agent instance lifetime (before session connect) to be too short to
connect the service.
-extend vdagent wait timeouts
-timeout occured when connecting during windows startup, using wan emulator with
1Mbps bandwith, and only when qxl driver is installed. It might be due to spice
commands window control which in this case indirectly affects windows startup
timings (needs further investigation).
-fix wait for vdagent connect
-fix wait for vdagent termination & exit code handling
-cleanup & nicify relevant logs while debugging
-prevent race between service control manager (SCM) & the service main thread.
-use events for stop, logon, agent restart.
-thread-safe control command queue
This patch is a little dirty due to EOL convertion to windows format.
+ add pci_vdi_port with PCIVDIPort taken from last commit before
changing to virtio-serial (a17ccbf323)
+ move handle_error to VDIPort (identical in VIRTIOVDIPort and PCIVDIPort)
+ make VDService create first a virtio, then init, the pci, then init,
stopping when the first init succeeds, and reporting to log which was
created.
introduce VDIPort::get_num_events and VDIPort::fill_events,
change VDService::_events to be dynamically allocated
document _events contents: STATIC events, then vdi_port, then agent.
The configuration is received from Spice client.
The main usage of this option is for disabling display features in order to accelerate Spice performance over limited network connections.