Re: PATCH: Separate QEMU impl of nodeinfo API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



+        if (!strncmp(line, "processor", 9)) {
//...
+        } else if (!strncmp(line, "cpu MHz", 7)) {

Gaah.  I know we don't have macros for these, but "== 0".

There might be a pathological cpuinfo file which has another entry beginning with ^processor. If only we were using a real language which allowed simple use of regexps. Such is the state of software "engineering" ..

The error handling in this next section of the patch is wrong. It should call __virRaiseError when the files cannot be opened or if the functions fail for some reason. In the Solaris case it should also call __virRaiseError (that print to stderr could be lost), but perhaps it's better to #error out?

+#ifdef __linux__
+    cpuinfo = fopen(CPUINFO_PATH, "r");
+    if (!cpuinfo)
+        return -1;
+    ret = linuxNodeInfoCPUPopulate(cpuinfo, nodeinfo);
+    fclose(cpuinfo);
+    if (ret < 0)
+        return -1;
+
+    meminfo = fopen(MEMINFO_PATH, "r");
+    if (!meminfo)
+        return -1;
+    ret = linuxNodeInfoMemPopulate(meminfo, nodeinfo);
+    fclose(meminfo);
+
+    return ret;
+#else
+    /* XXX Solaris will need an impl later if they port QEMU driver */
+ fprintf(stderr, "%s:%s not implemented on this platform\n", __FILE__, __FUNCTION__);
+    return -1;
+#endif

Rich.

--
Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod
Street, Windsor, Berkshire, SL4 1TE, United Kingdom.  Registered in
England and Wales under Company Registration No. 03798903

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]