[prev in list] [next in list] [prev in thread] [next in thread] 

List:       qemu-ppc
Subject:    Re: [Qemu-ppc] [PATCH for-2.2] spapr: add host Linux version information to device tree
From:       Alexander Graf <agraf () suse ! de>
Date:       2014-07-24 13:15:47
Message-ID: 53D10703.40505 () suse ! de
[Download RAW message or body]


On 18.07.14 06:31, cyrilbur@gmail.com wrote:
> It may prove useful know which Linux distribution version the host machine
> is running when an issue in the guest arises but a user cannot access
> the host.
>
> Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
> ---
>   hw/ppc/spapr.c       |  8 +++++++
>   target-ppc/kvm.c     | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>   target-ppc/kvm_ppc.h |  6 +++++
>   3 files changed, 76 insertions(+)
>
> 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_base,
>       _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)));

Is this even specified in sPAPR?

> +        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[] = {"NAME", "VERSION", "BUILD_ID"};
> +    bool names_found[ARRAY_SIZE(names)] = { 0 };
> +    GString *output = NULL;
> +    f = fopen("/etc/os-release", "r");

A few comments:

   1) Why would anyone care?
   2) I'm not sure KVM is the right decision maker on whether we want 
this exposed or not. After all, the files you read here are available on 
an x86 host just as well
   3) Use glib functions to read files


Alex



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic