-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathVMFFM.java
More file actions
186 lines (141 loc) · 15.7 KB
/
Copy pathVMFFM.java
File metadata and controls
186 lines (141 loc) · 15.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
package javaforce.ffm;
import java.lang.foreign.*;
import java.lang.invoke.*;
import static java.lang.foreign.ValueLayout.*;
import javaforce.*;
import javaforce.ffm.*;
import javaforce.api.linux.*;
import javaforce.vm.*;
/** VMAPI FFM implementation.
*
* Generated by GenFFM - DO NOT EDIT
*/
public class VMFFM implements VMAPI {
private FFM ffm;
private static VMFFM instance;
public static synchronized VMFFM getInstance() {
if (instance == null) {
instance = new VMFFM();
if (!instance.ffm_init()) {
JFLog.log("VMFFM init failed!");
instance = null;
}
}
return instance;
}
private MethodHandle vmConnect;
public boolean vmConnect(java.lang.String a1) { try { Arena arena = Arena.ofAuto(); boolean _ret_value_ = (boolean)vmConnect.invokeExact((MemorySegment)(a1 == null ? MemorySegment.NULL : arena.allocateFrom(a1)));return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle vmDiskCreate;
public boolean vmDiskCreate(java.lang.String a1,java.lang.String a2) { try { Arena arena = Arena.ofAuto(); boolean _ret_value_ = (boolean)vmDiskCreate.invokeExact((MemorySegment)(a1 == null ? MemorySegment.NULL : arena.allocateFrom(a1)),(MemorySegment)(a2 == null ? MemorySegment.NULL : arena.allocateFrom(a2)));return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle vmGetAllStats;
public boolean vmGetAllStats(int a1,int a2,int a3,int a4,int a5) { try { boolean _ret_value_ = (boolean)vmGetAllStats.invokeExact(a1,a2,a3,a4,a5);return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle vmInit;
public boolean vmInit() { try { boolean _ret_value_ = (boolean)vmInit.invokeExact();return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle vmMigrate;
public boolean vmMigrate(java.lang.String a1,java.lang.String a2,boolean a3) { try { Arena arena = Arena.ofAuto(); boolean _ret_value_ = (boolean)vmMigrate.invokeExact((MemorySegment)(a1 == null ? MemorySegment.NULL : arena.allocateFrom(a1)),(MemorySegment)(a2 == null ? MemorySegment.NULL : arena.allocateFrom(a2)),a3);return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle vmPowerOff;
public boolean vmPowerOff(java.lang.String a1) { try { Arena arena = Arena.ofAuto(); boolean _ret_value_ = (boolean)vmPowerOff.invokeExact((MemorySegment)(a1 == null ? MemorySegment.NULL : arena.allocateFrom(a1)));return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle vmRegister;
public boolean vmRegister(java.lang.String a1) { try { Arena arena = Arena.ofAuto(); boolean _ret_value_ = (boolean)vmRegister.invokeExact((MemorySegment)(a1 == null ? MemorySegment.NULL : arena.allocateFrom(a1)));return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle vmRestart;
public boolean vmRestart(java.lang.String a1) { try { Arena arena = Arena.ofAuto(); boolean _ret_value_ = (boolean)vmRestart.invokeExact((MemorySegment)(a1 == null ? MemorySegment.NULL : arena.allocateFrom(a1)));return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle vmResume;
public boolean vmResume(java.lang.String a1) { try { Arena arena = Arena.ofAuto(); boolean _ret_value_ = (boolean)vmResume.invokeExact((MemorySegment)(a1 == null ? MemorySegment.NULL : arena.allocateFrom(a1)));return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle vmSecretCreate;
public boolean vmSecretCreate(java.lang.String a1,java.lang.String a2) { try { Arena arena = Arena.ofAuto(); boolean _ret_value_ = (boolean)vmSecretCreate.invokeExact((MemorySegment)(a1 == null ? MemorySegment.NULL : arena.allocateFrom(a1)),(MemorySegment)(a2 == null ? MemorySegment.NULL : arena.allocateFrom(a2)));return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle vmSnapshotCreate;
public boolean vmSnapshotCreate(java.lang.String a1,java.lang.String a2,int a3) { try { Arena arena = Arena.ofAuto(); boolean _ret_value_ = (boolean)vmSnapshotCreate.invokeExact((MemorySegment)(a1 == null ? MemorySegment.NULL : arena.allocateFrom(a1)),(MemorySegment)(a2 == null ? MemorySegment.NULL : arena.allocateFrom(a2)),a3);return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle vmSnapshotDelete;
public boolean vmSnapshotDelete(java.lang.String a1,java.lang.String a2) { try { Arena arena = Arena.ofAuto(); boolean _ret_value_ = (boolean)vmSnapshotDelete.invokeExact((MemorySegment)(a1 == null ? MemorySegment.NULL : arena.allocateFrom(a1)),(MemorySegment)(a2 == null ? MemorySegment.NULL : arena.allocateFrom(a2)));return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle vmSnapshotExists;
public boolean vmSnapshotExists(java.lang.String a1) { try { Arena arena = Arena.ofAuto(); boolean _ret_value_ = (boolean)vmSnapshotExists.invokeExact((MemorySegment)(a1 == null ? MemorySegment.NULL : arena.allocateFrom(a1)));return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle vmSnapshotRestore;
public boolean vmSnapshotRestore(java.lang.String a1,java.lang.String a2) { try { Arena arena = Arena.ofAuto(); boolean _ret_value_ = (boolean)vmSnapshotRestore.invokeExact((MemorySegment)(a1 == null ? MemorySegment.NULL : arena.allocateFrom(a1)),(MemorySegment)(a2 == null ? MemorySegment.NULL : arena.allocateFrom(a2)));return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle vmStart;
public boolean vmStart(java.lang.String a1) { try { Arena arena = Arena.ofAuto(); boolean _ret_value_ = (boolean)vmStart.invokeExact((MemorySegment)(a1 == null ? MemorySegment.NULL : arena.allocateFrom(a1)));return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle vmStop;
public boolean vmStop(java.lang.String a1) { try { Arena arena = Arena.ofAuto(); boolean _ret_value_ = (boolean)vmStop.invokeExact((MemorySegment)(a1 == null ? MemorySegment.NULL : arena.allocateFrom(a1)));return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle vmStorageRegister;
public boolean vmStorageRegister(java.lang.String a1) { try { Arena arena = Arena.ofAuto(); boolean _ret_value_ = (boolean)vmStorageRegister.invokeExact((MemorySegment)(a1 == null ? MemorySegment.NULL : arena.allocateFrom(a1)));return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle vmStorageStart;
public boolean vmStorageStart(java.lang.String a1) { try { Arena arena = Arena.ofAuto(); boolean _ret_value_ = (boolean)vmStorageStart.invokeExact((MemorySegment)(a1 == null ? MemorySegment.NULL : arena.allocateFrom(a1)));return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle vmStorageStop;
public boolean vmStorageStop(java.lang.String a1) { try { Arena arena = Arena.ofAuto(); boolean _ret_value_ = (boolean)vmStorageStop.invokeExact((MemorySegment)(a1 == null ? MemorySegment.NULL : arena.allocateFrom(a1)));return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle vmStorageUnregister;
public boolean vmStorageUnregister(java.lang.String a1) { try { Arena arena = Arena.ofAuto(); boolean _ret_value_ = (boolean)vmStorageUnregister.invokeExact((MemorySegment)(a1 == null ? MemorySegment.NULL : arena.allocateFrom(a1)));return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle vmSuspend;
public boolean vmSuspend(java.lang.String a1) { try { Arena arena = Arena.ofAuto(); boolean _ret_value_ = (boolean)vmSuspend.invokeExact((MemorySegment)(a1 == null ? MemorySegment.NULL : arena.allocateFrom(a1)));return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle vmUnregister;
public boolean vmUnregister(java.lang.String a1) { try { Arena arena = Arena.ofAuto(); boolean _ret_value_ = (boolean)vmUnregister.invokeExact((MemorySegment)(a1 == null ? MemorySegment.NULL : arena.allocateFrom(a1)));return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle vmGetState;
public int vmGetState(java.lang.String a1) { try { Arena arena = Arena.ofAuto(); int _ret_value_ = (int)vmGetState.invokeExact((MemorySegment)(a1 == null ? MemorySegment.NULL : arena.allocateFrom(a1)));return _ret_value_; } catch (Throwable t) { JFLog.log(t); return -1;} }
private MethodHandle vmStorageGetState;
public int vmStorageGetState(java.lang.String a1) { try { Arena arena = Arena.ofAuto(); int _ret_value_ = (int)vmStorageGetState.invokeExact((MemorySegment)(a1 == null ? MemorySegment.NULL : arena.allocateFrom(a1)));return _ret_value_; } catch (Throwable t) { JFLog.log(t); return -1;} }
private MethodHandle vmGet;
public java.lang.String vmGet(java.lang.String a1) { try { Arena arena = Arena.ofAuto(); String _ret_value_ = FFM.getString((MemorySegment)vmGet.invokeExact((MemorySegment)(a1 == null ? MemorySegment.NULL : arena.allocateFrom(a1))));return _ret_value_; } catch (Throwable t) { JFLog.log(t); return null;} }
private MethodHandle vmSnapshotGetCurrent;
public java.lang.String vmSnapshotGetCurrent(java.lang.String a1) { try { Arena arena = Arena.ofAuto(); String _ret_value_ = FFM.getString((MemorySegment)vmSnapshotGetCurrent.invokeExact((MemorySegment)(a1 == null ? MemorySegment.NULL : arena.allocateFrom(a1))));return _ret_value_; } catch (Throwable t) { JFLog.log(t); return null;} }
private MethodHandle vmStorageGetUUID;
public java.lang.String vmStorageGetUUID(java.lang.String a1) { try { Arena arena = Arena.ofAuto(); String _ret_value_ = FFM.getString((MemorySegment)vmStorageGetUUID.invokeExact((MemorySegment)(a1 == null ? MemorySegment.NULL : arena.allocateFrom(a1))));return _ret_value_; } catch (Throwable t) { JFLog.log(t); return null;} }
private MethodHandle vmDeviceList;
public java.lang.String[] vmDeviceList(int a1) { try { FFM.createFFMArray();vmDeviceList.invokeExact(a1);return (java.lang.String[])FFM.getArray(); } catch (Throwable t) { JFLog.log(t); return null;} }
private MethodHandle vmList;
public java.lang.String[] vmList() { try { FFM.createFFMArray();vmList.invokeExact();return (java.lang.String[])FFM.getArray(); } catch (Throwable t) { JFLog.log(t); return null;} }
private MethodHandle vmNetworkListPhys;
public java.lang.String[] vmNetworkListPhys() { try { FFM.createFFMArray();vmNetworkListPhys.invokeExact();return (java.lang.String[])FFM.getArray(); } catch (Throwable t) { JFLog.log(t); return null;} }
private MethodHandle vmSnapshotList;
public java.lang.String[] vmSnapshotList(java.lang.String a1) { try { Arena arena = Arena.ofAuto(); FFM.createFFMArray();vmSnapshotList.invokeExact((MemorySegment)(a1 == null ? MemorySegment.NULL : arena.allocateFrom(a1)));return (java.lang.String[])FFM.getArray(); } catch (Throwable t) { JFLog.log(t); return null;} }
private MethodHandle vmStorageList;
public java.lang.String[] vmStorageList() { try { FFM.createFFMArray();vmStorageList.invokeExact();return (java.lang.String[])FFM.getArray(); } catch (Throwable t) { JFLog.log(t); return null;} }
private MethodHandle vmCpuLoad;
public long vmCpuLoad() { try { long _ret_value_ = (long)vmCpuLoad.invokeExact();return _ret_value_; } catch (Throwable t) { JFLog.log(t); return -1;} }
private MethodHandle vmFreeMemory;
public long vmFreeMemory() { try { long _ret_value_ = (long)vmFreeMemory.invokeExact();return _ret_value_; } catch (Throwable t) { JFLog.log(t); return -1;} }
private MethodHandle vmTotalMemory;
public long vmTotalMemory() { try { long _ret_value_ = (long)vmTotalMemory.invokeExact();return _ret_value_; } catch (Throwable t) { JFLog.log(t); return -1;} }
private boolean ffm_init() {
if (FFM.debug) JFLog.log("VMFFM init started");
MethodHandle init;
ffm = FFM.getInstance();
init = ffm.getFunction("VMAPIinit", ffm.getFunctionDesciptor(ValueLayout.JAVA_BOOLEAN));
if (init == null) return false;
try {if (!(boolean)init.invokeExact()) return false;} catch (Throwable t) {JFLog.log(t); return false;}
vmConnect = ffm.getFunctionPtr("_vmConnect", ffm.getFunctionDesciptor(JAVA_BOOLEAN,ADDRESS));
vmDiskCreate = ffm.getFunctionPtr("_vmDiskCreate", ffm.getFunctionDesciptor(JAVA_BOOLEAN,ADDRESS,ADDRESS));
vmGetAllStats = ffm.getFunctionPtr("_vmGetAllStats", ffm.getFunctionDesciptor(JAVA_BOOLEAN,JAVA_INT,JAVA_INT,JAVA_INT,JAVA_INT,JAVA_INT));
vmInit = ffm.getFunctionPtr("_vmInit", ffm.getFunctionDesciptor(JAVA_BOOLEAN));
vmMigrate = ffm.getFunctionPtr("_vmMigrate", ffm.getFunctionDesciptor(JAVA_BOOLEAN,ADDRESS,ADDRESS,JAVA_BOOLEAN));
vmPowerOff = ffm.getFunctionPtr("_vmPowerOff", ffm.getFunctionDesciptor(JAVA_BOOLEAN,ADDRESS));
vmRegister = ffm.getFunctionPtr("_vmRegister", ffm.getFunctionDesciptor(JAVA_BOOLEAN,ADDRESS));
vmRestart = ffm.getFunctionPtr("_vmRestart", ffm.getFunctionDesciptor(JAVA_BOOLEAN,ADDRESS));
vmResume = ffm.getFunctionPtr("_vmResume", ffm.getFunctionDesciptor(JAVA_BOOLEAN,ADDRESS));
vmSecretCreate = ffm.getFunctionPtr("_vmSecretCreate", ffm.getFunctionDesciptor(JAVA_BOOLEAN,ADDRESS,ADDRESS));
vmSnapshotCreate = ffm.getFunctionPtr("_vmSnapshotCreate", ffm.getFunctionDesciptor(JAVA_BOOLEAN,ADDRESS,ADDRESS,JAVA_INT));
vmSnapshotDelete = ffm.getFunctionPtr("_vmSnapshotDelete", ffm.getFunctionDesciptor(JAVA_BOOLEAN,ADDRESS,ADDRESS));
vmSnapshotExists = ffm.getFunctionPtr("_vmSnapshotExists", ffm.getFunctionDesciptor(JAVA_BOOLEAN,ADDRESS));
vmSnapshotRestore = ffm.getFunctionPtr("_vmSnapshotRestore", ffm.getFunctionDesciptor(JAVA_BOOLEAN,ADDRESS,ADDRESS));
vmStart = ffm.getFunctionPtr("_vmStart", ffm.getFunctionDesciptor(JAVA_BOOLEAN,ADDRESS));
vmStop = ffm.getFunctionPtr("_vmStop", ffm.getFunctionDesciptor(JAVA_BOOLEAN,ADDRESS));
vmStorageRegister = ffm.getFunctionPtr("_vmStorageRegister", ffm.getFunctionDesciptor(JAVA_BOOLEAN,ADDRESS));
vmStorageStart = ffm.getFunctionPtr("_vmStorageStart", ffm.getFunctionDesciptor(JAVA_BOOLEAN,ADDRESS));
vmStorageStop = ffm.getFunctionPtr("_vmStorageStop", ffm.getFunctionDesciptor(JAVA_BOOLEAN,ADDRESS));
vmStorageUnregister = ffm.getFunctionPtr("_vmStorageUnregister", ffm.getFunctionDesciptor(JAVA_BOOLEAN,ADDRESS));
vmSuspend = ffm.getFunctionPtr("_vmSuspend", ffm.getFunctionDesciptor(JAVA_BOOLEAN,ADDRESS));
vmUnregister = ffm.getFunctionPtr("_vmUnregister", ffm.getFunctionDesciptor(JAVA_BOOLEAN,ADDRESS));
vmGetState = ffm.getFunctionPtr("_vmGetState", ffm.getFunctionDesciptor(JAVA_INT,ADDRESS));
vmStorageGetState = ffm.getFunctionPtr("_vmStorageGetState", ffm.getFunctionDesciptor(JAVA_INT,ADDRESS));
vmGet = ffm.getFunctionPtr("_vmGet", ffm.getFunctionDesciptor(ADDRESS,ADDRESS));
vmSnapshotGetCurrent = ffm.getFunctionPtr("_vmSnapshotGetCurrent", ffm.getFunctionDesciptor(ADDRESS,ADDRESS));
vmStorageGetUUID = ffm.getFunctionPtr("_vmStorageGetUUID", ffm.getFunctionDesciptor(ADDRESS,ADDRESS));
vmDeviceList = ffm.getFunctionPtr("_vmDeviceList", ffm.getFunctionDesciptorVoid(JAVA_INT));
vmList = ffm.getFunctionPtr("_vmList", ffm.getFunctionDesciptorVoid());
vmNetworkListPhys = ffm.getFunctionPtr("_vmNetworkListPhys", ffm.getFunctionDesciptorVoid());
vmSnapshotList = ffm.getFunctionPtr("_vmSnapshotList", ffm.getFunctionDesciptorVoid(ADDRESS));
vmStorageList = ffm.getFunctionPtr("_vmStorageList", ffm.getFunctionDesciptorVoid());
vmCpuLoad = ffm.getFunctionPtr("_vmCpuLoad", ffm.getFunctionDesciptor(JAVA_LONG));
vmFreeMemory = ffm.getFunctionPtr("_vmFreeMemory", ffm.getFunctionDesciptor(JAVA_LONG));
vmTotalMemory = ffm.getFunctionPtr("_vmTotalMemory", ffm.getFunctionDesciptor(JAVA_LONG));
if (FFM.debug) JFLog.log("VMFFM init complete");
return true;
}
}