1 package org.libvirt; 2 3 import org.libvirt.jna.virDomainInfo; 4 5 /** 6 * This object is returned by Domain.getInfo() 7 * 8 * @author stoty 9 * 10 */ 11 public class DomainInfo { 12 /** 13 * @author stoty 14 * 15 */ 16 public enum DomainState { 17 /** 18 * no state 19 */ 20 VIR_DOMAIN_NOSTATE, 21 /** 22 * the domain is running 23 */ 24 VIR_DOMAIN_RUNNING, 25 /** 26 * the domain is blocked on resource 27 */ 28 VIR_DOMAIN_BLOCKED, 29 /** 30 * the domain is paused by user 31 */ 32 VIR_DOMAIN_PAUSED, 33 /** 34 * the domain is being shut down 35 */ 36 VIR_DOMAIN_SHUTDOWN, 37 /** 38 * the domain is shut off 39 */ 40 VIR_DOMAIN_SHUTOFF, 41 /** 42 * the domain is crashed 43 */ 44 VIR_DOMAIN_CRASHED 45 } 46 47 /** 48 * the running state, one of virDomainFlag 49 */ 50 public DomainState state; 51 /** 52 * the maximum memory in KBytes allowed 53 */ 54 public long maxMem; 55 /** 56 * the memory in KBytes used by the domain 57 */ 58 public long memory; 59 /** 60 * the number of virtual CPUs for the domain 61 */ 62 public int nrVirtCpu; 63 64 /** 65 * the CPU time used in nanoseconds 66 */ 67 public long cpuTime; 68 DomainInfo()69 public DomainInfo() { 70 71 } 72 DomainInfo(final virDomainInfo info)73 public DomainInfo(final virDomainInfo info) { 74 cpuTime = info.cpuTime; 75 maxMem = info.maxMem.longValue(); 76 memory = info.memory.longValue(); 77 nrVirtCpu = info.nrVirtCpu; 78 state = DomainState.values()[info.state]; 79 } 80 81 @Override toString()82 public String toString() { 83 return String.format("state:%s%nmaxMem:%d%nmemory:%d%nnrVirtCpu:%d%ncpuTime:%d%n", 84 state, maxMem, memory, nrVirtCpu, cpuTime); 85 } 86 } 87