Skip to content

Commit d3ccd39

Browse files
committed
[PATCH] -Comment and message translating
Signed-off-by: Iván Rodriguez <ivanrwcm25@gmail.com>
1 parent a282ac0 commit d3ccd39

1 file changed

Lines changed: 32 additions & 30 deletions

File tree

ShpCore.Kernel/VM_subsystem/QemuConnection.cs

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,29 @@ public QemuBridgeConnection(QemuOptions options)
2727

2828
}
2929

30-
public Task SendAsync(string path) // No lo voy a usar por ahora.
30+
public Task SendAsync(string path) // I wont use it for now. Just for the interface errs
3131
{
3232
return Task.Run(() =>
3333
{
3434
var remote = new RemoteLinuxBridgeConnection($"http://");
3535
});
3636
}
3737

38-
private void PreflightCheck()
38+
private void PreflightCheck() // Checkeo previo a la ejecución de la VM
3939
{
40-
KernelLog.Warn("[Preflight] Iniciando healthcheck previos para QEMU");
40+
KernelLog.Warn("[Preflight] Running QEMU preflight Healthcheck...");
4141

4242
if (_options == null)
4343
{
44-
KernelLog.Panic("[Preflight] Opciones de QEMU no definidas.");
44+
KernelLog.Panic("[Preflight QemuConnection.cs line:44] QEMU options undefined .");
4545
throw new ArgumentNullException(nameof(_options));
4646
}
4747

4848
// 1. Validar imagen
4949
if (string.IsNullOrWhiteSpace(_options.ImagePath) || !File.Exists(_options.ImagePath))
5050
{
51-
KernelLog.Panic($"[Preflight] Imagen no encontrada: {_options.ImagePath}");
52-
throw new FileNotFoundException("La imagen de disco no existe.", _options.ImagePath);
51+
KernelLog.Panic($"[Preflight] Linux Image not found: {_options.ImagePath}");
52+
throw new FileNotFoundException("La imagen no existe.", _options.ImagePath);
5353
}
5454

5555
// 2. Validar SharedFolder o asignar por defecto según OS
@@ -70,21 +70,21 @@ private void PreflightCheck()
7070
_options.SharedFolder = Path.Combine(userDir, "sharpcore-share");
7171
}
7272

73-
KernelLog.Warn($"[Preflight] Carpeta compartida no definida. Usando fallback: {_options.SharedFolder}");
73+
KernelLog.Warn($"[Preflight for Mounting System] Shared folder not found. Using fallback: {_options.SharedFolder}");
7474
}
7575

76-
// 4. Crear carpeta si no existe
76+
// 4 - Create folder if not exists
7777
try
7878
{
7979
if (!Directory.Exists(_options.SharedFolder))
8080
{
8181
Directory.CreateDirectory(_options.SharedFolder);
82-
KernelLog.Info($"[Preflight] Carpeta compartida creada: {_options.SharedFolder}");
82+
KernelLog.Info($"[Preflight] Shared Folder created : {_options.SharedFolder}");
8383
}
8484
}
8585
catch (Exception ex)
8686
{
87-
KernelLog.Panic($"[Preflight] Error al crear carpeta compartida: {ex.Message}");
87+
KernelLog.Panic($"[Preflight QemuConnection line:87] Failure creating the Shared folder for Mount: {ex.Message}");
8888
throw;
8989
}
9090

@@ -93,11 +93,11 @@ private void PreflightCheck()
9393
if (_options.Port == 0)
9494
{
9595
_options.Port = FindFreePort();
96-
KernelLog.Info($"[Preflight] Puerto libre asignado dinámicamente: {_options.Port}");
96+
KernelLog.Info($"[Preflight] Free port dynamically assigned: {_options.Port}");
9797
}
9898
else
9999
{
100-
KernelLog.Info($"[Preflight] Usando puerto especificado: {_options.Port}");
100+
KernelLog.Info($"[Preflight] Using port: {_options.Port}");
101101
}
102102

103103
// Limpieza de QEMU si está usando la imagen específica
@@ -110,16 +110,16 @@ private void PreflightCheck()
110110

111111
proc.Kill(true);
112112
proc.WaitForExit(1500);
113-
KernelLog.Info($"[Preflight] Proceso QEMU colgado eliminado: PID {proc.Id}");
113+
KernelLog.Info($"[Preflight] Zombie QEMU process killed: PID {proc.Id}");
114114

115115
}
116116
catch
117117
{
118-
KernelLog.Warn($"[Preflight] No se pudo eliminar el proceso QEMU con PID {proc.Id}. Puede que ya haya finalizado.");
118+
KernelLog.Warn($"[Preflight] Couldnt kill QEMU process with id: {proc.Id}. Maybe it already finished.");
119119
}
120120
}
121121

