diff --git a/server/src/libvirt.zig b/server/src/libvirt.zig index 7e74db7..5c2e1f2 100644 --- a/server/src/libvirt.zig +++ b/server/src/libvirt.zig @@ -164,6 +164,15 @@ pub const Connection = struct { ); } + pub fn createPool(self: *const Connection, xml: []const u8, flags: []const Pool.CreateFlags) !Pool { + const pool = c.virStoragePoolCreateXML(self.ptr, @ptrCast(xml), intFromFlags(Pool.CreateFlags, flags)); + return if (pool) |p| Pool.init(p, self.allocator) else handleError(); + } + pub fn definePoolFlags(self: *const Connection, xml: []const u8, flags: []const Pool.DefineFlags) !Pool { + const pool = c.virStoragePoolCreateXML(self.ptr, @ptrCast(xml), intFromFlags(Pool.DefineFlags, flags)); + return if (pool) |p| Pool.init(p, self.allocator) else handleError(); + } + pub fn numOfDomains(self: *const Connection) !u32 { const num = c.virConnectNumOfDomains(self.ptr); return if (num < 0) handleError() else @intCast(num); @@ -185,6 +194,19 @@ pub const Connection = struct { c.virConnectListAllDomains, ); } + + pub fn createDomain(self: *const Connection, xml: []const u8, flags: []const Domain.CreateFlags) !Domain { + const domain = c.virDomainCreateXML(self.ptr, @ptrCast(xml), intFromFlags(Domain.CreateFlags, flags)); + return if (domain) |d| Domain.init(d, self.allocator) else handleError(); + } + pub fn defineDomain(self: *const Connection, xml: []const u8) !Domain { + const domain = c.virDomainDefineXML(self.ptr, @ptrCast(xml)); + return if (domain) |d| Domain.init(d, self.allocator) else handleError(); + } + pub fn defineDomainFlags(self: *const Connection, xml: []const u8, flags: []const Domain.DefineFlags) !Domain { + const domain = c.virDomainDefineXMLFlags(self.ptr, @ptrCast(xml), intFromFlags(Domain.DefineFlags, flags)); + return if (domain) |d| Domain.init(d, self.allocator) else handleError(); + } }; pub const Pool = struct { @@ -397,6 +419,18 @@ pub const Domain = struct { 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 {}; @@ -411,6 +445,7 @@ pub const Domain = struct { 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);