oslib/server/src/libvirt-domain.zig

274 lines
8.3 KiB
Zig

const std = @import("std");
const mem = std.mem;
const heap = std.heap;
const h = @import("libvirt-helper.zig");
const c = @import("libvirt-c.zig").c;
const err = @import("libvirt-error.zig");
const Connection = @import("libvirt-connection.zig");
const VirError = err.VirError;
const Domain = @This();
ptr: c.virDomainPtr,
arena: *heap.ArenaAllocator,
pub fn init(ptr: c.virDomainPtr, allocator: mem.Allocator) Domain {
var arena = heap.ArenaAllocator.init(allocator);
return .{
.ptr = ptr,
.arena = &arena,
};
}
pub fn deinit(self: *const Domain) void {
self.arena.deinit();
}
// TODO event handling callbacks
pub fn xmlFromNative() void {}
pub fn xmlToNative() void {}
pub fn getAllDomainStats() void {}
pub fn getDomainCapabilities() void {}
pub fn listAllDomains() void {}
pub fn listDefinedDomains() void {}
pub fn listDomains() void {}
pub fn numOfDefinedDomains(conn: *const Connection) VirError!u32 {
const n = c.virConnectNumOfDomains(conn.ptr);
return if (n < 0) err.handleError() else @intCast(n);
}
pub fn numOfDomains(conn: *const Connection) VirError!u32 {
const n = c.virConnectNumOfDomains(conn.ptr);
return if (n < 0) err.handleError() else @intCast(n);
}
pub fn abortJob() void {}
pub fn abortJobFlags() void {}
pub fn addIOThread() void {}
pub fn agentSetResponseTimeout() void {}
pub fn attachDevice() void {}
pub fn attachDeviceFlags() void {}
pub fn authorizedSSHKeysSet() void {}
pub fn backupBegin() void {}
pub fn backupGetXMLDesc() void {}
pub fn blockCommit() void {}
pub fn blockCopy() void {}
pub fn blockJobAbort() void {}
pub fn blockJobSetSpeed() void {}
pub fn blockPeek() void {}
pub fn blockPull() void {}
pub fn blockRebase() void {}
pub fn blockResize() void {}
pub fn blockStats() void {}
pub fn blockStatsFlags() void {}
pub fn coreDump() void {}
pub fn coreDumpWithFormat() void {}
pub fn create() void {}
pub fn createLinux() void {}
pub fn createWithFiles() void {}
pub fn createWithFlags() void {}
pub fn createXML() void {}
pub fn createXMLWithFiles() void {}
pub fn defineXML() void {}
pub fn defineXMLFlags() void {}
pub fn delIOThread() void {}
pub fn destroy() void {}
pub fn destroyFlags() void {}
pub fn detachDevice() void {}
pub fn detachDeviceAlias() void {}
pub fn detachDeviceFlags() void {}
pub fn fdAssociate() void {}
pub fn fsFreeze() void {}
pub fn fsInfoFree() void {}
pub fn fsThaw() void {}
pub fn fsTrim() void {}
pub fn free(self: *const Domain) VirError!void {
if (c.virDomainFree(self.ptr) < 0) return err.handleError();
}
pub fn getAutostart() void {}
pub fn getBlkioParameters() void {}
pub fn getBlockInfo() void {}
pub fn getBlockIoTune() void {}
pub fn getBlockJobInfo() void {}
pub fn getCPUStats() void {}
pub fn getConnect() void {}
pub fn getControlInfo() void {}
pub fn getDiskErrors() void {}
pub fn getEmulatorPinInfo() void {}
pub fn getFSInfo() void {}
pub fn getGuestInfo() void {}
pub fn getGuestVcpus() void {}
pub fn getHostname() void {}
pub fn getID() void {}
pub fn getIOThreadInfo() void {}
pub fn getInfo() void {}
pub fn getInterfaceParameters() void {}
pub fn getJobInfo() void {}
pub fn getJobStats() void {}
pub fn getLaunchSecurityInfo() void {}
pub fn getMaxMemory() void {}
pub fn getMaxVcpus() void {}
pub fn getMemoryParameters() void {}
pub fn getMessages() void {}
pub fn getMetadata() void {}
pub fn getName(self: *const Domain) VirError![]const u8 {
const name = c.virDomainGetName(self.ptr);
const str = h.string(name);
return if (str.len == 0) err.handleError() else str;
}
pub fn getNumaParameters() void {}
pub fn getOSType() void {}
pub fn getPerfEvents() void {}
pub fn getSchedulerParameters() void {}
pub fn getSchedulerParametersFlags() void {}
pub fn getSchedulerType() void {}
pub fn getSecurityLabel() void {}
pub fn getSecurityLabelList() void {}
pub fn getState() void {}
pub fn getTime() void {}
pub fn getUUID() void {}
pub fn getUUIDString() void {}
pub fn getVcpuPinInfo() void {}
pub fn getVcpus() void {}
pub fn getVpusFlags() void {}
pub fn getXMLDesc() void {}
pub fn graphicsReload() void {}
pub fn hasManagedSaveImage() void {}
pub fn ioThreadInfoFree() void {}
pub fn injectNMI() void {}
pub fn interfaceAddresses() void {}
pub fn interfaceFree() void {}
pub fn interfaceStats() void {}
pub fn isActive(self: *const Domain) void {
const active = c.virDomainIsActive(self.ptr);
return if (active == 0) false else true;
}
pub fn isPersistent() void {}
pub fn isUpdated() void {}
pub fn listGetStats() void {}
pub fn lookupByID() void {}
pub fn lookupByUUID() void {}
pub fn lookupByUUIDString() void {}
pub fn managedSave() void {}
pub fn managedSaveDefineXML() void {}
pub fn managedSaveGetXMLDesc() void {}
pub fn managedSaveRemove() void {}
pub fn memoryPeek() void {}
pub fn memoryStats() void {}
// TODO virDomainMigrate*
pub fn openChannel() void {}
pub fn openConsole() void {}
pub fn openGraphics() void {}
pub fn openGraphicsFD() void {}
pub fn pmSuspendForDuration() void {}
pub fn pmWakeup() void {}
pub fn pinEmulator() void {}
pub fn pinIOThread() void {}
pub fn pinVcpu() void {}
pub fn pinVcpuFlags() void {}
pub fn reboot() void {}
pub fn ref(self: *const Domain) VirError!void {
if (c.virDomainRef(self.ptr) < 0) return err.handleError();
}
pub fn rename() void {}
pub fn reset() void {}
pub fn restore() void {}
pub fn restoreFlags() void {}
pub fn restoreParams() void {}
pub fn @"resume"() void {}
pub fn save() void {}
pub fn saveFlags() void {}
pub fn saveImageDefineXML() void {}
pub fn saveImageGetXMLDesc() void {}
pub fn saveParams() void {}
pub fn screenshot() void {}
pub fn sendKey() void {}
pub fn sendProcessSignal() void {}
pub fn setAutostart() void {}
pub fn setBlkioParameters() void {}
pub fn setBlockIoTune() void {}
pub fn setBlockThreshold() void {}
pub fn setGuestVcpus() void {}
pub fn setIOThreadParams() void {}
pub fn setInterfaceParameters() void {}
pub fn setLaunchSecurityState() void {}
pub fn setLifecycleAction() void {}
pub fn setMaxMemory() void {}
pub fn setMemory() void {}
pub fn setMemoryFlags() void {}
pub fn setMemoryParameters() void {}
pub fn setMemoryStatsPeriod() void {}
pub fn setMetadata() void {}
pub fn setNumaParameters() void {}
pub fn setPerfEvents() void {}
pub fn setSchedulerParameters() void {}
pub fn setSchedulerParametersFlags() void {}
pub fn setTime() void {}
pub fn setUserPassword() void {}
pub fn setVcpu() void {}
pub fn setVcpus() void {}
pub fn setVpusFlags() void {}
pub fn shutdown() void {}
pub fn @"suspend"() void {}
pub fn undefine() void {}
pub fn undefineFlags() void {}
pub fn updateDeviceFlags() void {}
pub const ListFlags = enum(c_uint) {
Active = c.VIR_CONNECT_LIST_DOMAINS_ACTIVE,
Inactive = c.VIR_CONNECT_LIST_DOMAINS_INACTIVE,
};
pub const AbortJobFlagsValues = enum(c_uint) {};
pub const AgentResponseTimeoutValues = enum(c_uint) {};
pub const AuthorizedSSHKeysSetFlags = enum(c_uint) {};
pub const BackupBeginFlags = enum(c_uint) {};
pub const BlockCommitFlags = enum(c_uint) {};
pub const BlockCopyFlags = enum(c_uint) {};
pub const BlockJobAbortFlags = enum(c_uint) {};
pub const BlockJobInfoFlags = enum(c_uint) {};
pub const BlockJobSetSpeedFlags = enum(c_uint) {};
pub const BlockPullFlags = enum(c_uint) {};
pub const BlockRebaseFlags = enum(c_uint) {};
pub const BlockResizeFlags = enum(c_uint) {};
pub const ChannelFlags = enum(c_uint) {};
pub const ConsoleFlags = enum(c_uint) {};
pub const CoreDumpFlags = enum(c_uint) {};
pub const CreateFlags = enum(c_uint) {
None = c.VIR_DOMAIN_NONE,
StartPaused = c.VIR_DOMAIN_START_PAUSED,
StartAutodestroy = c.VIR_DOMAIN_START_AUTODESTROY,
StartBypassCache = c.VIR_DOMAIN_START_BYPASS_CACHE,
StartForceBoot = c.VIR_DOMAIN_START_FORCE_BOOT,
StartValidate = c.VIR_DOMAIN_START_VALIDATE,
StartResetNvram = c.VIR_DOMAIN_START_RESET_NVRAM,
};
pub const DefineFlags = enum(c_uint) {
Validate = c.VIR_DOMAIN_DEFINE_VALIDATE,
};
// TODO rest
pub const BlockInfo = struct {};
pub const BlockJobCursor = u64;
pub const BlockJobInfo = struct {};
pub const BlockStats = struct {};
pub const ControlInfo = struct {};
// TODO rest
pub const BlockJobType = enum(c_uint) {};
pub const BlockedReason = enum(c_uint) {};
pub const ControlErrorReason = enum(c_uint) {};
pub const ControlState = enum(c_uint) {};
pub const CoreDumpFormat = enum(c_uint) {};
pub const CrashedReason = enum(c_uint) {};
// TODO rest
// pub const DomainIterator = Iterator(Domain, c.virDomainPtr, c.virDomainFree);