Author: janderwald Date: Tue Aug 28 22:41:08 2007 New Revision: 28624
URL: http://svn.reactos.org/svn/reactos?rev=28624&view=rev Log: - silence a few debug messages - implement creating of disk images with qemu-img for windows
Modified: trunk/reactos/tools/sysreg/conf_parser.cpp trunk/reactos/tools/sysreg/os_support.cpp trunk/reactos/tools/sysreg/os_support.h trunk/reactos/tools/sysreg/rosboot_test.cpp
Modified: trunk/reactos/tools/sysreg/conf_parser.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/conf_parser.cp... ============================================================================== --- trunk/reactos/tools/sysreg/conf_parser.cpp (original) +++ trunk/reactos/tools/sysreg/conf_parser.cpp Tue Aug 28 22:41:08 2007 @@ -84,7 +84,7 @@ ConfigMap::iterator it = m_Map.find (ConfVariable); if (it == m_Map.end ()) { - cerr << "ConfigParser::getValue failed to find " << ConfVariable << endl; + //cerr << "ConfigParser::getValue failed to find " << ConfVariable << endl; return false; }
Modified: trunk/reactos/tools/sysreg/os_support.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/os_support.cpp... ============================================================================== --- trunk/reactos/tools/sysreg/os_support.cpp (original) +++ trunk/reactos/tools/sysreg/os_support.cpp Tue Aug 28 22:41:08 2007 @@ -25,36 +25,66 @@ return ret; }
- OsSupport::ProcessID OsSupport::createProcess(TCHAR *procname, int procargsnum, TCHAR **procargs) + OsSupport::ProcessID OsSupport::createProcess(TCHAR *procname, int procargsnum, TCHAR **procargs, bool wait) { STARTUPINFO siStartInfo; PROCESS_INFORMATION piProcInfo; OsSupport::ProcessID pid; - - UNREFERENCED_PARAMETER(procargsnum); - UNREFERENCED_PARAMETER(procargs); - + DWORD length = 0; + TCHAR * szBuffer; + TCHAR * cmd; ZeroMemory(&siStartInfo, sizeof(STARTUPINFO)); ZeroMemory(&piProcInfo, sizeof(PROCESS_INFORMATION));
siStartInfo.cb = sizeof(STARTUPINFO); siStartInfo.wShowWindow = SW_SHOWNORMAL; siStartInfo.dwFlags = STARTF_USESHOWWINDOW; + + if (procargsnum) + { + for (int i = 0; i < procargsnum; i++) + { + length += _tcslen(procargs[i]); + }
- LPTSTR command = _tcsdup(procname); + length += procargsnum; + szBuffer = (TCHAR*)malloc(length * sizeof(TCHAR)); + length = 0; + for (int i = 0; i < procargsnum; i++) + { + _tcscpy(&szBuffer[length], procargs[i]); + length += _tcslen(procargs[i]); + szBuffer[length] = _T(' '); + length++; + } + length = _tcslen(procname) + _tcslen(szBuffer) + 2; + cmd = (TCHAR*)malloc(length * sizeof(TCHAR)); + _tcscpy(cmd, procname); + _tcscat(cmd, _T(" ")); + _tcscat(cmd, szBuffer); + free(szBuffer); + } + else + { + cmd = _tcsdup(procname);
- if (!CreateProcess(NULL, procname, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &siStartInfo, &piProcInfo)) + } + if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &siStartInfo, &piProcInfo)) { - cerr << "Error: CreateProcess failed " << command <<endl; + cerr << "Error: CreateProcess failed " << cmd << endl; pid = 0; } else { pid = piProcInfo.dwProcessId; + if (wait) + { + WaitForSingleObject(piProcInfo.hThread, INFINITE); + } CloseHandle(piProcInfo.hProcess); CloseHandle(piProcInfo.hThread); } - free(command); + free(cmd); return pid; } void OsSupport::sleep(long value)
Modified: trunk/reactos/tools/sysreg/os_support.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/os_support.h?r... ============================================================================== --- trunk/reactos/tools/sysreg/os_support.h (original) +++ trunk/reactos/tools/sysreg/os_support.h Tue Aug 28 22:41:08 2007 @@ -62,7 +62,7 @@ /// ///
- static ProcessID createProcess(TCHAR * procname, int procargsnum, TCHAR ** procargs); + static ProcessID createProcess(TCHAR * procname, int procargsnum, TCHAR ** procargs, bool wait);
//--------------------------------------------------------------------------------------- ///
Modified: trunk/reactos/tools/sysreg/rosboot_test.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/rosboot_test.c... ============================================================================== --- trunk/reactos/tools/sysreg/rosboot_test.cpp (original) +++ trunk/reactos/tools/sysreg/rosboot_test.cpp Tue Aug 28 22:41:08 2007 @@ -15,6 +15,7 @@ //#include "sym_file.h" #include "file_reader.h" #include "os_support.h" +#include "env_var.h"
#include <iostream> #include <vector> @@ -36,6 +37,7 @@ /* using System_::SymbolFile; */ using System_::FileReader; using System_::OsSupport; + using System_::EnvironmentVariable;
#ifdef UNICODE using std::wofstream; @@ -74,7 +76,7 @@ //--------------------------------------------------------------------------------------- bool RosBootTest::executeBootCmd() { - m_Pid = OsSupport::createProcess ((TCHAR*)m_BootCmd.c_str(), 0, NULL); + m_Pid = OsSupport::createProcess ((TCHAR*)m_BootCmd.c_str(), 0, NULL, false); if (!m_Pid) { cerr << "Error: failed to launch boot cmd" << m_BootCmd << endl; @@ -140,15 +142,34 @@ string qemuimgdir = qemupath; m_HDDImage = _T("ros.img"); #ifdef __LINUX___ - qemuimgdir += _T("qemu-img"); + qemuimgdir += _T("\qemu-img"); #else - qemuimgdir += _T("qemu-img.exe"); + qemuimgdir += _T("\qemu-img.exe"); #endif /// /// FIXME /// call qemu-img to create the tool /// - cerr << "Creating HDD Image ..." << qemuimgdir << endl; + TCHAR * options[] = { + _T("create"), + NULL, + _T("100M"), + NULL + }; + string output = "output-i386"; + EnvironmentVariable::getValue(_T("ROS_OUTPUT"), output); + output += _T("\ros.hd"); + options[1] = (TCHAR*)output.c_str(); + + cerr << "Creating HDD Image ..." << output << endl; + if (OsSupport::createProcess ((TCHAR*)qemuimgdir.c_str(), 3, options, true)) + { + m_HDDImage = output; + } + else + { + return false; + } }
if (!bootcmdprovided) @@ -170,11 +191,11 @@
if (bootfromcd) { - m_BootCmd = m_EmuPath + _T(" -serial ") + pipe + _T(" -m ") + m_MaxMem + _T(" -hda ") + m_HDDImage + _T(" -boot d -cdrom ") + m_CDImage; + m_BootCmd = m_EmuPath + _T(" -serial ") + pipe + _T(" -m ") + m_MaxMem + _T(" -hda ") + m_HDDImage + _T(" -boot d -cdrom ") + m_CDImage + _T(" -L ") + qemupath; } else { - m_BootCmd = m_EmuPath + _T(" -L ") + qemupath + _T(" -m ") + m_MaxMem + _T(" -boot c -serial ") + pipe; + m_BootCmd = m_EmuPath + _T(" -L ") + qemupath + _T(" -m ") + m_MaxMem + _T(" -boot c -serial ") + pipe + _T(" -hda ") + m_HDDImage; }
if (m_KillEmulator == _T("yes"))