Index: trunk/include/VBox/com/Guid.h
===================================================================
--- trunk/include/VBox/com/Guid.h	(revision 44038)
+++ trunk/include/VBox/com/Guid.h	(revision 44039)
@@ -48,4 +48,11 @@
 {
 
+typedef enum
+    {
+        ZERO_GUID,
+        NORMAL_GUID,
+        INVALID_GUID
+    }GuidState_t;
+
 /**
  *  Helper class that represents the UUID type and hides platform-specific
@@ -60,4 +67,5 @@
         ::RTUuidClear(&mUuid);
         refresh();
+        mGuidState = ZERO_GUID;
     }
 
@@ -66,4 +74,8 @@
         mUuid = that.mUuid;
         refresh();
+        if (isEmpty())
+            mGuidState = ZERO_GUID;
+        else
+            mGuidState = NORMAL_GUID;
     }
 
@@ -72,4 +84,8 @@
         mUuid = that;
         refresh();
+        if (isEmpty())
+            mGuidState = ZERO_GUID;
+        else
+            mGuidState = NORMAL_GUID;
     }
 
@@ -79,4 +95,8 @@
         ::memcpy(&mUuid, &that, sizeof(GUID));
         refresh();
+        if (isEmpty())
+            mGuidState = ZERO_GUID;
+        else
+            mGuidState = NORMAL_GUID;
     }
 
@@ -92,7 +112,15 @@
     Guid(const char *that)
     {
+        mGuidState = NORMAL_GUID;
+
         int rc = ::RTUuidFromStr(&mUuid, that);
+
         if (RT_FAILURE(rc))
+        {
             ::RTUuidClear(&mUuid);
+            mGuidState = INVALID_GUID;
+        }
+        else if(isEmpty())
+            mGuidState = ZERO_GUID;
         refresh();
     }
@@ -109,36 +137,69 @@
     Guid(const Bstr &that)
     {
-        int rc = !that.isEmpty()
-               ? ::RTUuidFromUtf16(&mUuid, that.raw())
-               : VERR_INVALID_UUID_FORMAT;
+        mGuidState = NORMAL_GUID;
+
+        if (that.isEmpty())
+        {
+            ::RTUuidClear(&mUuid);
+            mGuidState = ZERO_GUID;
+        }
+        else
+        {
+            int rc = ::RTUuidFromUtf16(&mUuid, that.raw());
+            if (RT_FAILURE(rc))
+            {
+                ::RTUuidClear(&mUuid);
+                mGuidState = INVALID_GUID;
+            }
+        }
+
+        refresh();
+    }
+
+    Guid& operator=(const Guid &that)
+    {
+        mGuidState = NORMAL_GUID;
+        ::memcpy(&mUuid, &that.mUuid, sizeof (RTUUID));
+        if (isEmpty())
+            mGuidState = ZERO_GUID;
+        refresh();
+        return *this;
+    }
+    Guid& operator=(const GUID &guid)
+    {
+        mGuidState = NORMAL_GUID;
+        ::memcpy(&mUuid, &guid, sizeof (GUID));
+        if (isEmpty())
+            mGuidState = ZERO_GUID;
+        refresh();
+        return *this;
+    }
+    Guid& operator=(const RTUUID &guid)
+    {
+        mGuidState = NORMAL_GUID;
+        ::memcpy(&mUuid, &guid, sizeof (RTUUID));
+        if (isEmpty())
+            mGuidState = ZERO_GUID;
+        refresh();
+        return *this;
+    }
+    Guid& operator=(const char *str)
+    {
+        mGuidState = NORMAL_GUID;
+        int rc = ::RTUuidFromStr(&mUuid, str);
+
         if (RT_FAILURE(rc))
+        {
             ::RTUuidClear(&mUuid);
-        refresh();
-    }
-
-    Guid& operator=(const Guid &that)
-    {
-        ::memcpy(&mUuid, &that.mUuid, sizeof (RTUUID));
-        refresh();
-        return *this;
-    }
-    Guid& operator=(const GUID &guid)
-    {
-        ::memcpy(&mUuid, &guid, sizeof (GUID));
-        refresh();
-        return *this;
-    }
-    Guid& operator=(const RTUUID &guid)
-    {
-        ::memcpy(&mUuid, &guid, sizeof (RTUUID));
-        refresh();
-        return *this;
-    }
-    Guid& operator=(const char *str)
-    {
-        int rc = ::RTUuidFromStr(&mUuid, str);
-        if (RT_FAILURE(rc))
-            ::RTUuidClear(&mUuid);
-        refresh();
+            mGuidState = INVALID_GUID;
+        }
+        else 
+        {
+            if (isEmpty())
+            mGuidState = ZERO_GUID;
+        }
+
+        refresh();
+
         return *this;
     }
@@ -147,4 +208,5 @@
     {
         ::RTUuidCreate(&mUuid);
+        mGuidState = NORMAL_GUID;
         refresh();
     }
@@ -152,4 +214,5 @@
     {
         ::RTUuidClear(&mUuid);
+        mGuidState = ZERO_GUID;
         refresh();
     }
@@ -164,5 +227,16 @@
     {
         char buf[RTUUID_STR_LENGTH];
+
+        ::memset(buf,0,RTUUID_STR_LENGTH);
+
+        if (mGuidState == INVALID_GUID)
+        {
+            /* What to return in case of wrong Guid */
+            return Utf8Str("00000000-0000-0000-0000-00000000000");
+        }
+
         ::RTUuidToStr(&mUuid, buf, RTUUID_STR_LENGTH);
