[ros-diffs] [cwittich] 32898: add EMU_TYPE_XEN and initial Xen detection (including hvm support)

cwittich at svn.reactos.org cwittich at svn.reactos.org
Wed Apr 9 18:29:14 CEST 2008


Author: cwittich
Date: Wed Apr  9 11:29:14 2008
New Revision: 32898

URL: http://svn.reactos.org/svn/reactos?rev=32898&view=rev
Log:
add EMU_TYPE_XEN and initial Xen detection (including hvm support)

Modified:
    trunk/reactos/tools/sysreg/rosboot_test.cpp
    trunk/reactos/tools/sysreg/rosboot_test.h

Modified: trunk/reactos/tools/sysreg/rosboot_test.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/rosboot_test.cpp?rev=32898&r1=32897&r2=32898&view=diff
==============================================================================
--- trunk/reactos/tools/sysreg/rosboot_test.cpp [iso-8859-1] (original)
+++ trunk/reactos/tools/sysreg/rosboot_test.cpp [iso-8859-1] Wed Apr  9 11:29:14 2008
@@ -53,6 +53,7 @@
 	string RosBootTest::ROS_EMU_TYPE= "ROS_EMU_TYPE";
 	string RosBootTest::EMU_TYPE_QEMU = "qemu";
 	string RosBootTest::EMU_TYPE_VMWARE = "vmware";
+	string RosBootTest::EMU_TYPE_XEN = "xen";
 	string RosBootTest::ROS_HDD_IMAGE= "ROS_HDD_IMAGE";
 	string RosBootTest::ROS_CD_IMAGE = "ROS_CD_IMAGE";
 	string RosBootTest::ROS_MAX_TIME = "ROS_MAX_TIME";
@@ -64,6 +65,7 @@
 	string RosBootTest::ROS_EMU_KILL = "ROS_EMU_KILL";
 	string RosBootTest::ROS_EMU_MEM = "ROS_EMU_MEM";
 	string RosBootTest::ROS_BOOT_CMD = "ROS_BOOT_CMD";
+	string RosBootTest::XEN_CONFIG_FILE = "XEN_CONFIG_FILE";
 
 #ifdef __LINUX__
     string RosBootTest::ROS_EMU_PATH = "ROS_EMU_PATH_LIN";
@@ -621,13 +623,58 @@
         m_DataSource = new NamedPipeReader();
         if (!executeBootCmd())
         {
+
             cerr << "Error: failed to launch emulator with: " << m_BootCmd << endl;
             return false;
         }
 
         return true;
     }
-
+	
+//---------------------------------------------------------------------------------------
+	bool RosBootTest::xenGetCaps()
+	{
+		FILE *fp;
+		int ch, i;
+		char buffer[2048];
+
+		fp = popen("xm info", "r");
+		if (!fp)
+		{
+			cerr << "Error getting Xen caps." << endl;
+			return false;
+		}
+		for (i=0;(i<2049)&&(feof(fp) == 0 && ((ch = fgetc(fp)) != -1)); i++)
+		{
+			buffer[i] = (char) ch;
+		}
+		buffer[i] = '\0';
+		pclose(fp);
+
+		if (strstr(buffer, "hvm") == 0)
+		{
+			cerr << "No hvm support detected!" << endl;
+			return false;
+		}
+		else
+		{
+			return true;
+		}
+
+	}
+
+//---------------------------------------------------------------------------------------
+    bool RosBootTest::configureXen()
+    {
+		if (!xenGetCaps())
+		{
+			return false;
+		}
+		
+        cerr << "Xen isn't supported yet." << endl;
+		
+		return false;
+    }
 //---------------------------------------------------------------------------------------
     bool RosBootTest::configureVmWare()
     {
@@ -637,17 +684,25 @@
 //---------------------------------------------------------------------------------------
     bool RosBootTest::readConfigurationValues(ConfigParser &conf_parser)
     {
-#if 0
+
         if (!conf_parser.getStringValue(RosBootTest::ROS_EMU_TYPE, m_EmuType))
         {
             cerr << "Error: ROS_EMU_TYPE is not set" << endl;
             return false;
         }
-#endif
+
+		if (ROS_EMU_TYPE == "xen")
+		{
+			if (!conf_parser.getStringValue(RosBootTest::XEN_CONFIG_FILE, m_XenConfig))
+			{
+				cerr << "Error: XEN_CONFIG_FILE is not set" << endl;
+				return false;
+			}
+		}
 
         if (!conf_parser.getStringValue(RosBootTest::ROS_EMU_PATH, m_EmuPath))
         {
-            cerr << "Error: ROS_EMU_PATH is not set" << endl;
+            cerr << "Error: ROS_EMU_PATH_[LIN/WIN] is not set" << endl;
             return false;
         }
         if (!m_HDDImage.length())
@@ -702,7 +757,7 @@
         {
             return false;
         }
-#if 0
+
         if (m_EmuType == EMU_TYPE_QEMU)
         {
             if (!configureQemu())
@@ -719,6 +774,14 @@
                 return false;
             }
         }
+        else if (m_EmuType == EMU_TYPE_XEN)
+        {
+            if (!configureXen())
+            {
+                cerr << "Error: failed to configure xen" << endl;
+                return false;
+            }
+        }
         else
         {
             ///
@@ -727,13 +790,6 @@
             cerr << "Error: ROS_EMU_TYPE value is not supported:" << m_EmuType << "=" << EMU_TYPE_QEMU << endl;
             return false;
         }
-#else
-        if (!configureQemu())
-        {
-            cerr << "Error: failed to configure qemu" << endl;
-            return false;
-        }
-#endif
 
         if (m_DelayRead)
         {

Modified: trunk/reactos/tools/sysreg/rosboot_test.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/sysreg/rosboot_test.h?rev=32898&r1=32897&r2=32898&view=diff
==============================================================================
--- trunk/reactos/tools/sysreg/rosboot_test.h [iso-8859-1] (original)
+++ trunk/reactos/tools/sysreg/rosboot_test.h [iso-8859-1] Wed Apr  9 11:29:14 2008
@@ -43,6 +43,7 @@
 		static string ROS_EMU_TYPE;
 		static string EMU_TYPE_QEMU;
 		static string EMU_TYPE_VMWARE;
+		static string EMU_TYPE_XEN;
 		static string ROS_EMU_PATH;
 		static string ROS_HDD_IMAGE;
 		static string ROS_CD_IMAGE;
@@ -55,6 +56,7 @@
 		static string ROS_EMU_KILL;
 		static string ROS_EMU_MEM;
 		static string ROS_BOOT_CMD;
+		static string XEN_CONFIG_FILE;
 
 //---------------------------------------------------------------------------------------
 ///
@@ -107,8 +109,10 @@
     bool readConfigurationValues(ConfigParser & conf_parser);
     bool configureQemu();
     bool configureVmWare();
+	bool configureXen();
     bool hasQemuNoRebootOption();
     void cleanup();
+	bool xenGetCaps();
 //---------------------------------------------------------------------------------------
 ///
 /// dumpCheckpoints
@@ -155,6 +159,7 @@
     string m_Src;
     string m_DebugPort;
     string m_PidFile;
+	string m_XenConfig;
 
     DataSource * m_DataSource;
     OsSupport::ProcessID m_Pid;



More information about the Ros-diffs mailing list