remote display fixes
This commit is contained in:
@@ -129,6 +129,10 @@ class Program
|
||||
case "port":
|
||||
await HandlePortCommandsAsync(arguments);
|
||||
break;
|
||||
|
||||
case "config":
|
||||
await HandleConfigCommandsAsync(vmService, arguments);
|
||||
break;
|
||||
case "exit":
|
||||
case "quit":
|
||||
System.Console.WriteLine("Goodbye!");
|
||||
@@ -1275,6 +1279,91 @@ class Program
|
||||
portForwards.Add(portForward);
|
||||
await SavePortForwardsAsync(portForwards);
|
||||
}
|
||||
|
||||
static async Task HandleConfigCommandsAsync(VmManagementService vmService, string[] arguments)
|
||||
{
|
||||
if (arguments.Length < 3)
|
||||
{
|
||||
System.Console.WriteLine("Usage: config <vm-name> <setting> <value>");
|
||||
System.Console.WriteLine("Settings:");
|
||||
System.Console.WriteLine(" display <type> [port] - Set display type (gtk, vnc, spice)");
|
||||
System.Console.WriteLine(" vga <type> - Set VGA type (std, virtio, qxl)");
|
||||
System.Console.WriteLine(" memory <size> - Set memory size in GB");
|
||||
System.Console.WriteLine(" cpu <cores> - Set CPU cores");
|
||||
System.Console.WriteLine("Examples:");
|
||||
System.Console.WriteLine(" config ubuntu-desktop display vnc 5900");
|
||||
System.Console.WriteLine(" config ubuntu-desktop display gtk");
|
||||
System.Console.WriteLine(" config ubuntu-desktop vga std");
|
||||
return;
|
||||
}
|
||||
|
||||
var vmName = arguments[0];
|
||||
var setting = arguments[1].ToLower();
|
||||
var value = arguments[2];
|
||||
|
||||
var config = vmService.GetVmConfiguration(vmName);
|
||||
if (config == null)
|
||||
{
|
||||
System.Console.WriteLine($"VM '{vmName}' not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
switch (setting)
|
||||
{
|
||||
case "display":
|
||||
config.Display.Type = value;
|
||||
if (arguments.Length > 3 && value == "vnc")
|
||||
{
|
||||
config.Display.SpicePort = int.Parse(arguments[3]);
|
||||
}
|
||||
System.Console.WriteLine($"Display type set to '{value}' for VM '{vmName}'");
|
||||
break;
|
||||
|
||||
case "vga":
|
||||
config.Display.Vga = value;
|
||||
System.Console.WriteLine($"VGA type set to '{value}' for VM '{vmName}'");
|
||||
break;
|
||||
|
||||
case "memory":
|
||||
if (int.TryParse(value, out int memorySize))
|
||||
{
|
||||
config.Memory.Size = memorySize;
|
||||
System.Console.WriteLine($"Memory set to {memorySize}GB for VM '{vmName}'");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.Console.WriteLine("Invalid memory size. Please specify a number.");
|
||||
}
|
||||
break;
|
||||
|
||||
case "cpu":
|
||||
if (int.TryParse(value, out int cpuCores))
|
||||
{
|
||||
config.Cpu.Cores = cpuCores;
|
||||
System.Console.WriteLine($"CPU cores set to {cpuCores} for VM '{vmName}'");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.Console.WriteLine("Invalid CPU cores. Please specify a number.");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
System.Console.WriteLine($"Unknown setting '{setting}'");
|
||||
break;
|
||||
}
|
||||
|
||||
// Save the updated configuration
|
||||
await vmService.UpdateVmConfigurationAsync(vmName, config);
|
||||
System.Console.WriteLine($"Configuration updated successfully for VM '{vmName}'");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Console.WriteLine($"Error updating configuration: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PortForward
|
||||
|
@@ -324,8 +324,22 @@ public class QemuCommandBuilder
|
||||
|
||||
_arguments.Add(displayType);
|
||||
|
||||
// For X11 forwarding compatibility, use std VGA instead of virtio
|
||||
// This avoids GLX/OpenGL issues when forwarding over X11
|
||||
if (displayType == "gtk" || displayType == "x11")
|
||||
{
|
||||
_arguments.Add("-vga");
|
||||
_arguments.Add("std"); // Use standard VGA for better X11 compatibility
|
||||
|
||||
// Add software rendering options to avoid GLX issues
|
||||
_arguments.Add("-device");
|
||||
_arguments.Add("virtio-gpu-pci,edid=off"); // Use virtio-gpu without EDID
|
||||
}
|
||||
else
|
||||
{
|
||||
_arguments.Add("-vga");
|
||||
_arguments.Add(display.Vga);
|
||||
}
|
||||
|
||||
if (display.EnableSpice)
|
||||
{
|
||||
|
Reference in New Issue
Block a user