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

[libvirt] [PATCH] BZ481602: Attempted to reproduce the bug led to issues around type mapping. They are resolved, and the code from the bug runs aginst hte test driver. Once published I will have the submitter reproduce it.



---
 src/main/java/org/libvirt/Domain.java             |    4 +---
 src/main/java/org/libvirt/SchedLongParameter.java |    2 +-
 src/main/java/org/libvirt/SchedParameter.java     |    2 ++
 src/main/java/org/libvirt/SchedUintParameter.java |    2 +-
 src/main/java/org/libvirt/jna/Libvirt.java        |    2 +-
 src/test/java/test.java                           |    8 ++++++++
 6 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/libvirt/Domain.java b/src/main/java/org/libvirt/Domain.java
index a9a6b25..a7b49ee 100644
--- a/src/main/java/org/libvirt/Domain.java
+++ b/src/main/java/org/libvirt/Domain.java
@@ -607,13 +607,11 @@ public class Domain {
      * @throws LibvirtException
      */
     public void setSchedulerParameters(SchedParameter[] params) throws LibvirtException {
-        IntByReference nParams = new IntByReference();
-        nParams.setValue(params.length);
         virSchedParameter[] input = new virSchedParameter[params.length];
         for (int x = 0; x < params.length; x++) {
             input[x] = SchedParameter.toNative(params[x]);
         }
-        libvirt.virDomainSetSchedulerParameters(VDP, input, nParams);
+        libvirt.virDomainSetSchedulerParameters(VDP, input, params.length);
         processError();
     }
 
diff --git a/src/main/java/org/libvirt/SchedLongParameter.java b/src/main/java/org/libvirt/SchedLongParameter.java
index 50628b0..7999777 100644
--- a/src/main/java/org/libvirt/SchedLongParameter.java
+++ b/src/main/java/org/libvirt/SchedLongParameter.java
@@ -21,7 +21,7 @@ public final class SchedLongParameter extends SchedParameter {
     }
 
     public int getType() {
-        return 2;
+        return 3;
     }
 
     public String getTypeAsString() {
diff --git a/src/main/java/org/libvirt/SchedParameter.java b/src/main/java/org/libvirt/SchedParameter.java
index 92b3547..370b0da 100644
--- a/src/main/java/org/libvirt/SchedParameter.java
+++ b/src/main/java/org/libvirt/SchedParameter.java
@@ -4,6 +4,7 @@ import java.util.Arrays;
 
 import org.libvirt.jna.Libvirt;
 import org.libvirt.jna.virSchedParameter;
+import org.libvirt.jna.virSchedParameterValue;
 
 import com.sun.jna.Native;
 
@@ -43,6 +44,7 @@ public abstract class SchedParameter {
 
     public static virSchedParameter toNative(SchedParameter param) {
         virSchedParameter returnValue = new virSchedParameter();
+        returnValue.value = new virSchedParameterValue() ;
         returnValue.field = Arrays.copyOf(param.field.getBytes(), Libvirt.VIR_DOMAIN_SCHED_FIELD_LENGTH);
         returnValue.type = param.getType();
         switch (param.getType()) {
diff --git a/src/main/java/org/libvirt/SchedUintParameter.java b/src/main/java/org/libvirt/SchedUintParameter.java
index 1b96758..9305579 100644
--- a/src/main/java/org/libvirt/SchedUintParameter.java
+++ b/src/main/java/org/libvirt/SchedUintParameter.java
@@ -22,7 +22,7 @@ public final class SchedUintParameter extends SchedParameter {
     }
 
     public int getType() {
-        return 3;
+        return 2;
     }
 
     public String getTypeAsString() {
diff --git a/src/main/java/org/libvirt/jna/Libvirt.java b/src/main/java/org/libvirt/jna/Libvirt.java
index 62f7ba3..0b30656 100644
--- a/src/main/java/org/libvirt/jna/Libvirt.java
+++ b/src/main/java/org/libvirt/jna/Libvirt.java
@@ -107,7 +107,7 @@ public interface Libvirt extends Library {
     public int virDomainSetAutostart(DomainPointer virDomainPtr, int autoStart);
     public int virDomainSetMaxMemory(DomainPointer virDomainPtr, NativeLong maxMemory);
     public int virDomainSetMemory(DomainPointer virDomainPtr, NativeLong maxMemory);
-    public int virDomainSetSchedulerParameters(DomainPointer virDomainPtr, virSchedParameter[] params, IntByReference nparams);
+    public int virDomainSetSchedulerParameters(DomainPointer virDomainPtr, virSchedParameter[] params, int nparams);
     public int virDomainSetVcpus(DomainPointer virDomainPtr, int nvcpus);
     public int virDomainShutdown(DomainPointer virDomainPtr);
     public int virDomainSuspend(DomainPointer virDomainPtr);
diff --git a/src/test/java/test.java b/src/test/java/test.java
index 9427cc5..be12d5e 100644
--- a/src/test/java/test.java
+++ b/src/test/java/test.java
@@ -245,6 +245,14 @@ public class test {
 			for(SchedParameter c: testDomain.getSchedulerParameters()){
 				System.out.println(c.getTypeAsString() +":"+ c.field +":"+  c.getValueAsString());
 			}
+
+			// test setting a scheduled parameter
+			SchedUintParameter[] pars = new SchedUintParameter[1];
+            pars[0] = new SchedUintParameter();
+            pars[0].field = "weight";
+            pars[0].value = 100;
+            testDomain.setSchedulerParameters(pars);
+
 			System.out.println("virDomainGetUUID:" + testDomain.getUUID());                   
 			for(int c: testDomain.getUUID())
 				System.out.print(String.format("%02x", c));
-- 
1.6.0.6


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