Skip to contentSkip to conversation

shadow_memory fix

PATCH New Rick Gonzalez 1 participant 1 message Aug 31, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 shadow_memory fix

Team,

attached is a patch to fix xmtest. This is for bug# 751.

What basically did was include the "shadow_memory" parameter in the HVM config file with 8MB by default. This fixes the problem alone. Now, I went further and created a function to grow this memory as needed.

The stipulation is that there should be 2KB of memory for every one MB of RAM assigned to the guest domain, plus a few MB per vcpu ( ~2MB).

The 8MB of shadow memory is more than enough for xmtest when concerning RAM. The my function grows this shadow memory if we have more than 3 vcpus. This is just a safety precaution. :)

Please look at the patch and let me know what you think.

regards,

Rick Gonzalez

tools/xm-test/lib/XmTestLib/XenDomain.py +17 -1
diff -Naur xen-unstable.hg/tools/xm-test/lib/XmTestLib/XenDomain.py xen-unstable-shadowfix.hg/tools/xm-test/lib/XmTestLib/XenDomain.py
@@ -74,6 +74,7 @@
                     }
 HVMDefaults =      {"memory"       : 64,
                     "vcpus"        : 1,
+		    "shadow_memory": 8,
                     "acpi"         : 0,
                     "apic"         : 0,
                     "disk"         : ["file:%s/disk.img,ioemu:%s,w!" %
@@ -169,6 +170,18 @@
         else:
             self.opts = self.defaultOpts
 
+    def computeShadowMem(self):
+        """Shadow Memory checking/assignment (for HVM domains only).
+            8MB by default. Minimum requirements for it is 2KB per every
+            1MB of RAM assigned to guest domain, plus a few more MB per vcpu.
+            8MB showld be enough but if vcpus is > 3, give 2MB more per vcpu."""
+
+        vcpus = self.getOpt("vcpus")
+        mem = self.getOpt("shadow_memory")
+        newmem = int(mem) + int(vcpus) * 2
+
+        return newmem
+
 class DomainError(Exception):
     def __init__(self, msg, extra="", errorcode=0):
         self.msg = msg
@@ -329,7 +342,6 @@
             return dev
         print "Device %s not found for domain %s" % (id, self.getName())
 
-
 class XmTestDomain(XenDomain):
 
     def __init__(self, name=None, extraConfig=None, baseConfig=configDefaults):
@@ -343,6 +355,10 @@
         if extraConfig:
             config.setOpts(extraConfig)
 
+	# if HVM enabled then check shadow memory
+        if ( ENABLE_HVM_SUPPORT ) and ( int(config.getOpt("vcpus")) > 3):
+            config.setOpt("shadow_memory",config.computeShadowMem())
+
         if name:
             config.setOpt("name", name)
         elif not config.getOpt("name"):

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel