[libvirt] getSchedulerParameters() always returning nullpointerexception in JAVA

Daniel Veillard veillard at redhat.com
Fri Dec 11 13:29:48 UTC 2009


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 at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list


-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel at veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/




More information about the libvir-list mailing list