//! Daemon Start Demo - Shows how to start virtiofsd daemons
//! 
//! This example demonstrates practical daemon startup using share_directory()

// Check if virtiofsd is available
if !virtiofsd_available() {
    print("Error: virtiofsd is not installed");
    throw "virtiofsd not available";
}

print("=== Virtiofsd Daemon Start Demo ===");

// Example 1: Start daemon for temporary file sharing
print("\n1. Starting daemon for temporary file sharing");

let temp_daemon = share_directory("/tmp", "/tmp/temp_share.sock");
print("✅ Temp daemon started");
print("   Socket: /tmp/temp_share.sock");
print("   Shared: /tmp");

// Example 2: Start daemon for home directory sharing
print("\n2. Starting daemon for home directory sharing");

let home_daemon = share_directory("/home", "/tmp/home_share.sock");
print("✅ Home daemon started");
print("   Socket: /tmp/home_share.sock");
print("   Shared: /home");

// Example 3: Start daemon for project directory sharing
print("\n3. Starting daemon for project sharing");

let project_daemon = share_directory("/home/rawda/projects", "/tmp/project_share.sock");
print("✅ Project daemon started");
print("   Socket: /tmp/project_share.sock");
print("   Shared: /home/rawda/projects");

print("\n=== Daemon Status ===");
print("All daemons are running!");
print("Check with: ps aux | grep virtiofsd");

print("\n=== VM Connection Instructions ===");
print("Add to your QEMU command:");
print("-device vhost-user-fs-pci,chardev=char0,tag=myshare");
print("-chardev socket,id=char0,path=/tmp/temp_share.sock");

print("\nInside VM, mount with:");
print("sudo mkdir /mnt/shared");
print("sudo mount -t virtiofs myshare /mnt/shared");

print("\n=== Cleanup ===");
print("To stop all daemons: pkill -f virtiofsd");

print("\n=== Demo completed successfully! ===");
