Change in vdsm[master]: virt: vm: sanitize earlier the 'smp' parameter

fromani at redhat.com fromani at redhat.com
Thu Sep 11 13:58:04 UTC 2014


Francesco Romani has uploaded a new change for review.

Change subject: virt: vm: sanitize earlier the 'smp' parameter
......................................................................

virt: vm: sanitize earlier the 'smp' parameter

In the VM creation path, in the Vm._run()
method, we ensure the presence of the 'smp' parameter,
which is used in the creation path to build
the VM Domain XML to be fed to libvirt.

However, parameter sanitization is better done earlier,
so this patch moves the check in the Vm.__init__ method,
and also adds a couple of tests to ensure the 'smp'
parameter is correct.

Change-Id: I1b90a26ff6af560359f3d60a73afc56fb25dc15c
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M tests/vmTests.py
M vdsm/virt/vm.py
2 files changed, 14 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/27/32827/1

diff --git a/tests/vmTests.py b/tests/vmTests.py
index a5f3446..4af07c3 100644
--- a/tests/vmTests.py
+++ b/tests/vmTests.py
@@ -1795,3 +1795,15 @@
                 self.assertEqual(vm.status()['status'], vmstatus.SAVING_STATE)
                 # state must not change even after we are sure the event was
                 # handled
+
+
+class TestVmSanity(TestCaseBase):
+    def testSmpPresentIfNotSpecified(self):
+        with FakeVM() as testvm:
+            print testvm.conf
+            self.assertEqual(int(testvm.conf['smp']), 1)
+
+    def testSmpByParameters(self):
+        smp = 4
+        with FakeVM({'smp': smp}) as testvm:
+            self.assertEqual(int(testvm.conf['smp']), smp)
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index a7dc916..c77ba6c 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -1451,6 +1451,8 @@
         self.conf = {'pid': '0'}
         self.conf['_blockJobs'] = {}
         self.conf.update(params)
+        if 'smp' not in self .conf:
+            self.conf['smp'] = '1'
         self._initLegacyConf()  # restore placeholders for BC sake
         self.cif = cif
         self.log = SimpleLogAdapter(self.log, {"vmId": self.conf['vmId']})
@@ -2855,7 +2857,6 @@
 
     def _run(self):
         self.log.info("VM wrapper has started")
-        self.conf['smp'] = self.conf.get('smp', '1')
         devices = self.buildConfDevices()
 
         if not self.recovering:


-- 
To view, visit http://gerrit.ovirt.org/32827
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1b90a26ff6af560359f3d60a73afc56fb25dc15c
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani at redhat.com>


More information about the vdsm-patches mailing list