Changeset 98122 in vbox
- Timestamp:
- Jan 19, 2023 12:03:23 AM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 155291
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/pdmusb.h
r98103 r98122 240 240 * VM Resume notification. 241 241 * 242 * This is not called when the device is hotplugged device, instead 243 * pfnHotPlugged will be called. 244 * 242 245 * @returns VBox status. 243 246 * @param pUsbIns The USB device instance data. … … 260 263 * Called after the constructor when attaching a device at run time. 261 264 * 262 * This can be used to do tasks normally assigned to pfnInitComplete and/or pfnVMPowerOn. 265 * This can be used to do tasks normally assigned to pfnInitComplete and/or 266 * pfnVMPowerOn. There will not be a call to pfnVMResume following this. 263 267 * 264 268 * @returns VBox status. -
trunk/include/VBox/vmm/vm.h
r98103 r98122 989 989 */ 990 990 #define VMSTATE_IS_RUNNING(a_enmVMState) \ 991 ( ( enmVMState) == VMSTATE_RUNNING \992 || ( enmVMState) == VMSTATE_RUNNING_LS )991 ( (a_enmVMState) == VMSTATE_RUNNING \ 992 || (a_enmVMState) == VMSTATE_RUNNING_LS ) 993 993 994 994 /** @def VM_IS_RUNNING_FOR_ASSERTIONS_ONLY … … 1000 1000 ( (pVM)->enmVMState == VMSTATE_RUNNING \ 1001 1001 || (pVM)->enmVMState == VMSTATE_RUNNING_LS ) 1002 1003 1004 /** @def VMSTATE_IS_POWERED_ON 1005 * Checks if the given state indicates the VM is powered on. 1006 * 1007 * @note Excludes all error states, so a powered on VM that hit a fatal error, 1008 * guru meditation, state load failure or similar will not be considered 1009 * powered on by this test. 1010 */ 1011 #define VMSTATE_IS_POWERED_ON(a_enmVMState) \ 1012 ( (a_enmVMState) >= VMSTATE_RESUMING && (a_enmVMState) < VMSTATE_POWERING_OFF ) 1002 1013 1003 1014 /** @def VM_ASSERT_IS_NOT_RUNNING -
trunk/src/VBox/VMM/VMMR3/PDM.cpp
r98103 r98122 2121 2121 DECLINLINE(int) pdmR3ResumeUsb(PPDMUSBINS pUsbIns) 2122 2122 { 2123 Assert(pUsbIns->Internal.s.fVMSuspended); 2124 if (pUsbIns->pReg->pfnVMResume) 2125 { 2126 LogFlow(("PDMR3Resume: Notifying - device '%s'/%d\n", pUsbIns->pReg->szName, pUsbIns->iInstance)); 2127 int rc = VINF_SUCCESS; pUsbIns->pReg->pfnVMResume(pUsbIns); 2128 if (RT_FAILURE(rc)) 2129 { 2130 LogRel(("PDMR3Resume: Device '%s'/%d -> %Rrc\n", pUsbIns->pReg->szName, pUsbIns->iInstance, rc)); 2131 return rc; 2132 } 2133 } 2134 pUsbIns->Internal.s.fVMSuspended = false; 2123 if (pUsbIns->Internal.s.fVMSuspended) 2124 { 2125 if (pUsbIns->pReg->pfnVMResume) 2126 { 2127 LogFlow(("PDMR3Resume: Notifying - device '%s'/%d\n", pUsbIns->pReg->szName, pUsbIns->iInstance)); 2128 int rc = VINF_SUCCESS; pUsbIns->pReg->pfnVMResume(pUsbIns); 2129 if (RT_FAILURE(rc)) 2130 { 2131 LogRel(("PDMR3Resume: Device '%s'/%d -> %Rrc\n", pUsbIns->pReg->szName, pUsbIns->iInstance, rc)); 2132 return rc; 2133 } 2134 } 2135 pUsbIns->Internal.s.fVMSuspended = false; 2136 } 2135 2137 return VINF_SUCCESS; 2136 2138 } -
trunk/src/VBox/VMM/VMMR3/PDMUsb.cpp
r98103 r98122 547 547 PCFGMNODE *ppInstanceNode, VUSBSPEED enmSpeed, const char *pszCaptureFilename) 548 548 { 549 const bool fAtRuntime = iInstance == -1;550 549 int rc; 551 550 … … 568 567 PCFGMNODE pInstanceToDelete = NULL; 569 568 PCFGMNODE pInstanceNode = NULL; 570 if ( fAtRuntime)569 if (iInstance == -1) 571 570 { 572 571 /** @todo r=bird: This code is bogus as it ASSUMES that all USB devices are … … 646 645 //pUsbIns->Internal.s.pHub = NULL; 647 646 pUsbIns->Internal.s.iPort = UINT32_MAX; /* to be determined. */ 648 /* Set the flag accordingly. 649 * Otherwise VMPowerOff, VMSuspend will not be called for devices attached at runtime. 650 */ 651 pUsbIns->Internal.s.fVMSuspended = !fAtRuntime; 647 VMSTATE const enmVMState = VMR3GetState(pVM); 648 pUsbIns->Internal.s.fVMSuspended = !VMSTATE_IS_POWERED_ON(enmVMState); 652 649 //pUsbIns->Internal.s.pfnAsyncNotify = NULL; 653 650 pUsbIns->pHlpR3 = &g_pdmR3UsbHlp; … … 712 709 713 710 /* Send the hot-plugged notification if applicable. */ 714 if ( fAtRuntime&& pUsbIns->pReg->pfnHotPlugged)711 if (VMSTATE_IS_POWERED_ON(enmVMState) && pUsbIns->pReg->pfnHotPlugged) 715 712 pUsbIns->pReg->pfnHotPlugged(pUsbIns); 716 713 … … 729 726 rc = VERR_PDM_USBDEV_VERSION_MISMATCH; 730 727 } 731 if ( fAtRuntime)728 if (VMSTATE_IS_POWERED_ON(enmVMState)) 732 729 pdmR3UsbDestroyDevice(pVM, pUsbIns); 733 730 /* else: destructors are invoked later. */ -
trunk/src/VBox/VMM/include/PDMInternal.h
r98103 r98122 367 367 uint32_t iPort; 368 368 /** Indicates that the USB device hasn't been powered on or resumed. 369 * See PDMDEVINSINT_FLAGS_SUSPENDED. */ 369 * See PDMDEVINSINT_FLAGS_SUSPENDED. 370 * @note Runtime attached USB devices gets a pfnHotPlugged callback rather than 371 * a pfnVMResume one. */ 370 372 bool fVMSuspended; 371 373 /** Indicates that the USB device has been reset. */
Note:
See TracChangeset
for help on using the changeset viewer.