Received: from eggs.gnu.org ([2001:4830:134:3::10]:49167) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XBfi5-0001ay-OE for qemu-devel@nongnu.org; Mon, 28 Jul 2014 03:51:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XBfhz-0000kW-F0 for qemu-devel@nongnu.org; Mon, 28 Jul 2014 03:51:05 -0400 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (1.0) From: Alexander Graf In-Reply-To: <53D5F1FD.8050702@ozlabs.ru> Date: Mon, 28 Jul 2014 09:50:56 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: References: <1405657877-12353-1-git-send-email-cyrilbur@gmail.com> <53D10703.40505@suse.de> <53D5F1FD.8050702@ozlabs.ru> Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH for-2.2] spapr: add host Linux version information to device tree List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexey Kardashevskiy Cc: Cyril Bur , "qemu-ppc@nongnu.org" , "cyrilbur@gmail.com" , "qemu-devel@nongnu.org" > Am 28.07.2014 um 08:47 schrieb Alexey Kardashevskiy : >=20 >> On 07/24/2014 11:15 PM, Alexander Graf wrote: >>=20 >>> On 18.07.14 06:31, cyrilbur@gmail.com wrote: >>> It may prove useful know which Linux distribution version the host machi= ne >>> is running when an issue in the guest arises but a user cannot access >>> the host. >>>=20 >>> Signed-off-by: Cyril Bur >>> --- >>> hw/ppc/spapr.c | 8 +++++++ >>> target-ppc/kvm.c | 62 >>> ++++++++++++++++++++++++++++++++++++++++++++++++++++ >>> target-ppc/kvm_ppc.h | 6 +++++ >>> 3 files changed, 76 insertions(+) >>>=20 >>> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c >>> index 6b48a26..391d47a 100644 >>> --- a/hw/ppc/spapr.c >>> +++ b/hw/ppc/spapr.c >>> @@ -375,6 +375,14 @@ static void *spapr_create_fdt_skel(hwaddr initrd_ba= se, >>> _FDT((fdt_property_string(fdt, "vm,uuid", buf))); >>> g_free(buf); >>> + /* >>> + * Add info to the guest FDT to tell it what linux the host is >>> + */ >>> + if (kvmppc_get_linux_host(&buf)) { >>> + _FDT((fdt_property_string(fdt, "linux,host", buf))); >>=20 >> Is this even specified in sPAPR? >=20 >=20 > PAPR does not know about any "linux,xxx" properties. >=20 >>=20 >>> + g_free(buf); >>> + } >>> + >>> _FDT((fdt_property_cell(fdt, "#address-cells", 0x2))); >>> _FDT((fdt_property_cell(fdt, "#size-cells", 0x2))); >>> diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c >>> index 8c9e79c..95e0970 100644 >>> --- a/target-ppc/kvm.c >>> +++ b/target-ppc/kvm.c >>> @@ -1415,6 +1415,68 @@ bool kvmppc_get_host_model(char **value) >>> return g_file_get_contents("/proc/device-tree/model", value, NULL, >>> NULL); >>> } >>> +bool kvmppc_get_linux_host(char **value) >>> +{ >>> + FILE *f; >>> + int i; >>> + char line[512]; >>> + const char *names[] =3D {"NAME", "VERSION", "BUILD_ID"}; >>> + bool names_found[ARRAY_SIZE(names)] =3D { 0 }; >>> + GString *output =3D NULL; >>> + f =3D fopen("/etc/os-release", "r"); >>=20 >> A few comments: >>=20 >> 1) Why would anyone care? >=20 >=20 > Useful debug info when the host is not reachable. >=20 >=20 >> 2) I'm not sure KVM is the right decision maker on whether we want this >> exposed or not. >=20 > Good point, there is no reason not to show this info in TCG. >=20 >> After all, the files you read here are available on an x86 >> host just as well >=20 > Does qemu-x86 has any way to pass information like this to the guest? Yes and no. It has fw_cfg where we could put it and it has DSST generation w= here we could also put it I guess. Just like here, there's no standardized w= ay to expose it though. Alex >=20 >=20 >> 3) Use glib functions to read files >>=20 >>=20 >> Alex >=20 >=20 > --=20 > Alexey