Browse Source

vm/qubesvm: do not assign all host vCPUs to a qube

Fixes QubesOS/qubes-issues#2900
Marek Marczykowski-Górecki 6 years ago
parent
commit
4037bf9abc
3 changed files with 7 additions and 7 deletions
  1. 1 1
      qubes/tests/api_admin.py
  2. 4 4
      qubes/tests/vm/qubesvm.py
  3. 2 2
      qubes/vm/qubesvm.py

+ 1 - 1
qubes/tests/api_admin.py

@@ -124,7 +124,7 @@ class TC_00_VMs(AdminAPITestCase):
     def test_021_vm_property_get_int(self):
         value = self.call_mgmt_func(b'admin.vm.property.Get', b'test-vm1',
             b'vcpus')
-        self.assertEqual(value, 'default=True type=int 42')
+        self.assertEqual(value, 'default=True type=int 2')
 
     def test_022_vm_property_get_bool(self):
         value = self.call_mgmt_func(b'admin.vm.property.Get', b'test-vm1',

+ 4 - 4
qubes/tests/vm/qubesvm.py

@@ -281,10 +281,10 @@ class TC_90_QubesVM(QubesVMTestsMixin, qubes.tests.QubesTestCase):
 
     def test_190_vcpus(self):
         vm = self.get_vm()
-        self.assertPropertyDefaultValue(vm, 'vcpus', self.app.host.no_cpus)
+        self.assertPropertyDefaultValue(vm, 'vcpus', 2)
         self.assertPropertyValue(vm, 'vcpus', 3, 3, '3')
         del vm.vcpus
-        self.assertPropertyDefaultValue(vm, 'vcpus', self.app.host.no_cpus)
+        self.assertPropertyDefaultValue(vm, 'vcpus', 2)
         self.assertPropertyValue(vm, 'vcpus', '3', 3, '3')
 
     def test_191_vcpus_invalid(self):
@@ -508,7 +508,7 @@ class TC_90_QubesVM(QubesVMTestsMixin, qubes.tests.QubesTestCase):
         <uuid>7db78950-c467-4863-94d1-af59806384ea</uuid>
         <memory unit="MiB">500</memory>
         <currentMemory unit="MiB">400</currentMemory>
-        <vcpu placement="static">4</vcpu>
+        <vcpu placement="static">2</vcpu>
         <os>
             <type arch="x86_64" machine="xenpv">linux</type>
             <kernel>/tmp/kernel/vmlinuz</kernel>
@@ -559,7 +559,7 @@ class TC_90_QubesVM(QubesVMTestsMixin, qubes.tests.QubesTestCase):
         <uuid>7db78950-c467-4863-94d1-af59806384ea</uuid>
         <memory unit="MiB">500</memory>
         <currentMemory unit="MiB">400</currentMemory>
-        <vcpu placement="static">4</vcpu>
+        <vcpu placement="static">2</vcpu>
         <cpu mode='host-passthrough'>
             <!-- disable nested HVM -->
             <feature name='vmx' policy='disable'/>

+ 2 - 2
qubes/vm/qubesvm.py

@@ -416,8 +416,8 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
     vcpus = qubes.property('vcpus',
         type=int,
         setter=_setter_positive_int,
-        default=(lambda self: self.app.host.no_cpus),
-        doc='FIXME')
+        default=2,
+        doc='Number of virtual CPUs for a qube')
 
     # CORE2: swallowed uses_default_kernel
     kernel = qubes.property('kernel', type=str,