]> git.proxmox.com Git - mirror_lxcfs.git/commitdiff
s390: print the virtualized #cpus in cpuinfo_read
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Sat, 2 Apr 2016 03:52:07 +0000 (22:52 -0500)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Sat, 2 Apr 2016 04:00:33 +0000 (23:00 -0500)
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
bindings.c

index f4aaf64f3735a9b8e46e4e671b4404e222a71343..22b64903f1020991aa83ab7cd7155fbd936e4a29 100644 (file)
@@ -3157,8 +3157,11 @@ static int proc_cpuinfo_read(char *buf, size_t size, off_t offset,
                        if (strstr(line, "IBM/S390") != NULL) {
                                is_s390x = true;
                                am_printing = true;
+                               continue;
                        }
                }
+               if (strncmp(line, "# processors:", 12) == 0)
+                       continue;
                if (is_processor_line(line)) {
                        am_printing = cpuline_in_cpuset(line, cpuset);
                        if (am_printing) {
@@ -3188,8 +3191,7 @@ static int proc_cpuinfo_read(char *buf, size_t size, off_t offset,
                        if (!p || !*p)
                                goto err;
                        p++;
-                       l = snprintf(cache, cache_size, "processor %d:%s", curcpu,
-                                   );
+                       l = snprintf(cache, cache_size, "processor %d:%s", curcpu, p);
                        if (l < 0) {
                                perror("Error writing to cache");
                                rv = 0;
@@ -3224,6 +3226,38 @@ static int proc_cpuinfo_read(char *buf, size_t size, off_t offset,
                }
        }
 
+       if (is_s390x) {
+               char *origcache = d->buf;
+               size_t l;
+               do {
+                       d->buf = malloc(d->buflen);
+               } while (!d->buf);
+               cache = d->buf;
+               cache_size = d->buflen;
+               total_len = 0;
+               l = snprintf(cache, cache_size, "vendor_id       : IBM/S390\n");
+               if (l < 0 || l >= cache_size) {
+                       free(origcache);
+                       goto err;
+               }
+               cache_size -= l;
+               cache += l;
+               total_len += l;
+               l = snprintf(cache, cache_size, "# processors    : %d\n", curcpu + 1);
+               if (l < 0 || l >= cache_size) {
+                       free(origcache);
+                       goto err;
+               }
+               cache_size -= l;
+               cache += l;
+               total_len += l;
+               l = snprintf(cache, cache_size, "%s", origcache);
+               free(origcache);
+               if (l < 0 || l >= cache_size)
+                       goto err;
+               total_len += l;
+       }
+
        d->cached = 1;
        d->size = total_len;
        if (total_len > size ) total_len = size;