public Domain CreateDomain(string xml) { IntPtr result = Libvirt.virDomainCreateXML(_conn, xml); ThrowExceptionOnError(result); return(new Domain(_conn, result)); }
public void Close(bool ignoreErrors = false) { if (!IsOpen) { return; } int result = Libvirt.virConnectClose(_conn); if (!ignoreErrors) { ThrowExceptionOnError(result); } IsOpen = false; }
public List <Domain> GetDomains(virConnectListAllDomainsFlags flags = default) { int result = Libvirt.virConnectListAllDomains(_conn, out IntPtr ptrDomains, flags); ThrowExceptionOnError(result); List <Domain> domains = new List <Domain>(); for (int i = 0; i < result; i++) { IntPtr ptrDomain = Marshal.ReadIntPtr(ptrDomains, i * IntPtr.Size); domains.Add(new Domain(_conn, ptrDomain)); } Libvirt.virFree(ptrDomains); return(domains); }
public void Open(bool readOnly = false) { if (IsDisposed) { throw new ObjectDisposedException("Connect", "Cannot open a disposed connection."); } if (readOnly) { _conn = Libvirt.virConnectOpenReadOnly(Uri); } else { _conn = Libvirt.virConnectOpen(Uri); } ThrowExceptionOnError(_conn); IsOpen = true; }
public void CleanUpNativeData(IntPtr pNativeData) { Libvirt.virFree(pNativeData); }
public void RestoreDomain(string file) => ThrowExceptionOnError(Libvirt.virDomainRestore(_conn, file));
public void Save(string file) => ThrowExceptionOnError(Libvirt.virDomainSave(_ptrDomain, file));
protected override void DisposeInternal() { Libvirt.virDomainFree(_ptrDomain); }
public void Resume() => ThrowExceptionOnError(Libvirt.virDomainResume(_ptrDomain));
public void Suspend() => ThrowExceptionOnError(Libvirt.virDomainSuspend(_ptrDomain));
public void Shutdown() => ThrowExceptionOnError(Libvirt.virDomainShutdown(_ptrDomain));
public void Destroy() => ThrowExceptionOnError(Libvirt.virDomainDestroy(_ptrDomain));
private static virError GetLastError() { IntPtr errPtr = Libvirt.virGetLastError(); return(Marshal.PtrToStructure <virError>(errPtr)); }