//! Type definitions for Cloud Hypervisor VMs.

use serde::{Deserialize, Serialize};

/// VM specification defining the configuration for a virtual machine.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VmSpec {
    /// Unique identifier for the VM.
    pub id: String,
    /// Optional kernel path for direct kernel boot.
    pub kernel_path: Option<String>,
    /// Optional firmware path for firmware boot (e.g., UEFI).
    pub firmware_path: Option<String>,
    /// Disk image path (qcow2 or raw format).
    pub disk_path: String,
    /// API socket path for ch-remote and management.
    pub api_socket: String,
    /// Number of vCPUs to boot with.
    pub vcpus: u32,
    /// Memory size in MB.
    pub memory_mb: u32,
    /// Kernel command line (only used for direct kernel boot).
    pub cmdline: Option<String>,
    /// Extra arguments for advanced configuration.
    pub extra_args: Option<Vec<String>>,
}

/// Runtime state of a virtual machine.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VmRuntime {
    /// PID of the cloud-hypervisor process if running.
    pub pid: Option<i64>,
    /// Last known status: "stopped" or "running".
    pub status: String,
    /// Console log file path.
    pub log_file: String,
}

/// Complete VM record containing both spec and runtime state.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VmRecord {
    /// VM specification.
    pub spec: VmSpec,
    /// Runtime state.
    pub runtime: VmRuntime,
}
