Changeset 23419 in vbox
- Timestamp:
- Sep 29, 2009 4:20:29 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 52987
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ConsoleImpl.cpp
r23379 r23419 2726 2726 unsigned uInstance = 0; 2727 2727 unsigned uLun = 0; 2728 BOOL fHostDrive = FALSE; 2728 2729 Utf8Str location; 2730 Utf8Str format; 2729 2731 BOOL fPassthrough = FALSE; 2730 2732 … … 2780 2782 AssertComRC(rc); 2781 2783 location = loc; 2784 Bstr fmt; 2785 rc = medium->COMGETTER(Format)(fmt.asOutParam()); 2786 AssertComRC(rc); 2787 format = fmt; 2788 rc = medium->COMGETTER(HostDrive)(&fHostDrive); 2789 AssertComRC(rc); 2782 2790 } 2783 2791 rc = aMediumAttachment->COMGETTER(Passthrough)(&fPassthrough); … … 2795 2803 PVMREQ pReq; 2796 2804 int vrc = VMR3ReqCall(mpVM, VMCPUID_ANY, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS, 2797 (PFNRT)Console::changeDrive, 6,2798 this, pszDevice, uInstance, uLun, location.raw(),fPassthrough);2805 (PFNRT)Console::changeDrive, 8, 2806 this, pszDevice, uInstance, uLun, !!fHostDrive, location.raw(), format.raw(), !!fPassthrough); 2799 2807 2800 2808 /* leave the lock before waiting for a result (EMT will call us back!) */ … … 2835 2843 * @param uInstance The PDM device instance. 2836 2844 * @param uLun The PDM LUN number of the drive. 2837 * @param eState The new state. 2838 * @param peState Pointer to the variable keeping the actual state of the drive. 2839 * This will be both read and updated to eState or other appropriate state. 2845 * @param fHostDrive True if this is a host drive attachment. 2840 2846 * @param pszPath The path to the media / drive which is now being mounted / captured. 2841 2847 * If NULL no media or drive is attached and the LUN will be configured with 2842 2848 * the default block driver with no media. This will also be the state if 2843 2849 * mounting / capturing the specified media / drive fails. 2850 * @param pszFormat Medium format string, usually "RAW". 2844 2851 * @param fPassthrough Enables using passthrough mode of the host DVD drive if applicable. 2845 2852 * … … 2849 2856 */ 2850 2857 DECLCALLBACK(int) Console::changeDrive(Console *pThis, const char *pszDevice, unsigned uInstance, unsigned uLun, 2851 const char *pszPath, bool fPassthrough)2858 bool fHostDrive, const char *pszPath, const char *pszFormat, bool fPassthrough) 2852 2859 { 2853 2860 /// @todo change this to use the same code as in ConsoleImpl2.cpp 2854 LogFlowFunc(("pThis=%p pszDevice=%p:{%s} uInstance=%u uLun=%u pszPath=%p:{%s} fPassthrough=%d\n",2855 pThis, pszDevice, pszDevice, uInstance, uLun, pszPath, pszPath, fPassthrough));2861 LogFlowFunc(("pThis=%p pszDevice=%p:{%s} uInstance=%u uLun=%u fHostDrive=%d pszPath=%p:{%s} pszFormat=%p:{%s} fPassthrough=%d\n", 2862 pThis, pszDevice, pszDevice, uInstance, uLun, fHostDrive, pszPath, pszPath, pszFormat, pszFormat, fPassthrough)); 2856 2863 2857 2864 AssertReturn(pThis, VERR_INVALID_PARAMETER); … … 2918 2925 * Unmount existing media / detach host drive. 2919 2926 */ 2920 PPDMIMOUNT pIMount = NULL;2921 2927 PPDMIBASE pBase; 2922 2928 rc = PDMR3QueryLun(pVM, pszDevice, uInstance, uLun, &pBase); 2923 2929 if (RT_FAILURE(rc)) 2924 2930 { 2925 if (rc == VERR_PDM_LUN_NOT_FOUND )2931 if (rc == VERR_PDM_LUN_NOT_FOUND || rc == VERR_PDM_NO_DRIVER_ATTACHED_TO_LUN) 2926 2932 rc = VINF_SUCCESS; 2927 2933 AssertRC(rc); … … 2929 2935 else 2930 2936 { 2937 PPDMIMOUNT pIMount = NULL; 2931 2938 pIMount = (PPDMIMOUNT) pBase->pfnQueryInterface(pBase, PDMINTERFACE_MOUNT); 2932 2939 AssertBreakStmt(pIMount, rc = VERR_INVALID_POINTER); … … 2938 2945 if (rc == VERR_PDM_MEDIA_NOT_MOUNTED) 2939 2946 rc = VINF_SUCCESS; 2947 2948 if (RT_SUCCESS(rc)) 2949 { 2950 rc = PDMR3DeviceDetach(pVM, pszDevice, uInstance, uLun, PDM_TACH_FLAGS_NOT_HOT_PLUG); 2951 if (rc == VERR_PDM_NO_DRIVER_ATTACHED_TO_LUN) 2952 rc = VINF_SUCCESS; 2953 } 2940 2954 } 2941 2955 … … 2945 2959 break; 2946 2960 } 2961 2962 /** @todo this does a very thorough job. usually it's too much, 2963 * as a simple medium change (without changing between host attachment 2964 * and image) could be done with a lot less effort, by just using the 2965 * pfnUnmount and pfnMount interfaces. Later. */ 2947 2966 2948 2967 /* … … 2956 2975 #define RC_CHECK() do { if (RT_FAILURE(rc)) { AssertReleaseRC(rc); break; } } while (0) 2957 2976 2958 /* create a new block driver config */2959 2977 PCFGMNODE pLunL0; 2978 PCFGMNODE pCfg; 2960 2979 rc = CFGMR3InsertNodeF(pInst, &pLunL0, "LUN#%d", uLun); RC_CHECK(); 2961 rc = CFGMR3InsertString(pLunL0, "Driver", "Block"); RC_CHECK(); 2962 PCFGMNODE pCfg; 2963 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 2964 rc = CFGMR3InsertString(pCfg, "Type", !strcmp(pszDevice, "i82078") ? "Floppy 1.44" : "DVD"); RC_CHECK(); 2965 rc = CFGMR3InsertInteger(pCfg, "Mountable", 1); RC_CHECK(); 2980 2981 if (fHostDrive) 2982 { 2983 rc = CFGMR3InsertString(pLunL0, "Driver", !strcmp(pszDevice, "i82078") ? "HostFloppy" : "HostDVD"); RC_CHECK(); 2984 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 2985 Assert(!pszPath && !*pszPath); 2986 rc = CFGMR3InsertString(pCfg, "Path", pszPath); RC_CHECK(); 2987 if (strcmp(pszDevice, "i82078")) 2988 { 2989 rc = CFGMR3InsertInteger(pCfg, "Passthrough", fPassthrough); RC_CHECK(); 2990 } 2991 } 2992 else 2993 { 2994 /* create a new block driver config */ 2995 rc = CFGMR3InsertString(pLunL0, "Driver", "Block"); RC_CHECK(); 2996 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 2997 rc = CFGMR3InsertString(pCfg, "Type", !strcmp(pszDevice, "i82078") ? "Floppy 1.44" : "DVD"); RC_CHECK(); 2998 rc = CFGMR3InsertInteger(pCfg, "Mountable", 1); RC_CHECK(); 2999 } 2966 3000 2967 3001 /* … … 2969 3003 */ 2970 3004 rc = PDMR3DeviceAttach(pVM, pszDevice, uInstance, uLun, PDM_TACH_FLAGS_NOT_HOT_PLUG, &pBase); RC_CHECK(); 2971 pIMount = (PPDMIMOUNT) pBase->pfnQueryInterface(pBase, PDMINTERFACE_MOUNT); 2972 if (!pIMount) 2973 { 2974 AssertFailed(); 2975 return rc; 2976 } 2977 2978 /* 2979 * If we've got an image, let's mount it. 2980 */ 2981 if (pszPath && *pszPath) 2982 { 2983 rc = pIMount->pfnMount(pIMount, pszPath, strcmp(pszDevice, "i82078") ? "MediaISO" : "RawImage"); 2984 } 3005 3006 if (!fHostDrive && pszPath && *pszPath) 3007 { 3008 PCFGMNODE pLunL1; 3009 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1); RC_CHECK(); 3010 rc = CFGMR3InsertString(pLunL1, "Driver", "VD"); RC_CHECK(); 3011 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg); RC_CHECK(); 3012 rc = CFGMR3InsertString(pCfg, "Path", pszPath); RC_CHECK(); 3013 rc = CFGMR3InsertString(pCfg, "Format", pszFormat); RC_CHECK(); 3014 if (strcmp(pszDevice, "i82078")) 3015 { 3016 rc = CFGMR3InsertInteger(pCfg, "ReadOnly", 1); RC_CHECK(); 3017 } 3018 /** @todo later pass full VDConfig information and parent images */ 3019 3020 PPDMIMOUNT pIMount = NULL; 3021 pIMount = (PPDMIMOUNT) pBase->pfnQueryInterface(pBase, PDMINTERFACE_MOUNT); 3022 if (!pIMount) 3023 { 3024 AssertFailed(); 3025 return rc; 3026 } 3027 3028 LogRelFunc(("mounting new medium\n")); 3029 rc = pIMount->pfnMount(pIMount, NULL , NULL); 3030 } 3031 CFGMR3Dump(pInst); 2985 3032 2986 3033 #undef RC_CHECK -
trunk/src/VBox/Main/include/ConsoleImpl.h
r23223 r23419 438 438 static DECLCALLBACK(int) changeDrive (Console *pThis, const char *pszDevice, 439 439 unsigned uInstance, unsigned uLun, 440 const char *pszPath, bool fPassthrough); 440 bool fHostDrive, const char *pszPath, 441 const char *pszFormat, bool fPassthrough); 441 442 const char *controllerTypeToDev(StorageControllerType_T enmCtrlType); 442 443 HRESULT convertBusPortDeviceToLun(StorageBus_T enmBus, LONG port, LONG device, unsigned &uLun);
Note:
See TracChangeset
for help on using the changeset viewer.