VirtualBox

source: vbox/trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibDrmClient.cpp@ 93222

Last change on this file since 93222 was 93222, checked in by vboxsync, 3 years ago

Addidions: X11: add interface to start VBoxClient --vmsvga, bugref:10134.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.6 KB
Line 
1/* $Id: VBoxGuestR3LibDrmClient.cpp 93222 2022-01-13 11:53:48Z vboxsync $ */
2/** @file
3 * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, DRM client handling.
4 */
5
6/*
7 * Copyright (C) 2020-2022 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.215389.xyz. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27
28/*********************************************************************************************************************************
29* Header Files *
30*********************************************************************************************************************************/
31#include "VBoxGuestR3LibInternal.h"
32
33#include <iprt/env.h>
34#include <iprt/path.h>
35#include <iprt/process.h>
36
37/** Defines the DRM client executable (image). */
38#define VBOX_DRMCLIENT_EXECUTABLE "/usr/bin/VBoxDRMClient"
39#define VBOX_DRMCLIENT_LEGACY_EXECUTABLE "/usr/bin/VBoxClient"
40/** Defines the guest property that defines if the DRM resizing client needs to be active or not. */
41#define VBOX_DRMCLIENT_GUEST_PROP_RESIZE "/VirtualBox/GuestAdd/DRMResize"
42
43/**
44 * Returns if the DRM resizing client is needed.
45 * This is achieved by querying existence of a guest property.
46 *
47 * @returns \c true if the DRM resizing client is needed, \c false if not.
48 */
49VBGLR3DECL(bool) VbglR3DrmClientIsNeeded(void)
50{
51 bool fStartClient = false;
52
53#ifdef VBOX_WITH_GUEST_PROPS
54 uint32_t idClient;
55 int rc = VbglR3GuestPropConnect(&idClient);
56 if (RT_SUCCESS(rc))
57 {
58 fStartClient = VbglR3GuestPropExist(idClient, VBOX_DRMCLIENT_GUEST_PROP_RESIZE /*pszPropName*/);
59 VbglR3GuestPropDisconnect(idClient);
60 }
61#endif
62
63 return fStartClient;
64}
65
66/**
67 * Returns if the DRM resizing client already is running.
68 * This is achieved by querying existence of a guest property.
69 *
70 * @returns \c true if the DRM resizing client is running, \c false if not.
71 */
72VBGLR3DECL(bool) VbglR3DrmClientIsRunning(void)
73{
74 return VbglR3DrmClientIsNeeded();
75}
76
77static int VbglR3DrmStart(const char *pszCmd, const char **apszArgs)
78{
79 return RTProcCreate(pszCmd, apszArgs, RTENV_DEFAULT,
80 RTPROC_FLAGS_DETACHED | RTPROC_FLAGS_SEARCH_PATH, NULL);
81}
82
83/**
84 * Starts (executes) the DRM resizing client process ("VBoxDRMClient").
85 *
86 * @returns VBox status code.
87 */
88VBGLR3DECL(int) VbglR3DrmClientStart(void)
89{
90 const char *apszArgs[1] = { NULL }; /** @todo r=andy Pass path + process name as argv0? */
91 return VbglR3DrmStart(VBOX_DRMCLIENT_EXECUTABLE, apszArgs);
92}
93
94/**
95 * Starts (executes) the legacy DRM resizing client process ("VBoxClient --vmsvga").
96 *
97 * @returns VBox status code.
98 */
99VBGLR3DECL(int) VbglR3DrmLegacyClientStart(void)
100{
101 const char *apszArgs[2] = { "--vmsvga", NULL };
102 return VbglR3DrmStart(VBOX_DRMCLIENT_LEGACY_EXECUTABLE, apszArgs);
103}
104
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette