VirtualBox

Ignore:
Timestamp:
Jun 23, 2010 10:32:17 AM (14 years ago)
Author:
vboxsync
Message:

Main: don't ignore the file system if there is no snapshot folder

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/ConsoleImpl2.cpp

    r30365 r30385  
    24212421            hrc = pMachine->COMGETTER(SnapshotFolder)(strSnap.asOutParam());            H();
    24222422            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);
    24282431            ULONG64 u64Size;
    24292432            hrc = pMedium->COMGETTER(LogicalSize)(&u64Size);                            H();
    24302433            u64Size *= _1M;
    2431             if (RT_SUCCESS(rc))
    2432             {
    24332434#ifdef RT_OS_WINDOWS
    2434                 if (   enmFsTypeFile == RTFSTYPE_FAT
    2435                     && u64Size >= _4G)
    2436                 {
    2437                     const char *pszUnit;
    2438                     uint64_t u64Print = formatDiskSize(u64Size, &pszUnit);
    2439                     setVMRuntimeErrorCallbackF(pVM, this, 0,
    2440                             "FatPartitionDetected",
    2441                             N_("The medium '%ls' has a logical size of %RU64%s "
    2442                                "but the file system the medium is located on seems "
    2443                                "to be FAT(32) which cannot handle files bigger than 4GB.\n"
    2444                                "We strongly recommend to put all your virtual disk images and "
    2445                                "the snapshot folder onto an NTFS partition"),
    2446                            strFile.raw(), u64Print, pszUnit);
    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            }
    24482449#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)
    24582467                    {
    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);
    24812481                    }
    24822482                }
     2483            }
    24832484#endif /* !RT_OS_WINDOWS */
    24842485
    2485                 /*
    2486                  * Snapshot folder:
    2487                  * Here we test only for a FAT partition as we had to create a dummy file otherwise
    2488                  */
    2489                 if (   enmFsTypeSnap == RTFSTYPE_FAT
    2490                     && u64Size >= _4G
    2491                     && !mfSnapshotFolderSizeWarningShown)
    2492                 {
    2493                     const char *pszUnit;
    2494                     uint64_t u64Print = formatDiskSize(u64Size, &pszUnit);
    2495                     setVMRuntimeErrorCallbackF(pVM, this, 0,
    2496                             "FatPartitionDetected",
     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",
    24972498#ifdef RT_OS_WINDOWS
    2498                             N_("The snapshot folder of this VM '%ls' seems to be located on "
    2499                                "a FAT(32) file system. The logical size of the medium '%ls' "
    2500                                "(%RU64%s) is bigger than the maximum file size this file "
    2501                                "system can handle (4GB).\n"
    2502                                "We strongly recommend to put all your virtual disk images and "
    2503                                "the snapshot folder onto an NTFS partition"),
     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"),
    25042505#else
    2505                             N_("The snapshot folder of this VM '%ls' seems to be located on "
    2506                                "a FAT(32) file system. The logical size of the medium '%ls' "
    2507                                "(%RU64%s) is bigger than the maximum file size this file "
    2508                                "system can handle (4GB).\n"
    2509                                "We strongly recommend to put all your virtual disk images and "
    2510                                "the snapshot folder onto a proper file system (e.g. ext3)"),
     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)"),
    25112512#endif
    2512                             strSnap.raw(), strFile.raw(), u64Print, pszUnit);
    2513                     /* Show this particular warning only once */
    2514                     mfSnapshotFolderSizeWarningShown = true;
    2515                 }
     2513                        strSnap.raw(), strFile.raw(), u64Print, pszUnit);
     2514                /* Show this particular warning only once */
     2515                mfSnapshotFolderSizeWarningShown = true;
     2516            }
    25162517
    25172518#ifdef RT_OS_LINUX
    2518                 /*
    2519                  * Ext4 bug: Check if the host I/O cache is disabled and the disk image is located
    2520                  *           on an ext4 partition. Later we have to check the Linux kernel version!
    2521                  * This bug apparently applies to the XFS file system as well.
    2522                  */
    2523                 if (   (uCaps & MediumFormatCapabilities_Asynchronous)
    2524                     && !fUseHostIOCache
    2525                     && (   enmFsTypeFile == RTFSTYPE_EXT4
    2526                         || enmFsTypeFile == RTFSTYPE_XFS))
    2527                 {
    2528                     setVMRuntimeErrorCallbackF(pVM, this, 0,
    2529                             "Ext4PartitionDetected",
    2530                             N_("The host I/O cache for at least one controller is disabled "
    2531                                "and the medium '%ls' for this VM "
    2532                                "is located on an %s partition. There is a known Linux "
    2533                                "kernel bug which can lead to the corruption of the virtual "
    2534                                "disk image under these conditions.\n"
    2535                                "Either enable the host I/O cache permanently in the VM "
    2536                                "settings or put the disk image and the snapshot folder "
    2537                                "onto a different file system.\n"
    2538                                "The host I/O cache will now be enabled for this medium"),
    2539                             strFile.raw(), enmFsTypeFile == RTFSTYPE_EXT4 ? "ext4" : "xfs");
    2540                     fUseHostIOCache = true;
    2541                 }
    2542                 else if (   (uCaps & MediumFormatCapabilities_Asynchronous)
    2543                          && !fUseHostIOCache
    2544                          && (   enmFsTypeSnap == RTFSTYPE_EXT4
    2545                              || enmFsTypeSnap == RTFSTYPE_XFS)
    2546                          && !mfSnapshotFolderExt4WarningShown)
    2547                 {
    2548                     setVMRuntimeErrorCallbackF(pVM, this, 0,
    2549                             "Ext4PartitionDetected",
    2550                             N_("The host I/O cache for at least one controller is disabled "
    2551                                "and the snapshot folder for this VM "
    2552                                "is located on an %s partition. There is a known Linux "
    2553                                "kernel bug which can lead to the corruption of the virtual "
    2554                                "disk image under these conditions.\n"
    2555                                "Either enable the host I/O cache permanently in the VM "
    2556                                "settings or put the disk image and the snapshot folder "
    2557                                "onto a different file system.\n"
    2558                                "The host I/O cache will now be enabled for this medium"),
    2559                             enmFsTypeSnap == RTFSTYPE_EXT4 ? "ext4" : "xfs");
    2560                     fUseHostIOCache = true;
    2561                     mfSnapshotFolderExt4WarningShown = true;
    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            }
    25632564#endif
    2564             }
    25652565        }
    25662566    }
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