Changeset 30385 in vbox for trunk/src/VBox/Main/ConsoleImpl2.cpp
- Timestamp:
- Jun 23, 2010 10:32:17 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ConsoleImpl2.cpp
r30365 r30385 2421 2421 hrc = pMachine->COMGETTER(SnapshotFolder)(strSnap.asOutParam()); H(); 2422 2422 Utf8Str utfSnap = Utf8Str(strSnap); 2423 RTFSTYPE enmFsTypeFile; 2424 RTFSTYPE enmFsTypeSnap; 2425 rc = RTFsQueryType(utfFile.c_str(), &enmFsTypeFile); 2426 if (RT_SUCCESS(rc)) 2427 rc = RTFsQueryType(utfSnap.c_str(), &enmFsTypeSnap); 2423 RTFSTYPE enmFsTypeFile = RTFSTYPE_UNKNOWN; 2424 RTFSTYPE enmFsTypeSnap = RTFSTYPE_UNKNOWN; 2425 int rc2 = RTFsQueryType(utfFile.c_str(), &enmFsTypeFile); 2426 AssertMsgRCReturn(rc2, "Querying the file type of '%s' failed!\n", rc2); 2427 /* Ignore the error code. On error, the file system type is still 'unknown' so 2428 * none of the following pathes is taken. This can happen for new VMs which 2429 * still don't have a snapshot folder. */ 2430 (void)RTFsQueryType(utfSnap.c_str(), &enmFsTypeSnap); 2428 2431 ULONG64 u64Size; 2429 2432 hrc = pMedium->COMGETTER(LogicalSize)(&u64Size); H(); 2430 2433 u64Size *= _1M; 2431 if (RT_SUCCESS(rc))2432 {2433 2434 #ifdef RT_OS_WINDOWS 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2435 if ( enmFsTypeFile == RTFSTYPE_FAT 2436 && u64Size >= _4G) 2437 { 2438 const char *pszUnit; 2439 uint64_t u64Print = formatDiskSize(u64Size, &pszUnit); 2440 setVMRuntimeErrorCallbackF(pVM, this, 0, 2441 "FatPartitionDetected", 2442 N_("The medium '%ls' has a logical size of %RU64%s " 2443 "but the file system the medium is located on seems " 2444 "to be FAT(32) which cannot handle files bigger than 4GB.\n" 2445 "We strongly recommend to put all your virtual disk images and " 2446 "the snapshot folder onto an NTFS partition"), 2447 strFile.raw(), u64Print, pszUnit); 2448 } 2448 2449 #else /* !RT_OS_WINDOWS */ 2449 if ( enmFsTypeFile == RTFSTYPE_FAT 2450 || enmFsTypeFile == RTFSTYPE_EXT 2451 || enmFsTypeFile == RTFSTYPE_EXT2 2452 || enmFsTypeFile == RTFSTYPE_EXT3 2453 || enmFsTypeFile == RTFSTYPE_EXT4) 2454 { 2455 RTFILE file; 2456 rc = RTFileOpen(&file, utfFile.c_str(), RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE); 2457 if (RT_SUCCESS(rc)) 2450 if ( enmFsTypeFile == RTFSTYPE_FAT 2451 || enmFsTypeFile == RTFSTYPE_EXT 2452 || enmFsTypeFile == RTFSTYPE_EXT2 2453 || enmFsTypeFile == RTFSTYPE_EXT3 2454 || enmFsTypeFile == RTFSTYPE_EXT4) 2455 { 2456 RTFILE file; 2457 rc = RTFileOpen(&file, utfFile.c_str(), RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE); 2458 if (RT_SUCCESS(rc)) 2459 { 2460 RTFOFF maxSize; 2461 /* Careful: This function will work only on selected local file systems! */ 2462 rc = RTFileGetMaxSizeEx(file, &maxSize); 2463 RTFileClose(file); 2464 if ( RT_SUCCESS(rc) 2465 && maxSize > 0 2466 && u64Size > (ULONG64)maxSize) 2458 2467 { 2459 RTFOFF maxSize; 2460 /* Careful: This function will work only on selected local file systems! */ 2461 rc = RTFileGetMaxSizeEx(file, &maxSize); 2462 RTFileClose(file); 2463 if ( RT_SUCCESS(rc) 2464 && maxSize > 0 2465 && u64Size > (ULONG64)maxSize) 2466 { 2467 const char *pszUnitSiz; 2468 const char *pszUnitMax; 2469 uint64_t u64PrintSiz = formatDiskSize(u64Size, &pszUnitSiz); 2470 uint64_t u64PrintMax = formatDiskSize(maxSize, &pszUnitMax); 2471 setVMRuntimeErrorCallbackF(pVM, this, 0, 2472 "FatPartitionDetected", /* <= not exact but ... */ 2473 N_("The medium '%ls' has a logical size of %RU64%s " 2474 "but the file system the medium is located on can " 2475 "only handle files up to %RU64%s in theory.\n" 2476 "We strongly recommend to put all your virtual disk " 2477 "images and the snapshot folder onto a proper " 2478 "file system (e.g. ext3) with a sufficient size"), 2479 strFile.raw(), u64PrintSiz, pszUnitSiz, u64PrintMax, pszUnitMax); 2480 } 2468 const char *pszUnitSiz; 2469 const char *pszUnitMax; 2470 uint64_t u64PrintSiz = formatDiskSize(u64Size, &pszUnitSiz); 2471 uint64_t u64PrintMax = formatDiskSize(maxSize, &pszUnitMax); 2472 setVMRuntimeErrorCallbackF(pVM, this, 0, 2473 "FatPartitionDetected", /* <= not exact but ... */ 2474 N_("The medium '%ls' has a logical size of %RU64%s " 2475 "but the file system the medium is located on can " 2476 "only handle files up to %RU64%s in theory.\n" 2477 "We strongly recommend to put all your virtual disk " 2478 "images and the snapshot folder onto a proper " 2479 "file system (e.g. ext3) with a sufficient size"), 2480 strFile.raw(), u64PrintSiz, pszUnitSiz, u64PrintMax, pszUnitMax); 2481 2481 } 2482 2482 } 2483 } 2483 2484 #endif /* !RT_OS_WINDOWS */ 2484 2485 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2486 /* 2487 * Snapshot folder: 2488 * Here we test only for a FAT partition as we had to create a dummy file otherwise 2489 */ 2490 if ( enmFsTypeSnap == RTFSTYPE_FAT 2491 && u64Size >= _4G 2492 && !mfSnapshotFolderSizeWarningShown) 2493 { 2494 const char *pszUnit; 2495 uint64_t u64Print = formatDiskSize(u64Size, &pszUnit); 2496 setVMRuntimeErrorCallbackF(pVM, this, 0, 2497 "FatPartitionDetected", 2497 2498 #ifdef RT_OS_WINDOWS 2498 2499 2500 2501 2502 2503 2499 N_("The snapshot folder of this VM '%ls' seems to be located on " 2500 "a FAT(32) file system. The logical size of the medium '%ls' " 2501 "(%RU64%s) is bigger than the maximum file size this file " 2502 "system can handle (4GB).\n" 2503 "We strongly recommend to put all your virtual disk images and " 2504 "the snapshot folder onto an NTFS partition"), 2504 2505 #else 2505 2506 2507 2508 2509 2510 2506 N_("The snapshot folder of this VM '%ls' seems to be located on " 2507 "a FAT(32) file system. The logical size of the medium '%ls' " 2508 "(%RU64%s) is bigger than the maximum file size this file " 2509 "system can handle (4GB).\n" 2510 "We strongly recommend to put all your virtual disk images and " 2511 "the snapshot folder onto a proper file system (e.g. ext3)"), 2511 2512 #endif 2512 2513 2514 2515 2513 strSnap.raw(), strFile.raw(), u64Print, pszUnit); 2514 /* Show this particular warning only once */ 2515 mfSnapshotFolderSizeWarningShown = true; 2516 } 2516 2517 2517 2518 #ifdef RT_OS_LINUX 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2519 /* 2520 * Ext4 bug: Check if the host I/O cache is disabled and the disk image is located 2521 * on an ext4 partition. Later we have to check the Linux kernel version! 2522 * This bug apparently applies to the XFS file system as well. 2523 */ 2524 if ( (uCaps & MediumFormatCapabilities_Asynchronous) 2525 && !fUseHostIOCache 2526 && ( enmFsTypeFile == RTFSTYPE_EXT4 2527 || enmFsTypeFile == RTFSTYPE_XFS)) 2528 { 2529 setVMRuntimeErrorCallbackF(pVM, this, 0, 2530 "Ext4PartitionDetected", 2531 N_("The host I/O cache for at least one controller is disabled " 2532 "and the medium '%ls' for this VM " 2533 "is located on an %s partition. There is a known Linux " 2534 "kernel bug which can lead to the corruption of the virtual " 2535 "disk image under these conditions.\n" 2536 "Either enable the host I/O cache permanently in the VM " 2537 "settings or put the disk image and the snapshot folder " 2538 "onto a different file system.\n" 2539 "The host I/O cache will now be enabled for this medium"), 2540 strFile.raw(), enmFsTypeFile == RTFSTYPE_EXT4 ? "ext4" : "xfs"); 2541 fUseHostIOCache = true; 2542 } 2543 else if ( (uCaps & MediumFormatCapabilities_Asynchronous) 2544 && !fUseHostIOCache 2545 && ( enmFsTypeSnap == RTFSTYPE_EXT4 2546 || enmFsTypeSnap == RTFSTYPE_XFS) 2547 && !mfSnapshotFolderExt4WarningShown) 2548 { 2549 setVMRuntimeErrorCallbackF(pVM, this, 0, 2550 "Ext4PartitionDetected", 2551 N_("The host I/O cache for at least one controller is disabled " 2552 "and the snapshot folder for this VM " 2553 "is located on an %s partition. There is a known Linux " 2554 "kernel bug which can lead to the corruption of the virtual " 2555 "disk image under these conditions.\n" 2556 "Either enable the host I/O cache permanently in the VM " 2557 "settings or put the disk image and the snapshot folder " 2558 "onto a different file system.\n" 2559 "The host I/O cache will now be enabled for this medium"), 2560 enmFsTypeSnap == RTFSTYPE_EXT4 ? "ext4" : "xfs"); 2561 fUseHostIOCache = true; 2562 mfSnapshotFolderExt4WarningShown = true; 2563 } 2563 2564 #endif 2564 }2565 2565 } 2566 2566 }
Note:
See TracChangeset
for help on using the changeset viewer.