- silence a few debug messages

- implement creating of disk images with qemu-img for windows

svn path=/trunk/; revision=28624
This commit is contained in:
Johannes Anderwald 2007-08-28 18:41:08 +00:00
parent df0b2c80d4
commit 2d0f7aa512
4 changed files with 68 additions and 17 deletions

View file

@ -84,7 +84,7 @@ namespace Sysreg_
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;
}

View file

@ -25,36 +25,66 @@ namespace System_
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)

View file

@ -62,7 +62,7 @@ namespace System_
///
///
static ProcessID createProcess(TCHAR * procname, int procargsnum, TCHAR ** procargs);
static ProcessID createProcess(TCHAR * procname, int procargsnum, TCHAR ** procargs, bool wait);
//---------------------------------------------------------------------------------------
///

View file

@ -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 @@ namespace Sysreg_
/* using System_::SymbolFile; */
using System_::FileReader;
using System_::OsSupport;
using System_::EnvironmentVariable;
#ifdef UNICODE
using std::wofstream;
@ -74,7 +76,7 @@ namespace Sysreg_
//---------------------------------------------------------------------------------------
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 @@ namespace Sysreg_
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 @@ namespace Sysreg_
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"))