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