本文整理汇总了C++中ComObjPtr::getMachine方法的典型用法代码示例。如果您正苦于以下问题:C++ ComObjPtr::getMachine方法的具体用法?C++ ComObjPtr::getMachine怎么用?C++ ComObjPtr::getMachine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ComObjPtr
的用法示例。
在下文中一共展示了ComObjPtr::getMachine方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: detachAllDevicesFromVM
/**
* Detach all USB devices currently attached to a VM.
*
* This is in an interface for SessionMachine::DetachAllUSBDevices(), which
* is an internal worker used by Console::powerDown() from the VM process
* at VM startup, and SessionMachine::uninit() at VM abend.
*
* This is, like #detachDeviceFromVM(), normally a two stage journey
* where \a aDone indicates where we are. In addition we may be called
* to clean up VMs that have abended, in which case there will be no
* preparatory call. Filters will be applied to the devices in the final
* call with the risk that we have to do some IPC when attaching them
* to other VMs.
*
* @param aMachine The machine to detach devices from.
*
* @returns COM status code, perhaps with error info.
*
* @remarks Write locks the host object and may temporarily abandon
* its locks to perform IPC.
*/
HRESULT USBProxyService::detachAllDevicesFromVM(SessionMachine *aMachine, bool aDone, bool aAbnormal)
{
// get a list of all running machines while we're outside the lock
// (getOpenedMachines requests locks which are incompatible with the host object lock)
SessionMachinesList llOpenedMachines;
mHost->parent()->getOpenedMachines(llOpenedMachines);
AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
/*
* Make a copy of the device list (not the HostUSBDevice objects, just
* the list) since we may end up performing IPC and temporarily have
* to abandon locks when applying filters.
*/
HostUSBDeviceList ListCopy = mDevices;
for (HostUSBDeviceList::iterator it = ListCopy.begin();
it != ListCopy.end();
++it)
{
ComObjPtr<HostUSBDevice> pHostDevice = *it;
AutoWriteLock devLock(pHostDevice COMMA_LOCKVAL_SRC_POS);
if (pHostDevice->getMachine() == aMachine)
{
/*
* Same procedure as in detachUSBDevice().
*/
bool fRunFilters = false;
HRESULT hrc = pHostDevice->onDetachFromVM(aMachine, aDone, &fRunFilters, aAbnormal);
if ( SUCCEEDED(hrc)
&& fRunFilters)
{
Assert(aDone && pHostDevice->getUnistate() == kHostUSBDeviceState_HeldByProxy && pHostDevice->getMachine().isNull());
devLock.release();
alock.release();
HRESULT hrc2 = runAllFiltersOnDevice(pHostDevice, llOpenedMachines, aMachine);
ComAssertComRC(hrc2);
alock.acquire();
}
}
}
return S_OK;
}
示例2: detachDeviceFromVM
/**
* Notification from VM process about USB device detaching progress.
*
* This is in an interface for SessionMachine::DetachUSBDevice(), which is
* an internal worker used by Console::DetachUSBDevice() from the VM process.
*
* @param aMachine The machine which is sending the notification.
* @param aId The UUID of the USB device is concerns.
* @param aDone \a false for the pre-action notification (necessary
* for advancing the device state to avoid confusing
* the guest).
* \a true for the post-action notification. The device
* will be subjected to all filters except those of
* of \a Machine.
*
* @returns COM status code.
*
* @remarks When \a aDone is \a true this method may end up doing IPC to other
* VMs when running filters. In these cases it will temporarily
* abandon its locks.
*/
HRESULT USBProxyService::detachDeviceFromVM(SessionMachine *aMachine, IN_GUID aId, bool aDone)
{
LogFlowThisFunc(("aMachine=%p{%s} aId={%RTuuid} aDone=%RTbool\n",
aMachine,
aMachine->getName().c_str(),
Guid(aId).raw(),
aDone));
// get a list of all running machines while we're outside the lock
// (getOpenedMachines requests locks which are incompatible with the lock of the machines list)
SessionMachinesList llOpenedMachines;
mHost->parent()->getOpenedMachines(llOpenedMachines);
AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
ComObjPtr<HostUSBDevice> pHostDevice = findDeviceById(aId);
ComAssertRet(!pHostDevice.isNull(), E_FAIL);
AutoWriteLock devLock(pHostDevice COMMA_LOCKVAL_SRC_POS);
/*
* Work the state machine.
*/
LogFlowThisFunc(("id={%RTuuid} state=%s aDone=%RTbool name={%s}\n",
pHostDevice->getId().raw(), pHostDevice->getStateName(), aDone, pHostDevice->getName().c_str()));
bool fRunFilters = false;
HRESULT hrc = pHostDevice->onDetachFromVM(aMachine, aDone, &fRunFilters);
/*
* Run filters if necessary.
*/
if ( SUCCEEDED(hrc)
&& fRunFilters)
{
Assert(aDone && pHostDevice->getUnistate() == kHostUSBDeviceState_HeldByProxy && pHostDevice->getMachine().isNull());
devLock.release();
alock.release();
HRESULT hrc2 = runAllFiltersOnDevice(pHostDevice, llOpenedMachines, aMachine);
ComAssertComRC(hrc2);
}
return hrc;
}