Like Jonny, I use VirtualBox to run XP and notice the issue occurred only when I left VBox running.. I'd come back to the machine and find keyboard and trackpad unresponsive; the only way to get back in for to force a shut-down.
I came across this thread just minutes after I realised I could probably use TeamViewer to dial into the mac, and sure enough, it was working just fine, just that the keyboard and trackpad on the macbook was being unresponsive.
Interestingly, once I logged in to the mac, there was a window looking for a bluetooth keyboard, and when I switched across to the vbox, there was an alert that some peripheral could not be attached.
At one point, I had all the USB inputs working perfectly with VirtualBox (by installing the Guest Additions image), so I could plug in USB things into the virtual machine, but it stopped working at some point and now it throws the same error (unable to attach <peripheral>).
Almost certain this is the problem. No idea (yet) about how to solve, apart from ensuring that the virtual machine is turned off when the machine is put to sleep. If I figure it out, I'll update this thread, as it's annoying to find the machine has 'frozen'
Sorry for the long reply 🙂