Index: /trunk/doc/manual/en_US/SDKRef.xml
===================================================================
--- /trunk/doc/manual/en_US/SDKRef.xml	(revision 55976)
+++ /trunk/doc/manual/en_US/SDKRef.xml	(revision 55977)
@@ -3907,5 +3907,8 @@
            </itemizedlist>
           Small adjustments to the parameter lists have been made to reduce
-          the number of API calls when taking online snapshots etc.</para>
+          the number of API calls when taking online snapshots (no longer
+          needs explicit pausing), and taking a snapshot also returns now
+          the snapshot id (useful for finding the right snapshot if there
+          are non-unique snapshot names).</para>
         </listitem>
 
Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp	(revision 55976)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp	(revision 55977)
@@ -519,5 +519,6 @@
         RTStrmPrintf(pStrm,
                            "%s snapshot %s        <uuid|vmname>\n"
-                     "                            take <name> [--description <desc>] [--live] |\n"
+                     "                            take <name> [--description <desc>] [--live]\n"
+                     "                                 [--uniquename Number,Timestamp,Space,Force] |\n"
                      "                            delete <uuid|snapname> |\n"
                      "                            restore <uuid|snapname> |\n"
Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageSnapshot.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageSnapshot.cpp	(revision 55976)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageSnapshot.cpp	(revision 55977)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2014 Oracle Corporation
+ * Copyright (C) 2006-2015 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -29,4 +29,5 @@
 #include <iprt/stream.h>
 #include <iprt/getopt.h>
+#include <iprt/time.h>
 
 #include "VBoxManage.h"
@@ -260,4 +261,49 @@
 }
 
+typedef enum SnapshotUniqueFlags
+{
+    SnapshotUniqueFlags_Null = 0,
+    SnapshotUniqueFlags_Number = RT_BIT(1),
+    SnapshotUniqueFlags_Timestamp = RT_BIT(2),
+    SnapshotUniqueFlags_Space = RT_BIT(16),
+    SnapshotUniqueFlags_Force = RT_BIT(30)
+} SnapshotUniqueFlags;
+
+static int parseSnapshotUniqueFlags(const char *psz, SnapshotUniqueFlags *pUnique)
+{
+    int rc = VINF_SUCCESS;
+    unsigned uUnique = 0;
+    while (psz && *psz && RT_SUCCESS(rc))
+    {
+        size_t len;
+        const char *pszComma = strchr(psz, ',');
+        if (pszComma)
+            len = pszComma - psz;
+        else
+            len = strlen(psz);
+        if (len > 0)
+        {
+            if (!RTStrNICmp(psz, "number", len))
+                uUnique |= SnapshotUniqueFlags_Number;
+            else if (!RTStrNICmp(psz, "timestamp", len))
+                uUnique |= SnapshotUniqueFlags_Timestamp;
+            else if (!RTStrNICmp(psz, "space", len))
+                uUnique |= SnapshotUniqueFlags_Space;
+            else if (!RTStrNICmp(psz, "force", len))
+                uUnique |= SnapshotUniqueFlags_Force;
+            else
+                rc = VERR_PARSE_ERROR;
+        }
+        if (pszComma)
+            psz += len + 1;
+        else
+            psz += len;
+    }
+
+    if (RT_SUCCESS(rc))
+        *pUnique = (SnapshotUniqueFlags)uUnique;
+    return rc;
+}
+
 /**
  * Implementation for all VBoxManage snapshot ... subcommands.
@@ -308,4 +354,5 @@
             Bstr desc;
             bool fPause = true; /* default is NO live snapshot */
+            SnapshotUniqueFlags enmUnique = SnapshotUniqueFlags_Null;
             static const RTGETOPTDEF s_aTakeOptions[] =
             {
@@ -314,5 +361,6 @@
                 { "-desc",         'd', RTGETOPT_REQ_STRING },
                 { "--pause",       'p', RTGETOPT_REQ_NOTHING },
-                { "--live",        'l', RTGETOPT_REQ_NOTHING }
+                { "--live",        'l', RTGETOPT_REQ_NOTHING },
+                { "--uniquename",  'u', RTGETOPT_REQ_STRING }
             };
             RTGETOPTSTATE GetOptState;
@@ -321,4 +369,5 @@
             int ch;
             RTGETOPTUNION Value;
+            int vrc;
             while (   SUCCEEDED(rc)
                    && (ch = RTGetOpt(&GetOptState, &Value)))
@@ -338,4 +387,10 @@
                         break;
 
