

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
4 messages in net.java.dev.jna.users[jna-users] [vmware-vix] vix java bin...| From | Sent On | Attachments |
|---|---|---|
| Jean...@sophia.inria.fr | Aug 20, 2008 7:22 am | |
| Timothy Wall | Aug 20, 2008 8:54 am | |
| Jean...@sophia.inria.fr | Aug 21, 2008 8:01 am | |
| Timothy Wall | Aug 21, 2008 8:20 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | [jna-users] [vmware-vix] vix java binding issue | Actions... |
|---|---|---|
| From: | Jean...@sophia.inria.fr (Jean...@sophia.inria.fr) | |
| Date: | Aug 20, 2008 7:22:06 am | |
| List: | net.java.dev.jna.users | |
Hello,
I'm currently trying to write a java binding for the vmware-vix API and I'm striking against a weird issue. I'm not using the entire API yet but when I try to powerOn a virtual, I obtain different results. Among those one: - err: 0 - The operation was successful - err: 16 - The system returned an error. Communication with the virtual machine may have been interrupted - err: 3006 - The virtual machine needs to be powered on The last one is my favorite :D... I saw that a Hudson plugin was written but I didn't find the sources, anyway I don't think that writing the Library binding using jna is a hard thing to do... below is an example of my implementation: [CODE] public static class VixHandle extends IntegerType { public static class ByReference extends IntByReference { public ByReference(){ super(); } } public VixHandle.ByReference ByReference = null; public VixHandle(long v){ super(4);//in vix.h -> typedef int VixHandle; ByReference = new ByReference(); } public VixHandle(){ super(4,0); ByReference = new ByReference(); } } [/CODE] And the main method: [CODE] VixHandle hostHandle = new VixHandle(); VixHandle vmHandle = new VixHandle(); IntByReference tmpVM = new IntByReference(vmHandle.intValue()); IntByReference tmpHost = new IntByReference(hostHandle.intValue()); VixHandle jobHandle = VixLibrary.SYNCH_INSTANCE.VixHost_Connect( VixLibrary.VIX_API_VERSION, VixLibrary.VIX_SERVICEPROVIDER_VMWARE_SERVER, null, 904, null, null,null,VixLibrary.VIX_INVALID_HANDLE,null,null);
VixError err = VixLibrary.SYNCH_INSTANCE.VixJob_Wait(jobHandle, VixLibrary.VIX_PROPERTY_JOB_RESULT_HANDLE, tmpHost, VixLibrary.VIX_PROPERTY_NONE); hostHandle.setValue(tmpHost.getValue()); VixLibrary.SYNCH_INSTANCE.Vix_ReleaseHandle(jobHandle);
jobHandle = VixLibrary.SYNCH_INSTANCE.VixVM_Open(hostHandle, "/home/inria/.vmware/Machines/Machine1/Machine1.vmx",null,null); err = VixLibrary.SYNCH_INSTANCE.VixJob_Wait(jobHandle, VixLibrary.VIX_PROPERTY_JOB_RESULT_HANDLE, tmpVM, VixLibrary.VIX_PROPERTY_NONE); vmHandle.setValue(tmpVM.getValue()); VixLibrary.SYNCH_INSTANCE.Vix_ReleaseHandle(jobHandle);
for(int i = 0; i != 100;i++){
jobHandle = VixLibrary.SYNCH_INSTANCE.VixVM_PowerOn(vmHandle,VixLibrary.VIX_VMPOWEROP_NORMAL,VixLibrary.VIX_INVALID_HANDLE,null,null); err = VixLibrary.SYNCH_INSTANCE.VixJob_Wait(jobHandle, VixLibrary.VIX_PROPERTY_NONE); System.out.println("err: "+err+" - "+VixLibrary.SYNCH_INSTANCE.Vix_GetErrorText(err,null)); System.out.println("myJob powerOn :"+jobHandle); VixLibrary.SYNCH_INSTANCE.Vix_ReleaseHandle(jobHandle); if(VixError.VIX_SUCCEEDED(err)) break;
}
//seulement si on a allumé la vm if(VixError.VIX_SUCCEEDED(err)){ for(int i = 15; i != 0; i--){ System.out.println("j'attends"); try { Thread.currentThread().sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } jobHandle = VixLibrary.SYNCH_INSTANCE.VixVM_PowerOff(vmHandle,VixLibrary.VIX_VMPOWEROP_NORMAL,null,null); err = VixLibrary.SYNCH_INSTANCE.VixJob_Wait(jobHandle, VixLibrary.VIX_PROPERTY_NONE); System.out.println("err: "+err+" - "+VixLibrary.SYNCH_INSTANCE.Vix_GetErrorText(err,null)); System.out.println("myJob powerOff :"+jobHandle); VixLibrary.SYNCH_INSTANCE.Vix_ReleaseHandle(jobHandle); }
VixLibrary.SYNCH_INSTANCE.Vix_ReleaseHandle(vmHandle);
VixLibrary.SYNCH_INSTANCE.VixHost_Disconnect(hostHandle); System.out.println("disconnected"); [/CODE]
I'm gonna post it on the user@vix to see what do they think about that...
ThX
Guillaume Jean-Michel







