- Timestamp:
- Jun 14, 2007 6:29:54 PM (18 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DevATA.cpp
r2981 r3113 2526 2526 PVMREQ pReq; 2527 2527 rc = VMR3ReqCall(PDMDevHlpGetVM(pDevIns), &pReq, RT_INDEFINITE_WAIT, 2528 (PFNRT)s->pDrvMount->pfnUnmount, 1, s->pDrvMount);2528 (PFNRT)s->pDrvMount->pfnUnmount, 2, s->pDrvMount, false); 2529 2529 AssertReleaseRC(rc); 2530 2530 VMR3ReqFree(pReq); -
trunk/src/VBox/Devices/Storage/DrvBlock.cpp
r2981 r3113 509 509 510 510 /** @copydoc PDMIMOUNT::pfnUnmount */ 511 static DECLCALLBACK(int) drvblockUnmount(PPDMIMOUNT pInterface )511 static DECLCALLBACK(int) drvblockUnmount(PPDMIMOUNT pInterface, bool fForce) 512 512 { 513 513 PDRVBLOCK pData = PDMIMOUNT_2_DRVBLOCK(pInterface); … … 521 521 return VERR_PDM_MEDIA_NOT_MOUNTED; 522 522 } 523 if (pData->fLocked )523 if (pData->fLocked && !fForce) 524 524 { 525 525 Log(("drvblockUmount: Locked\n")); 526 526 return VERR_PDM_MEDIA_LOCKED; 527 527 } 528 529 /* Media is no longer locked even if it was previously. */ 530 pData->fLocked = false; 528 531 529 532 /* -
trunk/src/VBox/Devices/Storage/DrvHostBase.cpp
r2981 r3113 457 457 458 458 /** @copydoc PDMIMOUNT::pfnUnmount */ 459 static DECLCALLBACK(int) drvHostBaseUnmount(PPDMIMOUNT pInterface )459 static DECLCALLBACK(int) drvHostBaseUnmount(PPDMIMOUNT pInterface, bool fForce) 460 460 { 461 461 LogFlow(("drvHostBaseUnmount: returns VERR_NOT_SUPPORTED\n")); … … 567 567 /** 568 568 * Gets the BSD Name (/dev/disc[0-9]+) for the service. 569 * 570 * This is done by recursing down the I/O registry until we hit upon an entry 571 * with a BSD Name. Usually we find it two levels down. (Further down under 569 * 570 * This is done by recursing down the I/O registry until we hit upon an entry 571 * with a BSD Name. Usually we find it two levels down. (Further down under 572 572 * the IOCDPartitionScheme, the volume (slices) BSD Name is found. We don't 573 573 * seem to have to go this far fortunately.) 574 * 574 * 575 575 * @return VINF_SUCCESS if found, VERR_FILE_NOT_FOUND otherwise. 576 576 * @param Entry The current I/O registry entry reference. 577 577 * @param pszName Where to store the name. 128 bytes. 578 * @param cRecursions Number of recursions. This is used as an precation 578 * @param cRecursions Number of recursions. This is used as an precation 579 579 * just to limit the depth and avoid blowing the stack 580 580 * should we hit a bug or something. … … 610 610 611 611 612 /** 612 /** 613 613 * Callback notifying us that the async DADiskClaim()/DADiskUnmount call has completed. 614 * 614 * 615 615 * @param DiskRef The disk that was attempted claimed / unmounted. 616 616 * @param DissenterRef NULL on success, contains details on failure. … … 630 630 /** 631 631 * Obtain exclusive access to the DVD device, umount it if necessary. 632 * 632 * 633 633 * @return VBox status code. 634 634 * @param pThis The driver instance. … … 644 644 if (irc == kIOReturnSuccess) 645 645 { 646 /* 646 /* 647 647 * This is a bit weird, but if we unmounted the DVD drive we also need to 648 648 * unlock it afterwards or the guest won't be able to eject it later on. … … 661 661 if (irc == kIOReturnExclusiveAccess) 662 662 return VERR_SHARING_VIOLATION; /* already used exclusivly. */ 663 if (irc != kIOReturnBusy) 663 if (irc != kIOReturnBusy) 664 664 return VERR_GENERAL_FAILURE; /* not mounted */ 665 665 666 666 /* 667 667 * Attempt to the unmount all volumes of the device. 668 * It seems we can can do this all in one go without having to enumerate the 669 * volumes (sessions) and deal with them one by one. This is very fortuitous 668 * It seems we can can do this all in one go without having to enumerate the 669 * volumes (sessions) and deal with them one by one. This is very fortuitous 670 670 * as the disk arbitration API is a bit cumbersome to deal with. 671 671 */ … … 683 683 if (pThis->pDADisk) 684 684 { 685 /* 685 /* 686 686 * Try claim the device. 687 687 */ … … 717 717 else 718 718 Log(("%s-%d: claim => rc32=%d & rcDA=%#x\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, rc32, rcDA)); 719 719 720 720 CFRelease(pThis->pDADisk); 721 721 pThis->pDADisk = NULL; … … 1501 1501 1502 1502 #ifdef __DARWIN__ 1503 /* 1504 * The unclaiming doesn't seem to mean much, the DVD is actaully 1503 /* 1504 * The unclaiming doesn't seem to mean much, the DVD is actaully 1505 1505 * remounted when we release exclusive access. I'm not quite sure 1506 1506 * if I should put the unclaim first or not... … … 1563 1563 } 1564 1564 1565 if (RTCritSectIsInitialized(&pThis->CritSect)) 1565 /* Forget about the notifications. */ 1566 pThis->pDrvMountNotify = NULL; 1567 1568 /* Leave the instance operational if this is just a cleanup of the state 1569 * after an attach error happened. So don't destry the critsect then. */ 1570 if (!pThis->fKeepInstance && RTCritSectIsInitialized(&pThis->CritSect)) 1566 1571 RTCritSectDelete(&pThis->CritSect); 1567 1572 LogFlow(("%s-%d: drvHostBaseDestruct completed\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance)); … … 1591 1596 */ 1592 1597 pThis->pDrvIns = pDrvIns; 1598 pThis->fKeepInstance = false; 1593 1599 pThis->ThreadPoller = NIL_RTTHREAD; 1594 1600 #ifdef __DARWIN__ … … 1722 1728 } 1723 1729 1730 /* Define whether attach failure is an error (default) or not. */ 1731 bool fAttachFailError; 1732 rc = CFGMR3QueryBool(pCfgHandle, "AttachFailError", &fAttachFailError); 1733 if (VBOX_FAILURE(rc)) 1734 fAttachFailError = true; 1735 pThis->fAttachFailError = fAttachFailError; 1736 1724 1737 /* name to open & watch for */ 1725 1738 #ifdef __WIN__ … … 1754 1767 int DRVHostBaseInitFinish(PDRVHOSTBASE pThis) 1755 1768 { 1769 int src = VINF_SUCCESS; 1756 1770 PPDMDRVINS pDrvIns = pThis->pDrvIns; 1757 1771 … … 1851 1865 pszDevice); 1852 1866 default: 1853 return rc; 1867 if (pThis->fAttachFailError) 1868 return rc; 1869 else 1870 { 1871 int erc = PDMDrvHlpVMSetRuntimeError(pDrvIns, 1872 false, "DrvHost_MOUNTFAIL", 1873 N_("Cannot attach to host device '%s'"), pszDevice); 1874 AssertRC(erc); 1875 src = rc; 1876 } 1854 1877 } 1855 1878 } 1856 1879 #ifdef __WIN__ 1857 DRVHostBaseMediaPresent(pThis); 1880 if (VBOX_SUCCESS(src)) 1881 DRVHostBaseMediaPresent(pThis); 1858 1882 #endif 1859 1883 … … 1873 1897 1874 1898 #ifndef __WIN__ 1875 /* 1876 * Create the event semaphore which the poller thread will wait on. 1877 */ 1878 rc = RTSemEventCreate(&pThis->EventPoller); 1879 if (VBOX_FAILURE(rc)) 1880 return rc; 1899 if (VBOX_SUCCESS(src)) 1900 { 1901 /* 1902 * Create the event semaphore which the poller thread will wait on. 1903 */ 1904 rc = RTSemEventCreate(&pThis->EventPoller); 1905 if (VBOX_FAILURE(rc)) 1906 return rc; 1907 } 1881 1908 #endif 1882 1909 … … 1888 1915 return rc; 1889 1916 1890 /* 1891 * Start the thread which will poll for the media. 1892 */ 1893 rc = RTThreadCreate(&pThis->ThreadPoller, drvHostBaseMediaThread, pThis, 0, 1894 RTTHREADTYPE_INFREQUENT_POLLER, RTTHREADFLAGS_WAITABLE, "DVDMEDIA"); 1895 if (VBOX_FAILURE(rc)) 1896 { 1897 AssertMsgFailed(("Failed to create poller thread. rc=%Vrc\n", rc)); 1917 if (VBOX_SUCCESS(src)) 1918 { 1919 /* 1920 * Start the thread which will poll for the media. 1921 */ 1922 rc = RTThreadCreate(&pThis->ThreadPoller, drvHostBaseMediaThread, pThis, 0, 1923 RTTHREADTYPE_INFREQUENT_POLLER, RTTHREADFLAGS_WAITABLE, "DVDMEDIA"); 1924 if (VBOX_FAILURE(rc)) 1925 { 1926 AssertMsgFailed(("Failed to create poller thread. rc=%Vrc\n", rc)); 1927 return rc; 1928 } 1929 1930 /* 1931 * Wait for the thread to start up (!w32:) and do one detection loop. 1932 */ 1933 rc = RTThreadUserWait(pThis->ThreadPoller, 10000); 1934 AssertRC(rc); 1935 #ifdef __WIN__ 1936 if (!pThis->hwndDeviceChange) 1937 return VERR_GENERAL_FAILURE; 1938 #endif 1939 } 1940 1941 if (VBOX_FAILURE(src)) 1942 return src; 1943 else 1898 1944 return rc; 1899 } 1900 1901 /* 1902 * Wait for the thread to start up (!w32:) and do one detection loop. 1903 */ 1904 rc = RTThreadUserWait(pThis->ThreadPoller, 10000); 1905 AssertRC(rc); 1906 #ifdef __WIN__ 1907 if (!pThis->hwndDeviceChange) 1908 return VERR_GENERAL_FAILURE; 1909 #endif 1910 1911 return rc; 1912 } 1913 1945 } 1946 -
trunk/src/VBox/Devices/Storage/DrvHostBase.h
r2981 r3113 49 49 /** The current readonly status. */ 50 50 bool fReadOnly; 51 /** Flag whether failure to attach is an error or not. */ 52 bool fAttachFailError; 53 /** Flag whether to keep instance working (as unmounted though). */ 54 bool fKeepInstance; 51 55 /** Device name (MMHeap). */ 52 56 char *pszDevice; -
trunk/src/VBox/Devices/Storage/DrvHostDVD.cpp
r2981 r3113 81 81 82 82 83 /* Forward declarations. */ 84 85 static DECLCALLBACK(int) drvHostDvdDoLock(PDRVHOSTBASE pThis, bool fLock); 83 86 84 87 85 88 /** @copydoc PDMIMOUNT::pfnUnmount */ 86 static DECLCALLBACK(int) drvHostDvdUnmount(PPDMIMOUNT pInterface )89 static DECLCALLBACK(int) drvHostDvdUnmount(PPDMIMOUNT pInterface, bool fForce) 87 90 { 88 91 PDRVHOSTBASE pThis = PDMIMOUNT_2_DRVHOSTBASE(pInterface); … … 93 96 */ 94 97 int rc = VINF_SUCCESS; 95 if (!pThis->fLocked )98 if (!pThis->fLocked || fForce) 96 99 { 100 /* Unlock drive if necessary. */ 101 if (pThis->fLocked) 102 drvHostDvdDoLock(pThis, false); 103 97 104 /* 98 105 * Eject the disc. … … 498 505 * Validate configuration. 499 506 */ 500 if (!CFGMR3AreValuesValid(pCfgHandle, "Path\0Interval\0Locked\0BIOSVisible\0 Passthrough\0"))507 if (!CFGMR3AreValuesValid(pCfgHandle, "Path\0Interval\0Locked\0BIOSVisible\0AttachFailError\0Passthrough\0")) 501 508 return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES; 502 509 … … 539 546 */ 540 547 rc = DRVHostBaseInitFinish(pThis); 541 if (VBOX_SUCCESS(rc)) 548 } 549 550 if (VBOX_FAILURE(rc)) 551 { 552 if (!pThis->fAttachFailError) 542 553 { 543 LogFlow(("drvHostDvdConstruct: return %Vrc\n", rc)); 544 return rc; 554 /* Suppressing the attach failure error must not affect the normal 555 * DRVHostBaseDestruct, so reset this flag below before leaving. */ 556 pThis->fKeepInstance = true; 557 rc = VINF_SUCCESS; 545 558 } 546 } 547 DRVHostBaseDestruct(pDrvIns); 559 DRVHostBaseDestruct(pDrvIns); 560 pThis->fKeepInstance = false; 561 } 548 562 549 563 LogFlow(("drvHostDvdConstruct: returns %Vrc\n", rc)); -
trunk/src/VBox/Devices/Storage/DrvHostFloppy.cpp
r2981 r3113 181 181 */ 182 182 rc = DRVHostBaseInitFinish(&pThis->Base); 183 if (VBOX_SUCCESS(rc)) 183 } 184 if (VBOX_FAILURE(rc)) 185 { 186 if (!pThis->Base.fAttachFailError) 184 187 { 185 LogFlow(("drvHostFloppyConstruct: return %Vrc\n", rc)); 186 return rc; 188 /* Suppressing the attach failure error must not affect the normal 189 * DRVHostBaseDestruct, so reset this flag below before leaving. */ 190 pThis->Base.fKeepInstance = true; 191 rc = VINF_SUCCESS; 187 192 } 188 } 189 DRVHostBaseDestruct(pDrvIns); 193 DRVHostBaseDestruct(pDrvIns); 194 pThis->Base.fKeepInstance = false; 195 } 190 196 191 197 LogFlow(("drvHostFloppyConstruct: returns %Vrc\n", rc)); -
trunk/src/VBox/Main/ConsoleImpl.cpp
r3086 r3113 2839 2839 * Unmount the media. 2840 2840 */ 2841 rc = pIMount->pfnUnmount (pIMount );2841 rc = pIMount->pfnUnmount (pIMount, false); 2842 2842 if (rc == VERR_PDM_MEDIA_NOT_MOUNTED) 2843 2843 rc = VINF_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.