Can I legally install Windows 8 in a virtual machine?
Yes. You can install any version of Windows 8 in a virtual machine, using virtualization software on any platform. (If the VM is running a properly licensed copy of a recent Windows version, you can use the upgrade edition of Windows 8; in most circumstances, the PUL System Builder edition is the correct choice.)
Note that you cannot share licenses between the host PC and a virtual instance. The following text appears in section 1(f):
If you use virtualization software, including Client Hyper-V, to create one or more virtual computers on a single computer hardware system, each virtual computer, and the physical computer, is considered a separate computer for purposes of this agreement. This license allows you to install only one copy of the software for use on one computer, whether that computer is physical or virtual. If you want to use the software on more than one virtual computer, you must obtain separate copies of the software and a separate license for each copy | Source
So it is perfectly legal to run a VM on the machine that has the OEM license of Windows 8. However, as others have stated - due to OEM Licenses being tied to specific hardware (occasionally) activation may or may not work.
After a bit more digging, it appears the if you purchase an OEM license (Windows 8 System Builder), not the one tied to the machine preinstalled, this is kosher. However, there is nothing that I can find that states you can transfer a preinstalled OEM license from hardware to a VM.