Index: /trunk/include/iprt/cpp/ministring.h
===================================================================
--- /trunk/include/iprt/cpp/ministring.h	(revision 55884)
+++ /trunk/include/iprt/cpp/ministring.h	(revision 55885)
@@ -248,6 +248,6 @@
            )
         {
-            int vrc = RTStrRealloc(&m_psz, cb);
-            if (RT_SUCCESS(vrc))
+            int rc = RTStrRealloc(&m_psz, cb);
+            if (RT_SUCCESS(rc))
                 m_cbAllocated = cb;
 #ifdef RT_EXCEPTIONS_ENABLED
@@ -256,4 +256,25 @@
 #endif
         }
+    }
+
+    /**
+     * A C like version of the reserve method, i.e. return code instead of throw.
+     *
+     * @returns VINF_SUCCESS or VERR_NO_STRING_MEMORY.
+     * @param   cb              New minimum size (in bytes) of member memory buffer.
+     */
+    int reserveNoThrow(size_t cb)
+    {
+        if (    cb != m_cbAllocated
+             && cb > m_cch + 1
+           )
+        {
+            int rc = RTStrRealloc(&m_psz, cb);
+            if (RT_SUCCESS(rc))
+                m_cbAllocated = cb;
+            else
+                return rc;
+        }
+        return VINF_SUCCESS;
     }
 
Index: /trunk/src/VBox/Main/idl/VirtualBox.xidl
===================================================================
--- /trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 55884)
+++ /trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 55885)
@@ -17164,5 +17164,5 @@
   <interface
     name="IMachineDebugger" extends="$unknown"
-    uuid="b08d5aa9-4e35-3a17-2e4d-61948b590989"
+    uuid="ae7afb78-4265-8c03-ccb9-33a7970057e3"
     wsmap="managed"
     >
@@ -17379,10 +17379,23 @@
     </method>
 
+    <method name="queryOSKernelLog">
+      <desc>
+        Tries to get the kernel log (dmesg) of the guest OS.
+
+      </desc>
+      <param name="maxMessages" type="unsigned long" dir="in">
+        <desc>Max number of messages to return, counting from the end of the
+          log.  If 0, there is no limit.</desc>
+      </param>
+      <param name="dmesg" type="wstring" dir="return">
+        <desc>
+          The kernel log.
+        </desc>
+      </param>
+    </method>
+
     <method name="getRegister">
       <desc>
         Gets one register.
-
-        This feature is not implemented in the 4.0.0 release but may show up
-        in a dot release.
       </desc>
       <param name="cpuId" type="unsigned long" dir="in">
@@ -17403,7 +17416,4 @@
       <desc>
         Gets all the registers for the given CPU.
-
-        This feature is not implemented in the 4.0.0 release but may show up
-        in a dot release.
       </desc>
       <param name="cpuId" type="unsigned long" dir="in">
Index: /trunk/src/VBox/Main/include/MachineDebuggerImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/MachineDebuggerImpl.h	(revision 55884)
+++ /trunk/src/VBox/Main/include/MachineDebuggerImpl.h	(revision 55885)
@@ -107,4 +107,6 @@
     HRESULT unloadPlugIn(const com::Utf8Str &aName);
     HRESULT detectOS(com::Utf8Str &aOs);
+    HRESULT queryOSKernelLog(ULONG aMaxMessages,
+                             com::Utf8Str &aDmesg);
     HRESULT getRegister(ULONG aCpuId,
                         const com::Utf8Str &aName,
Index: /trunk/src/VBox/Main/src-client/MachineDebuggerImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/MachineDebuggerImpl.cpp	(revision 55884)
+++ /trunk/src/VBox/Main/src-client/MachineDebuggerImpl.cpp	(revision 55885)
@@ -1183,4 +1183,51 @@
         else
             hrc = setError(VBOX_E_VM_ERROR, tr("DBGFR3OSDetect failed with %Rrc"), vrc);
+    }
+    return hrc;
+}
+
+HRESULT MachineDebugger::queryOSKernelLog(ULONG aMaxMessages, com::Utf8Str &aDmesg)
+{
+    /*
+     * Lock the debugger and get the VM pointer
+     */
+    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
+    Console::SafeVMPtr ptrVM(mParent);
+    HRESULT hrc = ptrVM.rc();
+    if (SUCCEEDED(hrc))
+    {
+        PDBGFOSIDMESG pDmesg = (PDBGFOSIDMESG)DBGFR3OSQueryInterface(ptrVM.rawUVM(), DBGFOSINTERFACE_DMESG);
+        if (pDmesg)
+        {
+            size_t   cbActual;
+            size_t   cbBuf  = _512K;
+            int vrc = aDmesg.reserveNoThrow(cbBuf);
+            if (RT_SUCCESS(vrc))
+            {
+                uint32_t cMessages = aMaxMessages == 0 ? UINT32_MAX : aMaxMessages;
+                vrc = pDmesg->pfnQueryKernelLog(pDmesg, ptrVM.rawUVM(), 0 /*fFlags*/, cMessages,
+                                                aDmesg.mutableRaw(), cbBuf, &cbActual);
+
+                uint32_t cTries = 10;
+                while (vrc == VERR_BUFFER_OVERFLOW && cbBuf < 16*_1M && cTries-- > 0)
+                {
+                    cbBuf = RT_ALIGN_Z(cbActual + _4K, _4K);
+                    int vrc = aDmesg.reserveNoThrow(cbBuf);
+                    if (RT_SUCCESS(vrc))
+                        vrc = pDmesg->pfnQueryKernelLog(pDmesg, ptrVM.rawUVM(), 0 /*fFlags*/, cMessages,
+                                                        aDmesg.mutableRaw(), cbBuf, &cbActual);
+                }
+                if (RT_SUCCESS(vrc))
+                    aDmesg.jolt();
+                else if (vrc == VERR_BUFFER_OVERFLOW)
+                    hrc = setError(E_FAIL, "Too much log available, must use the maxMessages parameter to restrict.");
+                else
+                    hrc = setErrorVrc(vrc);
+            }
+            else
+                hrc = setErrorBoth(E_OUTOFMEMORY, vrc);
+        }
+        else
+            hrc = setError(E_FAIL, "The dmesg interface isn't implemented by guest OS digger, or detectOS() has not been called.");
     }
     return hrc;
