~ubuntu-branches/ubuntu/quantal/libvirt/quantal

« back to all changes in this revision

Viewing changes to debian/patches/add-armhf-sysinfo-infomration.patch

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-07-19 14:54:47 UTC
  • Revision ID: package-import@ubuntu.com-20120719145447-ksf59r7lsc2df56l
Tags: 0.9.13-0ubuntu4
* debian/patches/add-armhf-sysinfo-infomration.patch:
  Provides cpuinfo for armhf cpus.
* debian/patches/add-armhf-cpuinfo-parser.patch:
  Fixes compile time warning about armhf cpus.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
diff -Naurp libvirt-0.9.13.orig/src/util/sysinfo.c libvirt-0.9.13/src/util/sysinfo.c
 
2
--- libvirt-0.9.13.orig/src/util/sysinfo.c      2012-06-26 20:44:39.000000000 -0500
 
3
+++ libvirt-0.9.13/src/util/sysinfo.c   2012-07-19 11:07:27.616440473 -0500
 
4
@@ -242,6 +242,163 @@ no_memory:
 
5
     return NULL;
 
6
 }
 
7
 
 
8
+#elif defined(__arm__)
 
9
+static int
 
10
+virSysinfoParseSystem(const char *base, virSysinfoDefPtr ret)
 
11
+{
 
12
+   char *eol = NULL;
 
13
+   const char *cur;
 
14
+
 
15
+   if ((cur = strstr(base, "Hardware")) == NULL)
 
16
+       return 0;
 
17
+
 
18
+   base = cur;
 
19
+   /* Account for format 'Hardware      : XXXX'*/
 
20
+   cur = strchr(cur, ':') + 1;
 
21
+   eol = strchr(cur, '\n');
 
22
+   virSkipSpaces(&cur);
 
23
+   if (eol &&
 
24
+       ((ret->system_family = strndup(cur, eol - cur)) == NULL))
 
25
+       goto no_memory;
 
26
+
 
27
+   if ((cur= strstr(base, "Revision")) != NULL) {
 
28
+       cur = strchr(cur, ':') + 1;
 
29
+       eol = strchr(cur, '\n');
 
30
+       virSkipSpaces(&cur);
 
31
+       if (eol && ((ret->system_version = strndup(cur, eol - cur))
 
32
+                                                         == NULL))
 
33
+          goto no_memory;
 
34
+   }
 
35
+
 
36
+   if ((cur = strstr(base, "Serial")) != NULL) {
 
37
+        cur = strchr(cur, ':') + 1;
 
38
+        eol = strchr(cur, '\n');
 
39
+        virSkipSpaces(&cur);
 
40
+        if (eol && ((ret->system_serial = strndup(cur, eol - cur))
 
41
+                                                          == NULL))
 
42
+           goto no_memory;
 
43
+   }
 
44
+
 
45
+   return 0;
 
46
+
 
47
+no_memory:
 
48
+     return -1;
 
49
+}
 
50
+
 
51
+static int
 
52
+virSysinfoParseProcessor(const char *base, virSysinfoDefPtr ret)
 
