VirtualBox

source: vbox/trunk/src/VBox/Main/GuestImpl.cpp@ 29003

Last change on this file since 29003 was 29003, checked in by vboxsync, 15 years ago

Guest Control/Main/HostService: Proper shutdown / notification when VM gets shut down.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 44.0 KB
Line 
1/* $Id: GuestImpl.cpp 29003 2010-05-04 11:26:52Z vboxsync $ */
2
3/** @file
4 *
5 * VirtualBox COM class implementation
6 */
7
8/*
9 * Copyright (C) 2006-2008 Oracle Corporation
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.215389.xyz. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 */
19
20#include "GuestImpl.h"
21
22#include "Global.h"
23#include "ConsoleImpl.h"
24#include "ProgressImpl.h"
25#include "VMMDev.h"
26
27#include "AutoCaller.h"
28#include "Logging.h"
29
30#include <VBox/VMMDev.h>
31#ifdef VBOX_WITH_GUEST_CONTROL
32# include <VBox/com/array.h>
33#endif
34#include <iprt/cpp/utils.h>
35#include <iprt/getopt.h>
36#include <VBox/pgm.h>
37
38// defines
39/////////////////////////////////////////////////////////////////////////////
40
41// constructor / destructor
42/////////////////////////////////////////////////////////////////////////////
43
44DEFINE_EMPTY_CTOR_DTOR (Guest)
45
46HRESULT Guest::FinalConstruct()
47{
48 return S_OK;
49}
50
51void Guest::FinalRelease()
52{
53 uninit ();
54}
55
56// public methods only for internal purposes
57/////////////////////////////////////////////////////////////////////////////
58
59/**
60 * Initializes the guest object.
61 */
62HRESULT Guest::init (Console *aParent)
63{
64 LogFlowThisFunc(("aParent=%p\n", aParent));
65
66 ComAssertRet(aParent, E_INVALIDARG);
67
68 /* Enclose the state transition NotReady->InInit->Ready */
69 AutoInitSpan autoInitSpan(this);
70 AssertReturn(autoInitSpan.isOk(), E_FAIL);
71
72 unconst(mParent) = aParent;
73
74 /* mData.mAdditionsActive is FALSE */
75
76 /* Confirm a successful initialization when it's the case */
77 autoInitSpan.setSucceeded();
78
79 ULONG aMemoryBalloonSize;
80 HRESULT ret = mParent->machine()->COMGETTER(MemoryBalloonSize)(&aMemoryBalloonSize);
81 if (ret == S_OK)
82 mMemoryBalloonSize = aMemoryBalloonSize;
83 else
84 mMemoryBalloonSize = 0; /* Default is no ballooning */
85
86 mStatUpdateInterval = 0; /* Default is not to report guest statistics at all */
87
88 /* Clear statistics. */
89 for (unsigned i = 0 ; i < GUESTSTATTYPE_MAX; i++)
90 mCurrentGuestStat[i] = 0;
91
92#ifdef VBOX_WITH_GUEST_CONTROL
93 /* Init the context ID counter at 1000. */
94 mNextContextID = 1000;
95#endif
96
97 return S_OK;
98}
99
100/**
101 * Uninitializes the instance and sets the ready flag to FALSE.
102 * Called either from FinalRelease() or by the parent when it gets destroyed.
103 */
104void Guest::uninit()
105{
106 LogFlowThisFunc(("\n"));
107
108#ifdef VBOX_WITH_GUEST_CONTROL
109 /*
110 * Cleanup must be done *before* AutoUninitSpan to cancel all
111 * all outstanding waits in API functions (which hold AutoCaller
112 * ref counts).
113 */
114 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
115
116 /* Clean up callback data. */
117 CallbackListIter it;
118 for (it = mCallbackList.begin(); it != mCallbackList.end(); it++)
119 removeCtrlCallbackContext(it);
120
121 /* Clear process list. */
122 mGuestProcessList.clear();
123#endif
124
125 /* Enclose the state transition Ready->InUninit->NotReady */
126 AutoUninitSpan autoUninitSpan(this);
127 if (autoUninitSpan.uninitDone())
128 return;
129
130 unconst(mParent) = NULL;
131}
132
133// IGuest properties
134/////////////////////////////////////////////////////////////////////////////
135
136STDMETHODIMP Guest::COMGETTER(OSTypeId) (BSTR *aOSTypeId)
137{
138 CheckComArgOutPointerValid(aOSTypeId);
139
140 AutoCaller autoCaller(this);
141 if (FAILED(autoCaller.rc())) return autoCaller.rc();
142
143 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
144
145 // redirect the call to IMachine if no additions are installed
146 if (mData.mAdditionsVersion.isEmpty())
147 return mParent->machine()->COMGETTER(OSTypeId)(aOSTypeId);
148
149 mData.mOSTypeId.cloneTo(aOSTypeId);
150
151 return S_OK;
152}
153
154STDMETHODIMP Guest::COMGETTER(AdditionsActive) (BOOL *aAdditionsActive)
155{
156 CheckComArgOutPointerValid(aAdditionsActive);
157
158 AutoCaller autoCaller(this);
159 if (FAILED(autoCaller.rc())) return autoCaller.rc();
160
161 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
162
163 *aAdditionsActive = mData.mAdditionsActive;
164
165 return S_OK;
166}
167
168STDMETHODIMP Guest::COMGETTER(AdditionsVersion) (BSTR *aAdditionsVersion)
169{
170 CheckComArgOutPointerValid(aAdditionsVersion);
171
172 AutoCaller autoCaller(this);
173 if (FAILED(autoCaller.rc())) return autoCaller.rc();
174
175 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
176
177 mData.mAdditionsVersion.cloneTo(aAdditionsVersion);
178
179 return S_OK;
180}
181
182STDMETHODIMP Guest::COMGETTER(SupportsSeamless) (BOOL *aSupportsSeamless)
183{
184 CheckComArgOutPointerValid(aSupportsSeamless);
185
186 AutoCaller autoCaller(this);
187 if (FAILED(autoCaller.rc())) return autoCaller.rc();
188
189 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
190
191 *aSupportsSeamless = mData.mSupportsSeamless;
192
193 return S_OK;
194}
195
196STDMETHODIMP Guest::COMGETTER(SupportsGraphics) (BOOL *aSupportsGraphics)
197{
198 CheckComArgOutPointerValid(aSupportsGraphics);
199
200 AutoCaller autoCaller(this);
201 if (FAILED(autoCaller.rc())) return autoCaller.rc();
202
203 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
204
205 *aSupportsGraphics = mData.mSupportsGraphics;
206
207 return S_OK;
208}
209
210STDMETHODIMP Guest::COMGETTER(MemoryBalloonSize) (ULONG *aMemoryBalloonSize)
211{
212 CheckComArgOutPointerValid(aMemoryBalloonSize);
213
214 AutoCaller autoCaller(this);
215 if (FAILED(autoCaller.rc())) return autoCaller.rc();
216
217 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
218
219 *aMemoryBalloonSize = mMemoryBalloonSize;
220
221 return S_OK;
222}
223
224STDMETHODIMP Guest::COMSETTER(MemoryBalloonSize) (ULONG aMemoryBalloonSize)
225{
226 AutoCaller autoCaller(this);
227 if (FAILED(autoCaller.rc())) return autoCaller.rc();
228
229 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
230
231 /* We must be 100% sure that IMachine::COMSETTER(MemoryBalloonSize)
232 * does not call us back in any way! */
233 HRESULT ret = mParent->machine()->COMSETTER(MemoryBalloonSize)(aMemoryBalloonSize);
234 if (ret == S_OK)
235 {
236 mMemoryBalloonSize = aMemoryBalloonSize;
237 /* forward the information to the VMM device */
238 VMMDev *vmmDev = mParent->getVMMDev();
239 if (vmmDev)
240 vmmDev->getVMMDevPort()->pfnSetMemoryBalloon(vmmDev->getVMMDevPort(), aMemoryBalloonSize);
241 }
242
243 return ret;
244}
245
246STDMETHODIMP Guest::COMGETTER(StatisticsUpdateInterval)(ULONG *aUpdateInterval)
247{
248 CheckComArgOutPointerValid(aUpdateInterval);
249
250 AutoCaller autoCaller(this);
251 if (FAILED(autoCaller.rc())) return autoCaller.rc();
252
253 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
254
255 *aUpdateInterval = mStatUpdateInterval;
256 return S_OK;
257}
258
259STDMETHODIMP Guest::COMSETTER(StatisticsUpdateInterval)(ULONG aUpdateInterval)
260{
261 AutoCaller autoCaller(this);
262 if (FAILED(autoCaller.rc())) return autoCaller.rc();
263
264 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
265
266 mStatUpdateInterval = aUpdateInterval;
267 /* forward the information to the VMM device */
268 VMMDev *vmmDev = mParent->getVMMDev();
269 if (vmmDev)
270 vmmDev->getVMMDevPort()->pfnSetStatisticsInterval(vmmDev->getVMMDevPort(), aUpdateInterval);
271
272 return S_OK;
273}
274
275STDMETHODIMP Guest::InternalGetStatistics(ULONG *aCpuUser, ULONG *aCpuKernel, ULONG *aCpuIdle,
276 ULONG *aMemTotal, ULONG *aMemFree, ULONG *aMemBalloon,
277 ULONG *aMemCache, ULONG *aPageTotal,
278 ULONG *aMemAllocTotal, ULONG *aMemFreeTotal, ULONG *aMemBalloonTotal)
279{
280 CheckComArgOutPointerValid(aCpuUser);
281 CheckComArgOutPointerValid(aCpuKernel);
282 CheckComArgOutPointerValid(aCpuIdle);
283 CheckComArgOutPointerValid(aMemTotal);
284 CheckComArgOutPointerValid(aMemFree);
285 CheckComArgOutPointerValid(aMemBalloon);
286 CheckComArgOutPointerValid(aMemCache);
287 CheckComArgOutPointerValid(aPageTotal);
288
289 AutoCaller autoCaller(this);
290 if (FAILED(autoCaller.rc())) return autoCaller.rc();
291
292 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
293
294 *aCpuUser = mCurrentGuestStat[GUESTSTATTYPE_CPUUSER];
295 *aCpuKernel = mCurrentGuestStat[GUESTSTATTYPE_CPUKERNEL];
296 *aCpuIdle = mCurrentGuestStat[GUESTSTATTYPE_CPUIDLE];
297 *aMemTotal = mCurrentGuestStat[GUESTSTATTYPE_MEMTOTAL] * (_4K/_1K); /* page (4K) -> 1KB units */
298 *aMemFree = mCurrentGuestStat[GUESTSTATTYPE_MEMFREE] * (_4K/_1K); /* page (4K) -> 1KB units */
299 *aMemBalloon = mCurrentGuestStat[GUESTSTATTYPE_MEMBALLOON] * (_4K/_1K); /* page (4K) -> 1KB units */
300 *aMemCache = mCurrentGuestStat[GUESTSTATTYPE_MEMCACHE] * (_4K/_1K); /* page (4K) -> 1KB units */
301 *aPageTotal = mCurrentGuestStat[GUESTSTATTYPE_PAGETOTAL] * (_4K/_1K); /* page (4K) -> 1KB units */
302
303 Console::SafeVMPtr pVM (mParent);
304 if (pVM.isOk())
305 {
306 uint64_t uFreeTotal, uAllocTotal, uBalloonedTotal;
307 *aMemFreeTotal = 0;
308 int rc = PGMR3QueryVMMMemoryStats(pVM.raw(), &uAllocTotal, &uFreeTotal, &uBalloonedTotal);
309 AssertRC(rc);
310 if (rc == VINF_SUCCESS)
311 {
312 *aMemAllocTotal = (ULONG)(uAllocTotal / _1K); /* bytes -> KB */
313 *aMemFreeTotal = (ULONG)(uFreeTotal / _1K);
314 *aMemBalloonTotal = (ULONG)(uBalloonedTotal / _1K);
315 }
316 }
317 else
318 *aMemFreeTotal = 0;
319
320 return S_OK;
321}
322
323HRESULT Guest::SetStatistic(ULONG aCpuId, GUESTSTATTYPE enmType, ULONG aVal)
324{
325 AutoCaller autoCaller(this);
326 if (FAILED(autoCaller.rc())) return autoCaller.rc();
327
328 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
329
330 if (enmType >= GUESTSTATTYPE_MAX)
331 return E_INVALIDARG;
332
333 mCurrentGuestStat[enmType] = aVal;
334 return S_OK;
335}
336
337STDMETHODIMP Guest::SetCredentials(IN_BSTR aUserName, IN_BSTR aPassword,
338 IN_BSTR aDomain, BOOL aAllowInteractiveLogon)
339{
340 AutoCaller autoCaller(this);
341 if (FAILED(autoCaller.rc())) return autoCaller.rc();
342
343 /* forward the information to the VMM device */
344 VMMDev *vmmDev = mParent->getVMMDev();
345 if (vmmDev)
346 {
347 uint32_t u32Flags = VMMDEV_SETCREDENTIALS_GUESTLOGON;
348 if (!aAllowInteractiveLogon)
349 u32Flags = VMMDEV_SETCREDENTIALS_NOLOCALLOGON;
350
351 vmmDev->getVMMDevPort()->pfnSetCredentials(vmmDev->getVMMDevPort(),
352 Utf8Str(aUserName).raw(), Utf8Str(aPassword).raw(),
353 Utf8Str(aDomain).raw(), u32Flags);
354 return S_OK;
355 }
356
357 return setError(VBOX_E_VM_ERROR,
358 tr("VMM device is not available (is the VM running?)"));
359}
360
361#ifdef VBOX_WITH_GUEST_CONTROL
362/**
363 * Appends environment variables to the environment block. Each var=value pair is separated
364 * by NULL (\0) sequence. The whole block will be stored in one blob and disassembled on the
365 * guest side later to fit into the HGCM param structure.
366 *
367 * @returns VBox status code.
368 *
369 * @todo
370 *
371 */
372int Guest::prepareExecuteEnv(const char *pszEnv, void **ppvList, uint32_t *pcbList, uint32_t *pcEnv)
373{
374 int rc = VINF_SUCCESS;
375 uint32_t cbLen = strlen(pszEnv);
376 if (*ppvList)
377 {
378 uint32_t cbNewLen = *pcbList + cbLen + 1; /* Include zero termination. */
379 char *pvTmp = (char*)RTMemRealloc(*ppvList, cbNewLen);
380 if (NULL == pvTmp)
381 {
382 rc = VERR_NO_MEMORY;
383 }
384 else
385 {
386 memcpy(pvTmp + *pcbList, pszEnv, cbLen);
387 pvTmp[cbNewLen - 1] = '\0'; /* Add zero termination. */
388 *ppvList = (void**)pvTmp;
389 }
390 }
391 else
392 {
393 char *pcTmp;
394 if (RTStrAPrintf(&pcTmp, "%s", pszEnv) > 0)
395 {
396 *ppvList = (void**)pcTmp;
397 /* Reset counters. */
398 *pcEnv = 0;
399 *pcbList = 0;
400 }
401 }
402 if (RT_SUCCESS(rc))
403 {
404 *pcbList += cbLen + 1; /* Include zero termination. */
405 *pcEnv += 1; /* Increase env pairs count. */
406 }
407 return rc;
408}
409
410/**
411 * Static callback function for receiving updates on guest control commands
412 * from the guest. Acts as a dispatcher for the actual class instance.
413 *
414 * @returns VBox status code.
415 *
416 * @todo
417 *
418 */
419DECLCALLBACK(int) Guest::doGuestCtrlNotification(void *pvExtension,
420 uint32_t u32Function,
421 void *pvParms,
422 uint32_t cbParms)
423{
424 using namespace guestControl;
425
426 /*
427 * No locking, as this is purely a notification which does not make any
428 * changes to the object state.
429 */
430 LogFlowFunc(("pvExtension = %p, u32Function = %d, pvParms = %p, cbParms = %d\n",
431 pvExtension, u32Function, pvParms, cbParms));
432 ComObjPtr<Guest> pGuest = reinterpret_cast<Guest *>(pvExtension);
433
434 int rc = VINF_SUCCESS;
435 if (u32Function == GUEST_EXEC_SEND_STATUS)
436 {
437 LogFlowFunc(("GUEST_EXEC_SEND_STATUS\n"));
438
439 PHOSTEXECCALLBACKDATA pCBData = reinterpret_cast<PHOSTEXECCALLBACKDATA>(pvParms);
440 AssertPtr(pCBData);
441 AssertReturn(sizeof(HOSTEXECCALLBACKDATA) == cbParms, VERR_INVALID_PARAMETER);
442 AssertReturn(HOSTEXECCALLBACKDATAMAGIC == pCBData->hdr.u32Magic, VERR_INVALID_PARAMETER);
443
444 rc = pGuest->notifyCtrlExec(u32Function, pCBData);
445 }
446 else if (u32Function == GUEST_EXEC_SEND_OUTPUT)
447 {
448 LogFlowFunc(("GUEST_EXEC_SEND_OUTPUT\n"));
449
450 PHOSTEXECOUTCALLBACKDATA pCBData = reinterpret_cast<PHOSTEXECOUTCALLBACKDATA>(pvParms);
451 AssertPtr(pCBData);
452 AssertReturn(sizeof(HOSTEXECOUTCALLBACKDATA) == cbParms, VERR_INVALID_PARAMETER);
453 AssertReturn(HOSTEXECOUTCALLBACKDATAMAGIC == pCBData->hdr.u32Magic, VERR_INVALID_PARAMETER);
454
455 rc = pGuest->notifyCtrlExecOut(u32Function, pCBData);
456 }
457 else
458 rc = VERR_NOT_SUPPORTED;
459 return rc;
460}
461
462/* Function for handling the execution start/termination notification. */
463int Guest::notifyCtrlExec(uint32_t u32Function,
464 PHOSTEXECCALLBACKDATA pData)
465{
466 LogFlowFuncEnter();
467 int rc = VINF_SUCCESS;
468
469 AssertPtr(pData);
470 CallbackListIter it = getCtrlCallbackContextByID(pData->hdr.u32ContextID);
471
472 /* Callback can be called several times. */
473 if (it != mCallbackList.end())
474 {
475 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
476
477 PHOSTEXECCALLBACKDATA pCBData = (HOSTEXECCALLBACKDATA*)it->pvData;
478 AssertPtr(pCBData);
479
480 pCBData->u32PID = pData->u32PID;
481 pCBData->u32Status = pData->u32Status;
482 pCBData->u32Flags = pData->u32Flags;
483 /** @todo Copy void* buffer contents! */
484
485 /* Was progress canceled before? */
486 BOOL fCancelled;
487 it->pProgress->COMGETTER(Canceled)(&fCancelled);
488
489 /* Do progress handling. */
490 Utf8Str errMsg;
491 HRESULT rc2 = S_OK;
492 switch (pData->u32Status)
493 {
494 case PROC_STS_STARTED:
495 break;
496
497 case PROC_STS_TEN: /* Terminated normally. */
498 if ( !it->pProgress->getCompleted()
499 && !fCancelled)
500 {
501 it->pProgress->notifyComplete(S_OK);
502 }
503 break;
504
505 case PROC_STS_TEA: /* Terminated abnormally. */
506 errMsg = Utf8StrFmt(Guest::tr("Process terminated abnormally with status '%u'"),
507 pCBData->u32Flags);
508 break;
509
510 case PROC_STS_TES: /* Terminated through signal. */
511 errMsg = Utf8StrFmt(Guest::tr("Process terminated via signal with status '%u'"),
512 pCBData->u32Flags);
513 break;
514
515 case PROC_STS_TOK:
516 errMsg = Utf8StrFmt(Guest::tr("Process timed out and was killed"));
517 break;
518
519 case PROC_STS_TOA:
520 errMsg = Utf8StrFmt(Guest::tr("Process timed out and could not be killed"));
521 break;
522
523 case PROC_STS_DWN:
524 errMsg = Utf8StrFmt(Guest::tr("Process exited because system is shutting down"));
525 break;
526
527 default:
528 break;
529 }
530
531 /* Handle process list. */
532 /** @todo What happens on/deal with PID reuse? */
533 /** @todo How to deal with multiple updates at once? */
534 GuestProcessIter it_proc = getProcessByPID(pCBData->u32PID);
535 if (it_proc == mGuestProcessList.end())
536 {
537 /* Not found, add to list. */
538 GuestProcess p;
539 p.mPID = pCBData->u32PID;
540 p.mStatus = pCBData->u32Status;
541 p.mExitCode = pCBData->u32Flags; /* Contains exit code. */
542 p.mFlags = 0;
543
544 mGuestProcessList.push_back(p);
545 }
546 else /* Update list. */
547 {
548 it_proc->mStatus = pCBData->u32Status;
549 it_proc->mExitCode = pCBData->u32Flags; /* Contains exit code. */
550 it_proc->mFlags = 0;
551 }
552
553 if ( !it->pProgress.isNull()
554 && errMsg.length())
555 {
556 if ( !it->pProgress->getCompleted()
557 && !fCancelled)
558 {
559 it->pProgress->notifyComplete(E_FAIL /** @todo Find a better rc! */, COM_IIDOF(IGuest),
560 (CBSTR)Guest::getComponentName(), errMsg.c_str());
561 LogFlowFunc(("Callback (context ID=%u, status=%u) progress marked as completed\n",
562 pData->hdr.u32ContextID, pData->u32Status));
563 }
564 else
565 LogFlowFunc(("Callback (context ID=%u, status=%u) progress already marked as completed\n",
566 pData->hdr.u32ContextID, pData->u32Status));
567 }
568 ASMAtomicWriteBool(&it->bCalled, true);
569 }
570 else
571 LogFlowFunc(("Unexpected callback (magic=%u, context ID=%u) arrived\n", pData->hdr.u32Magic, pData->hdr.u32ContextID));
572 LogFlowFuncLeave();
573 return rc;
574}
575
576/* Function for handling the execution output notification. */
577int Guest::notifyCtrlExecOut(uint32_t u32Function,
578 PHOSTEXECOUTCALLBACKDATA pData)
579{
580 LogFlowFuncEnter();
581 int rc = VINF_SUCCESS;
582
583 AssertPtr(pData);
584 CallbackListIter it = getCtrlCallbackContextByID(pData->hdr.u32ContextID);
585 if (it != mCallbackList.end())
586 {
587 Assert(!it->bCalled);
588 PHOSTEXECOUTCALLBACKDATA pCBData = (HOSTEXECOUTCALLBACKDATA*)it->pvData;
589 AssertPtr(pCBData);
590
591 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
592
593 pCBData->u32PID = pData->u32PID;
594 pCBData->u32HandleId = pData->u32HandleId;
595 pCBData->u32Flags = pData->u32Flags;
596
597 /* Make sure we really got something! */
598 if ( pData->cbData
599 && pData->pvData)
600 {
601 /* Allocate data buffer and copy it */
602 pCBData->pvData = RTMemAlloc(pData->cbData);
603 AssertReturn(pCBData->pvData, VERR_NO_MEMORY);
604 memcpy(pCBData->pvData, pData->pvData, pData->cbData);
605 pCBData->cbData = pData->cbData;
606 }
607 else
608 {
609 pCBData->pvData = NULL;
610 pCBData->cbData = 0;
611 }
612 ASMAtomicWriteBool(&it->bCalled, true);
613 }
614 else
615 LogFlowFunc(("Unexpected callback (magic=%u, context ID=%u) arrived\n", pData->hdr.u32Magic, pData->hdr.u32ContextID));
616 LogFlowFuncLeave();
617 return rc;
618}
619
620Guest::CallbackListIter Guest::getCtrlCallbackContextByID(uint32_t u32ContextID)
621{
622 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
623
624 /** @todo Maybe use a map instead of list for fast context lookup. */
625 CallbackListIter it;
626 for (it = mCallbackList.begin(); it != mCallbackList.end(); it++)
627 {
628 if (it->mContextID == u32ContextID)
629 return (it);
630 }
631 return it;
632}
633
634Guest::GuestProcessIter Guest::getProcessByPID(uint32_t u32PID)
635{
636 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
637
638 /** @todo Maybe use a map instead of list for fast context lookup. */
639 GuestProcessIter it;
640 for (it = mGuestProcessList.begin(); it != mGuestProcessList.end(); it++)
641 {
642 if (it->mPID == u32PID)
643 return (it);
644 }
645 return it;
646}
647
648void Guest::removeCtrlCallbackContext(Guest::CallbackListIter it)
649{
650 LogFlowFuncEnter();
651 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
652 if (it->pvData)
653 {
654 RTMemFree(it->pvData);
655 it->pvData = NULL;
656 it->cbData = 0;
657
658 /* Notify outstanding waits for progress ... */
659 if (!it->pProgress.isNull())
660 {
661 /* Only cancel if not canceled before! */
662 BOOL fCancelled;
663 if (SUCCEEDED(it->pProgress->COMGETTER(Canceled)(&fCancelled)) && !fCancelled)
664 it->pProgress->Cancel();
665 /*
666 * Do *not NULL pProgress here, because waiting function like executeProcess()
667 * will still rely on this object for checking whether they have to give up!
668 */
669 }
670 }
671 LogFlowFuncLeave();
672}
673
674/* Adds a callback with a user provided data block and an optional progress object
675 * to the callback list. A callback is identified by a unique context ID which is used
676 * to identify a callback from the guest side. */
677uint32_t Guest::addCtrlCallbackContext(eVBoxGuestCtrlCallbackType enmType, void *pvData, uint32_t cbData, Progress *pProgress)
678{
679 LogFlowFuncEnter();
680 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
681 uint32_t uNewContext = ASMAtomicIncU32(&mNextContextID);
682 if (uNewContext == UINT32_MAX)
683 ASMAtomicUoWriteU32(&mNextContextID, 1000);
684
685 CallbackContext context;
686 context.mContextID = uNewContext;
687 context.mType = enmType;
688 context.bCalled = false;
689 context.pvData = pvData;
690 context.cbData = cbData;
691 context.pProgress = pProgress;
692
693 mCallbackList.push_back(context);
694 if (mCallbackList.size() > 256) /* Don't let the container size get too big! */
695 {
696 Guest::CallbackListIter it = mCallbackList.begin();
697 removeCtrlCallbackContext(it);
698 mCallbackList.erase(it);
699 }
700
701 LogFlowFuncLeave();
702 return uNewContext;
703}
704#endif /* VBOX_WITH_GUEST_CONTROL */
705
706STDMETHODIMP Guest::ExecuteProcess(IN_BSTR aCommand, ULONG aFlags,
707 ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
708 IN_BSTR aStdIn, IN_BSTR aStdOut, IN_BSTR aStdErr,
709 IN_BSTR aUserName, IN_BSTR aPassword,
710 ULONG aTimeoutMS, ULONG *aPID, IProgress **aProgress)
711{
712#ifndef VBOX_WITH_GUEST_CONTROL
713 ReturnComNotImplemented();
714#else /* VBOX_WITH_GUEST_CONTROL */
715 using namespace guestControl;
716
717 CheckComArgStrNotEmptyOrNull(aCommand);
718 CheckComArgOutPointerValid(aPID);
719 CheckComArgOutPointerValid(aProgress);
720
721 AutoCaller autoCaller(this);
722 if (FAILED(autoCaller.rc())) return autoCaller.rc();
723
724 if (aFlags != 0) /* Flags are not supported at the moment. */
725 return E_INVALIDARG;
726
727 HRESULT rc = S_OK;
728
729 try
730 {
731 /*
732 * Create progress object.
733 */
734 ComObjPtr <Progress> progress;
735 rc = progress.createObject();
736 if (SUCCEEDED(rc))
737 {
738 rc = progress->init(static_cast<IGuest*>(this),
739 BstrFmt(tr("Executing process")),
740 TRUE);
741 }
742 if (FAILED(rc)) return rc;
743
744 /*
745 * Prepare process execution.
746 */
747 int vrc = VINF_SUCCESS;
748 Utf8Str Utf8Command(aCommand);
749
750 /* Adjust timeout */
751 if (aTimeoutMS == 0)
752 aTimeoutMS = UINT32_MAX;
753
754 /* Prepare arguments. */
755 char **papszArgv = NULL;
756 uint32_t uNumArgs = 0;
757 if (aArguments > 0)
758 {
759 com::SafeArray<IN_BSTR> args(ComSafeArrayInArg(aArguments));
760 uNumArgs = args.size();
761 papszArgv = (char**)RTMemAlloc(sizeof(char*) * (uNumArgs + 1));
762 AssertReturn(papszArgv, VERR_NO_MEMORY);
763 for (unsigned i = 0; RT_SUCCESS(vrc) && i < uNumArgs; i++)
764 vrc = RTStrAPrintf(&papszArgv[i], "%s", Utf8Str(args[i]).raw());
765 papszArgv[uNumArgs] = NULL;
766 }
767
768 Utf8Str Utf8StdIn(aStdIn);
769 Utf8Str Utf8StdOut(aStdOut);
770 Utf8Str Utf8StdErr(aStdErr);
771 Utf8Str Utf8UserName(aUserName);
772 Utf8Str Utf8Password(aPassword);
773 if (RT_SUCCESS(vrc))
774 {
775 uint32_t uContextID = 0;
776
777 char *pszArgs = NULL;
778 if (uNumArgs > 0)
779 vrc = RTGetOptArgvToString(&pszArgs, papszArgv, 0);
780 if (RT_SUCCESS(vrc))
781 {
782 uint32_t cbArgs = pszArgs ? strlen(pszArgs) + 1 : 0; /* Include terminating zero. */
783
784 /* Prepare environment. */
785 void *pvEnv = NULL;
786 uint32_t uNumEnv = 0;
787 uint32_t cbEnv = 0;
788 if (aEnvironment > 0)
789 {
790 com::SafeArray<IN_BSTR> env(ComSafeArrayInArg(aEnvironment));
791
792 for (unsigned i = 0; i < env.size(); i++)
793 {
794 vrc = prepareExecuteEnv(Utf8Str(env[i]).raw(), &pvEnv, &cbEnv, &uNumEnv);
795 if (RT_FAILURE(vrc))
796 break;
797 }
798 }
799
800 if (RT_SUCCESS(vrc))
801 {
802 PHOSTEXECCALLBACKDATA pData = (HOSTEXECCALLBACKDATA*)RTMemAlloc(sizeof(HOSTEXECCALLBACKDATA));
803 AssertReturn(pData, VBOX_E_IPRT_ERROR);
804 uContextID = addCtrlCallbackContext(VBOXGUESTCTRLCALLBACKTYPE_EXEC_START,
805 pData, sizeof(HOSTEXECCALLBACKDATA), progress);
806 Assert(uContextID > 0);
807
808 VBOXHGCMSVCPARM paParms[15];
809 int i = 0;
810 paParms[i++].setUInt32(uContextID);
811 paParms[i++].setPointer((void*)Utf8Command.raw(), (uint32_t)strlen(Utf8Command.raw()) + 1);
812 paParms[i++].setUInt32(aFlags);
813 paParms[i++].setUInt32(uNumArgs);
814 paParms[i++].setPointer((void*)pszArgs, cbArgs);
815 paParms[i++].setUInt32(uNumEnv);
816 paParms[i++].setUInt32(cbEnv);
817 paParms[i++].setPointer((void*)pvEnv, cbEnv);
818 paParms[i++].setPointer((void*)Utf8StdIn.raw(), (uint32_t)strlen(Utf8StdIn.raw()) + 1);
819 paParms[i++].setPointer((void*)Utf8StdOut.raw(), (uint32_t)strlen(Utf8StdOut.raw()) + 1);
820 paParms[i++].setPointer((void*)Utf8StdErr.raw(), (uint32_t)strlen(Utf8StdErr.raw()) + 1);
821 paParms[i++].setPointer((void*)Utf8UserName.raw(), (uint32_t)strlen(Utf8UserName.raw()) + 1);
822 paParms[i++].setPointer((void*)Utf8Password.raw(), (uint32_t)strlen(Utf8Password.raw()) + 1);
823 paParms[i++].setUInt32(aTimeoutMS);
824
825 /* Make sure mParent is valid, so set a read lock in this scope. */
826 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
827
828 /* Forward the information to the VMM device. */
829 AssertPtr(mParent);
830 VMMDev *vmmDev = mParent->getVMMDev();
831 if (vmmDev)
832 {
833 LogFlowFunc(("hgcmHostCall numParms=%d\n", i));
834 vrc = vmmDev->hgcmHostCall("VBoxGuestControlSvc", HOST_EXEC_CMD,
835 i, paParms);
836 }
837 else
838 vrc = VERR_INVALID_VM_HANDLE;
839 RTMemFree(pvEnv);
840 }
841 RTStrFree(pszArgs);
842 }
843 if (RT_SUCCESS(vrc))
844 {
845 LogFlowFunc(("Waiting for HGCM callback (timeout=%ldms) ...\n", aTimeoutMS));
846
847 /*
848 * Wait for the HGCM low level callback until the process
849 * has been started (or something went wrong). This is necessary to
850 * get the PID.
851 */
852 CallbackListIter it = getCtrlCallbackContextByID(uContextID);
853 BOOL fCanceled = FALSE;
854 if (it != mCallbackList.end())
855 {
856 uint64_t u64Started = RTTimeMilliTS();
857 while (!it->bCalled)
858 {
859 /* Check for timeout. */
860 unsigned cMsWait;
861 if (aTimeoutMS == RT_INDEFINITE_WAIT)
862 cMsWait = 10;
863 else
864 {
865 uint64_t cMsElapsed = RTTimeMilliTS() - u64Started;
866 if (cMsElapsed >= aTimeoutMS)
867 break; /* Timed out. */
868 cMsWait = RT_MIN(10, aTimeoutMS - (uint32_t)cMsElapsed);
869 }
870
871 /* Check for manual stop. */
872 if (!it->pProgress.isNull())
873 {
874 rc = it->pProgress->COMGETTER(Canceled)(&fCanceled);
875 if (FAILED(rc)) throw rc;
876 if (fCanceled)
877 break; /* Client wants to abort. */
878 }
879 RTThreadSleep(cMsWait);
880 }
881 }
882
883 /* Was the whole thing canceled? */
884 if (!fCanceled)
885 {
886 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
887
888 PHOSTEXECCALLBACKDATA pData = (HOSTEXECCALLBACKDATA*)it->pvData;
889 Assert(it->cbData == sizeof(HOSTEXECCALLBACKDATA));
890 AssertPtr(pData);
891
892 if (it->bCalled)
893 {
894 /* Did we get some status? */
895 switch (pData->u32Status)
896 {
897 case PROC_STS_STARTED:
898 /* Process is (still) running; get PID. */
899 *aPID = pData->u32PID;
900 break;
901
902 /* In any other case the process either already
903 * terminated or something else went wrong, so no PID ... */
904 case PROC_STS_TEN: /* Terminated normally. */
905 case PROC_STS_TEA: /* Terminated abnormally. */
906 case PROC_STS_TES: /* Terminated through signal. */
907 case PROC_STS_TOK:
908 case PROC_STS_TOA:
909 case PROC_STS_DWN:
910 /*
911 * Process (already) ended, but we want to get the
912 * PID anyway to retrieve the output in a later call.
913 */
914 *aPID = pData->u32PID;
915 break;
916
917 case PROC_STS_ERROR:
918 vrc = pData->u32Flags; /* u32Flags member contains IPRT error code. */
919 break;
920
921 default:
922 vrc = VERR_INVALID_PARAMETER; /* Unknown status, should never happen! */
923 break;
924 }
925 }
926 else /* If callback not called within time ... well, that's a timeout! */
927 vrc = VERR_TIMEOUT;
928
929 /*
930 * Do *not* remove the callback yet - we might wait with the IProgress object on something
931 * else (like end of process) ...
932 */
933 if (RT_FAILURE(vrc))
934 {
935 if (vrc == VERR_FILE_NOT_FOUND) /* This is the most likely error. */
936 {
937 rc = setError(VBOX_E_IPRT_ERROR,
938 tr("The file '%s' was not found on guest"), Utf8Command.raw());
939 }
940 else if (vrc == VERR_BAD_EXE_FORMAT)
941 {
942 rc = setError(VBOX_E_IPRT_ERROR,
943 tr("The file '%s' is not an executable format on guest"), Utf8Command.raw());
944 }
945 else if (vrc == VERR_LOGON_FAILURE)
946 {
947 rc = setError(VBOX_E_IPRT_ERROR,
948 tr("The specified user '%s' was not able to logon on guest"), Utf8UserName.raw());
949 }
950 else if (vrc == VERR_TIMEOUT)
951 {
952 rc = setError(VBOX_E_IPRT_ERROR,
953 tr("The guest did not respond within time (%ums)"), aTimeoutMS);
954 }
955 else if (vrc == VERR_INVALID_PARAMETER)
956 {
957 rc = setError(VBOX_E_IPRT_ERROR,
958 tr("The guest reported an unknown process status (%u)"), pData->u32Status);
959 }
960 else
961 {
962 rc = setError(E_UNEXPECTED,
963 tr("The service call failed with error %Rrc"), vrc);
964 }
965 }
966 else /* Execution went fine. */
967 {
968 /* Return the progress to the caller. */
969 progress.queryInterfaceTo(aProgress);
970 }
971 }
972 else /* Operation was canceled. */
973 {
974 rc = setError(VBOX_E_IPRT_ERROR,
975 tr("The operation was canceled."));
976 }
977 }
978 else /* HGCM related error codes .*/
979 {
980 if (vrc == VERR_INVALID_VM_HANDLE)
981 {
982 rc = setError(VBOX_E_VM_ERROR,
983 tr("VMM device is not available (is the VM running?)"));
984 }
985 else if (vrc == VERR_TIMEOUT)
986 {
987 rc = setError(VBOX_E_VM_ERROR,
988 tr("The guest execution service is not ready"));
989 }
990 else /* HGCM call went wrong. */
991 {
992 rc = setError(E_UNEXPECTED,
993 tr("The HGCM call failed with error %Rrc"), vrc);
994 }
995 }
996
997 for (unsigned i = 0; i < uNumArgs; i++)
998 RTMemFree(papszArgv[i]);
999 RTMemFree(papszArgv);
1000 }
1001 }
1002 catch (std::bad_alloc &)
1003 {
1004 rc = E_OUTOFMEMORY;
1005 }
1006 return rc;
1007#endif /* VBOX_WITH_GUEST_CONTROL */
1008}
1009
1010STDMETHODIMP Guest::GetProcessOutput(ULONG aPID, ULONG aFlags, ULONG aTimeoutMS, ULONG64 aSize, ComSafeArrayOut(BYTE, aData))
1011{
1012#ifndef VBOX_WITH_GUEST_CONTROL
1013 ReturnComNotImplemented();
1014#else /* VBOX_WITH_GUEST_CONTROL */
1015 using namespace guestControl;
1016
1017 CheckComArgExpr(aPID, aPID > 0);
1018
1019 if (aFlags != 0) /* Flags are not supported at the moment. */
1020 return E_INVALIDARG;
1021
1022 AutoCaller autoCaller(this);
1023 if (FAILED(autoCaller.rc())) return autoCaller.rc();
1024
1025 HRESULT rc = S_OK;
1026
1027 try
1028 {
1029 /*
1030 * Create progress object.
1031 */
1032 ComObjPtr <Progress> progress;
1033 rc = progress.createObject();
1034 if (SUCCEEDED(rc))
1035 {
1036 rc = progress->init(static_cast<IGuest*>(this),
1037 BstrFmt(tr("Getting output of process")),
1038 TRUE);
1039 }
1040 if (FAILED(rc)) return rc;
1041
1042 /* Adjust timeout */
1043 if (aTimeoutMS == 0)
1044 aTimeoutMS = UINT32_MAX;
1045
1046 /* Search for existing PID. */
1047 PHOSTEXECOUTCALLBACKDATA pData = (HOSTEXECOUTCALLBACKDATA*)RTMemAlloc(sizeof(HOSTEXECOUTCALLBACKDATA));
1048 AssertReturn(pData, VBOX_E_IPRT_ERROR);
1049 uint32_t uContextID = addCtrlCallbackContext(VBOXGUESTCTRLCALLBACKTYPE_EXEC_OUTPUT,
1050 pData, sizeof(HOSTEXECOUTCALLBACKDATA), progress);
1051 Assert(uContextID > 0);
1052
1053 size_t cbData = (size_t)RT_MIN(aSize, _64K);
1054 com::SafeArray<BYTE> outputData(cbData);
1055
1056 VBOXHGCMSVCPARM paParms[5];
1057 int i = 0;
1058 paParms[i++].setUInt32(uContextID);
1059 paParms[i++].setUInt32(aPID);
1060 paParms[i++].setUInt32(aFlags); /** @todo Should represent stdout and/or stderr. */
1061
1062 int vrc = VINF_SUCCESS;
1063
1064 {
1065 /* Make sure mParent is valid, so set the read lock while using. */
1066 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1067
1068 /* Forward the information to the VMM device. */
1069 AssertPtr(mParent);
1070 VMMDev *vmmDev = mParent->getVMMDev();
1071 if (vmmDev)
1072 {
1073 LogFlowFunc(("hgcmHostCall numParms=%d\n", i));
1074 vrc = vmmDev->hgcmHostCall("VBoxGuestControlSvc", HOST_EXEC_GET_OUTPUT,
1075 i, paParms);
1076 }
1077 }
1078
1079 if (RT_SUCCESS(vrc))
1080 {
1081 LogFlowFunc(("Waiting for HGCM callback (timeout=%ldms) ...\n", aTimeoutMS));
1082
1083 /*
1084 * Wait for the HGCM low level callback until the process
1085 * has been started (or something went wrong). This is necessary to
1086 * get the PID.
1087 */
1088 CallbackListIter it = getCtrlCallbackContextByID(uContextID);
1089 BOOL fCanceled = FALSE;
1090 if (it != mCallbackList.end())
1091 {
1092 uint64_t u64Started = RTTimeMilliTS();
1093 while (!it->bCalled)
1094 {
1095 /* Check for timeout. */
1096 unsigned cMsWait;
1097 if (aTimeoutMS == RT_INDEFINITE_WAIT)
1098 cMsWait = 10;
1099 else
1100 {
1101 uint64_t cMsElapsed = RTTimeMilliTS() - u64Started;
1102 if (cMsElapsed >= aTimeoutMS)
1103 break; /* Timed out. */
1104 cMsWait = RT_MIN(10, aTimeoutMS - (uint32_t)cMsElapsed);
1105 }
1106
1107 /* Check for manual stop. */
1108 if (!it->pProgress.isNull())
1109 {
1110 rc = it->pProgress->COMGETTER(Canceled)(&fCanceled);
1111 if (FAILED(rc)) throw rc;
1112 if (fCanceled)
1113 break; /* Client wants to abort. */
1114 }
1115 RTThreadSleep(cMsWait);
1116 }
1117
1118 /* Was the whole thing canceled? */
1119 if (!fCanceled)
1120 {
1121 if (it->bCalled)
1122 {
1123 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1124
1125 /* Did we get some output? */
1126 pData = (HOSTEXECOUTCALLBACKDATA*)it->pvData;
1127 Assert(it->cbData == sizeof(HOSTEXECOUTCALLBACKDATA));
1128 AssertPtr(pData);
1129
1130 if (pData->cbData)
1131 {
1132 /* Do we need to resize the array? */
1133 if (pData->cbData > cbData)
1134 outputData.resize(pData->cbData);
1135
1136 /* Fill output in supplied out buffer. */
1137 memcpy(outputData.raw(), pData->pvData, pData->cbData);
1138 outputData.resize(pData->cbData); /* Shrink to fit actual buffer size. */
1139 }
1140 else
1141 vrc = VERR_NO_DATA; /* This is not an error we want to report to COM. */
1142 }
1143 else /* If callback not called within time ... well, that's a timeout! */
1144 vrc = VERR_TIMEOUT;
1145 }
1146 else /* Operation was canceled. */
1147 vrc = VERR_CANCELLED;
1148
1149 if (RT_FAILURE(vrc))
1150 {
1151 if (vrc == VERR_NO_DATA)
1152 {
1153 /* This is not an error we want to report to COM. */
1154 }
1155 else if (vrc == VERR_TIMEOUT)
1156 {
1157 rc = setError(VBOX_E_IPRT_ERROR,
1158 tr("The guest did not output within time (%ums)"), aTimeoutMS);
1159 }
1160 else if (vrc == VERR_CANCELLED)
1161 {
1162 rc = setError(VBOX_E_IPRT_ERROR,
1163 tr("The operation was canceled."));
1164 }
1165 else
1166 {
1167 rc = setError(E_UNEXPECTED,
1168 tr("The service call failed with error %Rrc"), vrc);
1169 }
1170 }
1171 }
1172 else /* PID lookup failed. */
1173 rc = setError(VBOX_E_IPRT_ERROR,
1174 tr("Process (PID %u) not found!"), aPID);
1175 }
1176 else /* HGCM operation failed. */
1177 rc = setError(E_UNEXPECTED,
1178 tr("The HGCM call failed with error %Rrc"), vrc);
1179
1180 /* Cleanup. */
1181 progress->uninit();
1182 progress.setNull();
1183
1184 /* If something failed (or there simply was no data, indicated by VERR_NO_DATA,
1185 * we return an empty array so that the frontend knows when to give up. */
1186 if (RT_FAILURE(vrc) || FAILED(rc))
1187 outputData.resize(0);
1188 outputData.detachTo(ComSafeArrayOutArg(aData));
1189 }
1190 catch (std::bad_alloc &)
1191 {
1192 rc = E_OUTOFMEMORY;
1193 }
1194 return rc;
1195#endif
1196}
1197
1198STDMETHODIMP Guest::GetProcessStatus(ULONG aPID, ULONG *aExitCode, ULONG *aFlags, ULONG *aStatus)
1199{
1200#ifndef VBOX_WITH_GUEST_CONTROL
1201 ReturnComNotImplemented();
1202#else /* VBOX_WITH_GUEST_CONTROL */
1203 using namespace guestControl;
1204
1205 AutoCaller autoCaller(this);
1206 if (FAILED(autoCaller.rc())) return autoCaller.rc();
1207
1208 HRESULT rc = S_OK;
1209
1210 try
1211 {
1212 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1213
1214 GuestProcessIterConst it;
1215 for (it = mGuestProcessList.begin(); it != mGuestProcessList.end(); it++)
1216 {
1217 if (it->mPID == aPID)
1218 break;
1219 }
1220
1221 if (it != mGuestProcessList.end())
1222 {
1223 *aExitCode = it->mExitCode;
1224 *aFlags = it->mFlags;
1225 *aStatus = it->mStatus;
1226 }
1227 else
1228 rc = setError(VBOX_E_IPRT_ERROR,
1229 tr("Process (PID %u) not found!"), aPID);
1230 }
1231 catch (std::bad_alloc &)
1232 {
1233 rc = E_OUTOFMEMORY;
1234 }
1235 return rc;
1236#endif
1237}
1238
1239// public methods only for internal purposes
1240/////////////////////////////////////////////////////////////////////////////
1241
1242void Guest::setAdditionsVersion(Bstr aVersion, VBOXOSTYPE aOsType)
1243{
1244 AutoCaller autoCaller(this);
1245 AssertComRCReturnVoid (autoCaller.rc());
1246
1247 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1248
1249 mData.mAdditionsVersion = aVersion;
1250 mData.mAdditionsActive = !aVersion.isEmpty();
1251 /* Older Additions didn't have this finer grained capability bit,
1252 * so enable it by default. Newer Additions will disable it immediately
1253 * if relevant. */
1254 mData.mSupportsGraphics = mData.mAdditionsActive;
1255
1256 mData.mOSTypeId = Global::OSTypeId (aOsType);
1257}
1258
1259void Guest::setSupportsSeamless (BOOL aSupportsSeamless)
1260{
1261 AutoCaller autoCaller(this);
1262 AssertComRCReturnVoid (autoCaller.rc());
1263
1264 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1265
1266 mData.mSupportsSeamless = aSupportsSeamless;
1267}
1268
1269void Guest::setSupportsGraphics (BOOL aSupportsGraphics)
1270{
1271 AutoCaller autoCaller(this);
1272 AssertComRCReturnVoid (autoCaller.rc());
1273
1274 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1275
1276 mData.mSupportsGraphics = aSupportsGraphics;
1277}
1278/* vi: set tabstop=4 shiftwidth=4 expandtab: */
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