forked from pool/util-linux
This commit is contained in:
parent
a42c2690a3
commit
5eecd85b50
@ -0,0 +1,21 @@
|
|||||||
|
Index: util-linux-ng-2.14.1/disk-utils/mkfs.minix.c
|
||||||
|
===================================================================
|
||||||
|
--- util-linux-ng-2.14.1.orig/disk-utils/mkfs.minix.c 2008-09-10 11:02:42.000000000 +0200
|
||||||
|
+++ util-linux-ng-2.14.1/disk-utils/mkfs.minix.c 2008-10-23 17:25:49.000000000 +0200
|
||||||
|
@@ -653,9 +653,14 @@ main(int argc, char ** argv) {
|
||||||
|
die(_("cannot determine sector size for %s"));
|
||||||
|
if (BLOCK_SIZE < sectorsize)
|
||||||
|
die(_("block size smaller than physical sector size of %s"));
|
||||||
|
- if (!BLOCKS && blkdev_get_size(DEV, &BLOCKS) == -1)
|
||||||
|
- die(_("cannot determine size of %s"));
|
||||||
|
+ if (!BLOCKS) {
|
||||||
|
+ if (blkdev_get_size(DEV, &BLOCKS) == -1)
|
||||||
|
+ die(_("cannot determine size of %s"));
|
||||||
|
+ BLOCKS /= BLOCK_SIZE;
|
||||||
|
+ }
|
||||||
|
} else if (!S_ISBLK(statbuf.st_mode)) {
|
||||||
|
+ if (!BLOCKS)
|
||||||
|
+ BLOCKS = statbuf.st_size / BLOCK_SIZE;
|
||||||
|
check=0;
|
||||||
|
} else if (statbuf.st_rdev == 0x0300 || statbuf.st_rdev == 0x0340)
|
||||||
|
die(_("will not try to make filesystem on '%s'"));
|
284
util-linux-2.14.1-lscpu_add_hypervisor_detection.patch
Normal file
284
util-linux-2.14.1-lscpu_add_hypervisor_detection.patch
Normal file
@ -0,0 +1,284 @@
|
|||||||
|
commit c8b64f6d7770d62065bdc4fa5c4f80cc2326e203
|
||||||
|
Author: Karel Zak <kzak@redhat.com>
|
||||||
|
Date: Wed Oct 1 01:29:32 2008 +0200
|
||||||
|
|
||||||
|
lscpu: add Hypervisor detection
|
||||||
|
|
||||||
|
This patch adds two new fields:
|
||||||
|
|
||||||
|
* "Hypervisor vendor" -- based on CPUID and hypervisor specific
|
||||||
|
PCI devices. lscpu(1) supports KVM, XEN, Microsoft HV now.
|
||||||
|
|
||||||
|
* "Virtualization type"
|
||||||
|
- "none" = Xen dom0
|
||||||
|
- "full" = full virtualization (KVM, Xen, ...)
|
||||||
|
- "para" = Xen paravirtualization
|
||||||
|
|
||||||
|
Co-Author: Ky Srinivasan <ksrinivasan@novell.com>
|
||||||
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
||||||
|
|
||||||
|
diff --git a/sys-utils/lscpu.1 b/sys-utils/lscpu.1
|
||||||
|
index 78da8a1..e0e9935 100644
|
||||||
|
--- a/sys-utils/lscpu.1
|
||||||
|
+++ b/sys-utils/lscpu.1
|
||||||
|
@@ -22,6 +22,8 @@ Print out in parsable instead of printable format.
|
||||||
|
.SH BUGS
|
||||||
|
The program at the moment does not handle the system installed with
|
||||||
|
different types of physical processors.
|
||||||
|
+
|
||||||
|
+Sometimes in Xen Dom0 kernel reports wrong data.
|
||||||
|
.SH AUTHOR
|
||||||
|
Cai Qian <qcai@redhat.com>
|
||||||
|
.SH AVAILABILITY
|
||||||
|
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
|
||||||
|
index d6bb8b9..82972b3 100644
|
||||||
|
--- a/sys-utils/lscpu.c
|
||||||
|
+++ b/sys-utils/lscpu.c
|
||||||
|
@@ -38,8 +38,10 @@
|
||||||
|
/* /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"
|
||||||
|
+#define _PATH_PROC_PCIDEVS "proc/bus/pci/devices"
|
||||||
|
|
||||||
|
int have_topology;
|
||||||
|
int have_cache;
|
||||||
|
@@ -52,6 +54,33 @@ struct ca_desc {
|
||||||
|
int camap;
|
||||||
|
};
|
||||||
|
|
||||||
|
+/* virtualization types */
|
||||||
|
+enum {
|
||||||
|
+ VIRT_NONE = 0,
|
||||||
|
+ VIRT_PARA,
|
||||||
|
+ VIRT_FULL
|
||||||
|
+};
|
||||||
|
+const char *virt_types[] = {
|
||||||
|
+ [VIRT_NONE] = N_("none"),
|
||||||
|
+ [VIRT_PARA] = N_("para"),
|
||||||
|
+ [VIRT_FULL] = N_("full")
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+/* hypervisor vendors */
|
||||||
|
+enum {
|
||||||
|
+ HYPER_NONE = 0,
|
||||||
|
+ HYPER_XEN,
|
||||||
|
+ HYPER_KVM,
|
||||||
|
+ HYPER_MSHV
|
||||||
|
+};
|
||||||
|
+const char *hv_vendors[] = {
|
||||||
|
+ [HYPER_NONE] = NULL,
|
||||||
|
+ [HYPER_XEN] = "Xen",
|
||||||
|
+ [HYPER_KVM] = "KVM",
|
||||||
|
+ [HYPER_MSHV] = "Microsoft"
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+
|
||||||
|
/* CPU(s) description */
|
||||||
|
struct cpu_desc {
|
||||||
|
/* counters */
|
||||||
|
@@ -67,6 +96,9 @@ struct cpu_desc {
|
||||||
|
char *vendor;
|
||||||
|
char *family;
|
||||||
|
char *model;
|
||||||
|
+ char *virtflag; /* virtualization flag (vmx, svm) */
|
||||||
|
+ int hyper; /* hypervisor vendor ID */
|
||||||
|
+ int virtype; /* VIRT_PARA|FULL|NONE ? */
|
||||||
|
|
||||||
|
/* caches */
|
||||||
|
struct ca_desc cache[CACHE_MAX];
|
||||||
|
@@ -246,9 +278,130 @@ 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
+static int
|
||||||
|
+has_pci_device(int vendor, int device)
|
||||||
|
+{
|
||||||
|
+ FILE *f;
|
||||||
|
+ int num, fn, ven, dev;
|
||||||
|
+ int res = 1;
|
||||||
|
+
|
||||||
|
+ f = fopen(_PATH_PROC_PCIDEVS, "r");
|
||||||
|
+ if (!f)
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
+ /* for more details about bus/pci/devices format see
|
||||||
|
+ * drivers/pci/proc.c in linux kernel
|
||||||
|
+ */
|
||||||
|
+ while(fscanf(f, "%02x%02x\t%04x%04x\t%*[^\n]",
|
||||||
|
+ &num, &fn, &ven, &dev) == 4) {
|
||||||
|
+
|
||||||
|
+ if (ven == vendor && dev == device)
|
||||||
|
+ goto found;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ res = 0;
|
||||||
|
+found:
|
||||||
|
+ fclose(f);
|
||||||
|
+ return res;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+#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 = 0, ebx = 0, ecx = 0, edx = 0;
|
||||||
|
+ 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])
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ if (!strncmp("XenVMMXenVMM", hyper_vendor_id, 12))
|
||||||
|
+ cpu->hyper = HYPER_XEN;
|
||||||
|
+ else if (!strncmp("KVMKVMKVM", hyper_vendor_id, 9))
|
||||||
|
+ cpu->hyper = HYPER_KVM;
|
||||||
|
+ else if (!strncmp("Microsoft Hv", hyper_vendor_id, 12))
|
||||||
|
+ cpu->hyper = HYPER_MSHV;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+#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->hyper)
|
||||||
|
+ /* hvm */
|
||||||
|
+ cpu->virtype = VIRT_FULL;
|
||||||
|
+
|
||||||
|
+ else if (!access(_PATH_PROC_XEN, F_OK)) {
|
||||||
|
+ /* Xen para-virt or dom0 */
|
||||||
|
+ 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->virtype = dom0 ? VIRT_NONE : VIRT_PARA;
|
||||||
|
+ cpu->hyper = HYPER_XEN;
|
||||||
|
+
|
||||||
|
+ } else if (has_pci_device(0x5853, 0x0001)) {
|
||||||
|
+ /* Xen full-virt on non-x86_64 */
|
||||||
|
+ cpu->hyper = HYPER_XEN;
|
||||||
|
+ cpu->virtype = VIRT_FULL;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static void
|
||||||
|
read_topology(struct cpu_desc *cpu)
|
||||||
|
{
|
||||||
|
@@ -337,18 +490,6 @@ read_nodes(struct cpu_desc *cpu)
|
||||||
|
static void
|
||||||
|
check_system(void)
|
||||||
|
{
|
||||||
|
- FILE *fd;
|
||||||
|
- char buf[256];
|
||||||
|
-
|
||||||
|
- /* Dom0 Kernel gives wrong information. */
|
||||||
|
- fd = fopen(_PATH_PROC_XENCAP, "r");
|
||||||
|
- if (fd) {
|
||||||
|
- if (fscanf(fd, "%s", buf) == 1 && !strcmp(buf, "control_d"))
|
||||||
|
- errx(EXIT_FAILURE,
|
||||||
|
- _("error: Dom0 Kernel is unsupported."));
|
||||||
|
- fclose(fd);
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
/* Read through sysfs. */
|
||||||
|
if (access(_PATH_SYS_SYSTEM, F_OK))
|
||||||
|
errx(EXIT_FAILURE,
|
||||||
|
@@ -432,8 +573,6 @@ print_parsable(struct cpu_desc *cpu)
|
||||||
|
static void
|
||||||
|
print_readable(struct cpu_desc *cpu)
|
||||||
|
{
|
||||||
|
- char buf[BUFSIZ];
|
||||||
|
-
|
||||||
|
print_s("Architecture:", cpu->arch);
|
||||||
|
print_n("CPU(s):", cpu->ct_cpu);
|
||||||
|
|
||||||
|
@@ -455,15 +594,18 @@ 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->hyper) {
|
||||||
|
+ print_s(_("Hypervisor vendor:"), hv_vendors[cpu->hyper]);
|
||||||
|
+ print_s(_("Virtualization type:"), virt_types[cpu->virtype]);
|
||||||
|
+ }
|
||||||
|
if (have_cache) {
|
||||||
|
+ char buf[512];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = cpu->ct_cache - 1; i >= 0; i--) {
|
||||||
|
@@ -545,6 +687,8 @@ int main(int argc, char *argv[])
|
||||||
|
if (have_node)
|
||||||
|
read_nodes(cpu);
|
||||||
|
|
||||||
|
+ read_hypervisor(cpu);
|
||||||
|
+
|
||||||
|
/* Show time! */
|
||||||
|
if (parsable)
|
||||||
|
print_parsable(cpu);
|
@ -1,196 +0,0 @@
|
|||||||
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 <ksrinivasan@novell.com>.
|
|
||||||
>
|
|
||||||
> 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 <kzak@redhat.com>
|
|
||||||
Date: Wed, 1 Oct 2008 01:29:32 +0200
|
|
||||||
Subject: [PATCH] lscpu: add Hypervisor vendor ID
|
|
||||||
|
|
||||||
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
||||||
---
|
|
||||||
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
|
|
||||||
|
|
189
util-linux-2.14.1-mount_swap_pagesize.patch
Normal file
189
util-linux-2.14.1-mount_swap_pagesize.patch
Normal file
@ -0,0 +1,189 @@
|
|||||||
|
Index: util-linux-ng-2.14.1/mount/swapon.c
|
||||||
|
===================================================================
|
||||||
|
--- util-linux-ng-2.14.1.orig/mount/swapon.c 2008-09-10 11:02:43.000000000 +0200
|
||||||
|
+++ util-linux-ng-2.14.1/mount/swapon.c 2008-10-24 14:19:06.000000000 +0200
|
||||||
|
@@ -13,6 +13,8 @@
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
+#include <stdint.h>
|
||||||
|
+#include <byteswap.h>
|
||||||
|
#include "xmalloc.h"
|
||||||
|
#include "swap_constants.h"
|
||||||
|
#include "nls.h"
|
||||||
|
@@ -39,6 +41,33 @@
|
||||||
|
#define QUIET 1
|
||||||
|
#define CANONIC 1
|
||||||
|
|
||||||
|
+#define MAX_PAGESIZE (64 * 1024)
|
||||||
|
+static unsigned int page_size[] = { 4 * 1024,
|
||||||
|
+ 8 * 1024,
|
||||||
|
+ 16 * 1024,
|
||||||
|
+ 64 * 1024,
|
||||||
|
+ 0 };
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+struct swap_info {
|
||||||
|
+ char bootbits[1024]; /* Space for disklabel etc. */
|
||||||
|
+ uint32_t version;
|
||||||
|
+ uint32_t last_page;
|
||||||
|
+ uint32_t nr_badpages;
|
||||||
|
+ unsigned char sws_uuid[16];
|
||||||
|
+ unsigned char sws_volume[16];
|
||||||
|
+ uint32_t padding[117];
|
||||||
|
+ uint32_t badpages[1];
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+enum {
|
||||||
|
+ SWAP_V0 = 1,
|
||||||
|
+ SWAP_V1,
|
||||||
|
+ SWAP_SUSPEND,
|
||||||
|
+ SWAP_ULSUSPEND,
|
||||||
|
+ SWAP_OOTSUSPEND
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
int all = 0;
|
||||||
|
int priority = -1; /* non-prioritized swap by default */
|
||||||
|
|
||||||
|
@@ -238,11 +267,114 @@ swap_reinitialize(const char *device) {
|
||||||
|
return -1; /* error */
|
||||||
|
}
|
||||||
|
|
||||||
|
+int
|
||||||
|
+swap_detect_signature(const char *buf)
|
||||||
|
+{
|
||||||
|
+ if (memcmp(buf, "SWAP-SPACE", 10) == 0)
|
||||||
|
+ return SWAP_V0;
|
||||||
|
+ else if (memcmp(buf, "SWAPSPACE2", 10) == 0)
|
||||||
|
+ return SWAP_V1;
|
||||||
|
+ else if (memcmp(buf, "S1SUSPEND", 9) == 0)
|
||||||
|
+ return SWAP_SUSPEND;
|
||||||
|
+ else if (memcmp(buf, "ULSUSPEND", 9) == 0)
|
||||||
|
+ return SWAP_ULSUSPEND;
|
||||||
|
+ else if (memcmp(buf, "\xed\xc3\x02\xe9\x98\x56\xe5\x0c", 8) == 0)
|
||||||
|
+ return SWAP_OOTSUSPEND;
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/* return the pagesize the swap format has been built with
|
||||||
|
+ * as swap metadata depends on the pagesize, we have to
|
||||||
|
+ * reinitialize if it does not match with the current pagesize
|
||||||
|
+ * returns 0 if not a valid swap format
|
||||||
|
+ */
|
||||||
|
+unsigned int
|
||||||
|
+swap_get_pagesize(const char *dev)
|
||||||
|
+{
|
||||||
|
+ int fd;
|
||||||
|
+ char *buf;
|
||||||
|
+ unsigned int *page, last_page;
|
||||||
|
+ unsigned int pagesize = 0;
|
||||||
|
+ off_t size, swap_size;
|
||||||
|
+ int swap_version;
|
||||||
|
+ int flip = 0;
|
||||||
|
+ struct swap_info *s;
|
||||||
|
+
|
||||||
|
+ fd = open(dev, O_RDONLY);
|
||||||
|
+ if (fd == -1) {
|
||||||
|
+ perror("open");
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /* get size */
|
||||||
|
+ size = lseek(fd, 0, SEEK_END);
|
||||||
|
+ if (size == (off_t)-1) {
|
||||||
|
+ perror("lseek");
|
||||||
|
+ goto err;
|
||||||
|
+ }
|
||||||
|
+ /* rewind */
|
||||||
|
+ if (lseek(fd, 0, SEEK_SET)) {
|
||||||
|
+ perror("lseek");
|
||||||
|
+ goto err;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ buf = malloc(MAX_PAGESIZE);
|
||||||
|
+ if (!buf) {
|
||||||
|
+ perror("malloc");
|
||||||
|
+ goto err;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (read(fd, buf, MAX_PAGESIZE) == (ssize_t)-1) {
|
||||||
|
+ perror("read");
|
||||||
|
+ goto err1;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ for (page = page_size; *page; ++page) {
|
||||||
|
+ char *off = buf + *page - 10;
|
||||||
|
+ if (swap_detect_signature(off)) {
|
||||||
|
+ pagesize = *page;
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ if (pagesize) {
|
||||||
|
+ s = (struct swap_info *)buf;
|
||||||
|
+ if (s->version == 1)
|
||||||
|
+ last_page = s->last_page;
|
||||||
|
+ else if (bswap_32(s->version) == 1) {
|
||||||
|
+ flip = 1;
|
||||||
|
+ last_page = bswap_32(s->last_page);
|
||||||
|
+ }
|
||||||
|
+ if (verbose)
|
||||||
|
+ fprintf(stderr, _("found %sswap v%d signature string"
|
||||||
|
+ " for %d KiB PAGE_SIZE\n"),
|
||||||
|
+ flip ? "other-endian " : "", swap_version - 1,
|
||||||
|
+ pagesize / 1024);
|
||||||
|
+ swap_size = (last_page + 1) * pagesize;
|
||||||
|
+ if (swap_size > size) {
|
||||||
|
+ if (verbose)
|
||||||
|
+ fprintf(stderr, _("last_page 0x%08llx is larger"
|
||||||
|
+ " than actual size of swapspace\n"),
|
||||||
|
+ (unsigned long long)swap_size);
|
||||||
|
+ pagesize = 0;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+err1:
|
||||||
|
+ free(buf);
|
||||||
|
+err:
|
||||||
|
+ close(fd);
|
||||||
|
+ return pagesize;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static int
|
||||||
|
do_swapon(const char *orig_special, int prio, int canonic) {
|
||||||
|
int status;
|
||||||
|
+ int reinitialize = 0;
|
||||||
|
struct stat st;
|
||||||
|
const char *special = orig_special;
|
||||||
|
+ unsigned int pagesize = sysconf(_SC_PAGESIZE);
|
||||||
|
+ unsigned int swap_pagesize = 0;
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
printf(_("%s on %s\n"), progname, orig_special);
|
||||||
|
@@ -260,6 +392,15 @@ do_swapon(const char *orig_special, int
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ swap_pagesize = swap_get_pagesize(special);
|
||||||
|
+ if (swap_pagesize && (pagesize != swap_pagesize)) {
|
||||||
|
+ if (verbose)
|
||||||
|
+ fprintf(stderr, _("swap format pagesize does not match."
|
||||||
|
+ " Reinitializing the swap.\n"),
|
||||||
|
+ progname, special);
|
||||||
|
+ reinitialize = 1;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
/* We have to reinitialize swap with old (=useless) software suspend
|
||||||
|
* data. The problem is that if we don't do it, then we get data
|
||||||
|
* corruption the next time an attempt at unsuspending is made.
|
||||||
|
@@ -268,6 +409,10 @@ do_swapon(const char *orig_special, int
|
||||||
|
fprintf(stdout, _("%s: %s: software suspend data detected. "
|
||||||
|
"Reinitializing the swap.\n"),
|
||||||
|
progname, special);
|
||||||
|
+ reinitialize = 1;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (reinitialize) {
|
||||||
|
if (swap_reinitialize(special) < 0)
|
||||||
|
return -1;
|
||||||
|
}
|
11
util-linux-2.14.1-sys-utils_lscpu_exit.patch
Normal file
11
util-linux-2.14.1-sys-utils_lscpu_exit.patch
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
Index: util-linux-ng-2.14.1/sys-utils/lscpu.c
|
||||||
|
===================================================================
|
||||||
|
--- util-linux-ng-2.14.1.orig/sys-utils/lscpu.c 2008-10-20 15:00:44.000000000 +0200
|
||||||
|
+++ util-linux-ng-2.14.1/sys-utils/lscpu.c 2008-10-21 18:27:01.000000000 +0200
|
||||||
|
@@ -647,5 +647,5 @@ int main(int argc, char *argv[])
|
||||||
|
else
|
||||||
|
print_readable(cpu);
|
||||||
|
|
||||||
|
- return EXIT_FAILURE;
|
||||||
|
+ return EXIT_SUCCESS;
|
||||||
|
}
|
@ -1,3 +1,11 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Oct 23 17:58:28 CEST 2008 - mkoenig@suse.de
|
||||||
|
|
||||||
|
- swapon: add swap pagesize detection [bnc#433028]
|
||||||
|
- lscpu: fix return code [bnc#437367]
|
||||||
|
- mkfs.minix: fix device size detection [bnc#437980]
|
||||||
|
- lscpu: update to most recent version for hypervisor detection
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Thu Oct 2 11:10:11 CEST 2008 - mkoenig@suse.de
|
Thu Oct 2 11:10:11 CEST 2008 - mkoenig@suse.de
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ License: BSD 3-Clause; GPL v2 or later
|
|||||||
Group: System/Base
|
Group: System/Base
|
||||||
AutoReqProv: on
|
AutoReqProv: on
|
||||||
Version: 2.14.1
|
Version: 2.14.1
|
||||||
Release: 3
|
Release: 4
|
||||||
Requires: %name-lang = %{version}
|
Requires: %name-lang = %{version}
|
||||||
Summary: A collection of basic system utilities
|
Summary: A collection of basic system utilities
|
||||||
Source: ftp://ftp.kernel.org/pub/linux/utils/util-linux/%name-ng-%version.tar.bz2
|
Source: ftp://ftp.kernel.org/pub/linux/utils/util-linux/%name-ng-%version.tar.bz2
|
||||||
@ -73,7 +73,10 @@ Patch5: util-linux-2.13.1-fdisk_cfdisk_yesno.patch
|
|||||||
Patch7: util-linux-2.14-mount_retry_on_nomedium.patch
|
Patch7: util-linux-2.14-mount_retry_on_nomedium.patch
|
||||||
Patch8: util-linux-2.14.1-lscpu.patch
|
Patch8: util-linux-2.14.1-lscpu.patch
|
||||||
Patch9: util-linux-2.14.1-lscpu_sysroot_option.patch
|
Patch9: util-linux-2.14.1-lscpu_sysroot_option.patch
|
||||||
Patch10: util-linux-2.14.1-lscpu_add_hypervisor_vendor_id.patch
|
Patch10: util-linux-2.14.1-lscpu_add_hypervisor_detection.patch
|
||||||
|
Patch11: util-linux-2.14.1-mount_swap_pagesize.patch
|
||||||
|
Patch12: util-linux-2.14.1-sys-utils_lscpu_exit.patch
|
||||||
|
Patch13: util-linux-2.14.1-disk-utils_mkfs.minix_file_size_detection.patch
|
||||||
# crypto patch
|
# crypto patch
|
||||||
Patch20: util-linux-mount_losetup_crypto.patch
|
Patch20: util-linux-mount_losetup_crypto.patch
|
||||||
##
|
##
|
||||||
@ -120,6 +123,9 @@ Authors:
|
|||||||
%patch8 -p1
|
%patch8 -p1
|
||||||
%patch9 -p1
|
%patch9 -p1
|
||||||
%patch10 -p1
|
%patch10 -p1
|
||||||
|
%patch11 -p1
|
||||||
|
%patch12 -p1
|
||||||
|
%patch13 -p1
|
||||||
%patch20 -p1
|
%patch20 -p1
|
||||||
cp %{SOURCE7} %{SOURCE8} .
|
cp %{SOURCE7} %{SOURCE8} .
|
||||||
#
|
#
|
||||||
@ -587,6 +593,11 @@ fi
|
|||||||
#%endif
|
#%endif
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Oct 23 2008 mkoenig@suse.de
|
||||||
|
- swapon: add swap pagesize detection [bnc#433028]
|
||||||
|
- lscpu: fix return code [bnc#437367]
|
||||||
|
- mkfs.minix: fix device size detection [bnc#437980]
|
||||||
|
- lscpu: update to most recent version for hypervisor detection
|
||||||
* Thu Oct 02 2008 mkoenig@suse.de
|
* Thu Oct 02 2008 mkoenig@suse.de
|
||||||
- add lscpu tool from current util-linux-ng git,
|
- add lscpu tool from current util-linux-ng git,
|
||||||
needed for fate#303051
|
needed for fate#303051
|
||||||
|
Loading…
Reference in New Issue
Block a user