Re: [PATCH 0/5] lscpu: improve hypervisor detection

Ruediger Meier
2014-05-20T18:13:14Z

On Tuesday 20 May 2014, Stanislav Brabec wrote:
> Ruediger Meierwrote:
> > I've splitted the original patch into smaller pieces, removed some
> > incompatible output format changes and added some test data.
>
> There was a controversial part of this patch, that causes test
> failure.
>
> There should be a way how to output result of the virtual machine
> detection without breaking test cases (and possibly existing
> scripts).

We already output it per default "lscpu" without options. As you can see
in the newly added test output:

$ grep -A1 "Hypervisor" tests/expected/lscpu/lscpu-vbox-win
Hypervisor vendor: Oracle
Virtualization type: full

The other part of the original patch below only affected "-p" which was
IMO useless and bad because incompatible.

> Index: util-linux-2.24.1/sys-utils/lscpu.c
> ===================================================================
> --- util-linux-2.24.1.orig/sys-utils/lscpu.c
> +++ util-linux-2.24.1/sys-utils/lscpu.c
> @@ -1181,6 +1322,7 @@ print_parsable(struct lscpu_desc *desc,
> }
> fputs(data && *data ? data : "", stdout);
> }
> + printf(",HvVendor,VirtType");
> putchar('\n');
>
> /*
> @@ -1210,7 +1352,9 @@ print_parsable(struct lscpu_desc *desc,
> buf, sizeof(buf));
> fputs(data && *data ? data : "", stdout);
> }
> - putchar('\n');
> + printf(",%s,%s\n",
> + hv_vendors[desc->hyper] ? hv_vendors[desc->hyper] : "none",
> + virt_types[desc->virtype]);
> }
> }