Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1994980yba; Fri, 17 May 2019 08:43:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqzcj4WuoYMHJbZurmEtwFUZk5EcdUowaj3I4Ce+9pjgF9xiuUpX+hz/xUWZTmXd8Gvu4MwX X-Received: by 2002:a63:1a60:: with SMTP id a32mr13406520pgm.66.1558107797840; Fri, 17 May 2019 08:43:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558107797; cv=none; d=google.com; s=arc-20160816; b=08cIe45tfhXR1F909/tnHajQkXAObcaZLduerEeR8T0z5+fQ39M0IqA1yD4uL2Kp8v uvMqMZmMThpIMbALO/3f+g2Mguu/iiVY6caiU5K5LHZBGXdRfj153o/bFX58dvG3YKvp P2t/o4K7wm9+AEgsVNaASpzjKnZAZbl03glfJdYfia/kJU0vFQnnTaqUG/EHJaLpIDjq OXWGJwzGroDyDr074iQeRZYloDD/FrYW66T+Qx4JA/3IAiFwhUhBu1jt2DwSxs7CkmTZ syn3pKdMziR7f0uzk7e4ivDwv5IpV/Fl/jh30ibBsaNiqkYGyduGvaNJppYW5LKJPxN2 zfQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :dkim-signature; bh=5PwOvUa2QeUYezBMIw7pLuLH7aeDi9x8dxh6Bcuj1T0=; b=esbZdg/nNYqikEpsES/Rx5unEEbmxbOiycmwNhEcQ97pdReEjqX/ph+tWMMOZvUoQO oNf5PDq4vjIqfK5587DHusZzap8zgcxNmKCsNDVhTDToP6eicdu0yBZcuhmydRlYKQ/o yiTJ3Dd3tKBavZ1Jj45ruyyVXu2PC3KxzZNUnAcIRivqlEx88IBoPNNWhwZYUmtUy9Fw 8jkhoeNdOfZrloXt64pzOxAR6F+V1aWhLwN0UYjAMtGn8bI5SBhGfYMRZiTz0MoQF5gS wAzwbCtOwoiVMxWeT1xyY/Vfr5H9qgy5msJRtrdz7Sj4JwOQQ2D7FwPRmoIdeNah+5ak KE5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=pkPNEBpT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 76si9025566pfv.233.2019.05.17.08.43.02; Fri, 17 May 2019 08:43:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=pkPNEBpT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729229AbfEQPlq (ORCPT + 99 others); Fri, 17 May 2019 11:41:46 -0400 Received: from smtp-fw-6002.amazon.com ([52.95.49.90]:13948 "EHLO smtp-fw-6002.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728861AbfEQPlp (ORCPT ); Fri, 17 May 2019 11:41:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1558107704; x=1589643704; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:mime-version: content-transfer-encoding; bh=5PwOvUa2QeUYezBMIw7pLuLH7aeDi9x8dxh6Bcuj1T0=; b=pkPNEBpTfId2pSiHw35G46whRha12mw7LuOjkWbLFW2QpZWK7Pd+iACu O9gxMfRMILX+TNuS8NM+T6gt8jmnEgS3RVQZ97Z/RbsbLBTnGrfhWnprs fGsVAVV/HQWJ2e/faBWiCUigmoPh2x/kKqHIgD7t1w41Cx5QIu+r9lcCa c=; X-IronPort-AV: E=Sophos;i="5.60,480,1549929600"; d="scan'208";a="402579638" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1e-57e1d233.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 17 May 2019 15:41:43 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1e-57e1d233.us-east-1.amazon.com (8.14.7/8.14.7) with ESMTP id x4HFffwv037521 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Fri, 17 May 2019 15:41:42 GMT Received: from EX13D02EUC004.ant.amazon.com (10.43.164.117) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 17 May 2019 15:41:41 +0000 Received: from EX13D02EUC001.ant.amazon.com (10.43.164.92) by EX13D02EUC004.ant.amazon.com (10.43.164.117) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 17 May 2019 15:41:40 +0000 Received: from EX13D02EUC001.ant.amazon.com ([10.43.164.92]) by EX13D02EUC001.ant.amazon.com ([10.43.164.92]) with mapi id 15.00.1367.000; Fri, 17 May 2019 15:41:40 +0000 From: "Sironi, Filippo" To: "Graf, Alexander" CC: LKML , KVM list , Christian Borntraeger , Boris Ostrovsky , "cohuck@redhat.com" , "konrad.wilk@oracle.com" , "xen-devel@lists.xenproject.org" Subject: Re: [PATCH v2 1/2] KVM: Start populating /sys/hypervisor with KVM entries Thread-Topic: [PATCH v2 1/2] KVM: Start populating /sys/hypervisor with KVM entries Thread-Index: AQHVCmguTMwTmVyYP0+tMrT8Z/dQMaZtx8qAgAGxboA= Date: Fri, 17 May 2019 15:41:39 +0000 Message-ID: <3D2C4EE3-1C2E-4032-9964-31A066E542AA@amazon.de> References: <1539078879-4372-1-git-send-email-sironi@amazon.de> <1557847002-23519-1-git-send-email-sironi@amazon.de> <1557847002-23519-2-git-send-email-sironi@amazon.de> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.43.165.155] Content-Type: text/plain; charset="us-ascii" Content-ID: <10D2265497ECB941BB8FCEB5614DF2F7@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On 16. May 2019, at 15:50, Graf, Alexander wrote: > = > On 14.05.19 08:16, Filippo Sironi wrote: >> Start populating /sys/hypervisor with KVM entries when we're running on >> KVM. This is to replicate functionality that's available when we're >> running on Xen. >> = >> Start with /sys/hypervisor/uuid, which users prefer over >> /sys/devices/virtual/dmi/id/product_uuid as a way to recognize a virtual >> machine, since it's also available when running on Xen HVM and on Xen PV >> and, on top of that doesn't require root privileges by default. >> Let's create arch-specific hooks so that different architectures can >> provide different implementations. >> = >> Signed-off-by: Filippo Sironi > = > I think this needs something akin to > = > https://www.kernel.org/doc/Documentation/ABI/stable/sysfs-hypervisor-xen > = > to document which files are available. > = >> --- >> v2: >> * move the retrieval of the VM UUID out of uuid_show and into >> kvm_para_get_uuid, which is a weak function that can be overwritten >> = >> drivers/Kconfig | 2 ++ >> drivers/Makefile | 2 ++ >> drivers/kvm/Kconfig | 14 ++++++++++++++ >> drivers/kvm/Makefile | 1 + >> drivers/kvm/sys-hypervisor.c | 30 ++++++++++++++++++++++++++++++ >> 5 files changed, 49 insertions(+) >> create mode 100644 drivers/kvm/Kconfig >> create mode 100644 drivers/kvm/Makefile >> create mode 100644 drivers/kvm/sys-hypervisor.c >> = > = > [...] > = >> + >> +__weak const char *kvm_para_get_uuid(void) >> +{ >> + return NULL; >> +} >> + >> +static ssize_t uuid_show(struct kobject *obj, >> + struct kobj_attribute *attr, >> + char *buf) >> +{ >> + const char *uuid =3D kvm_para_get_uuid(); >> + return sprintf(buf, "%s\n", uuid); > = > The usual return value for the Xen /sys/hypervisor interface is > "". Wouldn't it make sense to follow that pattern for the KVM > one too? Currently, if we can not determine the UUID this will just > return (null). > = > Otherwise, looks good to me. Are you aware of any other files we should > provide? Also, is there any reason not to implement ARM as well while at = it? > = > Alex This originated from a customer request that was using /sys/hypervisor/uuid. My guess is that we would want to expose "type" and "version" moving forward and that's when we hypervisor hooks will be useful on top of arch hooks. On a different note, any idea how to check whether the OS is running virtualized on KVM on ARM and ARM64? kvm_para_available() isn't an option and the same is true for S390 where kvm_para_available() always returns true and it would even if a KVM enabled kernel would be running on bare metal. I think we will need another arch hook to call a function that says whether the OS is running virtualized on KVM. >> +} >> + >> +static struct kobj_attribute uuid =3D __ATTR_RO(uuid); >> + >> +static int __init uuid_init(void) >> +{ >> + if (!kvm_para_available()) >> + return 0; >> + return sysfs_create_file(hypervisor_kobj, &uuid.attr); >> +} >> + >> +device_initcall(uuid_init); Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrer: Christian Schlaeger, Ralf Herbrich Ust-ID: DE 289 237 879 Eingetragen am Amtsgericht Charlottenburg HRB 149173 B