53
+{
 
54
+   const char *cur;
 
55
+   char *eol, *tmp_base;
 
56
+   virSysinfoProcessorDefPtr processor;
 
57
+
 
58
+   while ((tmp_base = strstr(base, "Processor")) != NULL) {
 
59
+       base = tmp_base;
 
60
+       eol = strchr(base, '\n');
 
61
+       cur = strchr(base, ':') + 1;
 
62
+
 
63
+      if (VIR_EXPAND_N(ret->processor, ret->nprocessor, 1) < 0) {
 
64
+          goto no_memory;
 
65
+      }
 
66
+      processor = &ret->processor[ret->nprocessor - 1];
 
67
+
 
68
+      virSkipSpaces(&cur);
 
69
+      if (eol &&
 
70
+          ((processor->processor_socket_destination = strndup
 
71
+                                   (cur, eol - cur)) == NULL))
 
72
+          goto no_memory;
 
73
+
 
74
+      if ((cur = strstr(base, "CPU implementer")) != NULL) {
 
75
+          cur = strchr(cur, ':') + 1;
 
76
+          eol = strchr(cur, '\n');
 
77
+          virSkipSpaces(&cur);
 
78
+          if (eol && 
 
79
+              ((processor->processor_manufacturer = strndup(cur, eol - cur))
 
80
+                                                           == NULL))
 
81
+              goto no_memory;
 
82
+       }
 
83
+
 
84
+      if ((cur = strstr(base, "CPU architecture")) != NULL) {
 
85
+          cur = strchr(cur, ':') + 1;
 
86
+          eol = strchr(cur, '\n');
 
87
+          virSkipSpaces(&cur);
 
88
+          if (eol &&
 
89
+              ((processor->processor_type = strndup(cur, eol - cur))
 
90
+                                                  == NULL))
 
91
+               goto no_memory;
 
92
+      }
 
93
+
 
94
+      if ((cur = strstr(base, "CPU variant")) != NULL) {
 
95
+          cur = strchr(cur, ':') + 1;
 
96
+         eol = strchr(cur, '\n');
 
97
+          virSkipSpaces(&cur);
 
98
+          if (eol &&
 
99
+                ((processor->processor_family = strndup(cur, eol - cur))
 
100
+                                                       == NULL))
 
101
+                goto no_memory;
 
102
+      }
 
103
+
 
104
+      if ((cur = strstr(base, "CPU part")) != NULL) {
 
105
+           cur = strchr(cur, ':') + 1;
 
106
+           eol = strchr(cur, '\n');
 
107
+           virSkipSpaces(&cur);
 
108
+           if (eol &&
 
109
+               ((processor->processor_part_number = strndup(cur, eol - cur))
 
110
+                                                                 == NULL))
 
111
+                 goto no_memory;
 
112
+      }
 
113
+
 
114
+      if ((cur = strstr(base, "CPU revision")) != NULL) {
 
115
+           cur = strchr(cur, ':') + 1;
 
116
+           eol = strchr(cur, '\n');
 
117
+           virSkipSpaces(&cur);
 
118
+           if (eol && 
 
119
+               ((processor->processor_version = strndup(cur, eol - cur))
 
120
+                                                             == NULL))
 
121
+                 goto no_memory;
 
122
+      }
 
123
+  
 
124
+      base = cur;
 
125
+   }
 
126
+
 
127
+   return 0;
 
128
+
 
129
+no_memory:
 
130
+     return -1;
 
131
+}
 
132
+
 
133
+/* virSysinfoRead for ARMHF
 
134
+ * Gathers sysinfo data from /proc/cpuinfo */
 
135
+virSysinfoDefPtr
 
136
+virSysinfoRead(void) {
 
137
+    virSysinfoDefPtr ret = NULL;
 
138
+    char *outbuf = NULL;
 
139
+
 
140
+    if (VIR_ALLOC(ret) < 0)
 
141
+        goto no_memory;
 
142
+
 
143
+    if (virFileReadAll(CPUINFO, 2048, &outbuf) < 0) {
 
144
+         virSmbiosReportError(VIR_ERR_INTERNAL_ERROR,
 
145
+                            _("Failed to open %s"), CPUINFO);
 
146
+        return NULL;
 
147
+    }
 
148
+
 
149
+    ret->nprocessor = 0;
 
150
+    ret->processor = NULL;
 
151
+    if (virSysinfoParseProcessor(outbuf, ret) < 0)
 
152
+       goto no_memory;
 
153
+
 
154
+    if (virSysinfoParseSystem(outbuf, ret) < 0)
 
155
+        goto no_memory;
 
156
+
 
157
+    return ret;
 
158
+
 
159
+no_memory:
 
160
+    VIR_FREE(outbuf);
 
161
+    return NULL;
 
162
+}
 
163
+
 
164
+
 
165
 #elif defined(__s390__) || defined(__s390x__)
 
166
 
 
167
 static int