+                    case 'u':
+                        vrc = parseSnapshotUniqueFlags(Value.psz, &enmUnique);
+                        if (RT_FAILURE(vrc))
+                            return errorArgument("Invalid unique name description '%s'", Value.psz);
+                        break;
+
                     default:
                         errorGetOpt(USAGE_SNAPSHOT, ch, &Value);
@@ -347,11 +402,73 @@
                 break;
 
+            if (enmUnique & (SnapshotUniqueFlags_Number | SnapshotUniqueFlags_Timestamp))
+            {
+                ComPtr<ISnapshot> pSnapshot;
+                rc = sessionMachine->FindSnapshot(name.raw(),
+                                                  pSnapshot.asOutParam());
+                if (SUCCEEDED(rc) || (enmUnique & SnapshotUniqueFlags_Force))
+                {
+                    /* there is a duplicate, need to create a unique name */
+                    uint32_t count = 0;
+                    RTTIMESPEC now;
+
+                    if (enmUnique & SnapshotUniqueFlags_Number)
+                    {
+                        if (enmUnique & SnapshotUniqueFlags_Force)
+                            count = 1;
+                        else
+                            count = 2;
+                    }
+                    else
+                        RTTimeNow(&now);
+
+                    while (count < 500)
+                    {
+                        Utf8Str suffix;
+                        if (enmUnique & SnapshotUniqueFlags_Number)
+                            suffix = Utf8StrFmt("%u", count);
+                        else
+                        {
+                            RTTIMESPEC nowplus = now;
+                            RTTimeSpecAddSeconds(&nowplus, count);
+                            RTTIME stamp;
+                            RTTimeExplode(&stamp, &nowplus);
+                            suffix = Utf8StrFmt("%04u-%02u-%02uT%02u:%02u:%02uZ", stamp.i32Year, stamp.u8Month, stamp.u8MonthDay, stamp.u8Hour, stamp.u8Minute, stamp.u8Second);
+                        }
+                        Bstr tryName = name;
+                        if (enmUnique & SnapshotUniqueFlags_Space)
+                            tryName = BstrFmt("%ls %s", name.raw(), suffix.c_str());
+                        else
+                            tryName = BstrFmt("%ls%s", name.raw(), suffix.c_str());
+                        count++;
+                        rc = sessionMachine->FindSnapshot(tryName.raw(),
+                                                          pSnapshot.asOutParam());
+                        if (FAILED(rc))
+                        {
+                            name = tryName;
+                            break;
+                        }
+                    }
+                    if (SUCCEEDED(rc))
+                    {
+                        errorArgument("Failed to generate a unique snapshot name");
+                        rc = E_FAIL;
+                        break;
+                    }
+                }
+                rc = S_OK;
+            }
+
             ComPtr<IProgress> progress;
+            Bstr snapId;
             CHECK_ERROR_BREAK(sessionMachine, TakeSnapshot(name.raw(), desc.raw(),
-                                                           fPause,
+                                                           fPause, snapId.asOutParam(),
                                                            progress.asOutParam()));
 
             rc = showProgress(progress);
-            CHECK_PROGRESS_ERROR(progress, ("Failed to take snapshot"));
+            if (SUCCEEDED(rc))
+                RTPrintf("Snapshot taken. UUID: %ls\n", snapId.raw());
+            else
+                CHECK_PROGRESS_ERROR(progress, ("Failed to take snapshot"));
         }
         else if (    (fDelete = !strcmp(a->argv[1], "delete"))
@@ -389,5 +506,5 @@
                 // restore or delete snapshot: then resolve cmd line argument to snapshot instance
                 CHECK_ERROR_BREAK(sessionMachine, FindSnapshot(Bstr(a->argv[2]).raw(),
-                                                         pSnapshot.asOutParam()));
+                                                               pSnapshot.asOutParam()));
             }
 
@@ -397,5 +514,5 @@
             {
                 CHECK_ERROR_BREAK(sessionMachine, DeleteSnapshot(bstrSnapGuid.raw(),
-                                                           pProgress.asOutParam()));
+                                                                 pProgress.asOutParam()));
             }
             else
@@ -428,5 +545,5 @@
             {
                 CHECK_ERROR_BREAK(sessionMachine, FindSnapshot(Bstr(a->argv[2]).raw(),
-                                                         pSnapshot.asOutParam()));
+                                                               pSnapshot.asOutParam()));
             }
 
Index: /trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp	(revision 55976)
+++ /trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp	(revision 55977)
@@ -4958,7 +4958,8 @@
             gpProgress = NULL;
             HRESULT rc;
