VirtualBox

Changeset 98122 in vbox


Ignore:
Timestamp:
Jan 19, 2023 12:03:23 AM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
155291
Message:

VMM/PDM: Fixed assertion in PDMR3ResumeUsb after attaching a virtual MSD.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/pdmusb.h

    r98103 r98122  
    240240     * VM Resume notification.
    241241     *
     242     * This is not called when the device is hotplugged device, instead
     243     * pfnHotPlugged will be called.
     244     *
    242245     * @returns VBox status.
    243246     * @param   pUsbIns     The USB device instance data.
     
    260263     * Called after the constructor when attaching a device at run time.
    261264     *
    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.
    263267     *
    264268     * @returns VBox status.
  • trunk/include/VBox/vmm/vm.h

    r98103 r98122  
    989989 */
    990990#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 )
    993993
    994994/** @def VM_IS_RUNNING_FOR_ASSERTIONS_ONLY
     
    10001000    (   (pVM)->enmVMState == VMSTATE_RUNNING \
    10011001     || (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 )
    10021013
    10031014/** @def VM_ASSERT_IS_NOT_RUNNING
  • trunk/src/VBox/VMM/VMMR3/PDM.cpp

    r98103 r98122  
    21212121DECLINLINE(int) pdmR3ResumeUsb(PPDMUSBINS pUsbIns)
    21222122{
    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    }
    21352137    return VINF_SUCCESS;
    21362138}
  • trunk/src/VBox/VMM/VMMR3/PDMUsb.cpp

    r98103 r98122  
    547547                                PCFGMNODE *ppInstanceNode, VUSBSPEED enmSpeed, const char *pszCaptureFilename)
    548548{
    549     const bool fAtRuntime = iInstance == -1;
    550549    int rc;
    551550
     
    568567    PCFGMNODE pInstanceToDelete = NULL;
    569568    PCFGMNODE pInstanceNode = NULL;
    570     if (fAtRuntime)
     569    if (iInstance == -1)
    571570    {
    572571        /** @todo r=bird: This code is bogus as it ASSUMES that all USB devices are
     
    646645    //pUsbIns->Internal.s.pHub                = NULL;
    647646    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);
    652649    //pUsbIns->Internal.s.pfnAsyncNotify      = NULL;
    653650    pUsbIns->pHlpR3                         = &g_pdmR3UsbHlp;
     
    712709
    713710            /* Send the hot-plugged notification if applicable. */
    714             if (fAtRuntime && pUsbIns->pReg->pfnHotPlugged)
     711            if (VMSTATE_IS_POWERED_ON(enmVMState) && pUsbIns->pReg->pfnHotPlugged)
    715712                pUsbIns->pReg->pfnHotPlugged(pUsbIns);
    716713
     
    729726            rc = VERR_PDM_USBDEV_VERSION_MISMATCH;
    730727    }
    731     if (fAtRuntime)
     728    if (VMSTATE_IS_POWERED_ON(enmVMState))
    732729        pdmR3UsbDestroyDevice(pVM, pUsbIns);
    733730    /* else: destructors are invoked later. */
  • trunk/src/VBox/VMM/include/PDMInternal.h

    r98103 r98122  
    367367    uint32_t                        iPort;
    368368    /** 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. */
    370372    bool                            fVMSuspended;
    371373    /** Indicates that the USB device has been reset. */
Note: See TracChangeset for help on using the changeset viewer.

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