Index: /trunk/src/VBox/Main/ConsoleImpl2.cpp
===================================================================
--- /trunk/src/VBox/Main/ConsoleImpl2.cpp	(revision 30384)
+++ /trunk/src/VBox/Main/ConsoleImpl2.cpp	(revision 30385)
@@ -2421,146 +2421,146 @@
             hrc = pMachine->COMGETTER(SnapshotFolder)(strSnap.asOutParam());            H();
             Utf8Str utfSnap = Utf8Str(strSnap);
-            RTFSTYPE enmFsTypeFile;
-            RTFSTYPE enmFsTypeSnap;
-            rc = RTFsQueryType(utfFile.c_str(), &enmFsTypeFile);
-            if (RT_SUCCESS(rc))
-                rc = RTFsQueryType(utfSnap.c_str(), &enmFsTypeSnap);
+            RTFSTYPE enmFsTypeFile = RTFSTYPE_UNKNOWN;
+            RTFSTYPE enmFsTypeSnap = RTFSTYPE_UNKNOWN;
+            int rc2 = RTFsQueryType(utfFile.c_str(), &enmFsTypeFile);
+            AssertMsgRCReturn(rc2, "Querying the file type of '%s' failed!\n", rc2);
+            /* Ignore the error code. On error, the file system type is still 'unknown' so
+             * none of the following pathes is taken. This can happen for new VMs which
+             * still don't have a snapshot folder. */
+            (void)RTFsQueryType(utfSnap.c_str(), &enmFsTypeSnap);
             ULONG64 u64Size;
             hrc = pMedium->COMGETTER(LogicalSize)(&u64Size);                            H();
             u64Size *= _1M;
