[Libvir] PATCH: Separate QEMU impl of nodeinfo API

Richard W.M. Jones rjones at redhat.com
Wed Jul 25 09:22:53 UTC 2007


+        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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3237 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20070725/e4fb5dc8/attachment-0001.bin>


More information about the libvir-list mailing list