Changeset 30847 in vbox
- Timestamp:
- Jul 14, 2010 3:40:49 PM (14 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 6 edited
-
MachineImpl.cpp (modified) (1 diff)
-
Performance.cpp (modified) (3 diffs)
-
VirtualBoxImpl.cpp (modified) (1 diff)
-
include/MachineImpl.h (modified) (2 diffs)
-
include/Performance.h (modified) (2 diffs)
-
include/VirtualBoxImpl.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/MachineImpl.cpp
r30812 r30847 9597 9597 AutoMultiWriteLock3 multilock(mParent, mParent->host(), this COMMA_LOCKVAL_SRC_POS); 9598 9598 9599 #ifdef VBOX_WITH_RESOURCE_USAGE_API 9600 unregisterMetrics(mParent->performanceCollector(), mPeer); 9601 #endif /* VBOX_WITH_RESOURCE_USAGE_API */ 9599 // Trigger async cleanup tasks, avoid doing things here which are not 9600 // vital to be done immediately and maybe need more locks. This calls 9601 // Machine::unregisterMetrics(). 9602 mParent->onMachineUninit(mPeer); 9602 9603 9603 9604 if (aReason == Uninit::Abnormal) -
trunk/src/VBox/Main/Performance.cpp
r30764 r30847 120 120 121 121 #ifndef VBOX_COLLECTOR_TEST_CASE 122 123 uint32_t CollectorGuestHAL::cVMsEnabled = 0; 124 125 CollectorGuestHAL::CollectorGuestHAL(Machine *machine, CollectorHAL *hostHAL) 126 : CollectorHAL(), cEnabled(0), mMachine(machine), mConsole(NULL), 127 mGuest(NULL), mLastTick(0), mHostHAL(hostHAL), mCpuUser(0), 128 mCpuKernel(0), mCpuIdle(0), mMemTotal(0), mMemFree(0), 129 mMemBalloon(0), mMemShared(0), mMemCache(0), mPageTotal(0) 130 { 131 Assert(mMachine); 132 /* cannot use ComObjPtr<Machine> in Performance.h, do it manually */ 133 mMachine->AddRef(); 134 } 135 122 136 CollectorGuestHAL::~CollectorGuestHAL() 123 137 { 138 /* cannot use ComObjPtr<Machine> in Performance.h, do it manually */ 139 mMachine->Release(); 124 140 Assert(!cEnabled); 125 141 } … … 127 143 int CollectorGuestHAL::enable() 128 144 { 145 /* Must make sure that the machine object does not get uninitialized 146 * in the middle of enabling this collector. Causes timing-related 147 * behavior otherwise, which we don't want. In particular the 148 * GetRemoteConsole call below can hang if the VM didn't completely 149 * terminate (the VM processes stop processing events shortly before 150 * closing the session). This avoids the hang. */ 151 AutoCaller autoCaller(mMachine); 152 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 153 129 154 HRESULT ret = S_OK; 130 155 131 156 if (ASMAtomicIncU32(&cEnabled) == 1) 132 157 { 158 ASMAtomicIncU32(&cVMsEnabled); 133 159 ComPtr<IInternalSessionControl> directControl; 134 160 … … 153 179 if (ASMAtomicDecU32(&cEnabled) == 0) 154 180 { 181 if (ASMAtomicDecU32(&cVMsEnabled) == 0) 182 { 183 if (mHostHAL) 184 mHostHAL->setMemHypervisorStats(0 /* ulMemAllocTotal */, 0 /* ulMemFreeTotal */, 0 /* ulMemBalloonTotal */, 0 /* ulMemSharedTotal */); 185 } 155 186 Assert(mGuest && mConsole); 156 187 mGuest->COMSETTER(StatisticsUpdateInterval)(0 /* off */); -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r30825 r30847 2701 2701 { 2702 2702 postEvent(new GuestPropertyEvent(this, aMachineId, aName, aValue, aFlags)); 2703 } 2704 2705 /** Event for onMachineUninit(), this is not a CallbackEvent */ 2706 class MachineUninitEvent : public Event 2707 { 2708 public: 2709 2710 MachineUninitEvent(VirtualBox *aVirtualBox, Machine *aMachine) 2711 : mVirtualBox(aVirtualBox), mMachine(aMachine) 2712 { 2713 Assert(aVirtualBox); 2714 Assert(aMachine); 2715 } 2716 2717 void *handler() 2718 { 2719 #ifdef VBOX_WITH_RESOURCE_USAGE_API 2720 /* Handle unregistering metrics here, as it is not vital to get 2721 * it done immediately. It reduces the number of locks needed and 2722 * the lock contention in SessionMachine::uninit. */ 2723 mMachine->unregisterMetrics(mVirtualBox->performanceCollector(), mMachine); 2724 #endif /* VBOX_WITH_RESOURCE_USAGE_API */ 2725 2726 return NULL; 2727 } 2728 2729 private: 2730 2731 /** 2732 * Note that this is a weak ref -- the CallbackEvent handler thread 2733 * is bound to the lifetime of the VirtualBox instance, so it's safe. 2734 */ 2735 VirtualBox *mVirtualBox; 2736 2737 /** Reference to the machine object. */ 2738 ComObjPtr<Machine> mMachine; 2739 }; 2740 2741 /** 2742 * Trigger internal event. This isn't meant to be signalled to clients. 2743 * @note Doesn't lock any object. 2744 */ 2745 void VirtualBox::onMachineUninit(Machine *aMachine) 2746 { 2747 postEvent(new MachineUninitEvent(this, aMachine)); 2703 2748 } 2704 2749 -
trunk/src/VBox/Main/include/MachineImpl.h
r30764 r30847 356 356 357 357 void uninit(); 358 359 #ifdef VBOX_WITH_RESOURCE_USAGE_API 360 // Needed from VirtualBox, for the delayed metrics cleanup. 361 void unregisterMetrics(PerformanceCollector *aCollector, Machine *aMachine); 362 #endif /* VBOX_WITH_RESOURCE_USAGE_API */ 358 363 359 364 protected: … … 801 806 #ifdef VBOX_WITH_RESOURCE_USAGE_API 802 807 void registerMetrics(PerformanceCollector *aCollector, Machine *aMachine, RTPROCESS pid); 803 void unregisterMetrics(PerformanceCollector *aCollector, Machine *aMachine);804 808 805 809 pm::CollectorGuestHAL *mGuestHAL; -
trunk/src/VBox/Main/include/Performance.h
r29632 r30847 186 186 { 187 187 public: 188 CollectorGuestHAL(Machine *machine, CollectorHAL *hostHAL) : CollectorHAL(), cEnabled(0), mMachine(machine), mConsole(NULL), mGuest(NULL), 189 mLastTick(0), mHostHAL(hostHAL), mCpuUser(0), mCpuKernel(0), mCpuIdle(0), mMemTotal(0), mMemFree(0), 190 mMemBalloon(0), mMemShared(0), mMemCache(0), mPageTotal(0) {}; 188 CollectorGuestHAL(Machine *machine, CollectorHAL *hostHAL); 191 189 ~CollectorGuestHAL(); 192 190 … … 236 234 ULONG mMemCache; 237 235 ULONG mPageTotal; 236 237 private: 238 static uint32_t cVMsEnabled; 238 239 }; 239 240 -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r30832 r30847 215 215 void onGuestPropertyChange(const Guid &aMachineId, IN_BSTR aName, IN_BSTR aValue, 216 216 IN_BSTR aFlags); 217 void onMachineUninit(Machine *aMachine); 217 218 218 219 ComObjPtr<GuestOSType> getUnknownOSType();
Note:
See TracChangeset
for help on using the changeset viewer.

