Author: cwittich
Date: Mon Sep 1 07:20:29 2008
New Revision: 35852
URL:
http://svn.reactos.org/svn/reactos?rev=35852&view=rev
Log:
-fix some bugs
-create a blank hdd image before each run
Modified:
trunk/tools/sysreg2/options.c
trunk/tools/sysreg2/reactos.xml
trunk/tools/sysreg2/sysreg.h
trunk/tools/sysreg2/sysreg.xml
trunk/tools/sysreg2/virt.c
Modified: trunk/tools/sysreg2/options.c
URL:
http://svn.reactos.org/svn/reactos/trunk/tools/sysreg2/options.c?rev=35852&…
==============================================================================
--- trunk/tools/sysreg2/options.c [iso-8859-1] (original)
+++ trunk/tools/sysreg2/options.c [iso-8859-1] Mon Sep 1 07:20:29 2008
@@ -30,7 +30,7 @@
strncpy(AppSettings.Filename, obj->stringval, 254);
}
- obj = xmlXPathEval(BAD_CAST"string(/settings/@name)",ctxt);
+ obj = xmlXPathEval(BAD_CAST"string(/settings/@vm)",ctxt);
if ((obj != NULL) && ((obj->type == XPATH_STRING) &&
(obj->stringval != NULL) && (obj->stringval[0] !=
0)))
{
@@ -43,6 +43,15 @@
/* when no value is set - return value is negative
* which means infinite */
AppSettings.Timeout = (int)obj->floatval;
+ }
+
+ obj = xmlXPathEval(BAD_CAST"number(/settings/general/hdd/@size)",ctxt);
+ if ((obj != NULL) && (obj->type == XPATH_NUMBER))
+ {
+ if (obj->floatval <= 0)
+ AppSettings.ImageSize = 512;
+ else
+ AppSettings.ImageSize = (int)obj->floatval;
}
for (Stage=0;Stage<3;Stage++)
@@ -59,6 +68,27 @@
}
xmlFreeDoc(xml);
xmlXPathFreeContext(ctxt);
+
+ xml = xmlReadFile(AppSettings.Filename, NULL, 0);
+ if (!xml)
+ return false;
+ ctxt = xmlXPathNewContext(xml);
+ if (!ctxt)
+ {
+ xmlFreeDoc(xml);
+ return false;
+ }
+
+ obj =
xmlXPathEval(BAD_CAST"string(/domain/devices/disk[@device='disk']/source/@file)",ctxt);
+ if ((obj != NULL) && ((obj->type == XPATH_STRING) &&
+ (obj->stringval != NULL) && (obj->stringval[0] !=
0)))
+ {
+ strncpy(AppSettings.HardDiskImage, obj->stringval, 254);
+ }
+
+ xmlFreeDoc(xml);
+ xmlXPathFreeContext(ctxt);
return true;
}
+
Modified: trunk/tools/sysreg2/reactos.xml
URL:
http://svn.reactos.org/svn/reactos/trunk/tools/sysreg2/reactos.xml?rev=3585…
==============================================================================
--- trunk/tools/sysreg2/reactos.xml [iso-8859-1] (original)
+++ trunk/tools/sysreg2/reactos.xml [iso-8859-1] Mon Sep 1 07:20:29 2008
@@ -21,7 +21,7 @@
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='cdrom'>
- <source file='/opt/buildbot/kvmtest/ReactOS.iso'/>
+ <source file='/opt/buildbot/kvmtest/ReactOS-RegTest.iso'/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
Modified: trunk/tools/sysreg2/sysreg.h
URL:
http://svn.reactos.org/svn/reactos/trunk/tools/sysreg2/sysreg.h?rev=35852&a…
==============================================================================
--- trunk/tools/sysreg2/sysreg.h [iso-8859-1] (original)
+++ trunk/tools/sysreg2/sysreg.h [iso-8859-1] Mon Sep 1 07:20:29 2008
@@ -18,6 +18,8 @@
int Timeout;
char Filename[255];
char Name[80];
+ char HardDiskImage[255];
+ int ImageSize;
stage Stage[3];
} Settings;
Modified: trunk/tools/sysreg2/sysreg.xml
URL:
http://svn.reactos.org/svn/reactos/trunk/tools/sysreg2/sysreg.xml?rev=35852…
==============================================================================
--- trunk/tools/sysreg2/sysreg.xml [iso-8859-1] (original)
+++ trunk/tools/sysreg2/sysreg.xml [iso-8859-1] Mon Sep 1 07:20:29 2008
@@ -2,7 +2,9 @@
<general>
<!-- kill the VM after n milliseconds without debug msg -->
<timeout ms="20000"/>
- </general2
+ <!-- size of the hdd image in MB -->
+ <hdd size="512"/>
+ </general>
<firststage bootdevice="cdrom">
<success on="SYSREG_CHECKPOINT:USETUP_COMPLETE"/>
</firststage>
Modified: trunk/tools/sysreg2/virt.c
URL:
http://svn.reactos.org/svn/reactos/trunk/tools/sysreg2/virt.c?rev=35852&…
==============================================================================
--- trunk/tools/sysreg2/virt.c [iso-8859-1] (original)
+++ trunk/tools/sysreg2/virt.c [iso-8859-1] Mon Sep 1 07:20:29 2008
@@ -41,24 +41,40 @@
bool IsVirtualMachineRunning(virConnectPtr vConn, const char* name)
{
- char* names[10];
- int iDomains;
- int iMaxnames = 10;
+ int* ids = NULL;
+ int numids;
+ int maxids = 0;
+ const char* domname;
+ virDomainPtr vDomPtr = NULL;
- iDomains = virConnectListDefinedDomains(vConn, names, iMaxnames);
- if (iDomains != -1)
+ maxids = virConnectNumOfDomains(vConn);
+ if (maxids < 0)
+ return false;
+
+ ids = malloc(sizeof(int) * maxids);
+ if (!ids)
+ return false;
+
+ numids = virConnectListDomains(vConn, &ids[0], maxids);
+ if (numids > -1)
{
int i;
- for(i=0; i<iDomains; i++)
+ for(i=0; i<numids; i++)
{
- if (strcasecmp(name, names[i]) == 0)
- return true;
+ vDomPtr = virDomainLookupByID(vConn, ids[i]);
+ domname = virDomainGetName(vDomPtr);
+ if (strcasecmp(name, domname) == 0)
+ {
+ virDomainFree(vDomPtr);
+ return true;
+ }
+ virDomainFree(vDomPtr);
}
}
return false;
}
-virDomainPtr LaunchVirtualMachine(virConnectPtr vConn, const char* XmlFileName, const
char* BootDevice)
+virDomainPtr LaunchVirtualMachine(virConnectPtr vConn, const char* XmlFileName, const
char* BootDevice)
{
xmlDocPtr xml = NULL;
xmlXPathObjectPtr obj = NULL;
@@ -111,7 +127,8 @@
name = virDomainGetName(vDomPtr);
domname = strdup(name);
virDomainFree(vDomPtr);
- free(domname);
+ vDomPtr = virDomainLookupByName(vConn, domname);
+ free(domname);
}
}
return vDomPtr;
@@ -124,6 +141,8 @@
virDomainPtr vDom;
int Stage;
int Stages = 1; /* 1 for testing, should be set to 3 later */
+ char qemu_img_cmdline[300];
+ FILE* file;
if (!LoadSettings("sysreg.xml"))
{
@@ -133,26 +152,45 @@
vConn = virConnectOpen("qemu:///session");
+ if (IsVirtualMachineRunning(vConn, AppSettings.Name))
+ {
+ printf("Error: Virtual Machine is already running.\n");
+ return EXIT_FAILURE;
+ }
+
+ if (file = fopen(AppSettings.HardDiskImage, "r"))
+ {
+ fclose(file);
+ remove(AppSettings.HardDiskImage);
+ }
+
+ sprintf(qemu_img_cmdline, "qemu-img create -f qcow2 %s %dM",
+ AppSettings.HardDiskImage, AppSettings.ImageSize);
+ FILE* p = popen(qemu_img_cmdline, "r");
+ char buf[100];
+ while(feof(p)==0)
+ {
+ memset(buf,0,strlen(buf));
+ fgets(buf,100,p);
+ printf("%s\n",buf);
+ }
+ pclose(p);
+
for (Stage=0;Stage<Stages; Stage++)
{
- if (IsVirtualMachineRunning(vConn, AppSettings.Name))
- printf("Virtual Machine is already running\n");
- else
+ vDom = LaunchVirtualMachine(vConn, AppSettings.Filename,
+ AppSettings.Stage[Stage].BootDevice);
{
- vDom = LaunchVirtualMachine(vConn, AppSettings.Filename,
- AppSettings.Stage[Stage].BootDevice);
+ if (vDom)
{
- if (vDom)
- {
- printf("Domain %s started.\n", virDomainGetName(vDom));
- ProcessDebugData(GetConsole(vDom),
- AppSettings.Timeout, Stage);
- virDomainDestroy(vDom);
- virDomainUndefine(vDom);
- virDomainFree(vDom);
- }
- }
- }
+ printf("Domain %s started.\n", virDomainGetName(vDom));
+ ProcessDebugData(GetConsole(vDom),
+ AppSettings.Timeout, Stage);
+ virDomainDestroy(vDom);
+ virDomainUndefine(vDom);
+ virDomainFree(vDom);
+ }
+ }
}
virConnectClose(vConn);