122-
KernelLog.Info("[Preflight] Todos los chequeos pasaron correctamente. Ready to boot");
122+
KernelLog.Info("[Preflight] All checks passed. Ready to boot");
123123
}
124124

125125

@@ -131,15 +131,11 @@ public void Start()
131131
if (_options.Port == 0)
132132

133133
_options.Port = FindFreePort();
134-
KernelLog.Info($"[QEMU] Puerto libre asignado dinámicamente: {_options.Port}");
135-
136-
137-
138-
KernelLog.Info($"[QEMU] Puerto libre asignado dinámicamente: {_options.Port}");
134+
KernelLog.Info($"[QEMU] Free port dynamically assigned: {_options.Port}");
139135

140136
PreflightCheck();
141137

142-
KernelLog.Info($"[QEMU] Iniciando VM desde {_options.ImagePath}");
138+
KernelLog.Info($"[QEMU] Starting VM from: {_options.ImagePath}");
143139

144140

145141
string virtfsArg = string.Empty;
@@ -196,21 +192,21 @@ public void Start()
196192
_vmProcess.BeginErrorReadLine();
197193
}
198194

199-
KernelLog.Info($"[QEMU] Esperando a que el puerto {_options.Port} esté disponible...");
195+
KernelLog.Info($"[QEMU] Waiting for port: {_options.Port}");
200196
WaitForPort("127.0.0.1", _options.Port);
201197

202198
if (_options.UseSnapshot)
203199
{
204200
_vmProcess.WaitForExit();
205-
KernelLog.Info("[QEMU] VM finalizó correctamente.");
201+
KernelLog.Info("[QEMU] VM finished succesfully.");
206202
}
207203
}
208204

209205
public void Send(string command)
210206
{
211207
if (_options == null)
212208
{
213-
KernelLog.Panic("[Preflight] Opciones de QEMU no definidas.");
209+
KernelLog.Panic("[Preflight] QEMU options undefined.");
214210
throw new ArgumentNullException(nameof(_options));
215211
}
216212

@@ -222,7 +218,7 @@ public void Dispose()
222218
{
223219
if (_vmProcess != null && !_vmProcess.HasExited)
224220

225-
KernelLog.Info("[QEMU] Apagando la VM");
221+
KernelLog.Info("[QEMU] Shooting off VM");
226222
_vmProcess.Kill(true);
227223

228224
}
@@ -239,11 +235,11 @@ private void WaitForPort(string host, int port, int timeoutSeconds = 15)
239235

240236
if (_options == null)
241237
{
242-
KernelLog.Panic("[Preflight] Opciones de QEMU no definidas.");
238+
KernelLog.Panic("[Preflight] QEMU otions undefined.");
243239
throw new ArgumentNullException(nameof(_options));
244240
}
245241

246-
KernelLog.Info($"[QEMU] VM escuchando en http://127.0.0.1:{_options.Port}");
242+
KernelLog.Info($"[QEMU] VM listening on: http://127.0.0.1:{_options.Port}");
247243
return;
248244
}
249245
catch
@@ -252,7 +248,7 @@ private void WaitForPort(string host, int port, int timeoutSeconds = 15)
252248
}
253249
}
254250

255-
KernelLog.Panic("[QEMU] Timeout esperando a que la VM esté online");
251+
KernelLog.Panic("[QEMU] Timeout reached. VM didnt start on time");
256252
throw new Exception("QEMU VM did not start in time.");
257253
}
258254

@@ -265,7 +261,7 @@ private int FindFreePort(int startPort = 5000) // Busca un puerto libre a partir
265261

266262
if (port == 0)
267263
{
268-
KernelLog.Panic("[QEMU] No se pudo encontrar un puerto libre.");
264+
KernelLog.Panic("[QEMU] Couldnt find free port.");
269265
throw new Exception("No free port found for QEMU.");
270266
}
271267

@@ -285,11 +281,17 @@ public bool IsHostshareMounted()
285281

286282
if (!string.IsNullOrWhiteSpace(result) && result.Contains("9p"))
287283
{
288-
KernelLog.Info("[MountCheck] Montaje de carpeta hostshare OK.");
284+
Console.ForegroundColor = ConsoleColor.Green;
285+
Console.WriteLine("OK");
286+
Console.ResetColor();
287+
KernelLog.Info("[MountCheck] Shared folder succesfully mounted.");
289288
return true;
290289
}
291290
else
292291
{
292+
Console.ForegroundColor = ConsoleColor.Red;
293+
Console.WriteLine("FAIL");
294+
Console.ResetColor();
293295
KernelLog.Warn("[MountCheck] Montaje no detectado en /mnt/hostshare.");
294296
return false;
295297
}

0 commit comments

Comments
 (0)