Initial commit
This commit is contained in:
13
QemuVmManager.Models/QemuVmManager.Models.csproj
Normal file
13
QemuVmManager.Models/QemuVmManager.Models.csproj
Normal file
@@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Text.Json" Version="8.0.5" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
29
QemuVmManager.Models/VirtualizationType.cs
Normal file
29
QemuVmManager.Models/VirtualizationType.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
namespace QemuVmManager.Models;
|
||||
|
||||
public enum VirtualizationType
|
||||
{
|
||||
/// <summary>
|
||||
/// Kernel-based Virtual Machine (Linux)
|
||||
/// </summary>
|
||||
KVM,
|
||||
|
||||
/// <summary>
|
||||
/// Hyper-V (Windows)
|
||||
/// </summary>
|
||||
HyperV,
|
||||
|
||||
/// <summary>
|
||||
/// Intel Hardware Accelerated Execution Manager (Windows/macOS)
|
||||
/// </summary>
|
||||
HAXM,
|
||||
|
||||
/// <summary>
|
||||
/// Hypervisor.framework (macOS)
|
||||
/// </summary>
|
||||
HVF,
|
||||
|
||||
/// <summary>
|
||||
/// Tiny Code Generator (Software emulation)
|
||||
/// </summary>
|
||||
TCG
|
||||
}
|
189
QemuVmManager.Models/VmConfiguration.cs
Normal file
189
QemuVmManager.Models/VmConfiguration.cs
Normal file
@@ -0,0 +1,189 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace QemuVmManager.Models;
|
||||
|
||||
public class VmConfiguration
|
||||
{
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("description")]
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("cpu")]
|
||||
public CpuConfiguration Cpu { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("memory")]
|
||||
public MemoryConfiguration Memory { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("storage")]
|
||||
public StorageConfiguration Storage { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("network")]
|
||||
public NetworkConfiguration Network { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("display")]
|
||||
public DisplayConfiguration Display { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("boot")]
|
||||
public BootConfiguration Boot { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("advanced")]
|
||||
public AdvancedConfiguration Advanced { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("created")]
|
||||
public DateTime Created { get; set; } = DateTime.UtcNow;
|
||||
|
||||
[JsonPropertyName("lastModified")]
|
||||
public DateTime LastModified { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
public class CpuConfiguration
|
||||
{
|
||||
[JsonPropertyName("cores")]
|
||||
public int Cores { get; set; } = 2;
|
||||
|
||||
[JsonPropertyName("sockets")]
|
||||
public int Sockets { get; set; } = 1;
|
||||
|
||||
[JsonPropertyName("threads")]
|
||||
public int Threads { get; set; } = 1;
|
||||
|
||||
[JsonPropertyName("model")]
|
||||
public string Model { get; set; } = "qemu64";
|
||||
|
||||
[JsonPropertyName("enableKvm")]
|
||||
public bool EnableKvm { get; set; } = true;
|
||||
}
|
||||
|
||||
public class MemoryConfiguration
|
||||
{
|
||||
[JsonPropertyName("size")]
|
||||
public long Size { get; set; } = 2048; // MB
|
||||
|
||||
[JsonPropertyName("unit")]
|
||||
public string Unit { get; set; } = "M";
|
||||
}
|
||||
|
||||
public class StorageConfiguration
|
||||
{
|
||||
[JsonPropertyName("disks")]
|
||||
public List<DiskConfiguration> Disks { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("cdrom")]
|
||||
public string? Cdrom { get; set; }
|
||||
}
|
||||
|
||||
public class DiskConfiguration
|
||||
{
|
||||
[JsonPropertyName("path")]
|
||||
public string Path { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("size")]
|
||||
public long Size { get; set; } = 10; // GB
|
||||
|
||||
[JsonPropertyName("format")]
|
||||
public string Format { get; set; } = "qcow2";
|
||||
|
||||
[JsonPropertyName("interface")]
|
||||
public string Interface { get; set; } = "virtio";
|
||||
|
||||
[JsonPropertyName("cache")]
|
||||
public string Cache { get; set; } = "writeback";
|
||||
|
||||
[JsonPropertyName("isBoot")]
|
||||
public bool IsBoot { get; set; } = false;
|
||||
}
|
||||
|
||||
public class NetworkConfiguration
|
||||
{
|
||||
[JsonPropertyName("interfaces")]
|
||||
public List<NetworkInterfaceConfiguration> Interfaces { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("bridge")]
|
||||
public string Bridge { get; set; } = "virbr0";
|
||||
}
|
||||
|
||||
public class NetworkInterfaceConfiguration
|
||||
{
|
||||
[JsonPropertyName("type")]
|
||||
public string Type { get; set; } = "bridge";
|
||||
|
||||
[JsonPropertyName("model")]
|
||||
public string Model { get; set; } = "virtio-net-pci";
|
||||
|
||||
[JsonPropertyName("mac")]
|
||||
public string? Mac { get; set; }
|
||||
|
||||
[JsonPropertyName("bridge")]
|
||||
public string Bridge { get; set; } = "virbr0";
|
||||
}
|
||||
|
||||
public class DisplayConfiguration
|
||||
{
|
||||
[JsonPropertyName("type")]
|
||||
public string Type { get; set; } = "gtk";
|
||||
|
||||
[JsonPropertyName("vga")]
|
||||
public string Vga { get; set; } = "virtio";
|
||||
|
||||
[JsonPropertyName("resolution")]
|
||||
public string Resolution { get; set; } = "1024x768";
|
||||
|
||||
[JsonPropertyName("enableSpice")]
|
||||
public bool EnableSpice { get; set; } = false;
|
||||
|
||||
[JsonPropertyName("spicePort")]
|
||||
public int SpicePort { get; set; } = 5930;
|
||||
}
|
||||
|
||||
public class BootConfiguration
|
||||
{
|
||||
[JsonPropertyName("order")]
|
||||
public List<string> Order { get; set; } = new() { "c", "d", "n" };
|
||||
|
||||
[JsonPropertyName("kernel")]
|
||||
public string? Kernel { get; set; }
|
||||
|
||||
[JsonPropertyName("initrd")]
|
||||
public string? Initrd { get; set; }
|
||||
|
||||
[JsonPropertyName("cmdline")]
|
||||
public string? Cmdline { get; set; }
|
||||
}
|
||||
|
||||
public class AdvancedConfiguration
|
||||
{
|
||||
[JsonPropertyName("enableAudio")]
|
||||
public bool EnableAudio { get; set; } = false;
|
||||
|
||||
[JsonPropertyName("enableUsb")]
|
||||
public bool EnableUsb { get; set; } = false;
|
||||
|
||||
[JsonPropertyName("enableBalloon")]
|
||||
public bool EnableBalloon { get; set; } = true;
|
||||
|
||||
[JsonPropertyName("enableVirtioRng")]
|
||||
public bool EnableVirtioRng { get; set; } = true;
|
||||
|
||||
[JsonPropertyName("enableVirtioFs")]
|
||||
public bool EnableVirtioFs { get; set; } = false;
|
||||
|
||||
[JsonPropertyName("sharedFolders")]
|
||||
public List<SharedFolderConfiguration> SharedFolders { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("extraArgs")]
|
||||
public List<string> ExtraArgs { get; set; } = new();
|
||||
}
|
||||
|
||||
public class SharedFolderConfiguration
|
||||
{
|
||||
[JsonPropertyName("hostPath")]
|
||||
public string HostPath { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("guestPath")]
|
||||
public string GuestPath { get; set; } = string.Empty;
|
||||
|
||||
[JsonPropertyName("readOnly")]
|
||||
public bool ReadOnly { get; set; } = false;
|
||||
}
|
44
QemuVmManager.Models/VmStatus.cs
Normal file
44
QemuVmManager.Models/VmStatus.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
namespace QemuVmManager.Models;
|
||||
|
||||
public enum VmState
|
||||
{
|
||||
Stopped,
|
||||
Starting,
|
||||
Running,
|
||||
Paused,
|
||||
Stopping,
|
||||
Error
|
||||
}
|
||||
|
||||
public class VmStatus
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public VmState State { get; set; } = VmState.Stopped;
|
||||
public int ProcessId { get; set; } = -1;
|
||||
public DateTime? StartedAt { get; set; }
|
||||
public DateTime? StoppedAt { get; set; }
|
||||
public string? ErrorMessage { get; set; }
|
||||
public VmResourceUsage? ResourceUsage { get; set; }
|
||||
}
|
||||
|
||||
public class VmResourceUsage
|
||||
{
|
||||
public double CpuUsage { get; set; } = 0.0; // Percentage
|
||||
public long MemoryUsage { get; set; } = 0; // MB
|
||||
public long DiskUsage { get; set; } = 0; // MB
|
||||
public long NetworkRx { get; set; } = 0; // Bytes
|
||||
public long NetworkTx { get; set; } = 0; // Bytes
|
||||
}
|
||||
|
||||
public class VmPerformanceMetrics
|
||||
{
|
||||
public DateTime Timestamp { get; set; }
|
||||
public int ProcessId { get; set; }
|
||||
public double CpuUsagePercent { get; set; }
|
||||
public double SystemCpuUsagePercent { get; set; }
|
||||
public long MemoryUsageMB { get; set; }
|
||||
public long PrivateMemoryMB { get; set; }
|
||||
public long VirtualMemoryMB { get; set; }
|
||||
public int ThreadCount { get; set; }
|
||||
public int HandleCount { get; set; }
|
||||
}
|
Reference in New Issue
Block a user