From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chris J Arges Subject: KVM Guest Detection Date: Fri, 06 Feb 2015 14:08:09 -0600 Message-ID: <54D51F29.2000305@canonical.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit To: kvm@vger.kernel.org Return-path: Received: from youngberry.canonical.com ([91.189.89.112]:43618 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754237AbbBFUIM (ORCPT ); Fri, 6 Feb 2015 15:08:12 -0500 Received: from cpe-173-174-67-34.austin.res.rr.com ([173.174.67.34] helo=[192.168.1.139]) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1YJpCE-0003Ua-GW for kvm@vger.kernel.org; Fri, 06 Feb 2015 20:08:10 +0000 Sender: kvm-owner@vger.kernel.org List-ID: Is there a architecture and machine type independent way to detect that one is running inside a KVM guest? I've noticed the following systemd code which does this detection and it seems to be very architecture dependent for KVM: https://github.com/systemd/systemd/blob/master/src/shared/virt.c In addition one could grep for strings in the kernel log or CPU types if using QEMU CPU model. Given the many ways to do this, would it make sense to create a sysfs entry (similar to how Xen does this with /sys/hypervisor/type), so that one can easily tell they are running in a KVM guest? I can work on a patch, but initial feedback would be helpful. Thanks, --chris j arges