[libvirt] getSchedulerParameters() always returning nullpointerexception in JAVA

Marc Gonzalez Mateo marcg at ac.upc.edu
Fri Dec 11 13:01:36 UTC 2009


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();

            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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20091211/4147aa2d/attachment-0001.htm>


More information about the libvir-list mailing list