public static string Save(MachineProfile profile) { string log = Machine.WriteProfileData(profile); string path = Path.Combine(ProfileDirectory, profile.Name + ".json"); Directory.CreateDirectory(ProfileDirectory); File.WriteAllText(path, JsonConvert.SerializeObject(profile)); return(log); }
private static void WriteDefaultFiles(MachineProfile profile) { DirectoryInfo dir = Directory.CreateDirectory(Path.Combine(profile.ProfileRoot, "configs", "cpu", "extensions")); CopyDir(VMCORE_DEFAULT_LIB_PATH, dir.FullName); DirectoryInfo biosDir = Directory.CreateDirectory(Path.Combine(profile.ProfileRoot, "bios")); CopyDir(VMCORE_DEFAULT_BIOS_DIR, biosDir.FullName); }
public static string WriteProfileData(MachineProfile profile) { WriteDefaultFiles(profile); ProcessStartInfo psi = new ProcessStartInfo( VIS_EXECUTABLE, $"--root {profile.ProfileRoot} write-default" ); psi.RedirectStandardOutput = true; psi.CreateNoWindow = true; psi.UseShellExecute = false; Process p = Process.Start(psi); p.WaitForExit(); return(p.StandardOutput.ReadToEnd()); }
public static Machine Create(MachineProfile profile) { ProcessStartInfo psi = new ProcessStartInfo( VIS_EXECUTABLE, $"--root {profile.ProfileRoot} run -run:i {profile.BiosPath} {profile.StartArguments}" ); psi.WorkingDirectory = profile.ProfileRoot; return(new Machine( profile, () => { Process p = Process.Start(psi); p.EnableRaisingEvents = true; return p; })); }
private Machine(MachineProfile profile, Func <Process> proc) { Profile = profile; m_ProcSpawner = proc; }