Hi Bryan,<br><br>I've applied and tested the PATCH and still does not work.<br><br>Here is the console output:<br><br> -> [chipiron04, Domain-0, XenTest, XenTest2, chipiron03]<br>Dec 15, 2009 9:49:14 AM net.emotivecloud.virtmonitor.VirtMonitor getCPUPriority<br>
SEVERE: Error: getting CPU priority of "XenTest".class java.lang.NullPointerException<br>java.lang.NullPointerException<br> at org.libvirt.SchedParameter.create(Unknown Source)<br> at org.libvirt.Domain.getSchedulerParameters(Unknown Source)<br>
at net.emotivecloud.virtmonitor.VirtMonitor.getCPUPriority(VirtMonitor.java:495)<br> at net.emotivecloud.virtmonitor.VirtMonitor.main(VirtMonitor.java:775)<br> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br>
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)<br> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)<br> at java.lang.reflect.Method.invoke(Method.java:616)<br>
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:283)<br> at java.lang.Thread.run(Thread.java:636)<br>-1<br>Dec 15, 2009 9:49:14 AM net.emotivecloud.virtmonitor.VirtMonitor getCPUCapacity<br>SEVERE: Error: getting CPU capacity of "XenTest".<br>
java.lang.NullPointerException<br> at org.libvirt.SchedParameter.create(Unknown Source)<br> at org.libvirt.Domain.getSchedulerParameters(Unknown Source)<br> at net.emotivecloud.virtmonitor.VirtMonitor.getCPUCapacity(VirtMonitor.java:470)<br>
at net.emotivecloud.virtmonitor.VirtMonitor.main(VirtMonitor.java:776)<br> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)<br>
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)<br> at java.lang.reflect.Method.invoke(Method.java:616)<br> at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:283)<br>
at java.lang.Thread.run(Thread.java:636)<br>-1<br><br><br>Both GetCPUCapacity and GetCPUPriority use the schedparameter type. Here is the code and the main. <br><br>getDomain method just returns the domain object itself and I've also tested it's not null value at this point of the code:<br>
<br> public int getCPUCapacity(String name) {<br> int ret = -1;<br><br> try {<br> Domain d = getDomain(name);<br> SchedParameter[] pars= d.getSchedulerParameters();<br> <br>
for (SchedParameter pri : pars) {<br> if (pri.field=="cap")<br> ret=Integer.parseInt(pri.getValueAsString());<br> }<br><br> } catch (Exception e) {<br>
log.error(" Error: getting CPU capacity of \""+name+"\".");<br> e.printStackTrace();<br> }<br><br> return ret;<br> }<br><br> /**<br> * Returns CPU Priority assigned to VM name<br>
* @param name<br> * @return<br> */<br> public int getCPUPriority(String name) {<br> int res=-1;<br> <br> try {<br> Domain d = getDomain(name);<br> SchedParameter[] pars = d.getSchedulerParameters();<br>
<br> for (SchedParameter pri : pars) {<br> if (pri.field=="weight")<br> res=Integer.parseInt(pri.getValueAsString());<br> }<br> <br> } catch (Exception e) {<br>
log.error(" Error: getting CPU priority of \""+name+"\"." + e.getClass());<br> e.printStackTrace();<br> }<br> <br> return res;<br> }<br> <br>
<br><br>public static void main(String args[]) {<br> VirtMonitor virt = new VirtMonitor();<br> <br> System.out.println(" -> " + virt.getDomains());<br><br> <br> System.out.println(virt.getCPUPriority("XenTest"));<br>
System.out.println(virt.getCPUCapacity("XenTest"));<br>}<br><br><br><br><br>Thanks in advance,<br><br><br><br>Marc Gonzalez Mateo<br><a href="mailto:marcg@ac.upc.edu">marcg@ac.upc.edu</a><br>Universitat Politècnica de Catalunya<br>
<br><br><br><br><br>El 14/12/2009, a las 16:41, Bryan Kearney escribió:<br><br>Can you send me more info on the use case.. and I will try and recreate it? In the mean time.. tell me if the patched jar file at:<br><br><a href="http://bkearney.fedorapeople.org/libvirt-0.4.0-PATCH.jar">http://bkearney.fedorapeople.org/libvirt-0.4.0-PATCH.jar</a><br>
<br>works. You will need to download this and copy it into<br><br>/usr/share/java/libvirt-0.4.0.jar<br><br>-- bk<br><br>On 12/14/2009 04:22 AM, Marc Gonzalez Mateo wrote:<br>OK, let's see if Bryan has an idea/solution about this.<br>
<br>Thanks guys!<br><br><br><br>MARC<br><br><br>El 11/12/2009, a las 14:29, Daniel Veillard escribió:<br><br>On Fri, Dec 11, 2009 at 02:01:36PM +0100, Marc Gonzalez Mateo wrote:<br>Hi everyvody,<br>I'm developing a new API based on libvirt.<br>
I'm currently stucked using getSchedulerParameters, always is returning a<br>nullpointerexception, no matter which Xen Domain I'm passing to the<br>function.<br><br>Enclosing both the code and the error console:<br>
<br><br>public int getCPUPriority(String name) {<br> int res=-1;<br><br> try {<br> Domain d = getDomain(name);<br> SchedParameter[] pars = d.getSchedulerParameters();<br><br> Hum, it seems<br>
<br> Domain.getSchedulerParameters()<br><br>does<br><br> SchedParameter[] returnValue = new SchedParameter[0];<br><br>and<br><br> public static SchedParameter create(virSchedParameter vParam) {<br> SchedParameter returnValue = null;<br>
switch (vParam.type) {<br> case (1):<br><br>and the create method getting there gets a null pointer as the<br>initialization argument, which it first dereference ...<br><br> so not surprizing looking at the code, maybe Bryan has an idea of what<br>
is going on there, I'm a bit lost in this initialization process ...<br><br>Daniel<br><br> for (SchedParameter pri : pars) {<br> if (pri.field=="weight")<br> res=Integer.parseInt(pri.getValueAsString());<br>
}<br><br> } catch (LibvirtException e) {<br> log.error(" Error: getting CPU priority of \""+name+"\"." +<br>e.getClass());<br> e.printStackTrace();<br> }<br>
<br> return res;<br> }<br><br><br><br>Dec 11, 2009 1:04:18 PM net.emotivecloud.virtmonitor.VirtMonitor<br>getCPUCapacity<br>SEVERE: Error: getting CPU capacity of "XenTest".<br>java.lang.NullPointerException<br>
at org.libvirt.SchedParameter.create(Unknown Source)<br> at org.libvirt.Domain.getSchedulerParameters(Unknown Source)<br> at<br>net.emotivecloud.virtmonitor.VirtMonitor.getCPUCapacity(VirtMonitor.java:462)<br> at net.emotivecloud.virtmonitor.VirtMonitor.main(VirtMonitor.java:763)<br>
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br> at<br>sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)<br> at<br>sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)<br>
at java.lang.reflect.Method.invoke(Method.java:616)<br> at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:283)<br> at java.lang.Thread.run(Thread.java:636)<br><br><br>Any ideas?<br><br>Thanks in advance,<br>
<br><br>Marc Gonzalez Mateo<br><br>--<br>Libvir-list mailing list<br><a href="mailto:Libvir-list@redhat.com">Libvir-list@redhat.com</a><br><a href="https://www.redhat.com/mailman/listinfo/libvir-list">https://www.redhat.com/mailman/listinfo/libvir-list</a><br>
<br><br>--<br>Daniel Veillard | libxml Gnome XML XSLT toolkit <a href="http://xmlsoft.org/">http://xmlsoft.org/</a><br><a href="mailto:daniel@veillard.com">daniel@veillard.com</a> | Rpmfind RPM search engine <a href="http://rpmfind.net/">http://rpmfind.net/</a><br>
<a href="http://veillard.com/">http://veillard.com/</a> | virtualization library <a href="http://libvirt.org/">http://libvirt.org/</a><br><br><br><br>