From: Paolo Bonzini <pbonzini@redhat.com>
To: Chris J Arges <chris.j.arges@canonical.com>, kvm@vger.kernel.org
Subject: Re: KVM Guest Detection
Date: Mon, 09 Feb 2015 14:26:17 +0100 [thread overview]
Message-ID: <54D8B579.9070502@redhat.com> (raw)
In-Reply-To: <54D51F29.2000305@canonical.com>
On 06/02/2015 21:08, Chris J Arges wrote:
> 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
No, there is no other way. In fact on some architectures (PPC and s390
for example) KVM implements the same paravirtualized architecture that
is used by proprietary hypervisors, and should be indistiguishable from
them.
> In addition one could grep for strings in the kernel log or CPU types if
> using QEMU CPU model.
KVM can also be used without QEMU though. Also, not all architectures
support custom model names the way x86 has them in /proc/cpuinfo.
> 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?
Why do you need that? If you are disabling something if you are on a
virtualized platform, then that is most of the time (and I am not saying
always only because of things like microcode.service) wrong.
In order of likelihood:
1) you are working around a bug in KVM, and the developers won't know;
2) you are sweeping under the carpet a bug in your program (e.g. in the
service that you're writing a unit file for);
3) your assumptions are flawed. For example the (now removed) readahead
daemon in systemd was disabled under virtualization... except that most
of the time production virtual machines are run with O_DIRECT so the
benefit from readahead is the same as on bare metal.
Paolo
> I can work on a patch, but initial feedback would be helpful.
>
> Thanks,
> --chris j arges
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2015-02-09 13:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-06 20:08 KVM Guest Detection Chris J Arges
2015-02-09 13:26 ` Paolo Bonzini [this message]
2015-02-09 14:37 ` Chris J Arges
2015-02-09 16:12 ` Paolo Bonzini
-- strict thread matches above, loose matches on Subject: below --
2008-08-13 17:57 KVM Guest detection jd
2008-08-13 18:40 ` David Mair
2008-08-13 18:59 ` Anthony Liguori
2008-08-13 21:05 ` jd
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54D8B579.9070502@redhat.com \
--to=pbonzini@redhat.com \
--cc=chris.j.arges@canonical.com \
--cc=kvm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).