From b447d73c83ba7d8266341488ffa20d6a646d2c9c Mon Sep 17 00:00:00 2001
From: Someone <someone@somenet.org>
Date: Mon, 3 Jun 2013 13:25:42 +0200
Subject: [PATCH] fixed VM.resize()

---
 src/at/ac/tuwien/lsdc/sched/SchedulerB.java     | 3 +++
 src/at/ac/tuwien/lsdc/types/VirtualMachine.java | 6 +++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/at/ac/tuwien/lsdc/sched/SchedulerB.java b/src/at/ac/tuwien/lsdc/sched/SchedulerB.java
index 12d026f..4d5f5e6 100644
--- a/src/at/ac/tuwien/lsdc/sched/SchedulerB.java
+++ b/src/at/ac/tuwien/lsdc/sched/SchedulerB.java
@@ -64,6 +64,9 @@ public class SchedulerB extends AbstractScheduler {
 			}
 		}
 
+		// TODO: migrate apps to get an empty VM and shut it down.
+		// TODO: run all delayed.
+
 		for (SchedulerEvent evt : events) {
 			if (evt.getType() == EventType.startApplication) {
 				VirtualMachine vm = null;
diff --git a/src/at/ac/tuwien/lsdc/types/VirtualMachine.java b/src/at/ac/tuwien/lsdc/types/VirtualMachine.java
index d1c7491..abf4637 100644
--- a/src/at/ac/tuwien/lsdc/types/VirtualMachine.java
+++ b/src/at/ac/tuwien/lsdc/types/VirtualMachine.java
@@ -54,12 +54,16 @@ public class VirtualMachine {
 	 * Set the VM size to the given new values.
 	 * 
 	 * @param newSize
+	 *          the new size of the VM, excluding the initial consumption.
 	 * @param newRAM
+	 *          the new RAM of the VM, excluding the initial consumption.
 	 * @param newCPU
+	 *          the new CPU of the VM, excluding the initial consumption.
 	 * @return
 	 */
 	public boolean resizeVM(int newSize, int newRAM, int newCPU) {
-		if (type == VMType.Resizable && runningOn.checkVM(newSize, newRAM, newCPU)) {
+		if (type == VMType.Resizable
+				&& runningOn.checkVM(newSize - reservedSize, newRAM - reservedRAM, newCPU - reservedCPU)) {
 			// Resize VM
 			reservedSize = initialSize + newSize;
 			reservedRAM = initialRAM + newRAM;
-- 
2.43.0