From Fedora Project Wiki

http://people.redhat.com/~rjones/virt-what/

virt-what lets you detect if you are running inside a VM.

Simply install virt-what in a guest (or on the host if you like), and run it as root:

# virt-what 
kvm

Consult the virt-what man page to find out the possible values that it can print:

$ man virt-what