Author: janderwald
Date: Mon Jul 23 00:41:51 2007
New Revision: 27782
URL:
http://svn.reactos.org/svn/reactos?rev=27782&view=rev
Log:
- make sysreg working on linux
Modified:
trunk/reactos/tools/sysreg/data_source.h
trunk/reactos/tools/sysreg/namedpipe_reader.cpp
trunk/reactos/tools/sysreg/namedpipe_reader.h
trunk/reactos/tools/sysreg/pipe_reader.cpp
trunk/reactos/tools/sysreg/pipe_reader.h
trunk/reactos/tools/sysreg/rosboot_test.cpp
trunk/reactos/tools/sysreg/rosboot_test.h
trunk/reactos/tools/sysreg/txtmode.cfg
trunk/reactos/tools/sysreg/user_types.h
Modified: trunk/reactos/tools/sysreg/data_source.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/data_source.h…
==============================================================================
--- trunk/reactos/tools/sysreg/data_source.h (original)
+++ trunk/reactos/tools/sysreg/data_source.h Mon Jul 23 00:41:51 2007
@@ -33,6 +33,8 @@
virtual bool closeSource() = 0;
virtual bool readSource(std::vector<string> & vect) = 0;
+
+ virtual bool isSourceOpen() = 0;
}; // end of class DataSource
Modified: trunk/reactos/tools/sysreg/namedpipe_reader.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/namedpipe_rea…
==============================================================================
--- trunk/reactos/tools/sysreg/namedpipe_reader.cpp (original)
+++ trunk/reactos/tools/sysreg/namedpipe_reader.cpp Mon Jul 23 00:41:51 2007
@@ -31,6 +31,11 @@
}
+ bool NamedPipeReader::isSourceOpen()
+ {
+ return true;
+ }
+
//---------------------------------------------------------------------------------------
bool NamedPipeReader::openSource(const string & PipeCmd)
Modified: trunk/reactos/tools/sysreg/namedpipe_reader.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/namedpipe_rea…
==============================================================================
--- trunk/reactos/tools/sysreg/namedpipe_reader.h (original)
+++ trunk/reactos/tools/sysreg/namedpipe_reader.h Mon Jul 23 00:41:51 2007
@@ -105,7 +105,7 @@
/// Description: returns true if the pipe has reached end of file. The caller should
call
/// closePipe if this function returns true
- bool isEof();
+ virtual bool isSourceOpen();
protected:
//---------------------------------------------------------------------------------------
Modified: trunk/reactos/tools/sysreg/pipe_reader.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/pipe_reader.c…
==============================================================================
--- trunk/reactos/tools/sysreg/pipe_reader.cpp (original)
+++ trunk/reactos/tools/sysreg/pipe_reader.cpp Mon Jul 23 00:41:51 2007
@@ -36,7 +36,9 @@
cerr << "PipeReader::openPipe> pipe already open" << endl;
return false;
}
- //
+
+ cerr << "cmd>" << PipeCmd << endl;
+
m_File = popen(PipeCmd.c_str(), "r"); //AccessMode.c_str());
if (m_File)
{
@@ -72,7 +74,7 @@
//---------------------------------------------------------------------------------------
- bool PipeReader::isEof()
+ bool PipeReader::isSourceOpen()
{
return feof(m_File);
}
Modified: trunk/reactos/tools/sysreg/pipe_reader.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/pipe_reader.h…
==============================================================================
--- trunk/reactos/tools/sysreg/pipe_reader.h (original)
+++ trunk/reactos/tools/sysreg/pipe_reader.h Mon Jul 23 00:41:51 2007
@@ -61,7 +61,7 @@
/// w ... allows writing to the pipe
/// @return bool
- bool openSource(const string & PipeCmd);
+ virtual bool openSource(const string & PipeCmd);
//---------------------------------------------------------------------------------------
///
@@ -71,7 +71,7 @@
///
/// @return bool
- bool closeSource();
+ virtual bool closeSource();
//---------------------------------------------------------------------------------------
///
@@ -92,7 +92,7 @@
/// Description: returns true if the pipe has reached end of file. The caller should
call
/// closePipe if this function returns true
- bool isEof();
+ virtual bool isSourceOpen();
protected:
FILE * m_File;
Modified: trunk/reactos/tools/sysreg/rosboot_test.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/rosboot_test.…
==============================================================================
--- trunk/reactos/tools/sysreg/rosboot_test.cpp (original)
+++ trunk/reactos/tools/sysreg/rosboot_test.cpp Mon Jul 23 00:41:51 2007
@@ -44,20 +44,21 @@
using std::ofstream;
#endif
- string RosBootTest::ROS_EMU_TYPE= _T("ROS_EMU_TYPE");
- string RosBootTest::EMU_TYPE_QEMU = _T("qemu");
- string RosBootTest::EMU_TYPE_VMWARE = _T("vmware");
- string RosBootTest::ROS_EMU_PATH = _T("ROS_EMU_PATH");
- string RosBootTest::ROS_HDD_IMAGE= _T("ROS_HDD_IMAGE");
- string RosBootTest::ROS_CD_IMAGE = _T("ROS_CD_IMAGE");
- string RosBootTest::ROS_MAX_TIME = _T("ROS_MAX_TIME");
- string RosBootTest::ROS_LOG_FILE = _T("ROS_LOG_FILE");
- string RosBootTest::ROS_SYM_DIR = _T("ROS_SYM_DIR");
+ string RosBootTest::ROS_EMU_TYPE= _T("ROS_EMU_TYPE");
+ string RosBootTest::EMU_TYPE_QEMU = _T("qemu");
+ string RosBootTest::EMU_TYPE_VMWARE = _T("vmware");
+ string RosBootTest::ROS_EMU_PATH = _T("ROS_EMU_PATH");
+ string RosBootTest::ROS_HDD_IMAGE= _T("ROS_HDD_IMAGE");
+ string RosBootTest::ROS_CD_IMAGE = _T("ROS_CD_IMAGE");
+ string RosBootTest::ROS_MAX_TIME = _T("ROS_MAX_TIME");
+ string RosBootTest::ROS_LOG_FILE = _T("ROS_LOG_FILE");
+ string RosBootTest::ROS_SYM_DIR = _T("ROS_SYM_DIR");
string RosBootTest::ROS_DELAY_READ = _T("ROS_DELAY_READ");
string RosBootTest::ROS_SYSREG_CHECKPOINT = _T("SYSREG_CHECKPOINT:");
string RosBootTest::ROS_CRITICAL_IMAGE = _T("ROS_CRITICAL_IMAGE");
string RosBootTest::ROS_EMU_KILL = _T("ROS_EMU_KILL");
- string RosBootTest::ROS_EMU_MEM = _T("ROS_EMU_MEM");
+ string RosBootTest::ROS_EMU_MEM = _T("ROS_EMU_MEM");
+ string RosBootTest::ROS_BOOT_CMD = _T("ROS_BOOT_CMD");
//---------------------------------------------------------------------------------------
RosBootTest::RosBootTest() : m_MaxTime(0.0), m_DelayRead(0)
@@ -102,10 +103,18 @@
string::size_type pos;
bool bootfromcd = false;
-
+ bool bootcmdprovided = false;
if (m_CDImage != _T("") )
{
bootfromcd = true;
+ }
+
+ if (m_BootCmd != _T("") )
+ {
+ ///
+ /// boot cmd is provided already
+ ///
+ bootcmdprovided = true;
}
#ifdef __LINUX__
@@ -129,6 +138,7 @@
return false;
}
string qemuimgdir = qemupath;
+ m_HDDImage = _T("ros.img");
#ifdef __LINUX___
qemuimgdir += _T("qemu-img");
#else
@@ -138,33 +148,92 @@
/// FIXME
/// call qemu-img to create the tool
///
- cerr << "Creating HDD Image ..." << endl;
- }
-
- if (m_MaxMem == "")
- {
- // default to 64M
- m_MaxMem = "64";
- }
- if (bootfromcd)
- {
- m_BootCmd = m_EmuPath + _T(" -serial pipe:qemu -L ") + qemupath +
_T(" -m ") + m_MaxMem + _T(" -hda ") + m_HDDImage + _T(" -boot d
-cdrom ") + m_CDImage;
- }
- else
- {
- m_BootCmd = m_EmuPath + _T(" -L ") + qemupath + _T(" -m
") + m_MaxMem + _T(" -boot c -serial pipe:sysreg");
- }
-
- if (m_KillEmulator == _T("yes"))
- {
+ cerr << "Creating HDD Image ..." << qemuimgdir <<
endl;
+ }
+
+ if (!bootcmdprovided)
+ {
+ if (m_MaxMem == "")
+ {
+ // default to 64M
+ m_MaxMem = "64";
+ }
+ string pipe;
#ifdef __LINUX__
- m_BootCmd += _T(" -pidfile pid.txt");
+ pipe = _T("stdio");
+ m_Src = _T("");
+#else
+ pipe = _T("pipe:qemu");
+ m_Src = _T("\\\\.\\pipe\\qemu");
+#endif
+
+
+ if (bootfromcd)
+ {
+ m_BootCmd = m_EmuPath + _T(" -serial ") + pipe + _T(" -m
") + m_MaxMem + _T(" -hda ") + m_HDDImage + _T(" -boot d -cdrom
") + m_CDImage;
+ }
+ else
+ {
+ m_BootCmd = m_EmuPath + _T(" -L ") + qemupath + _T(" -m
") + m_MaxMem + _T(" -boot c -serial ") + pipe;
+ }
+
+ if (m_KillEmulator == _T("yes"))
+ {
+#ifdef __LINUX__
+ m_BootCmd += _T(" -pidfile pid.txt");
#endif
- }
- else
- {
- m_BootCmd += _T(" -no-reboot ");
- }
+ }
+ else
+ {
+ m_BootCmd += _T(" -no-reboot ");
+ }
+ }
+ else
+ {
+ string::size_type pos = m_BootCmd.find(_T("-serial"));
+ if (pos != string::npos)
+ {
+ string pipe = m_BootCmd.substr(pos + 7, m_BootCmd.size() - pos -7);
+ pos = pipe.find(_T("pipe:"));
+ if (pos == 0)
+ {
+#ifdef __LINUX__
+ cerr << "Error: popen doesnot support reading from pipe" <<
endl;
+ return false;
+#else
+ pipe = pipe.substr(pos + 5, pipe.size() - pos - 5);
+ pos = pipe.find(_T(" "));
+ if (pos != string::npos)
+ {
+ m_Src = _T("\\\\.\\pipe\\") + pipe.substr(0, pos);
+ }
+ else
+ {
+ m_Src = _T("\\\\.\\pipe\\" + pipe;
+ }
+#endif
+ }
+ else
+ {
+ pos = pipe.find(_T("stdio"));
+ if (pos == 0)
+ {
+#ifdef __LINUX__
+ m_Src = m_BootCmd;
+#else
+ cerr << "Error: sysreg doesnot support reading stdio" <<
endl;
+ return false;
+#endif
+
+ }
+
+
+ }
+
+ }
+
+
+ }
cerr << "Opening Data Source:" << m_BootCmd << endl;
@@ -174,8 +243,6 @@
m_Src = m_BootCmd;
#else
m_DataSource = new NamedPipeReader();
- m_Src = _T("\\\\.\\pipe\\qemu");
-
if (!executeBootCmd())
{
cerr << "Error: failed to launch emulator with: " <<
m_BootCmd << endl;
@@ -217,9 +284,26 @@
conf_parser.getStringValue (RosBootTest::ROS_CRITICAL_IMAGE, m_CriticalImage);
conf_parser.getStringValue (RosBootTest::ROS_EMU_KILL, m_KillEmulator);
conf_parser.getStringValue (RosBootTest::ROS_EMU_MEM, m_MaxMem);
+ conf_parser.getStringValue (RosBootTest::ROS_BOOT_CMD, m_BootCmd);
return true;
}
+//---------------------------------------------------------------------------------------
+ void RosBootTest::cleanup()
+ {
+ m_DataSource->closeSource();
+ if (m_KillEmulator == "yes")
+ {
+ OsSupport::sleep(3 * CLOCKS_PER_SEC);
+ if (m_Pid)
+ {
+ OsSupport::terminateProcess (m_Pid);
+ }
+ }
+ delete m_DataSource;
+
+ }
+
//---------------------------------------------------------------------------------------
bool RosBootTest::execute(ConfigParser &conf_parser)
{
@@ -252,28 +336,24 @@
cerr << "Error: ROS_EMU_TYPE value is not supported:"
<< m_EmuType << "=" << EMU_TYPE_QEMU << endl;
return false;
}
-
+#ifndef __LINUX__
OsSupport::sleep(500);
-
+#endif
+
+ assert(m_DataSource != 0);
if (!m_DataSource->openSource(m_Src))
{
cerr << "Error: failed to open data source with " <<
m_Src << endl;
- return false;
- }
-
- OsSupport::sleep(3000);
-
+ cleanup();
+ return false;
+ }
+
+#ifndef __LINUX__
+ OsSupport::sleep(3000); //FIXME
+#endif
bool ret = analyzeDebugData();
-
- m_DataSource->closeSource();
- if (m_KillEmulator == "yes")
- {
- OsSupport::sleep(3 * CLOCKS_PER_SEC);
- if (m_Pid)
- {
- OsSupport::terminateProcess (m_Pid);
- }
- }
+ cleanup();
+
return ret;
}
//---------------------------------------------------------------------------------------
Modified: trunk/reactos/tools/sysreg/rosboot_test.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/rosboot_test.…
==============================================================================
--- trunk/reactos/tools/sysreg/rosboot_test.h (original)
+++ trunk/reactos/tools/sysreg/rosboot_test.h Mon Jul 23 00:41:51 2007
@@ -35,21 +35,21 @@
{
public:
- static string ROS_EMU_TYPE;
- static string EMU_TYPE_QEMU;
- static string EMU_TYPE_VMWARE;
- static string ROS_EMU_PATH;
- static string ROS_HDD_IMAGE;
- static string ROS_CD_IMAGE;
- static string ROS_MAX_TIME;
- static string ROS_LOG_FILE;
- static string ROS_SYM_DIR;
- static string ROS_DELAY_READ;
- static string ROS_SYSREG_CHECKPOINT;
- static string ROS_CRITICAL_IMAGE;
- static string ROS_EMU_KILL;
- static string ROS_EMU_MEM;
-
+ static string ROS_EMU_TYPE;
+ static string EMU_TYPE_QEMU;
+ static string EMU_TYPE_VMWARE;
+ static string ROS_EMU_PATH;
+ static string ROS_HDD_IMAGE;
+ static string ROS_CD_IMAGE;
+ static string ROS_MAX_TIME;
+ static string ROS_LOG_FILE;
+ static string ROS_SYM_DIR;
+ static string ROS_DELAY_READ;
+ static string ROS_SYSREG_CHECKPOINT;
+ static string ROS_CRITICAL_IMAGE;
+ static string ROS_EMU_KILL;
+ static string ROS_EMU_MEM;
+ static string ROS_BOOT_CMD;
//---------------------------------------------------------------------------------------
///
@@ -92,7 +92,7 @@
bool readConfigurationValues(ConfigParser & conf_parser);
bool configureQemu();
bool configureVmWare();
-
+ void cleanup();
//---------------------------------------------------------------------------------------
///
/// dumpCheckpoints
Modified: trunk/reactos/tools/sysreg/txtmode.cfg
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/txtmode.cfg?r…
==============================================================================
--- trunk/reactos/tools/sysreg/txtmode.cfg (original)
+++ trunk/reactos/tools/sysreg/txtmode.cfg Mon Jul 23 00:41:51 2007
@@ -10,8 +10,8 @@
;
; This variable sets the path to the emulator
;
-;ROS_EMU_PATH=/usr/bin/qemu
-ROS_EMU_PATH=E:\reactos\qemu\qemu.exe
+ROS_EMU_PATH=/usr/bin/qemu
+;ROS_EMU_PATH=E:\reactos\qemu\qemu.exe
; ROS_HDD_IMAGE
@@ -19,8 +19,8 @@
; The hdd image to use for running the emulator. If this variable is not
; set, SysReg will create a HDD with name "ros.img" using the qemu-img tool. It
will search
; this tool in the directory of emulator and abort if the tool cannot be found
-
-ROS_HDD_IMAGE=E:\reactos\qemu\ReactOS.hd
+ROS_HDD_IMAGE=~/reactos/qemu/ReactOS.hd
+;ROS_HDD_IMAGE=E:\reactos\qemu\ReactOS.hd
; ROS_CD_IMAGE
;
@@ -28,8 +28,8 @@
; an ReactOS unattended installation disk. If this variable is not set, SysReg lets the
emulator boot
; from harddisk.
;
-
-ROS_CD_IMAGE=E:\reactos\qemu\Reactos.iso
+ROS_CD_IMAGE=~/reactos/qemu/bootcd.iso
+;ROS_CD_IMAGE=E:\reactos\qemu\Reactos.iso
;-------------------------------------------------------------------------------------------
; Additional Options
@@ -92,4 +92,11 @@
;
; ROS_EMU_MEM=64
+; ROS_BOOT_CMD
+;
+; Sysreg normally builds the boot command from ROS_EMU_PATH and ROS_CD_IMAGE etc... If
you want to override
+; all settings set this value
+;
+; ROS_BOOT_CMD=/usr/bin/qemu -serial stdio -m 64 -hda ~/reactos/qemu/ReactOS.hd -boot d
-cdrom ~/reactos/qemu/bootcd.iso
+; -no-reboot
Modified: trunk/reactos/tools/sysreg/user_types.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/user_types.h?…
==============================================================================
--- trunk/reactos/tools/sysreg/user_types.h (original)
+++ trunk/reactos/tools/sysreg/user_types.h Mon Jul 23 00:41:51 2007
@@ -33,6 +33,7 @@
#define _fgetts fgets
#define _tgetenv getenv
#define _tmain main
+ #define _tcstol strtol
#endif
typedef std::basic_string<TCHAR> string;