Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7fb0e8e

Browse files
Additions: Linux: Guest Lib: Add functionality to terminate VBoxDRMClient process by its PID file, bugref:10134, github:gh-311.
svn:sync-xref-src-repo-rev: r171082
1 parent b2837d1 commit 7fb0e8e

File tree

3 files changed

+67
-3
lines changed

3 files changed

+67
-3
lines changed

‎include/VBox/VBoxGuestLib.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,11 +843,14 @@ VBGLR3DECL(int) VbglR3WriteCoreDump(void);
843843
# define VBGLR3DRMPROPPTR "/VirtualBox/GuestAdd/DRM*"
844844
/** Guest property that defines if the DRM IPC server access should be restricted to a specific user group. */
845845
# define VBGLR3DRMIPCPROPRESTRICT "/VirtualBox/GuestAdd/DRMIpcRestricted"
846+
/** Pid file path for VBoxDRMClient. */
847+
# define VBGLR3DRMPIDFILE "/var/run/VBoxDRMClient"
846848

847849
VBGLR3DECL(bool) VbglR3DrmClientIsNeeded(void);
848850
VBGLR3DECL(bool) VbglR3DrmRestrictedIpcAccessIsNeeded(void);
849851
VBGLR3DECL(bool) VbglR3DrmClientIsRunning(void);
850852
VBGLR3DECL(int) VbglR3DrmClientStart(void);
853+
VBGLR3DECL(int) VbglR3DrmClientStop(void);
851854
VBGLR3DECL(int) VbglR3DrmLegacyClientStart(void);
852855
VBGLR3DECL(int) VbglR3DrmLegacyX11AgentStart(void);
853856
/** @} */

‎src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibDrmClient.cpp‎

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Id: VBoxGuestR3LibDrmClient.cpp 110684 2025-08-11 17:18:47Z klaus.espenlaub@oracle.com $ */
1+
/* $Id: VBoxGuestR3LibDrmClient.cpp 111520 2025-10-30 12:50:00Z vadim.galitsyn@oracle.com $ */
22
/** @file
33
* VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, DRM client handling.
44
*/
@@ -45,7 +45,9 @@
4545
#include <iprt/process.h>
4646

4747
#if defined(RT_OS_LINUX)
48+
# include <signal.h>
4849
# include <VBox/HostServices/GuestPropertySvc.h>
50+
# include <iprt/file.h>
4951

5052
/** Defines the DRM client executable (image). */
5153
# define VBOX_DRMCLIENT_EXECUTABLE "/usr/bin/VBoxDRMClient"
@@ -167,6 +169,65 @@ VBGLR3DECL(int) VbglR3DrmClientStart(void)
167169
#endif
168170
}
169171

172+
/**
173+
* Stops the DRM resizing client process ("VBoxDRMClient").
174+
*
175+
* @returns VBox status code.
176+
*/
177+
VBGLR3DECL(int) VbglR3DrmClientStop(void)
178+
{
179+
#if defined(RT_OS_LINUX)
180+
int rc;
181+
RTFILE hFile;
182+
183+
/* Try open PID file. */
184+
rc = RTFileOpen(&hFile, VBGLR3DRMPIDFILE, RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_NONE);
185+
if (RT_SUCCESS(rc))
186+
{
187+
uint64_t cbFile = 0;
188+
189+
/* Read process ID. */
190+
rc = RTFileQuerySize(hFile, &cbFile);
191+
if (RT_SUCCESS(rc))
192+
{
193+
char *szPid = (char *)RTMemAllocZ(cbFile + 1 /* 0円 */);
194+
if (RT_VALID_PTR(szPid))
195+
{
196+
rc = RTFileRead(hFile, szPid, cbFile, NULL);
197+
if (RT_SUCCESS(rc))
198+
{
199+
int32_t pid = RTStrToInt32(szPid);
200+
if (pid > 0)
201+
{
202+
/* Send SIGTERM to the process. */
203+
if (kill(pid, SIGTERM) == 0)
204+
{
205+
/* Wait until process terminated. */
206+
RTFILE hFileNew;
207+
rc = VbglR3PidfileWait(VBGLR3DRMPIDFILE, &hFileNew, 5000);
208+
if (RT_SUCCESS(rc))
209+
VbglR3ClosePidFile(VBGLR3DRMPIDFILE, hFileNew);
210+
}
211+
else
212+
rc = VERR_INVALID_PARAMETER;
213+
}
214+
else
215+
rc = VERR_INVALID_PARAMETER;
216+
}
217+
218+
RTMemFree(szPid);
219+
}
220+
}
221+
222+
RTFileClose(hFile);
223+
}
224+
225+
return rc;
226+
#else
227+
return VERR_NOT_SUPPORTED;
228+
#endif
229+
}
230+
170231
/**
171232
* Starts (executes) the legacy DRM resizing client process ("VBoxClient --vmsvga").
172233
*

‎src/VBox/Additions/x11/VBoxClient/display-drm.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Id: display-drm.cpp 110684 2025-08-11 17:18:47Z klaus.espenlaub@oracle.com $ */
1+
/* $Id: display-drm.cpp 111520 2025-10-30 12:50:00Z vadim.galitsyn@oracle.com $ */
22
/** @file
33
* Guest Additions - VMSVGA guest screen resize service.
44
*
@@ -245,7 +245,7 @@ unsigned g_cRespawn = 0;
245245
unsigned g_cVerbosity = 0;
246246

247247
/** Path to the PID file. */
248-
static const char *g_pszPidFile = "/var/run/VBoxDRMClient";
248+
static const char *g_pszPidFile = VBGLR3DRMPIDFILE;
249249

250250
/** Global flag which is triggered when service requested to shutdown. */
251251
static bool volatile g_fShutdown;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /