Commit 46aa1baec158111fe176dcda998ae225f85ee295

  • avatar
  • Bryan Kearney <bkearney @red…at.com>
  • Wed May 19 14:34:49 CEST 2010
Add in the 0.7.7 APIs
  
11version=0.4.3
22release=1
3libvirt.required=0.7.5
3libvirt.required=0.7.7
44java.required=1:1.5.0
55rpm.topdir=/home/bkearney/rpmbuild
66jar.dir=/usr/share/java
  
223223 }
224224
225225 /**
226 * Computes the most feature-rich CPU which is compatible with all given host CPUs.
227 * @param xmlCPUs array of XML descriptions of host CPUs
228 * @return XML description of the computed CPU or NULL on error.
229 * @throws LibvirtException
230 */
231 public String baselineCPU(String[] xmlCPUs) throws LibvirtException {
232 String returnValue = libvirt.virConnectBaselineCPU(VCP, xmlCPUs, xmlCPUs.length, 0);
233 processError();
234 return returnValue;
235 }
236
237 /**
226238 * Closes the connection to the hypervisor/driver. Calling any methods on
227239 * the object after close() will result in an exception.
228240 *
  
55import org.libvirt.jna.virDomainBlockStats;
66import org.libvirt.jna.virDomainInfo;
77import org.libvirt.jna.virDomainInterfaceStats;
8import org.libvirt.jna.virDomainJobInfo;
89import org.libvirt.jna.virDomainMemoryStats;
910import org.libvirt.jna.virSchedParameter;
1011import org.libvirt.jna.virVcpuInfo;
7272 }
7373
7474 /**
75 * Requests that the current background job be aborted at
76 * the soonest opportunity. This will block until the job has either
77 * completed, or aborted.
78 * @see <a href="http://www.libvirt.org/html/libvirt-libvirt.html#virDomainAbortJob">Libvirt Documentation</a>
79 * @return 0 in case of success and -1 in case of failure.
80 * @throws LibvirtException
81 */
82 public int abortJob() throws LibvirtException {
83 int returnValue = libvirt.virDomainAbortJob(VDP);
84 processError();
85 return returnValue;
86 }
87
88 /**
7589 * Creates a virtual device attachment to backend.
76 *
90 * @see <a href="http://www.libvirt.org/html/libvirt-libvirt.html#virDomainAttachDevice">Libvirt Documentation</a>
7791 * @param xmlDesc
7892 * XML description of one device
7993 * @throws LibvirtException
9696 libvirt.virDomainAttachDevice(VDP, xmlDesc);
9797 processError();
9898 }
99
100 /**
101 * Creates a virtual device attachment to backend.
102 * @see <a href="http://www.libvirt.org/html/libvirt-libvirt.html#virDomainAttachDeviceFlags">Libvirt Documentation</a>
103 * @param xmlDesc
104 * XML description of one device
105 * @param flags the an OR'ed set of virDomainDeviceModifyFlags
106 * @throws LibvirtException
107 */
108 public void attachDeviceFlags(String xmlDesc, int flags) throws LibvirtException {
109 libvirt.virDomainAttachDeviceFlags(VDP, xmlDesc, flags);
110 processError();
111 }
99112
100113 /**
101114 * Returns block device (disk) stats for block devices attached to this
181181
182182 /**
183183 * Destroys a virtual device attachment to backend.
184 *
184 * @see <a href="http://www.libvirt.org/html/libvirt-libvirt.html#virDomainDetachDevice">Libvirt Documentation</a>
185185 * @param xmlDesc
186186 * XML description of one device
187187 * @throws LibvirtException
190190 libvirt.virDomainDetachDevice(VDP, xmlDesc);
191191 processError();
192192 }
193
194 /**
195 * Destroys a virtual device attachment to backend.
196 * @see <a href="http://www.libvirt.org/html/libvirt-libvirt.html#virDomainDetachDeviceFlags">Libvirt Documentation</a>
197 * @param xmlDesc
198 * XML description of one device
199 * @throws LibvirtException
200 */
201 public void detachDeviceFlags(String xmlDesc, int flags) throws LibvirtException {
202 libvirt.virDomainDetachDeviceFlags(VDP, xmlDesc, flags);
203 processError();
204 }
205
193206
194207 @Override
195208 public void finalize() throws LibvirtException {
266266 * Extract information about a domain. Note that if the connection used to
267267 * get the domain is limited only a partial set of the information can be
268268 * extracted.
269 * @see <a href="http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetInfo">Libvirt Documentation</a>
269270 *
270271 * @return a DomainInfo object describing this domain
271272 * @throws LibvirtException
281281 }
282282 return returnValue;
283283 }
284
285 /**
286 * Extract information about progress of a background job on a domain.
287 * Will return an error if the domain is not active.
288 * @see <a href="http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetJobInfo">Libvirt Documentation</a>
289 * @return a DomainJobInfo object describing this domain
290 * @throws LibvirtException
291 */
292 public DomainJobInfo getJobInfo() throws LibvirtException {
293 DomainJobInfo returnValue = null;
294 virDomainJobInfo vInfo = new virDomainJobInfo();
295 int success = libvirt.virDomainGetJobInfo(VDP, vInfo);
296 processError();
297 if (success == 0) {
298 returnValue = new DomainJobInfo(vInfo);
299 }
300 return returnValue;
301 }
284302
285303 /**
286304 * Retrieve the maximum amount of physical memory allocated to a domain.
  
1package org.libvirt;
2
3import org.libvirt.jna.virDomainJobInfo;
4
5public class DomainJobInfo {
6 protected int type;
7 protected long timeElapsed;
8 protected long timeRemaining;
9 protected long dataTotal;
10 protected long dataProcessed;
11 protected long dataRemaining;
12 protected long memTotal;
13 protected long memProcessed;
14 protected long memRemaining;
15 protected long fileTotal;
16 protected long fileProcessed;
17 protected long fileRemaining;
18
19 public DomainJobInfo(virDomainJobInfo info) {
20 this.type = info.type;
21 this.timeElapsed = info.timeElapsed;
22 this.timeRemaining = info.timeRemaining;
23 this.dataTotal = info.dataTotal;
24 this.dataProcessed = info.dataProcessed;
25 this.dataRemaining = info.dataRemaining;
26 this.memTotal = info.memTotal;
27 this.memProcessed = info.memProcessed;
28 this.memRemaining = info.memRemaining;
29 this.fileTotal = info.fileTotal;
30 this.fileProcessed = info.fileProcessed;
31 this.fileRemaining = info.fileRemaining;
32 }
33
34 public int getType() {
35 return type;
36 }
37 public void setType(int type) {
38 this.type = type;
39 }
40 public long getTimeElapsed() {
41 return timeElapsed;
42 }
43 public void setTimeElapsed(long timeElapsed) {
44 this.timeElapsed = timeElapsed;
45 }
46 public long getTimeRemaining() {
47 return timeRemaining;
48 }
49 public void setTimeRemaining(long timeRemaining) {
50 this.timeRemaining = timeRemaining;
51 }
52 public long getDataTotal() {
53 return dataTotal;
54 }
55 public void setDataTotal(long dataTotal) {
56 this.dataTotal = dataTotal;
57 }
58 public long getDataProcessed() {
59 return dataProcessed;
60 }
61 public void setDataProcessed(long dataProcessed) {
62 this.dataProcessed = dataProcessed;
63 }
64 public long getDataRemaining() {
65 return dataRemaining;
66 }
67 public void setDataRemaining(long dataRemaining) {
68 this.dataRemaining = dataRemaining;
69 }
70 public long getMemTotal() {
71 return memTotal;
72 }
73 public void setMemTotal(long memTotal) {
74 this.memTotal = memTotal;
75 }
76 public long getMemProcessed() {
77 return memProcessed;
78 }
79 public void setMemProcessed(long memProcessed) {
80 this.memProcessed = memProcessed;
81 }
82 public long getMemRemaining() {
83 return memRemaining;
84 }
85 public void setMemRemaining(long memRemaining) {
86 this.memRemaining = memRemaining;
87 }
88 public long getFileTotal() {
89 return fileTotal;
90 }
91 public void setFileTotal(long fileTotal) {
92 this.fileTotal = fileTotal;
93 }
94 public long getFileProcessed() {
95 return fileProcessed;
96 }
97 public void setFileProcessed(long fileProcessed) {
98 this.fileProcessed = fileProcessed;
99 }
100 public long getFileRemaining() {
101 return fileRemaining;
102 }
103 public void setFileRemaining(long fileRemaining) {
104 this.fileRemaining = fileRemaining;
105 }
106}
  
9393 public static int VIR_DOMAIN_SCHED_FIELD_LENGTH = 80;
9494
9595 // Connection Functions
96 public String virConnectBaselineCPU(ConnectionPointer virConnectPtr, String[] xmlCPUs, int ncpus, int flags);
9697 public int virConnCopyLastError(ConnectionPointer virConnectPtr, virError to);
9798 public int virConnectClose(ConnectionPointer virConnectPtr);
9899 public int virConnectCompareCPU(ConnectionPointer virConnectPtr, String xmlDesc, int flags);
145145 public void virSetErrorFunc(Pointer userData, VirErrorCallback callback);
146146
147147 // Domain functions
148 public ConnectionPointer virDomainGetConnect(DomainPointer virDomainPtr);
148 public int virDomainAbortJob(DomainPointer virDomainPtr);
149149 public int virDomainAttachDevice(DomainPointer virDomainPtr, String deviceXML);
150 public int virDomainAttachDeviceFlags(DomainPointer virDomainPtr, String deviceXML, int flags);
150151 public int virDomainBlockStats(DomainPointer virDomainPtr, String path, virDomainBlockStats stats, int size);
151152 public int virDomainCoreDump(DomainPointer virDomainPtr, String to, int flags);
152153 public int virDomainCreate(DomainPointer virDomainPtr);
156156 public DomainPointer virDomainDefineXML(ConnectionPointer virConnectPtr, String xmlDesc);
157157 public int virDomainDestroy(DomainPointer virDomainPtr);
158158 public int virDomainDetachDevice(DomainPointer virDomainPtr, String deviceXML);
159 public int virDomainDetachDeviceFlags(DomainPointer virDomainPtr, String deviceXML, int flags);
159160 public int virDomainFree(DomainPointer virDomainPtr);
160161 public int virDomainGetAutostart(DomainPointer virDomainPtr, IntByReference value);
162 public ConnectionPointer virDomainGetConnect(DomainPointer virDomainPtr);
161163 public int virDomainGetID(DomainPointer virDomainPtr);
162164 public int virDomainGetInfo(DomainPointer virDomainPtr, virDomainInfo vInfo);
165 public int virDomainGetJobInfo(DomainPointer virDomainPtr, virDomainJobInfo vInfo);
163166 public NativeLong virDomainGetMaxMemory(DomainPointer virDomainPtr);
164167 public int virDomainGetMaxVcpus(DomainPointer virDomainPtr);
165168 public String virDomainGetName(DomainPointer virDomainPtr);
  
1package org.libvirt.jna;
2
3import com.sun.jna.Structure;
4
5public class virDomainJobInfo extends Structure {
6 public int type;
7 public long timeElapsed;
8 public long timeRemaining;
9 public long dataTotal;
10 public long dataProcessed;
11 public long dataRemaining;
12 public long memTotal;
13 public long memProcessed;
14 public long memRemaining;
15 public long fileTotal;
16 public long fileProcessed;
17 public long fileRemaining;
18}