+
+
         return Utf8Str(buf);
     }
@@ -176,8 +250,17 @@
     Utf8Str toStringCurly() const
     {
+
+        if (mGuidState == INVALID_GUID)
+        {
+            /* What to return in case of wrong Guid */
+            return Utf8Str("{00000000-0000-0000-0000-00000000000}");
+        }
+
         char buf[RTUUID_STR_LENGTH + 2] = "{";
+
         ::RTUuidToStr(&mUuid, buf + 1, RTUUID_STR_LENGTH);
         buf[sizeof(buf) - 2] = '}';
         buf[sizeof(buf) - 1] = '\0';
+
         return Utf8Str(buf);
     }
@@ -191,6 +274,6 @@
     Bstr toUtf16() const
     {
-        if (isEmpty())
-          return Bstr();
+        if (mGuidState == INVALID_GUID)
+          return Bstr("00000000-0000-0000-0000-00000000000");
 
         RTUTF16 buf[RTUUID_STR_LENGTH];
@@ -199,12 +282,16 @@
     }
 
-    bool isEmpty() const
-    {
-        return ::RTUuidIsNull(&mUuid);
-    }
-
-    bool isNotEmpty() const
-    {
-        return !::RTUuidIsNull(&mUuid);
+    bool isValid() const
+    {
+        bool res = true;
+        if (mGuidState == INVALID_GUID)
+            res = false;
+
+        return res;
+    }
+
+    bool isZero() const
+    {
+        return (::RTUuidIsNull(&mUuid) && mGuidState == ZERO_GUID);
     }
 
@@ -257,4 +344,5 @@
         if (ppGuid)
             *ppGuid = (nsID *)nsMemory::Clone(&mUuid, sizeof(nsID));
+
         return *this;
     }
@@ -309,4 +397,16 @@
     static const Guid Empty;
 
+protected:
+
+    bool isEmpty() const
+    {
+        return ::RTUuidIsNull(&mUuid);
+    }
+
+    bool isNotEmpty() const
+    {
+        return !::RTUuidIsNull(&mUuid);
+    }
+
 private:
     /**
@@ -327,4 +427,6 @@
     /** The UUID. */
     RTUUID mUuid;
+
+    GuidState_t mGuidState;
 
 #ifdef DEBUG
@@ -335,5 +437,5 @@
 #endif
 };
-
+/*
 inline Bstr asGuidStr(const Bstr& str)
 {
@@ -341,9 +443,10 @@
    return guid.isEmpty() ? Bstr() : guid.toUtf16();
 }
-
+*/
 inline bool isValidGuid(const Bstr& str)
 {
    Guid guid(str);
-   return !guid.isEmpty();
+   return guid.isValid();
+//   return !guid.isEmpty();
 }
 
Index: trunk/src/VBox/Frontends/VBoxManage/VBoxManageControlVM.cpp
===================================================================
--- trunk/src/VBox/Frontends/VBoxManage/VBoxManageControlVM.cpp	(revision 44038)
+++ trunk/src/VBox/Frontends/VBoxManage/VBoxManageControlVM.cpp	(revision 44039)
@@ -874,5 +874,7 @@
 
             Bstr usbId = a->argv[2];
-            if (Guid(usbId).isEmpty())
+
+            Guid guid(usbId);
+            if (!guid.isValid())
             {
                 // assume address
@@ -897,4 +899,10 @@
                     CHECK_ERROR_BREAK(dev, COMGETTER(Id)(usbId.asOutParam()));
                 }
+            }
+            else if (guid.isZero())
+            {
+                errorArgument("Zero UUID argument '%s'", a->argv[2]);
+                rc = E_FAIL;
+                break;
             }
 
Index: trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp
===================================================================
--- trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp	(revision 44038)
+++ trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp	(revision 44039)
@@ -159,5 +159,5 @@
 
     /* If it is no UUID, convert the filename to an absolute one. */
