[PATCH] [libvirt-java] Fix JNA passing of scheduler parameters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



trying to use setSchedulerParameters for the cpu_share was always
ending up setting the value to 2. in practice the JNA code was not
passing the parameter value, letting it uninitialized to zero and
the kernel accepts 2 as the closest value leading to that behaviour.
The code was actually telling JNA which type to use from the enum
but the JNA refused to take it into account possibly because multiple
C types maps to the same Java types and in that case it refuses to
accept setType(class) and simply act as if the information had not
been given (no warning/no error at runtime) !
The workaround is to actually tell it the field name in the enum,
that is accepted and the function works properly once done.

diff --git a/src/main/java/org/libvirt/SchedParameter.java b/src/main/java/org/libvirt/SchedParameter.java
index ab988e9..1dece56 100644
--- a/src/main/java/org/libvirt/SchedParameter.java
+++ b/src/main/java/org/libvirt/SchedParameter.java
@@ -52,33 +52,33 @@ public abstract class SchedParameter {
         switch (param.getType()) {
             case (1):
                 returnValue.value.i = ((SchedIntParameter) param).value;
-                returnValue.value.setType(int.class);
+                returnValue.value.setType("i");
                 break;
             case (2):
                 returnValue.value.ui = ((SchedUintParameter) param).value;
-                returnValue.value.setType(int.class);
+                returnValue.value.setType("ui");
                 break;
             case (3):
                 returnValue.value.l = ((SchedLongParameter) param).value;
-                returnValue.value.setType(long.class);
+                returnValue.value.setType("l");
                 break;
             case (4):
                 returnValue.value.ul = ((SchedUlongParameter) param).value;
-                returnValue.value.setType(long.class);
+                returnValue.value.setType("ul");
                 break;
             case (5):
                 returnValue.value.d = ((SchedDoubleParameter) param).value;
-                returnValue.value.setType(double.class);
+                returnValue.value.setType("d");
                 break;
             case (6):
                 returnValue.value.b = (byte) (((SchedBooleanParameter) param).value ? 1 : 0);
-                returnValue.value.setType(byte.class);
+                returnValue.value.setType("b");
                 break;
 
         }
         return returnValue;
     }
-    
+
     public static byte[] copyOf(byte[] original, int length) {
         byte[] returnValue = new byte[length];
         int originalLength = original.length ;

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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]