Commit 46aa1baec158111fe176dcda998ae225f85ee295
- Diff rendering mode:
- inline
- side by side
build.properties
(1 / 1)
|   | |||
| 1 | 1 | version=0.4.3 | |
| 2 | 2 | release=1 | |
| 3 | libvirt.required=0.7.5 | ||
| 3 | libvirt.required=0.7.7 | ||
| 4 | 4 | java.required=1:1.5.0 | |
| 5 | 5 | rpm.topdir=/home/bkearney/rpmbuild | |
| 6 | 6 | jar.dir=/usr/share/java |
|   | |||
| 223 | 223 | } | |
| 224 | 224 | ||
| 225 | 225 | /** | |
| 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 | /** | ||
| 226 | 238 | * Closes the connection to the hypervisor/driver. Calling any methods on | |
| 227 | 239 | * the object after close() will result in an exception. | |
| 228 | 240 | * |
|   | |||
| 5 | 5 | import org.libvirt.jna.virDomainBlockStats; | |
| 6 | 6 | import org.libvirt.jna.virDomainInfo; | |
| 7 | 7 | import org.libvirt.jna.virDomainInterfaceStats; | |
| 8 | import org.libvirt.jna.virDomainJobInfo; | ||
| 8 | 9 | import org.libvirt.jna.virDomainMemoryStats; | |
| 9 | 10 | import org.libvirt.jna.virSchedParameter; | |
| 10 | 11 | import org.libvirt.jna.virVcpuInfo; | |
| … | … | ||
| 72 | 72 | } | |
| 73 | 73 | ||
| 74 | 74 | /** | |
| 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 | /** | ||
| 75 | 89 | * Creates a virtual device attachment to backend. | |
| 76 | * | ||
| 90 | * @see <a href="http://www.libvirt.org/html/libvirt-libvirt.html#virDomainAttachDevice">Libvirt Documentation</a> | ||
| 77 | 91 | * @param xmlDesc | |
| 78 | 92 | * XML description of one device | |
| 79 | 93 | * @throws LibvirtException | |
| … | … | ||
| 96 | 96 | libvirt.virDomainAttachDevice(VDP, xmlDesc); | |
| 97 | 97 | processError(); | |
| 98 | 98 | } | |
| 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 | } | ||
| 99 | 112 | ||
| 100 | 113 | /** | |
| 101 | 114 | * Returns block device (disk) stats for block devices attached to this | |
| … | … | ||
| 181 | 181 | ||
| 182 | 182 | /** | |
| 183 | 183 | * Destroys a virtual device attachment to backend. | |
| 184 | * | ||
| 184 | * @see <a href="http://www.libvirt.org/html/libvirt-libvirt.html#virDomainDetachDevice">Libvirt Documentation</a> | ||
| 185 | 185 | * @param xmlDesc | |
| 186 | 186 | * XML description of one device | |
| 187 | 187 | * @throws LibvirtException | |
| … | … | ||
| 190 | 190 | libvirt.virDomainDetachDevice(VDP, xmlDesc); | |
| 191 | 191 | processError(); | |
| 192 | 192 | } | |
| 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 | |||
| 193 | 206 | ||
| 194 | 207 | @Override | |
| 195 | 208 | public void finalize() throws LibvirtException { | |
| … | … | ||
| 266 | 266 | * Extract information about a domain. Note that if the connection used to | |
| 267 | 267 | * get the domain is limited only a partial set of the information can be | |
| 268 | 268 | * extracted. | |
| 269 | * @see <a href="http://www.libvirt.org/html/libvirt-libvirt.html#virDomainGetInfo">Libvirt Documentation</a> | ||
| 269 | 270 | * | |
| 270 | 271 | * @return a DomainInfo object describing this domain | |
| 271 | 272 | * @throws LibvirtException | |
| … | … | ||
| 281 | 281 | } | |
| 282 | 282 | return returnValue; | |
| 283 | 283 | } | |
| 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 | } | ||
| 284 | 302 | ||
| 285 | 303 | /** | |
| 286 | 304 | * Retrieve the maximum amount of physical memory allocated to a domain. |
|   | |||
| 1 | package org.libvirt; | ||
| 2 | |||
| 3 | import org.libvirt.jna.virDomainJobInfo; | ||
| 4 | |||
| 5 | public 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 | } |
|   | |||
| 93 | 93 | public static int VIR_DOMAIN_SCHED_FIELD_LENGTH = 80; | |
| 94 | 94 | ||
| 95 | 95 | // Connection Functions | |
| 96 | public String virConnectBaselineCPU(ConnectionPointer virConnectPtr, String[] xmlCPUs, int ncpus, int flags); | ||
| 96 | 97 | public int virConnCopyLastError(ConnectionPointer virConnectPtr, virError to); | |
| 97 | 98 | public int virConnectClose(ConnectionPointer virConnectPtr); | |
| 98 | 99 | public int virConnectCompareCPU(ConnectionPointer virConnectPtr, String xmlDesc, int flags); | |
| … | … | ||
| 145 | 145 | public void virSetErrorFunc(Pointer userData, VirErrorCallback callback); | |
| 146 | 146 | ||
| 147 | 147 | // Domain functions | |
| 148 | public ConnectionPointer virDomainGetConnect(DomainPointer virDomainPtr); | ||
| 148 | public int virDomainAbortJob(DomainPointer virDomainPtr); | ||
| 149 | 149 | public int virDomainAttachDevice(DomainPointer virDomainPtr, String deviceXML); | |
| 150 | public int virDomainAttachDeviceFlags(DomainPointer virDomainPtr, String deviceXML, int flags); | ||
| 150 | 151 | public int virDomainBlockStats(DomainPointer virDomainPtr, String path, virDomainBlockStats stats, int size); | |
| 151 | 152 | public int virDomainCoreDump(DomainPointer virDomainPtr, String to, int flags); | |
| 152 | 153 | public int virDomainCreate(DomainPointer virDomainPtr); | |
| … | … | ||
| 156 | 156 | public DomainPointer virDomainDefineXML(ConnectionPointer virConnectPtr, String xmlDesc); | |
| 157 | 157 | public int virDomainDestroy(DomainPointer virDomainPtr); | |
| 158 | 158 | public int virDomainDetachDevice(DomainPointer virDomainPtr, String deviceXML); | |
| 159 | public int virDomainDetachDeviceFlags(DomainPointer virDomainPtr, String deviceXML, int flags); | ||
| 159 | 160 | public int virDomainFree(DomainPointer virDomainPtr); | |
| 160 | 161 | public int virDomainGetAutostart(DomainPointer virDomainPtr, IntByReference value); | |
| 162 | public ConnectionPointer virDomainGetConnect(DomainPointer virDomainPtr); | ||
| 161 | 163 | public int virDomainGetID(DomainPointer virDomainPtr); | |
| 162 | 164 | public int virDomainGetInfo(DomainPointer virDomainPtr, virDomainInfo vInfo); | |
| 165 | public int virDomainGetJobInfo(DomainPointer virDomainPtr, virDomainJobInfo vInfo); | ||
| 163 | 166 | public NativeLong virDomainGetMaxMemory(DomainPointer virDomainPtr); | |
| 164 | 167 | public int virDomainGetMaxVcpus(DomainPointer virDomainPtr); | |
| 165 | 168 | public String virDomainGetName(DomainPointer virDomainPtr); |
|   | |||
| 1 | package org.libvirt.jna; | ||
| 2 | |||
| 3 | import com.sun.jna.Structure; | ||
| 4 | |||
| 5 | public 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 | } |