+            Bstr snapId;
             CHECK_ERROR(gpMachine, TakeSnapshot(Bstr(pszSnapshotName).raw(),
                                                 Bstr("Taken by VBoxSDL").raw(),
-						TRUE,
+                                                TRUE, snapId.asOutParam(),
                                                 gpProgress.asOutParam()));
             if (FAILED(rc))
Index: /trunk/src/VBox/Frontends/VBoxShell/vboxshell.py
===================================================================
--- /trunk/src/VBox/Frontends/VBoxShell/vboxshell.py	(revision 55976)
+++ /trunk/src/VBox/Frontends/VBoxShell/vboxshell.py	(revision 55977)
@@ -2635,5 +2635,5 @@
         else:
             desc = ""
-        cmdAnyVm(ctx, mach, lambda ctx, mach, console, args: progressBar(ctx, mach.takeSnapshot(name, desc, true)))
+        cmdAnyVm(ctx, mach, lambda ctx, mach, console, args: progressBar(ctx, mach.takeSnapshot(name, desc, true)[-1]))
         return 0
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp	(revision 55976)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp	(revision 55977)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2010-2014 Oracle Corporation
+ * Copyright (C) 2010-2015 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -1424,6 +1424,7 @@
     if (fDialogAccepted)
     {
+        QString strSnapshotId;
         /* Prepare the take-snapshot progress: */
-        CProgress progress = machine().TakeSnapshot(strSnapshotName, strSnapshotDescription, true);
+        CProgress progress = machine().TakeSnapshot(strSnapshotName, strSnapshotDescription, true, strSnapshotId);
         if (machine().isOk())
         {
Index: /trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSnapshotsWgt.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSnapshotsWgt.cpp	(revision 55976)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSnapshotsWgt.cpp	(revision 55977)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2014 Oracle Corporation
+ * Copyright (C) 2006-2015 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -889,6 +889,7 @@
             if (fDialogAccepted)
             {
+                QString strSnapshotId;
                 /* Prepare the take-snapshot progress: */
-                CProgress progress = machine.TakeSnapshot(strSnapshotName, strSnapshotDescription, true);
+                CProgress progress = machine.TakeSnapshot(strSnapshotName, strSnapshotDescription, true, strSnapshotId);
                 if (machine.isOk())
                 {
Index: /trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVM.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVM.cpp	(revision 55976)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVM.cpp	(revision 55977)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2011-2014 Oracle Corporation
+ * Copyright (C) 2011-2015 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -84,5 +84,6 @@
         /* Take the snapshot: */
         QString strSnapshotName = tr("Linked Base for %1 and %2").arg(m_machine.GetName()).arg(strName);
-        CProgress progress = machine.TakeSnapshot(strSnapshotName, "", true);
+        QString strSnapshotId;
+        CProgress progress = machine.TakeSnapshot(strSnapshotName, "", true, strSnapshotId);
 
         if (machine.isOk())
@@ -107,5 +108,5 @@
 
         /* Get the new snapshot and the snapshot machine. */
-        const CSnapshot &newSnapshot = m_machine.FindSnapshot(strSnapshotName);
+        const CSnapshot &newSnapshot = m_machine.FindSnapshot(strSnapshotId);
         if (newSnapshot.isNull())
         {
Index: /trunk/src/VBox/Main/idl/VirtualBox.xidl
===================================================================
--- /trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 55976)
+++ /trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 55977)
@@ -4170,5 +4170,5 @@
   <interface
     name="IMachine" extends="$unknown"
-    uuid="feb138aa-dbce-4a89-8ec0-380fc7ec4913"
+    uuid="520a0c22-8dbc-458d-b637-31eb078b5526"
     wsmap="managed"
     wrap-hint-server-addinterfaces="IInternalMachineControl"
@@ -7392,4 +7392,8 @@
           (@c true) and live (@c false) snapshots. When the VM is not running
           the result is always an offline snapshot.</desc>
+      </param>
+      <param name="id" type="uuid" mod="string" dir="out">
+        <desc>UUID of the snapshot which will be created. Useful for follow-up
+        operations after the snapshot has been created.</desc>
       </param>
       <param name="progress" type="IProgress" dir="return">
Index: /trunk/src/VBox/Main/include/MachineImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/MachineImpl.h	(revision 55976)
+++ /trunk/src/VBox/Main/include/MachineImpl.h	(revision 55977)
@@ -1193,4 +1193,5 @@
                          const com::Utf8Str &aDescription,
                          BOOL aPause,
+                         com::Guid &aId,
                          ComPtr<IProgress> &aProgress);
     HRESULT deleteSnapshot(const com::Guid &aId,
@@ -1439,4 +1440,5 @@
                          const com::Utf8Str &aDescription,
                          BOOL aPause,
+                         com::Guid &aId,
                          ComPtr<IProgress> &aProgress);
     HRESULT deleteSnapshot(const com::Guid &aId,
Index: /trunk/src/VBox/Main/src-server/SnapshotImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-server/SnapshotImpl.cpp	(revision 55976)
+++ /trunk/src/VBox/Main/src-server/SnapshotImpl.cpp	(revision 55977)
@@ -1332,4 +1332,5 @@
                      const Utf8Str &strName,
                      const Utf8Str &strDescription,
+                     const Guid &uuidSnapshot,
                      bool fPause,
                      uint32_t uMemSize,
@@ -1338,4 +1339,5 @@
           m_strName(strName),
           m_strDescription(strDescription),
+          m_uuidSnapshot(uuidSnapshot),
           m_fPause(fPause),
           m_uMemSize(uMemSize),
@@ -1357,4 +1359,5 @@
     Utf8Str m_strName;
     Utf8Str m_strDescription;
+    Guid m_uuidSnapshot;
     Utf8Str m_strStateFilePath;
     ComPtr<IInternalSessionControl> m_pDirectControl;
@@ -1412,4 +1415,5 @@
                               const com::Utf8Str &aDescription,
                               BOOL fPause,
+                              com::Guid &aId,
                               ComPtr<IProgress> &aProgress)
 {
@@ -1417,4 +1421,5 @@
     NOREF(aDescription);
     NOREF(fPause);
+    NOREF(aId);
     NOREF(aProgress);
     ReturnComNotImplemented();
@@ -1424,4 +1429,5 @@
                                      const com::Utf8Str &aDescription,
                                      BOOL fPause,
+                                     com::Guid &aId,
                                      ComPtr<IProgress> &aProgress)
 {
@@ -1482,4 +1488,8 @@
         return rc;
 
+    /* create an ID for the snapshot */
+    Guid snapshotId;
+    snapshotId.create();
+
     /* create and start the task on a separate thread (note that it will not
      * start working until we release alock) */
@@ -1490,4 +1500,5 @@
                                                    aName,
                                                    aDescription,
+                                                   snapshotId,
                                                    !!fPause,
                                                    mHWData->mMemorySize,
@@ -1509,4 +1520,5 @@
         i_setMachineState(MachineState_Snapshotting);
 
+    aId = snapshotId;
     pTask->m_pProgress.queryInterfaceTo(aProgress.asOutParam());
 
@@ -1555,5 +1567,4 @@
     bool fBeganTakingSnapshot = false;
     BOOL fSuspendedBySave     = FALSE;
-    Guid snapshotId;
 
     try
@@ -1606,11 +1617,8 @@
         /* STEP 1: create the snapshot object */
 
-        /* create an ID for the snapshot */
-        snapshotId.create();
-
         /* create a snapshot machine object */
         ComObjPtr<SnapshotMachine> pSnapshotMachine;
         pSnapshotMachine.createObject();
-        rc = pSnapshotMachine->init(this, snapshotId.ref(), task.m_strStateFilePath);
+        rc = pSnapshotMachine->init(this, task.m_uuidSnapshot.ref(), task.m_strStateFilePath);
         AssertComRCThrowRC(rc);
 
@@ -1620,5 +1628,5 @@
         task.m_pSnapshot.createObject();
         rc = task.m_pSnapshot->init(mParent,
-                                    snapshotId,
+                                    task.m_uuidSnapshot,
                                     task.m_strName,
                                     task.m_strDescription,
@@ -1797,5 +1805,5 @@
 
     if (SUCCEEDED(rc))
-        mParent->i_onSnapshotTaken(mData->mUuid, snapshotId);
+        mParent->i_onSnapshotTaken(mData->mUuid, task.m_uuidSnapshot);
     LogFlowThisFuncLeave();
 }
Index: /trunk/src/VBox/ValidationKit/testdriver/vboxwrappers.py
===================================================================
--- /trunk/src/VBox/ValidationKit/testdriver/vboxwrappers.py	(revision 55976)
+++ /trunk/src/VBox/ValidationKit/testdriver/vboxwrappers.py	(revision 55977)
@@ -2250,5 +2250,5 @@
                 self.o.console.pause();
             if self.fpApiVer >= 5.0:
-                oProgressCom = self.o.machine.takeSnapshot(sName, sDescription, True);
+                (sSnapId, oProgressCom) = self.o.machine.takeSnapshot(sName, sDescription, True);
             else:
                 oProgressCom = self.o.console.takeSnapshot(sName, sDescription);