-            if (RT_SUCCESS(rc))
-            {
 #ifdef RT_OS_WINDOWS
-                if (   enmFsTypeFile == RTFSTYPE_FAT
-                    && u64Size >= _4G)
-                {
-                    const char *pszUnit;
-                    uint64_t u64Print = formatDiskSize(u64Size, &pszUnit);
-                    setVMRuntimeErrorCallbackF(pVM, this, 0,
-                            "FatPartitionDetected",
-                            N_("The medium '%ls' has a logical size of %RU64%s "
-                               "but the file system the medium is located on seems "
-                               "to be FAT(32) which cannot handle files bigger than 4GB.\n"
-                               "We strongly recommend to put all your virtual disk images and "
-                               "the snapshot folder onto an NTFS partition"),
-                           strFile.raw(), u64Print, pszUnit);
-                }
+            if (   enmFsTypeFile == RTFSTYPE_FAT
+                && u64Size >= _4G)
+            {
+                const char *pszUnit;
+                uint64_t u64Print = formatDiskSize(u64Size, &pszUnit);
+                setVMRuntimeErrorCallbackF(pVM, this, 0,
+                        "FatPartitionDetected",
+                        N_("The medium '%ls' has a logical size of %RU64%s "
+                           "but the file system the medium is located on seems "
+                           "to be FAT(32) which cannot handle files bigger than 4GB.\n"
+                           "We strongly recommend to put all your virtual disk images and "
+                           "the snapshot folder onto an NTFS partition"),
+                        strFile.raw(), u64Print, pszUnit);
+            }
 #else /* !RT_OS_WINDOWS */
-                if (   enmFsTypeFile == RTFSTYPE_FAT
-                    || enmFsTypeFile == RTFSTYPE_EXT
-                    || enmFsTypeFile == RTFSTYPE_EXT2
-                    || enmFsTypeFile == RTFSTYPE_EXT3
-                    || enmFsTypeFile == RTFSTYPE_EXT4)
-                {
-                    RTFILE file;
-                    rc = RTFileOpen(&file, utfFile.c_str(), RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
-                    if (RT_SUCCESS(rc))
+            if (   enmFsTypeFile == RTFSTYPE_FAT
+                || enmFsTypeFile == RTFSTYPE_EXT
+                || enmFsTypeFile == RTFSTYPE_EXT2
+                || enmFsTypeFile == RTFSTYPE_EXT3
+                || enmFsTypeFile == RTFSTYPE_EXT4)
+            {
+                RTFILE file;
+                rc = RTFileOpen(&file, utfFile.c_str(), RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
+                if (RT_SUCCESS(rc))
+                {
+                    RTFOFF maxSize;
+                    /* Careful: This function will work only on selected local file systems! */
+                    rc = RTFileGetMaxSizeEx(file, &maxSize);
+                    RTFileClose(file);
+                    if (   RT_SUCCESS(rc)
+                        && maxSize > 0
+                        && u64Size > (ULONG64)maxSize)
                     {
-                        RTFOFF maxSize;
-                        /* Careful: This function will work only on selected local file systems! */
-                        rc = RTFileGetMaxSizeEx(file, &maxSize);
-                        RTFileClose(file);
-                        if (   RT_SUCCESS(rc)
-                            && maxSize > 0
-                            && u64Size > (ULONG64)maxSize)
-                        {
-                            const char *pszUnitSiz;
-                            const char *pszUnitMax;
-                            uint64_t u64PrintSiz = formatDiskSize(u64Size, &pszUnitSiz);
-                            uint64_t u64PrintMax = formatDiskSize(maxSize, &pszUnitMax);
-                            setVMRuntimeErrorCallbackF(pVM, this, 0,
-                                    "FatPartitionDetected", /* <= not exact but ... */
-                                    N_("The medium '%ls' has a logical size of %RU64%s "
-                                       "but the file system the medium is located on can "
-                                       "only handle files up to %RU64%s in theory.\n"
-                                       "We strongly recommend to put all your virtual disk "
-                                       "images and the snapshot folder onto a proper "
-                                       "file system (e.g. ext3) with a sufficient size"),
-                                    strFile.raw(), u64PrintSiz, pszUnitSiz, u64PrintMax, pszUnitMax);
-                        }
+                        const char *pszUnitSiz;
+                        const char *pszUnitMax;
+                        uint64_t u64PrintSiz = formatDiskSize(u64Size, &pszUnitSiz);
+                        uint64_t u64PrintMax = formatDiskSize(maxSize, &pszUnitMax);
+                        setVMRuntimeErrorCallbackF(pVM, this, 0,
+                                "FatPartitionDetected", /* <= not exact but ... */
+                                N_("The medium '%ls' has a logical size of %RU64%s "
+                                   "but the file system the medium is located on can "
+                                   "only handle files up to %RU64%s in theory.\n"
+                                   "We strongly recommend to put all your virtual disk "
+                                   "images and the snapshot folder onto a proper "
+                                   "file system (e.g. ext3) with a sufficient size"),
+                                strFile.raw(), u64PrintSiz, pszUnitSiz, u64PrintMax, pszUnitMax);
                     }
                 }
+            }
 #endif /* !RT_OS_WINDOWS */
 
-                /*
-                 * Snapshot folder:
-                 * Here we test only for a FAT partition as we had to create a dummy file otherwise
-                 */
-                if (   enmFsTypeSnap == RTFSTYPE_FAT
-                    && u64Size >= _4G
-                    && !mfSnapshotFolderSizeWarningShown)
-                {
-                    const char *pszUnit;
-                    uint64_t u64Print = formatDiskSize(u64Size, &pszUnit);
-                    setVMRuntimeErrorCallbackF(pVM, this, 0,
-                            "FatPartitionDetected",
+            /*
+             * Snapshot folder:
+             * Here we test only for a FAT partition as we had to create a dummy file otherwise
+             */
+            if (   enmFsTypeSnap == RTFSTYPE_FAT
+                && u64Size >= _4G
+                && !mfSnapshotFolderSizeWarningShown)
+            {
+                const char *pszUnit;
+                uint64_t u64Print = formatDiskSize(u64Size, &pszUnit);
+                setVMRuntimeErrorCallbackF(pVM, this, 0,
+                        "FatPartitionDetected",
 #ifdef RT_OS_WINDOWS
-                            N_("The snapshot folder of this VM '%ls' seems to be located on "
-                               "a FAT(32) file system. The logical size of the medium '%ls' "
-                               "(%RU64%s) is bigger than the maximum file size this file "
-                               "system can handle (4GB).\n"
-                               "We strongly recommend to put all your virtual disk images and "
-                               "the snapshot folder onto an NTFS partition"),
+                        N_("The snapshot folder of this VM '%ls' seems to be located on "
+                           "a FAT(32) file system. The logical size of the medium '%ls' "
+                           "(%RU64%s) is bigger than the maximum file size this file "
+                           "system can handle (4GB).\n"
+                           "We strongly recommend to put all your virtual disk images and "
+                           "the snapshot folder onto an NTFS partition"),
 #else
-                            N_("The snapshot folder of this VM '%ls' seems to be located on "
-                               "a FAT(32) file system. The logical size of the medium '%ls' "
-                               "(%RU64%s) is bigger than the maximum file size this file "
-                               "system can handle (4GB).\n"
-                               "We strongly recommend to put all your virtual disk images and "
-                               "the snapshot folder onto a proper file system (e.g. ext3)"),
+                        N_("The snapshot folder of this VM '%ls' seems to be located on "
+                            "a FAT(32) file system. The logical size of the medium '%ls' "
+                            "(%RU64%s) is bigger than the maximum file size this file "
+                            "system can handle (4GB).\n"
+                            "We strongly recommend to put all your virtual disk images and "
+                            "the snapshot folder onto a proper file system (e.g. ext3)"),
 #endif
-                            strSnap.raw(), strFile.raw(), u64Print, pszUnit);
-                    /* Show this particular warning only once */
-                    mfSnapshotFolderSizeWarningShown = true;
-                }
+                        strSnap.raw(), strFile.raw(), u64Print, pszUnit);
+                /* Show this particular warning only once */
+                mfSnapshotFolderSizeWarningShown = true;
+            }
 
 #ifdef RT_OS_LINUX
-                /*
-                 * Ext4 bug: Check if the host I/O cache is disabled and the disk image is located
-                 *           on an ext4 partition. Later we have to check the Linux kernel version!
-                 * This bug apparently applies to the XFS file system as well.
-                 */
-                if (   (uCaps & MediumFormatCapabilities_Asynchronous)
-                    && !fUseHostIOCache
-                    && (   enmFsTypeFile == RTFSTYPE_EXT4
-                        || enmFsTypeFile == RTFSTYPE_XFS))
-                {
-                    setVMRuntimeErrorCallbackF(pVM, this, 0,
-                            "Ext4PartitionDetected",
-                            N_("The host I/O cache for at least one controller is disabled "
-                               "and the medium '%ls' for this VM "
-                               "is located on an %s partition. There is a known Linux "
-                               "kernel bug which can lead to the corruption of the virtual "
-                               "disk image under these conditions.\n"
-                               "Either enable the host I/O cache permanently in the VM "
-                               "settings or put the disk image and the snapshot folder "
-                               "onto a different file system.\n"
-                               "The host I/O cache will now be enabled for this medium"),
-                            strFile.raw(), enmFsTypeFile == RTFSTYPE_EXT4 ? "ext4" : "xfs");
-                    fUseHostIOCache = true;
-                }
-                else if (   (uCaps & MediumFormatCapabilities_Asynchronous)
-                         && !fUseHostIOCache
-                         && (   enmFsTypeSnap == RTFSTYPE_EXT4
-                             || enmFsTypeSnap == RTFSTYPE_XFS)
-                         && !mfSnapshotFolderExt4WarningShown)
-                {
-                    setVMRuntimeErrorCallbackF(pVM, this, 0,
-                            "Ext4PartitionDetected",
-                            N_("The host I/O cache for at least one controller is disabled "
-                               "and the snapshot folder for this VM "
-                               "is located on an %s partition. There is a known Linux "
-                               "kernel bug which can lead to the corruption of the virtual "
-                               "disk image under these conditions.\n"
-                               "Either enable the host I/O cache permanently in the VM "
-                               "settings or put the disk image and the snapshot folder "
-                               "onto a different file system.\n"
-                               "The host I/O cache will now be enabled for this medium"),
-                            enmFsTypeSnap == RTFSTYPE_EXT4 ? "ext4" : "xfs");
-                    fUseHostIOCache = true;
-                    mfSnapshotFolderExt4WarningShown = true;
-                }
+            /*
+             * Ext4 bug: Check if the host I/O cache is disabled and the disk image is located
+             *           on an ext4 partition. Later we have to check the Linux kernel version!
+             * This bug apparently applies to the XFS file system as well.
+             */
+            if (   (uCaps & MediumFormatCapabilities_Asynchronous)
+                && !fUseHostIOCache
+                && (   enmFsTypeFile == RTFSTYPE_EXT4
+                    || enmFsTypeFile == RTFSTYPE_XFS))
+            {
+                setVMRuntimeErrorCallbackF(pVM, this, 0,
+                        "Ext4PartitionDetected",
+                        N_("The host I/O cache for at least one controller is disabled "
+                           "and the medium '%ls' for this VM "
+                           "is located on an %s partition. There is a known Linux "
+                           "kernel bug which can lead to the corruption of the virtual "
+                           "disk image under these conditions.\n"
+                           "Either enable the host I/O cache permanently in the VM "
+                           "settings or put the disk image and the snapshot folder "
+                           "onto a different file system.\n"
+                           "The host I/O cache will now be enabled for this medium"),
+                        strFile.raw(), enmFsTypeFile == RTFSTYPE_EXT4 ? "ext4" : "xfs");
+                fUseHostIOCache = true;
+            }
+            else if (   (uCaps & MediumFormatCapabilities_Asynchronous)
+                     && !fUseHostIOCache
+                     && (   enmFsTypeSnap == RTFSTYPE_EXT4
+                         || enmFsTypeSnap == RTFSTYPE_XFS)
+                     && !mfSnapshotFolderExt4WarningShown)
+            {
+                setVMRuntimeErrorCallbackF(pVM, this, 0,
+                        "Ext4PartitionDetected",
+                        N_("The host I/O cache for at least one controller is disabled "
+                           "and the snapshot folder for this VM "
+                           "is located on an %s partition. There is a known Linux "
+                           "kernel bug which can lead to the corruption of the virtual "
+                           "disk image under these conditions.\n"
+                           "Either enable the host I/O cache permanently in the VM "
+                           "settings or put the disk image and the snapshot folder "
+                           "onto a different file system.\n"
+                           "The host I/O cache will now be enabled for this medium"),
+                        enmFsTypeSnap == RTFSTYPE_EXT4 ? "ext4" : "xfs");
+                fUseHostIOCache = true;
+                mfSnapshotFolderExt4WarningShown = true;
+            }
 #endif
-            }
         }
     }
