190 lines
4.9 KiB
C#
190 lines
4.9 KiB
C#
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;
|
|
}
|