Hello community,
here is the log from the commit of package util-linux
checked in at Wed Oct 8 18:42:45 CEST 2008.
--------
--- util-linux/util-linux.changes 2008-09-24 13:13:22.000000000 +0200
+++ /mounts/work_src_done/STABLE/util-linux/util-linux.changes 2008-10-07 15:04:02.000000000 +0200
@@ -1,0 +2,8 @@
+Thu Oct 2 11:10:11 CEST 2008 - mkoenig@suse.de
+
+- add lscpu tool from current util-linux-ng git,
+ needed for fate#303051
+- replace hypervisor detection tool with the solution blessed by
+ upstream, which adds hv detection as lscpu feature [fate#303051]
+
+-------------------------------------------------------------------
calling whatdependson for head-i586
Old:
----
util-linux-2.14.1-hypervisor_detection.patch
New:
----
util-linux-2.14.1-lscpu_add_hypervisor_vendor_id.patch
util-linux-2.14.1-lscpu.patch
util-linux-2.14.1-lscpu_sysroot_option.patch
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ util-linux.spec ++++++
--- /var/tmp/diff_new_pack.r29266/_old 2008-10-08 18:41:49.000000000 +0200
+++ /var/tmp/diff_new_pack.r29266/_new 2008-10-08 18:41:49.000000000 +0200
@@ -30,7 +30,7 @@
Group: System/Base
AutoReqProv: on
Version: 2.14.1
-Release: 2
+Release: 3
Requires: %name-lang = %{version}
Summary: A collection of basic system utilities
Source: ftp://ftp.kernel.org/pub/linux/utils/util-linux/%name-ng-%version.tar.bz2
@@ -71,7 +71,9 @@
#
Patch5: util-linux-2.13.1-fdisk_cfdisk_yesno.patch
Patch7: util-linux-2.14-mount_retry_on_nomedium.patch
-Patch8: util-linux-2.14.1-hypervisor_detection.patch
+Patch8: util-linux-2.14.1-lscpu.patch
+Patch9: util-linux-2.14.1-lscpu_sysroot_option.patch
+Patch10: util-linux-2.14.1-lscpu_add_hypervisor_vendor_id.patch
# crypto patch
Patch20: util-linux-mount_losetup_crypto.patch
##
@@ -116,6 +118,8 @@
%patch5 -p1
%patch7 -p1
%patch8 -p1
+%patch9 -p1
+%patch10 -p1
%patch20 -p1
cp %{SOURCE7} %{SOURCE8} .
#
@@ -185,7 +189,7 @@
# architecture dependent builds
BUILD_ENABLE=
%ifarch %ix86 x86_64
-BUILD_ENABLE="--enable-rdev --enable-hypervisor"
+BUILD_ENABLE="--enable-rdev"
%endif
# Use autogen, when building from git tree
autoreconf -fi
@@ -411,6 +415,7 @@
#/usr/bin/linux32
#/usr/bin/linux64
/usr/bin/look
+/usr/bin/lscpu
/usr/bin/mcookie
/usr/bin/mesg
%ifnarch ppc ppc64
@@ -465,6 +470,7 @@
%{_mandir}/man1/line.1.gz
%{_mandir}/man1/logger.1.gz
%{_mandir}/man1/look.1.gz
+%{_mandir}/man1/lscpu.1.gz
%{_mandir}/man1/mcookie.1.gz
%{_mandir}/man1/mesg.1.gz
%{_mandir}/man1/more.1.gz
@@ -536,12 +542,10 @@
/sbin/sfdisk
%endif
%ifarch %ix86 x86_64
-/bin/hypervisor
/usr/sbin/ramsize
/usr/sbin/rdev
/usr/sbin/rootflags
/usr/sbin/vidmode
-%{_mandir}/man1/hypervisor.1.gz
%{_mandir}/man8/ramsize.8.gz
%{_mandir}/man8/rdev.8.gz
%{_mandir}/man8/rootflags.8.gz
@@ -583,6 +587,11 @@
#%endif
%changelog
+* Thu Oct 02 2008 mkoenig@suse.de
+- add lscpu tool from current util-linux-ng git,
+ needed for fate#303051
+- replace hypervisor detection tool with the solution blessed by
+ upstream, which adds hv detection as lscpu feature [fate#303051]
* Wed Sep 24 2008 mkoenig@suse.de
- add new tool /bin/hypervisor for x86, x86_64
from Ky Srinivasan
++++++ util-linux-2.14.1-lscpu_add_hypervisor_vendor_id.patch ++++++
X-Gnus-Coding-System: -*- coding: utf-8; -*-
On Mon, Sep 29, 2008 at 11:01:05PM +0200, Karel Zak wrote:
On Mon, Sep 29, 2008 at 03:17:28PM +0200, Matthias Koenig wrote:
The tool has been written by Ky Srinivasan .
Do we really need a new tool? IMHO the hypervisor Vendor ID should
be exported by kernel in /sys or /proc -- or we can add this info to
lscpu(1) or so.
The (untested) patch below introduces a new fields "Hypervisor vendor
ID:" and "Para-Virtualized:" in lscpu(1).
The "Hypervisor vendor ID:" field reports the raw ID, it means it works
for all hypervisors (the same logic like CPU "Vendor ID:").
I think this solution is a good compromise to avoid a new tool.
(Note that lscpu(1) does not support XEN dom0 now. This problem will
be resolved ASAP.)
Comments?
Karel
From 5a8e8f8b28eb6ea4bdce27ed6629dfb4fb1665b5 Mon Sep 17 00:00:00 2001
From: Karel Zak
Date: Wed, 1 Oct 2008 01:29:32 +0200
Subject: [PATCH] lscpu: add Hypervisor vendor ID
Signed-off-by: Karel Zak
---
sys-utils/lscpu.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 101 insertions(+), 5 deletions(-)
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index d6bb8b9..5f39ced 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -38,7 +38,8 @@
/* /sys paths */
#define _PATH_SYS_SYSTEM "sys/devices/system"
#define _PATH_SYS_CPU0 _PATH_SYS_SYSTEM "/cpu/cpu0"
-#define _PATH_PROC_XENCAP "proc/xen/capabilities"
+#define _PATH_PROC_XEN "proc/xen"
+#define _PATH_PROC_XENCAP _PATH_PROC_XEN "/capabilities"
#define _PATH_PROC_CPUINFO "proc/cpuinfo"
int have_topology;
@@ -67,6 +68,9 @@ struct cpu_desc {
char *vendor;
char *family;
char *model;
+ char *virtflag; /* virtualization flag (vmx, svm) */
+ char *hvid; /* hypervisor vendor ID */
+ int is_para; /* is paravirtualized ? */
/* caches */
struct ca_desc cache[CACHE_MAX];
@@ -246,9 +250,94 @@ read_basicinfo(struct cpu_desc *cpu)
else
continue;
}
+
+ if (cpu->flags) {
+ snprintf(buf, sizeof(buf), " %s ", cpu->flags);
+ if (strstr(buf, " svm "))
+ cpu->virtflag = strdup("svm");
+ else if (strstr(buf, " vmx "))
+ cpu->virtflag = strdup("vmx");
+ }
+
fclose(fp);
}
+#if defined(__x86_64__) || defined(__i386__)
+
+/*
+ * This CPUID leaf returns the information about the hypervisor.
+ * EAX : maximum input value for CPUID supported by the hypervisor.
+ * EBX, ECX, EDX : Hypervisor vendor ID signature. E.g. VMwareVMware.
+ */
+#define HYPERVISOR_INFO_LEAF 0x40000000
+
+static inline void
+cpuid(unsigned int op, unsigned int *eax, unsigned int *ebx,
+ unsigned int *ecx, unsigned int *edx)
+{
+ __asm__("cpuid"
+ : "=a" (*eax),
+ "=b" (*ebx),
+ "=c" (*ecx),
+ "=d" (*edx)
+ : "0" (op), "c"(0));
+}
+
+static void
+read_hypervisor_cpuid(struct cpu_desc *cpu)
+{
+ unsigned int eax, ebx, ecx, edx;
+ char hyper_vendor_id[13];
+
+ memset(hyper_vendor_id, 0, sizeof(hyper_vendor_id));
+
+ cpuid(HYPERVISOR_INFO_LEAF, &eax, &ebx, &ecx, &edx);
+ memcpy(hyper_vendor_id + 0, &ebx, 4);
+ memcpy(hyper_vendor_id + 4, &ecx, 4);
+ memcpy(hyper_vendor_id + 8, &edx, 4);
+ hyper_vendor_id[12] = '\0';
+
+ if (hyper_vendor_id[0])
+ cpu->hvid = strdup(hyper_vendor_id);
+}
+
+#else /* ! __x86_64__ */
+static void
+read_hypervisor_cpuid(struct cpu_desc *cpu)
+{
+}
+#endif
+
+static void
+read_hypervisor(struct cpu_desc *cpu)
+{
+ read_hypervisor_cpuid(cpu);
+
+ if (!cpu->hvid) {
+ /* fallback for non-x86 archs */
+
+ if (!access(_PATH_PROC_XEN, F_OK))
+ /* XEN dom0 or domU */
+ cpu->hvid = strdup("Xen");
+ }
+
+ if (!cpu->virtflag && cpu->hvid && !strncmp(cpu->hvid, "Xen", 3)) {
+
+ FILE *fd = fopen(_PATH_PROC_XENCAP, "r");
+ int dom0 = 0;
+
+ if (fd) {
+ char buf[256];
+
+ if (fscanf(fd, "%s", buf) == 1 &&
+ !strcmp(buf, "control_d"))
+ dom0 = 1;
+ fclose(fd);
+ }
+ cpu->is_para = !dom0;
+ }
+}
+
static void
read_topology(struct cpu_desc *cpu)
{
@@ -344,6 +433,7 @@ check_system(void)
fd = fopen(_PATH_PROC_XENCAP, "r");
if (fd) {
if (fscanf(fd, "%s", buf) == 1 && !strcmp(buf, "control_d"))
+ /* !!!!!!!! TODO */
errx(EXIT_FAILURE,
_("error: Dom0 Kernel is unsupported."));
fclose(fd);
@@ -455,13 +545,17 @@ print_readable(struct cpu_desc *cpu)
print_s(_("Stepping:"), cpu->stepping);
if (cpu->mhz)
print_s(_("CPU MHz:"), cpu->mhz);
- if (cpu->flags) {
- snprintf(buf, sizeof(buf), " %s ", cpu->flags);
- if (strstr(buf, " svm "))
+ if (cpu->virtflag) {
+ if (!strcmp(cpu->virtflag, "svm"))
print_s(_("Virtualization:"), "AMD-V");
- else if (strstr(buf, " vmx "))
+ else if (!strcmp(cpu->virtflag, "vmx"))
print_s(_("Virtualization:"), "VT-x");
}
+ if (cpu->hvid) {
+ print_s(_("Hypervisor vendor ID:"), cpu->hvid);
+ print_s(_("Para-Virtualized:"),
+ cpu->is_para ? _("Yes") : _("Not"));
+ }
if (have_cache) {
int i;
@@ -545,6 +639,8 @@ int main(int argc, char *argv[])
if (have_node)
read_nodes(cpu);
+ read_hypervisor(cpu);
+
/* Show time! */
if (parsable)
print_parsable(cpu);
--
1.5.5.1
++++++ util-linux-2.14.1-lscpu.patch ++++++
++++ 630 lines (skipped)
++++++ util-linux-2.14.1-lscpu_sysroot_option.patch ++++++
commit 47b6e8b684ad28228c9255fe4237b5a8a1c8c7d3
Author: Cai Qian
Date: Sun Aug 10 15:33:51 2008 +0800
lscpu: --sysroot option and stable cache output
This patch added a --sysroot command-line option for testing purpose. It
also sorted cache names, and displayed cache information in a sorted
manner instead of randomly before. In addition, it had some other minor
fixes.
Signed-off-by: Cai Qian
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index 275d4c7..d6bb8b9 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -36,17 +36,24 @@
#define CACHE_MAX 100
/* /sys paths */
-#define _PATH_SYS_SYSTEM "/sys/devices/system"
+#define _PATH_SYS_SYSTEM "sys/devices/system"
#define _PATH_SYS_CPU0 _PATH_SYS_SYSTEM "/cpu/cpu0"
-#define _PATH_PROC_XENCAP "/proc/xen/capabilities"
-#define _PATH_PROC_CPUINFO "/proc/cpuinfo"
+#define _PATH_PROC_XENCAP "proc/xen/capabilities"
+#define _PATH_PROC_CPUINFO "proc/cpuinfo"
int have_topology;
int have_cache;
int have_node;
+/* cache(s) description */
+struct ca_desc {
+ char *caname;
+ char *casize;
+ int camap;
+};
+
/* CPU(s) description */
-struct cpu_decs {
+struct cpu_desc {
/* counters */
int ct_cpu;
int ct_thread;
@@ -62,9 +69,7 @@ struct cpu_decs {
char *model;
/* caches */
- char *caname[CACHE_MAX];
- char *casize[CACHE_MAX];
- int camap[CACHE_MAX];
+ struct ca_desc cache[CACHE_MAX];
/* misc */
char *mhz;
@@ -75,7 +80,7 @@ struct cpu_decs {
int *nodecpu;
};
-char pathbuf[PATH_MAX];
+char pathbuf[PATH_MAX] = "/";
static void path_scanstr(char *result, const char *path, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));
@@ -211,7 +216,7 @@ int lookup(char *line, char *pattern, char **value)
}
static void
-read_basicinfo(struct cpu_decs *cpu)
+read_basicinfo(struct cpu_desc *cpu)
{
FILE *fp = xfopen(_PATH_PROC_CPUINFO, "r");
char buf[BUFSIZ];
@@ -245,7 +250,7 @@ read_basicinfo(struct cpu_decs *cpu)
}
static void
-read_topology(struct cpu_decs *cpu)
+read_topology(struct cpu_desc *cpu)
{
/* number of threads */
cpu->ct_thread = path_sibling(
@@ -261,7 +266,7 @@ read_topology(struct cpu_decs *cpu)
}
static void
-read_cache(struct cpu_decs *cpu)
+read_cache(struct cpu_desc *cpu)
{
char buf[256];
DIR *dp;
@@ -295,14 +300,14 @@ read_cache(struct cpu_decs *cpu)
else
snprintf(buf, sizeof(buf), "L%d", level);
- cpu->caname[cpu->ct_cache] = xstrdup(buf);
+ cpu->cache[cpu->ct_cache].caname = xstrdup(buf);
/* cache size */
path_scanstr(buf, _PATH_SYS_CPU0 "/cache/%s/size", dir->d_name);
- cpu->casize[cpu->ct_cache] = xstrdup(buf);
+ cpu->cache[cpu->ct_cache].casize = xstrdup(buf);
/* information about how CPUs share different caches */
- cpu->camap[cpu->ct_cache] = path_sibling(
+ cpu->cache[cpu->ct_cache].camap = path_sibling(
_PATH_SYS_CPU0 "/cache/%s/shared_cpu_map",
dir->d_name);
cpu->ct_cache++;
@@ -310,7 +315,7 @@ read_cache(struct cpu_decs *cpu)
}
static void
-read_nodes(struct cpu_decs *cpu)
+read_nodes(struct cpu_desc *cpu)
{
int i;
@@ -346,7 +351,8 @@ check_system(void)
/* Read through sysfs. */
if (access(_PATH_SYS_SYSTEM, F_OK))
- errx(1, _("error: /sys filesystem is not accessable."));
+ errx(EXIT_FAILURE,
+ _("error: /sys filesystem is not accessable."));
if (!access(_PATH_SYS_SYSTEM "/node", F_OK))
have_node = 1;
@@ -359,22 +365,22 @@ check_system(void)
}
static void
-print_parsable(struct cpu_decs *cpu)
+print_parsable(struct cpu_desc *cpu)
{
int i, j;
- puts(
+ printf(_(
"# The following is the parsable format, which can be fed to other\n"
- "# programs. Each different item in every column has a unique ID\n"
+ "# programs. Each different item in every column has an unique ID\n"
"# starting from zero.\n"
- "# CPU,Core,Socket,Node");
+ "# CPU,Core,Socket,Node"));
if (have_cache) {
/* separator between CPU topology and cache information */
putchar(',');
for (i = cpu->ct_cache - 1; i >= 0; i--)
- printf(",%s", cpu->caname[i]);
+ printf(",%s", cpu->cache[i].caname);
}
putchar('\n');
@@ -407,11 +413,11 @@ print_parsable(struct cpu_decs *cpu)
for (j = cpu->ct_cache - 1; j >= 0; j--) {
/* If shared_cpu_map is 0, all CPUs share the same
cache. */
- if (cpu->camap[j] == 0)
- cpu->camap[j] = cpu->ct_core *
- cpu->ct_thread;
+ if (cpu->cache[j].camap == 0)
+ cpu->cache[j].camap = cpu->ct_core *
+ cpu->ct_thread;
- printf(",%d", i / cpu->camap[j]);
+ printf(",%d", i / cpu->cache[j].camap);
}
}
putchar('\n');
@@ -424,7 +430,7 @@ print_parsable(struct cpu_decs *cpu)
#define print_n(_key, _val) printf("%-23s%d\n", _key, _val)
static void
-print_readable(struct cpu_decs *cpu)
+print_readable(struct cpu_desc *cpu)
{
char buf[BUFSIZ];
@@ -462,8 +468,8 @@ print_readable(struct cpu_decs *cpu)
for (i = cpu->ct_cache - 1; i >= 0; i--) {
snprintf(buf, sizeof(buf),
- _("%s cache:"), cpu->caname[i]);
- print_s(buf, cpu->casize[i]);
+ _("%s cache:"), cpu->cache[i].caname);
+ print_s(buf, cpu->cache[i].casize);
}
}
}
@@ -475,18 +481,29 @@ void usage(int rc)
puts(_( "CPU architecture information helper\n\n"
" -h, --help usage information\n"
- " -p, --parse print out in parsable instead of printable format.\n"));
+ " -p, --parse print out in parsable instead of printable format.\n"
+ " -s, --sysroot use the directory as a new system root.\n"));
exit(rc);
}
+static int
+ca_compare(const void *a, const void *b)
+{
+ struct ca_desc *cache1 = (struct ca_desc *) a;
+ struct ca_desc *cache2 = (struct ca_desc *) b;
+
+ return strcmp(cache2->caname, cache1->caname);
+}
+
int main(int argc, char *argv[])
{
- struct cpu_decs _cpu, *cpu = &_cpu;
+ struct cpu_desc _cpu, *cpu = &_cpu;
int parsable = 0, c;
struct option longopts[] = {
- { "help", no_argument, 0, 'h' },
- { "parse", no_argument, 0, 'p' },
+ { "help", no_argument, 0, 'h' },
+ { "parse", no_argument, 0, 'p' },
+ { "sysroot", required_argument, 0, 's' },
{ NULL, 0, 0, 0 }
};
@@ -494,18 +511,25 @@ int main(int argc, char *argv[])
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- while((c = getopt_long(argc, argv, "hp", longopts, NULL)) != -1) {
+ while((c = getopt_long(argc, argv, "hps:", longopts, NULL)) != -1) {
switch (c) {
case 'h':
usage(EXIT_SUCCESS);
case 'p':
parsable = 1;
break;
+ case 's':
+ strncpy(pathbuf, optarg, sizeof(pathbuf));
+ break;
default:
usage(EXIT_FAILURE);
}
}
+ if (chdir(pathbuf) == -1)
+ errx(EXIT_FAILURE,
+ _("error: change working directory to %s."), pathbuf);
+
memset(cpu, 0, sizeof(*cpu));
check_system();
@@ -514,8 +538,10 @@ int main(int argc, char *argv[])
if (have_topology)
read_topology(cpu);
- if (have_cache)
+ if (have_cache) {
read_cache(cpu);
+ qsort(cpu->cache, cpu->ct_cache, sizeof(struct ca_desc), ca_compare);
+ }
if (have_node)
read_nodes(cpu);
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...
--
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org