-    if (id.isEmpty())
+    if (!id.isValid())
     {
         int irc = RTPathAbs(pszFilenameOrUuid, szFilenameAbs, sizeof(szFilenameAbs));
Index: trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp
===================================================================
--- trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp	(revision 44038)
+++ trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp	(revision 44039)
@@ -950,8 +950,14 @@
             // first check if a UUID was supplied
             uuidVM = argv[curArg];
-            if (uuidVM.isEmpty())
+
+            if (!uuidVM.isValid())
             {
                 LogFlow(("invalid UUID format, assuming it's a VM name\n"));
                 vmName = argv[curArg];
+            }
+            else if (uuidVM.isZero())
+            {
+                RTPrintf("Error: UUID argument is zero!\n");
+                return 1;
             }
         }
@@ -1417,5 +1423,5 @@
      * Do we have a UUID?
      */
-    if (!uuidVM.isEmpty())
+    if (uuidVM.isValid())
     {
         rc = pVirtualBox->FindMachine(uuidVM.toUtf16().raw(), pMachine.asOutParam());
@@ -1443,9 +1449,4 @@
             goto leave;
         }
-    }
-    else if (uuidVM.isEmpty())
-    {
-        RTPrintf("Error: no machine specified!\n");
-        goto leave;
     }
 
Index: trunk/src/VBox/Main/include/VirtualBoxBase.h
===================================================================
--- trunk/src/VBox/Main/include/VirtualBoxBase.h	(revision 44038)
+++ trunk/src/VBox/Main/include/VirtualBoxBase.h	(revision 44039)
@@ -384,5 +384,5 @@
         Guid tmpGuid(a_Arg); \
         (a_GuidVar) = tmpGuid; \
-        if (RT_UNLIKELY((a_GuidVar).isEmpty())) \
+        if (RT_UNLIKELY((a_GuidVar).isValid() == false)) \
             return setError(E_INVALIDARG, \
                 tr("GUID argument %s is not valid (\"%ls\")"), #a_Arg, Bstr(a_Arg).raw()); \
Index: trunk/src/VBox/Main/src-all/ProgressImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-all/ProgressImpl.cpp	(revision 44038)
+++ trunk/src/VBox/Main/src-all/ProgressImpl.cpp	(revision 44039)
@@ -200,5 +200,5 @@
     {
         /* remove the added progress on failure to complete the initialization */
-        if (aAutoUninitSpan.initFailed() && !mId.isEmpty())
+        if (aAutoUninitSpan.initFailed() && mId.isValid() && !mId.isZero())
             mParent->removeProgress(mId.ref());
 
Index: trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-client/ConsoleImpl.cpp	(revision 44038)
+++ trunk/src/VBox/Main/src-client/ConsoleImpl.cpp	(revision 44039)
@@ -3177,5 +3177,5 @@
 {
 #ifdef VBOX_WITH_USB
-    CheckComArgExpr(aId, Guid(aId).isEmpty() == false);
+    CheckComArgExpr(aId, Guid(aId).isValid() == true);
     CheckComArgOutPointerValid(aDevice);
 
@@ -3489,5 +3489,5 @@
 STDMETHODIMP Console::DeleteSnapshot(IN_BSTR aId, IProgress **aProgress)
 {
-    CheckComArgExpr(aId, Guid(aId).isEmpty() == false);
+    CheckComArgExpr(aId, Guid(aId).isValid() == true);
     CheckComArgOutPointerValid(aProgress);
 
@@ -3512,5 +3512,5 @@
 STDMETHODIMP Console::DeleteSnapshotAndAllChildren(IN_BSTR aId, IProgress **aProgress)
 {
-    CheckComArgExpr(aId, Guid(aId).isEmpty() == false);
+    CheckComArgExpr(aId, Guid(aId).isValid() == true);
     CheckComArgOutPointerValid(aProgress);
 
@@ -3535,6 +3535,6 @@
 STDMETHODIMP Console::DeleteSnapshotRange(IN_BSTR aStartId, IN_BSTR aEndId, IProgress **aProgress)
 {
-    CheckComArgExpr(aStartId, Guid(aStartId).isEmpty() == false);
-    CheckComArgExpr(aEndId, Guid(aEndId).isEmpty() == false);
+    CheckComArgExpr(aStartId, Guid(aStartId).isValid() == true);
+    CheckComArgExpr(aEndId, Guid(aEndId).isValid() == true);
     CheckComArgOutPointerValid(aProgress);
 
Index: trunk/src/VBox/Main/src-client/RemoteUSBBackend.cpp
===================================================================
--- trunk/src/VBox/Main/src-client/RemoteUSBBackend.cpp	(revision 44038)
+++ trunk/src/VBox/Main/src-client/RemoteUSBBackend.cpp	(revision 44039)
@@ -901,5 +901,5 @@
     for (i = 0; i < RT_ELEMENTS(aGuids); i++)
     {
-        if (aGuids[i].isEmpty ())
+        if (aGuids[i].isZero())
         {
             aGuids[i] = *pUuid;
Index: trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp
===================================================================
--- trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp	(revision 44038)
+++ trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp	(revision 44039)
@@ -2640,5 +2640,5 @@
                 if (cHardDisks == 1)
                 {
-                    if (hdUuid.isEmpty())
+                    if (hdUuid.isZero())
                         hdUuid = thisUuid;
                     else
@@ -2647,5 +2647,5 @@
                 else
                 {
-                    if (thisUuid.isEmpty())
+                   if (thisUuid.isZero())
                         fInconsistent = true;
                     else if (thisUuid == hdUuid)
@@ -2700,5 +2700,5 @@
             settings::AttachedDevice &d = *dit;
 
-            if (d.uuid.isEmpty())
+            if (d.uuid.isZero())
                 // empty DVD and floppy media
                 continue;
Index: trunk/src/VBox/Main/src-server/HostImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-server/HostImpl.cpp	(revision 44038)
+++ trunk/src/VBox/Main/src-server/HostImpl.cpp	(revision 44039)
@@ -1434,5 +1434,5 @@
     return E_NOTIMPL;
 #else
-    if (Guid(id).isEmpty())
+    if (!Guid(id).isValid())
         return E_INVALIDARG;
     if (!networkInterface)
@@ -1538,5 +1538,5 @@
 {
 #ifdef VBOX_WITH_USB
-    CheckComArgExpr(aId, Guid (aId).isEmpty() == false);
+    CheckComArgExpr(aId, Guid (aId).isValid() == true);
     CheckComArgOutPointerValid(aDevice);
 
@@ -1869,5 +1869,5 @@
 
     Guid uuid(strNameOrId);
-    if (!uuid.isEmpty())
+    if (uuid.isValid() && !uuid.isZero())
         return findHostDriveById(mediumType, uuid, true /* fRefresh */, pMedium);
 
Index: trunk/src/VBox/Main/src-server/HostNetworkInterfaceImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-server/HostNetworkInterfaceImpl.cpp	(revision 44038)
+++ trunk/src/VBox/Main/src-server/HostNetworkInterfaceImpl.cpp	(revision 44039)
@@ -70,5 +70,5 @@
 
     ComAssertRet(!aInterfaceName.isEmpty(), E_INVALIDARG);
-    ComAssertRet(!aGuid.isEmpty(), E_INVALIDARG);
+    ComAssertRet(!aGuid.isValid(), E_INVALIDARG);
 
     /* Enclose the state transition NotReady->InInit->Ready */
@@ -185,5 +185,5 @@
 
 //    ComAssertRet(aInterfaceName, E_INVALIDARG);
-//    ComAssertRet(!aGuid.isEmpty(), E_INVALIDARG);
+//    ComAssertRet(aGuid.isValid(), E_INVALIDARG);
     ComAssertRet(pIf, E_INVALIDARG);
 
Index: trunk/src/VBox/Main/src-server/MachineImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-server/MachineImpl.cpp	(revision 44038)
+++ trunk/src/VBox/Main/src-server/MachineImpl.cpp	(revision 44039)
@@ -685,5 +685,5 @@
     AssertReturn(!isSessionMachine(), E_FAIL);
     AssertReturn(!isSnapshotMachine(), E_FAIL);
-    AssertReturn(!mData->mUuid.isEmpty(), E_FAIL);
+    AssertReturn(mData->mUuid.isValid(), E_FAIL);
     AssertReturn(!mData->mAccessible, E_FAIL);
 
@@ -854,5 +854,6 @@
      * because at this point we did not call uninitDataAndChildObjects() yet
      * and therefore also removeBackReference() for all these mediums was not called! */
-    if (!uuidMachine.isEmpty())     // can be empty if we're called from a failure of Machine::init
+
+    if (uuidMachine.isValid() && !uuidMachine.isZero())     // can be empty if we're called from a failure of Machine::init
         mParent->unregisterMachineMedia(uuidMachine);
 
@@ -1000,5 +1001,6 @@
     // never be found by findMachine()
     Guid test(aName);
-    if (test.isNotEmpty())
+    //if (test.isNotEmpty())
+    if (test.isValid())
         return setError(E_INVALIDARG,  tr("A machine cannot have a UUID as its name"));
 
@@ -1338,5 +1340,5 @@
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-    if (!mHWData->mHardwareUUID.isEmpty())
+    if (mHWData->mHardwareUUID.isValid())
         mHWData->mHardwareUUID.toUtf16().cloneTo(aUUID);
     else
@@ -1349,5 +1351,5 @@
 {
     Guid hardwareUUID(aUUID);
-    if (hardwareUUID.isEmpty())
+    if (!hardwareUUID.isValid())
         return E_INVALIDARG;
 
@@ -5293,5 +5295,5 @@
     {
         Guid uuid(aNameOrId);
-        if (!uuid.isEmpty())
+        if (uuid.isValid())
             rc = findSnapshotById(uuid, pSnapshot, true /* aSetError */);
         else
@@ -9029,5 +9031,5 @@
     }
 
-    if (aId.isEmpty())
+    if (aId.isZero())
         aSnapshot = mData->mFirstSnapshot;
     else
Index: trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp
===================================================================
--- trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp	(revision 44038)
+++ trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp	(revision 44039)
@@ -951,5 +951,6 @@
          * with the stuff from the snapshot. */
         settings::Snapshot sn;
-        if (!d->snapshotId.isEmpty())
+
+        if (d->snapshotId.isValid() && !d->snapshotId.isZero())
             if (!d->findSnapshot(trgMCF.llFirstSnapshot, d->snapshotId, sn))
                 throw p->setError(E_FAIL,
@@ -960,5 +961,5 @@
         if (d->mode == CloneMode_MachineState)
         {
-            if (!sn.uuid.isEmpty())
+            if (sn.uuid.isValid() && !sn.uuid.isZero())
             {
                 trgMCF.hardwareMachine = sn.hardware;
@@ -971,5 +972,6 @@
         }
         else if (   d->mode == CloneMode_MachineAndChildStates
-                 && !sn.uuid.isEmpty())
+                    && sn.uuid.isValid()
+                    && !sn.uuid.isZero())
         {
             if (!d->pOldMachineState.isNull())
@@ -1323,5 +1325,5 @@
             /* Update the path in the configuration either for the current
              * machine state or the snapshots. */
-            if (sst.snapshotUuid.isEmpty())
+            if (!sst.snapshotUuid.isValid() || sst.snapshotUuid.isZero())
                 trgMCF.strStateFile = strTrgSaveState;
             else
Index: trunk/src/VBox/Main/src-server/MediumImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-server/MediumImpl.cpp	(revision 44038)
+++ trunk/src/VBox/Main/src-server/MediumImpl.cpp	(revision 44039)
@@ -69,7 +69,7 @@
             const Guid &aSnapshotId = Guid::Empty)
         : machineId(aMachineId),
-          fInCurState(aSnapshotId.isEmpty())
-    {
-        if (!aSnapshotId.isEmpty())
+          fInCurState(aSnapshotId.isZero())
+    {
+        if (aSnapshotId.isValid() && !aSnapshotId.isZero())
             llSnapshotIds.push_back(aSnapshotId);
     }
@@ -942,5 +942,5 @@
     unconst(m->pVirtualBox) = aVirtualBox;
 
-    if (!uuidMachineRegistry.isEmpty())
+    if (uuidMachineRegistry.isValid() && !uuidMachineRegistry.isZero())
         m->llRegistryIDs.push_back(uuidMachineRegistry);
 
@@ -1087,5 +1087,5 @@
         else
         {
-            AssertStmt(!m->id.isEmpty(),
+            AssertStmt(!m->id.isZero(),
                        alock.release(); autoCaller.release(); uninit(); return E_FAIL);
 
@@ -1142,5 +1142,5 @@
     unconst(m->pVirtualBox) = aVirtualBox;
 
-    if (!uuidMachineRegistry.isEmpty())
+    if (uuidMachineRegistry.isValid() && !uuidMachineRegistry.isZero())
         m->llRegistryIDs.push_back(uuidMachineRegistry);
 
@@ -2000,6 +2000,6 @@
         {
             imageId = Guid(aImageId);
-            if (imageId.isEmpty())
-                return setError(E_INVALIDARG, tr("Argument %s is empty"), "aImageId");
+            if (!imageId.isValid())
+                return setError(E_INVALIDARG, tr("Argument %s is invalid"), "aImageId");
         }
     }
@@ -2061,5 +2061,5 @@
                                     ComSafeArrayOut(BSTR, aSnapshotIds))
 {
-    CheckComArgExpr(aMachineId, Guid(aMachineId).isEmpty() == false);
+    CheckComArgExpr(aMachineId, Guid(aMachineId).isValid() == true);
     CheckComArgOutSafeArrayPointerValid(aSnapshotIds);
 
@@ -3401,5 +3401,5 @@
                                  const Guid &aSnapshotId /*= Guid::Empty*/)
 {
-    AssertReturn(!aMachineId.isEmpty(), E_FAIL);
+    AssertReturn(aMachineId.isValid(), E_FAIL);
 
     LogFlowThisFunc(("ENTER, aMachineId: {%RTuuid}, aSnapshotId: {%RTuuid}\n", aMachineId.raw(), aSnapshotId.raw()));
@@ -3443,5 +3443,6 @@
     // to a machine a medium which represents the machine's current state,
     // so set the flag
-    if (aSnapshotId.isEmpty())
+
+    if (aSnapshotId.isZero())
     {
         /* sanity: no duplicate attachments */
@@ -3499,5 +3500,5 @@
                                     const Guid &aSnapshotId /*= Guid::Empty*/)
 {
-    AssertReturn(!aMachineId.isEmpty(), E_FAIL);
+    AssertReturn(aMachineId.isValid(), E_FAIL);
 
     AutoCaller autoCaller(this);
@@ -3511,5 +3512,5 @@
     AssertReturn(it != m->backRefs.end(), E_FAIL);
 
-    if (aSnapshotId.isEmpty())
+    if (aSnapshotId.isZero())
     {
         /* remove the current state attachment */
@@ -4589,7 +4590,7 @@
                 && (   !aMachineId
                     || m->backRefs.size() != 1
-                    || aMachineId->isEmpty()
+                    || aMachineId->isZero()
                     || *getFirstMachineBackrefId() != *aMachineId
-                    || (   (!aSnapshotId || !aSnapshotId->isEmpty())
+                    || (   (!aSnapshotId || !aSnapshotId->isZero())
                         && *getFirstMachineBackrefSnapshotId() != *aSnapshotId)))
                 throw setError(VBOX_E_OBJECT_IN_USE,
@@ -5435,5 +5436,5 @@
     /* are we dealing with a new medium constructed using the existing
      * location? */
-    bool isImport = m->id.isEmpty();
+    bool isImport = m->id.isZero();
     unsigned uOpenFlags = VD_OPEN_FLAGS_INFO;
 
@@ -5560,5 +5561,5 @@
                     mediumId = uuid;
 
-                    if (mediumId.isEmpty() && (m->hddOpenMode == OpenReadOnly))
+                    if (mediumId.isZero() && (m->hddOpenMode == OpenReadOnly))
                         // only when importing a VDMK that has no UUID, create one in memory
                         mediumId.create();
@@ -5566,5 +5567,5 @@
                 else
                 {
-                    Assert(!mediumId.isEmpty());
+                     Assert(!mediumId.isZero());
 
                     if (mediumId != uuid)
@@ -6034,5 +6035,5 @@
                   || (    autoCaller.state() == InInit
                        && m->state != MediumState_NotCreated
-                       && m->id.isEmpty()
+                       && m->id.isZero()
                        && m->strFormat.isEmpty()
                        && m->formatObj.isNull()),
@@ -6593,5 +6594,6 @@
         * the setLocation() argument). Otherwise we have to generate it */
         Guid id = m->id;
-        fGenerateUuid = id.isEmpty();
+
+        fGenerateUuid = id.isZero();
         if (fGenerateUuid)
         {
@@ -6730,5 +6732,6 @@
          * the setLocation() argument). Otherwise we have to generate it */
         Guid targetId = pTarget->m->id;
-        fGenerateUuid = targetId.isEmpty();
+
+        fGenerateUuid = targetId.isZero();
         if (fGenerateUuid)
         {
@@ -7234,5 +7237,6 @@
          * the setLocation() argument). Otherwise we have to generate it */
         Guid targetId = pTarget->m->id;
-        fGenerateUuid = targetId.isEmpty();
+
+        fGenerateUuid = targetId.isZero();
         if (fGenerateUuid)
         {
@@ -8052,5 +8056,6 @@
          * the setLocation() argument). Otherwise we have to generate it */
         Guid targetId = m->id;
-        fGenerateUuid = targetId.isEmpty();
+
+        fGenerateUuid = targetId.isZero();
         if (fGenerateUuid)
         {
Index: trunk/src/VBox/Main/src-server/SnapshotImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-server/SnapshotImpl.cpp	(revision 44038)
+++ trunk/src/VBox/Main/src-server/SnapshotImpl.cpp	(revision 44039)
@@ -115,5 +115,5 @@
     LogFlowThisFunc(("uuid=%s aParent->uuid=%s\n", aId.toString().c_str(), (aParent) ? aParent->m->uuid.toString().c_str() : ""));
 
-    ComAssertRet(!aId.isEmpty() && !aName.isEmpty() && aMachine, E_INVALIDARG);
+    ComAssertRet(!aId.isZero() && aId.isValid() && !aName.isEmpty() && aMachine, E_INVALIDARG);
 
     /* Enclose the state transition NotReady->InInit->Ready */
@@ -329,5 +329,6 @@
     // never be found by findMachine()
     Guid test(aName);
-    if (test.isNotEmpty())
+
+    if (!test.isZero() && test.isValid())
         return setError(E_INVALIDARG,  tr("A machine cannot have a UUID as its name"));
 
@@ -956,5 +957,6 @@
     LogFlowThisFunc(("mName={%s}\n", aSessionMachine->mUserData->s.strName.c_str()));
 
-    AssertReturn(aSessionMachine && !Guid(aSnapshotId).isEmpty(), E_INVALIDARG);
+    Guid l_guid(aSnapshotId);
+    AssertReturn(aSessionMachine && (!l_guid.isZero() && l_guid.isValid()), E_INVALIDARG);
 
     /* Enclose the state transition NotReady->InInit->Ready */
@@ -1097,5 +1099,6 @@
     LogFlowThisFunc(("mName={%s}\n", aMachine->mUserData->s.strName.c_str()));
 
-    AssertReturn(aMachine && !Guid(aSnapshotId).isEmpty(), E_INVALIDARG);
+    Guid l_guid(aSnapshotId);
+    AssertReturn(aMachine && (!l_guid.isZero() && l_guid.isValid()), E_INVALIDARG);
 
     /* Enclose the state transition NotReady->InInit->Ready */
@@ -2062,5 +2065,7 @@
     Guid startId(aStartId);
     Guid endId(aEndId);
-    AssertReturn(aInitiator && !startId.isEmpty() && !endId.isEmpty(), E_INVALIDARG);
+
+    AssertReturn(aInitiator && !startId.isZero() && !endId.isZero() && startId.isValid() && endId.isValid(), E_INVALIDARG);
+
     AssertReturn(aMachineState && aProgress, E_POINTER);
 
@@ -2463,5 +2468,5 @@
                 replaceSnapshotId = *pSnapshotId;
 
-            if (!replaceMachineId.isEmpty())
+            if (replaceMachineId.isValid() && !replaceMachineId.isZero())
             {
                 // Adjust the backreferences, otherwise merging will assert.
@@ -3240,5 +3245,5 @@
     }
 
-    if (!aMachineId.isEmpty())
+    if (aMachineId.isValid() && !aMachineId.isZero())
     {
         // reattach the source media to the snapshot
Index: trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp	(revision 44038)
+++ trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp	(revision 44039)
@@ -1453,6 +1453,14 @@
         }
     }
-    if (id.isEmpty())
+
+    if (id.isZero())
         fDirectoryIncludesUUID = false;
+    else if (!id.isValid())
+    {
+        /* do something else */
+        return setError(E_INVALIDARG,
+                 tr("'%ls' is not a valid Guid"),
+                 id.toStringCurly().c_str());
+    }
 
     Utf8Str strGroup(aGroup);
@@ -1649,6 +1657,13 @@
     }
     /* Create UUID if none was specified. */
-    if (id.isEmpty())
+    if (id.isZero())
         id.create();
+    else if (!id.isValid())
+    {
+        /* do something else */
+        return setError(E_INVALIDARG,
+                 tr("'%ls' is not a valid Guid"),
+                 id.toStringCurly().c_str());
+    }
 
     /* NULL settings file means compose automatically */
@@ -1780,5 +1795,6 @@
 
     Guid id(aNameOrId);
-    if (!id.isEmpty())
+    if (id.isValid() && !id.isZero())
+
         rc = findMachine(id,
                          true /* fPermitInaccessible */,
@@ -1953,5 +1969,5 @@
     {
         case DeviceType_HardDisk:
-            if (!id.isEmpty())
+            if (id.isValid() && !id.isZero())
                 rc = findHardDiskById(id, false /* setError */, &pMedium);
             else
@@ -1963,5 +1979,5 @@
         case DeviceType_Floppy:
         case DeviceType_DVD:
-            if (!id.isEmpty())
+            if (id.isValid() && !id.isZero())
                 rc = findDVDOrFloppyImage(deviceType, &id, Utf8Str::Empty,
                                           false /* setError */, &pMedium);
@@ -3407,5 +3423,5 @@
                                      ComObjPtr<Medium> *aHardDisk /*= NULL*/)
 {
-    AssertReturn(!id.isEmpty(), E_INVALIDARG);
+    AssertReturn(!id.isZero(), E_INVALIDARG);
 
     // we use the hard disks map, but it is protected by the
@@ -3614,9 +3630,16 @@
                                          ComObjPtr<Medium> &pMedium)
 {
-    if (uuid.isEmpty())
+    if (uuid.isZero())
     {
         // that's easy
         pMedium.setNull();
         return S_OK;
+    }
+    else if (!uuid.isValid())
+    {
+        /* handling of case invalid GUID */
+        return setError(VBOX_E_OBJECT_NOT_FOUND,
+                            tr("Guid '%ls' is invalid"),
+                            uuid.toString().c_str());
     }
 
@@ -3821,5 +3844,5 @@
                                            ComObjPtr<Medium> *ppMedium)
 {
-    AssertReturn(!aId.isEmpty() && !aLocation.isEmpty(), E_FAIL);
+    AssertReturn(!aId.isZero() && !aLocation.isEmpty(), E_FAIL);
     AssertReturn(ppMedium, E_INVALIDARG);
 
@@ -3834,5 +3857,5 @@
     const char *pcszType = NULL;
 
-    if (!aId.isEmpty())
+    if (aId.isValid() && !aId.isZero())
         rc = findHardDiskById(aId, false /* aSetError */, &pMediumFound);
     if (FAILED(rc) && !aLocation.isEmpty())
@@ -4423,5 +4446,5 @@
 HRESULT VirtualBox::unregisterMachineMedia(const Guid &uuidMachine)
 {
-    Assert(!uuidMachine.isEmpty());
+    Assert(!uuidMachine.isZero() && uuidMachine.isValid());
 
     LogFlowFuncEnter();
Index: trunk/src/VBox/Main/xml/Settings.cpp
===================================================================
--- trunk/src/VBox/Main/xml/Settings.cpp	(revision 44038)
+++ trunk/src/VBox/Main/xml/Settings.cpp	(revision 44039)
@@ -383,5 +383,7 @@
 {
     guid = strUUID.c_str();
-    if (guid.isEmpty())
+    if (guid.isZero())
+        throw ConfigFileError(this, NULL, N_("UUID \"%s\" has zero format"), strUUID.c_str());
+    else if (!guid.isValid())
         throw ConfigFileError(this, NULL, N_("UUID \"%s\" has invalid format"), strUUID.c_str());
 }
@@ -3545,6 +3547,8 @@
     if (m->sv >= SettingsVersion_v1_4)
         pelmHardware->setAttribute("version", hw.strVersion);
-    if (    (m->sv >= SettingsVersion_v1_9)
-         && (!hw.uuid.isEmpty())
+
+    if ((m->sv >= SettingsVersion_v1_9)
+         && !hw.uuid.isZero()
+         && hw.uuid.isValid()
        )
         pelmHardware->setAttribute("uuid", hw.uuid.toStringCurly());
@@ -3862,5 +3866,6 @@
                         if (att.fTempEject)
                             pelmDVD->setAttribute("tempeject", att.fTempEject);
-                        if (!att.uuid.isEmpty())
+
+                        if (!att.uuid.isZero() && att.uuid.isValid())
                             pelmDVD->createChild("Image")->setAttribute("uuid", att.uuid.toStringCurly());
                         else if (att.strHostDriveSrc.length())
@@ -3878,5 +3883,6 @@
                     const AttachedDevice &att = sctl.llAttachedDevices.front();
                     pelmFloppy->setAttribute("enabled", true);
-                    if (!att.uuid.isEmpty())
+
+                    if (!att.uuid.isZero() && att.uuid.isValid())
                         pelmFloppy->createChild("Image")->setAttribute("uuid", att.uuid.toStringCurly());
                     else if (att.strHostDriveSrc.length())
@@ -4451,6 +4457,7 @@
 
             // attached image, if any
-            if (    !att.uuid.isEmpty()
-                 && (    att.deviceType == DeviceType_HardDisk
+            if (!att.uuid.isZero()
+                 && att.uuid.isValid()
+                 && (att.deviceType == DeviceType_HardDisk
                       || !fSkipRemovableMedia
                     )
@@ -4655,6 +4662,8 @@
        )
         elmMachine.setAttributePath("stateFile", strStateFile);
-    if (    (fl & BuildMachineXML_IncludeSnapshots)
-         && !uuidCurrentSnapshot.isEmpty())
+
+    if ((fl & BuildMachineXML_IncludeSnapshots)
+         && !uuidCurrentSnapshot.isZero()
+         && uuidCurrentSnapshot.isValid())
         elmMachine.setAttribute("currentSnapshot", uuidCurrentSnapshot.toStringCurly());
 
@@ -5174,5 +5183,5 @@
               || !machineUserData.strTeleporterAddress.isEmpty()
               || !machineUserData.strTeleporterPassword.isEmpty()
-              || !hardwareMachine.uuid.isEmpty()
+              || (!hardwareMachine.uuid.isZero() && hardwareMachine.uuid.isValid())
             )
         )
