Gustavo Frederico Temple Pedrosa has uploaded a new change for review.
Change subject: core: Disable balloon by default - Patch 1 of 2
......................................................................
core: Disable balloon by default - Patch 1 of 2
* Some guest OSes may crash if the VirtIO balloon is enabled in ppc64
VMs. This can be worked around by the system administrator if he
disables the balloon kernel module in the guest OS.
* This change adds in the osinfo file the description for the balloon
disabled by default:
os.{id}.devices.balloonDisabledByDefault.value = false
* Provides the access in the backend.
* Prevents that an OS enable the balloon by default.
Change-Id: I1b048b3d54e5e1732f8a13de8c9d4c1df4b6d8e5
Signed-off-by: Gustavo Pedrosa <[email protected]>
---
M
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/OsRepositoryQuery.java
M
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepository.java
M
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/OsQueryParameters.java
M
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmsResource.java
M
backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/utils/OsTypeMockUtils.java
M
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/OsRepositoryImpl.java
M
backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/OsRepositoryImplTest.java
M packaging/conf/osinfo-defaults.properties
8 files changed, 78 insertions(+), 5 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/55/22055/1
diff --git
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/OsRepositoryQuery.java
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/OsRepositoryQuery.java
index afa2644..7f1abc4 100644
---
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/OsRepositoryQuery.java
+++
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/OsRepositoryQuery.java
@@ -45,6 +45,12 @@
case GetSpiceSupportMatrix:
setReturnValue(osRepository.getSpiceSupportMatrix());
break;
+ case GetBalloonDisabledByDefaultMatrix:
+
setReturnValue(osRepository.getBalloonDisabledByDefaultMatrix());
+ break;
+ case IsBalloonDisabledByDefault:
+
setReturnValue(osRepository.isBalloonDisabledByDefault(getParameters().getOsId(),
getParameters().getVersion()));
+ break;
case HasNicHotplugSupport:
setReturnValue(osRepository.hasNicHotplugSupport(getParameters().getOsId(),
getParameters().getVersion()));
break;
diff --git
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepository.java
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepository.java
index 0f860a1..c0e1994 100644
---
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepository.java
+++
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepository.java
@@ -75,6 +75,20 @@
public Map<Integer, Map<Version, Boolean>> getSpiceSupportMatrix();
/**
+ * @return map (osId -> compatibility version -> Boolean) that indicates
balloon disabled for all OSs and
+ * compatibility versions
+ */
+ public Map<Integer, Map<Version, Boolean>>
getBalloonDisabledByDefaultMatrix();
+
+ /**
+ * Checks if is recommended disable the OS balloon.
+ * @param osId
+ * @param version
+ * @return an boolean
+ */
+ public boolean isBalloonDisabledByDefault(int osId, Version version);
+
+ /**
* Checks if that OS network devices support hotplug.
* @param osId
* @param version
diff --git
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/OsQueryParameters.java
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/OsQueryParameters.java
index d3053d0..e660dc8 100644
---
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/OsQueryParameters.java
+++
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/OsQueryParameters.java
@@ -39,6 +39,8 @@
public enum OsRepositoryVerb {
GetSpiceSupportMatrix,
+ GetBalloonDisabledByDefaultMatrix,
+ IsBalloonDisabledByDefault,
HasNicHotplugSupport,
GetNicHotplugSupportMap,
GetDiskHotpluggableInterfacesMap,
diff --git
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmsResource.java
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmsResource.java
index bc0e26f..1cd0948 100644
---
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmsResource.java
+++
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmsResource.java
@@ -48,6 +48,7 @@
import org.ovirt.engine.core.common.businessentities.VmStatic;
import org.ovirt.engine.core.common.businessentities.VmTemplate;
import org.ovirt.engine.core.common.interfaces.SearchType;
+import org.ovirt.engine.core.common.osinfo.OsRepository;
import
org.ovirt.engine.core.common.queries.GetVmFromConfigurationQueryParameters;
import org.ovirt.engine.core.common.queries.GetVmTemplateParameters;
import org.ovirt.engine.core.common.queries.IdQueryParameters;
@@ -55,7 +56,9 @@
import org.ovirt.engine.core.common.queries.VdcQueryParametersBase;
import org.ovirt.engine.core.common.queries.VdcQueryReturnValue;
import org.ovirt.engine.core.common.queries.VdcQueryType;
+import org.ovirt.engine.core.common.utils.SimpleDependecyInjector;
import org.ovirt.engine.core.compat.Guid;
+import org.ovirt.engine.core.compat.Version;
public class BackendVmsResource extends
AbstractBackendCollectionResource<VM,
org.ovirt.engine.core.common.businessentities.VM>
@@ -103,8 +106,9 @@
staticVm.setVdsGroupId(getClusterId(vm));
}
+ VDSGroup vdsGroup = lookupCluster(staticVm.getVdsGroupId());
staticVm.setUsbPolicy(VmMapper.getUsbPolicyOnCreate(vm.getUsb(),
- lookupCluster(staticVm.getVdsGroupId())));
+ vdsGroup));
if (!isFiltered()) {
// if the user set the host-name within placement-policy,
rather than the host-id (legal) -
@@ -124,9 +128,9 @@
if (vm.isSetDisks() && vm.getDisks().isSetClone() &&
vm.getDisks().isClone()) {
response = cloneVmFromTemplate(staticVm, vm, templateId);
} else if (Guid.Empty.equals(templateId)) {
- response = addVmFromScratch(staticVm, vm, storageDomainId);
+ response = addVmFromScratch(staticVm, vm, storageDomainId,
vdsGroup);
} else {
- response = addVm(staticVm, vm, storageDomainId,
templateId);
+ response = addVm(staticVm, vm, storageDomainId,
templateId, vdsGroup);
}
}
}
@@ -318,11 +322,14 @@
return (DiskImage)getMapper(Disk.class,
org.ovirt.engine.core.common.businessentities.Disk.class).map(entity, template);
}
- protected Response addVm(VmStatic staticVm, VM vm, Guid storageDomainId,
Guid templateId) {
+ protected Response addVm(VmStatic staticVm, VM vm, Guid storageDomainId,
Guid templateId, VDSGroup vdsGroup) {
VmManagementParametersBase params = new
VmManagementParametersBase(staticVm);
params.setVmPayload(getPayload(vm));
if (vm.isSetMemoryPolicy() && vm.getMemoryPolicy().isSetBallooning()) {
params.setBalloonEnabled(vm.getMemoryPolicy().isBallooning());
+ } else {
+
params.setBalloonEnabled(!isBalloonDisabledByDefault(staticVm.getOsId(),
+ vdsGroup.getcompatibility_version()));
}
params.setStorageDomainId(storageDomainId);
params.setDiskInfoDestinationMap(getDisksToClone(vm.getDisks(),
templateId));
@@ -341,17 +348,25 @@
new
QueryIdResolver<Guid>(VdcQueryType.GetVmByVmId, IdQueryParameters.class));
}
+ protected boolean isBalloonDisabledByDefault(int osId, Version version) {
+ return SimpleDependecyInjector.getInstance().get(OsRepository.class)
+ .isBalloonDisabledByDefault(osId, version);
+ }
+
void setupCloneTemplatePermissions(VM vm, VmManagementParametersBase
params) {
if (vm.isSetPermissions() && vm.getPermissions().isSetClone()) {
params.setCopyTemplatePermissions(vm.getPermissions().isClone());
}
}
- protected Response addVmFromScratch(VmStatic staticVm, VM vm, Guid
storageDomainId) {
+ protected Response addVmFromScratch(VmStatic staticVm, VM vm, Guid
storageDomainId, VDSGroup vdsGroup) {
AddVmFromScratchParameters params = new
AddVmFromScratchParameters(staticVm, mapDisks(vm.getDisks()), Guid.Empty);
params.setVmPayload(getPayload(vm));
if (vm.isSetMemoryPolicy() && vm.getMemoryPolicy().isSetBallooning()) {
params.setBalloonEnabled(vm.getMemoryPolicy().isBallooning());
+ } else {
+
params.setBalloonEnabled(!isBalloonDisabledByDefault(staticVm.getOsId(),
+ vdsGroup.getcompatibility_version()));
}
params.setMakeCreatorExplicitOwner(shouldMakeCreatorExplicitOwner());
params.setStorageDomainId(storageDomainId);
diff --git
a/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/utils/OsTypeMockUtils.java
b/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/utils/OsTypeMockUtils.java
index 2ce82fb..2a06a48 100644
---
a/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/utils/OsTypeMockUtils.java
+++
b/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/utils/OsTypeMockUtils.java
@@ -1,5 +1,7 @@
package org.ovirt.engine.api.restapi.utils;
+import static org.easymock.EasyMock.anyInt;
+import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.expect;
import java.util.HashMap;
@@ -8,6 +10,7 @@
import org.easymock.IMocksControl;
import org.ovirt.engine.core.common.osinfo.OsRepository;
import org.ovirt.engine.core.common.utils.SimpleDependecyInjector;
+import org.ovirt.engine.core.compat.Version;
public class OsTypeMockUtils {
@@ -17,6 +20,9 @@
HashMap<Integer, String> osNames = new HashMap<>(1);
osNames.put(0, "Unassigned");
expect(osRepositoryMock.getUniqueOsNames()).andReturn(osNames).anyTimes();
+ expect(osRepositoryMock.isBalloonDisabledByDefault(anyInt(),
+ anyObject(Version.class))).andReturn(false).anyTimes();
+
SimpleDependecyInjector.getInstance().bind(OsRepository.class,
osRepositoryMock);
control.replay();
}
diff --git
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/OsRepositoryImpl.java
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/OsRepositoryImpl.java
index 9033178..5e14e5a 100644
---
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/OsRepositoryImpl.java
+++
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/OsRepositoryImpl.java
@@ -261,6 +261,29 @@
}
@Override
+ public Map<Integer, Map<Version, Boolean>>
getBalloonDisabledByDefaultMatrix() {
+ Map<Integer, Map<Version, Boolean>> balloonDisabledByDefaultMatrix =
new HashMap<Integer, Map<Version, Boolean>>();
+ Set<Version> versionsWithNull = new HashSet<Version>(Version.ALL);
+ versionsWithNull.add(null);
+
+ for (Integer osId : getOsIds()) {
+ balloonDisabledByDefaultMatrix.put(osId, new HashMap<Version,
Boolean>());
+
+ for (Version ver : versionsWithNull) {
+ boolean isBalloonDisabledByDefault =
isBalloonDisabledByDefault(osId, ver);
+ balloonDisabledByDefaultMatrix.get(osId).put(ver,
isBalloonDisabledByDefault);
+ }
+ }
+
+ return balloonDisabledByDefaultMatrix;
+ }
+
+ @Override
+ public boolean isBalloonDisabledByDefault(int osId, Version version) {
+ return getBoolean(getValueByVersion(idToUnameLookup.get(osId),
"devices.balloonDisabledByDefault", version), false);
+ }
+
+ @Override
public boolean hasNicHotplugSupport(int osId, Version version) {
return getBoolean(getValueByVersion(idToUnameLookup.get(osId),
"devices.network.hotplugSupport", version), false);
}
diff --git
a/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/OsRepositoryImplTest.java
b/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/OsRepositoryImplTest.java
index ed9cd58..63f02df 100644
---
a/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/OsRepositoryImplTest.java
+++
b/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/OsRepositoryImplTest.java
@@ -35,6 +35,7 @@
preferences.node("/os/rhel7/resources/minimum/ram").put("value.3.1",
"512");
preferences.node("/os/rhel7/resources/maximum/ram").put("value",
"2048");
preferences.node("/os/rhel7/spiceSupport").put("value", "true");
+
preferences.node("/os/rhel7/devices/balloonDisabledByDefault").put("value",
"false");
preferences.node("/os/rhel7/sysprepPath").put("value",
PATH_TO_SYSPREP);
preferences.node("/os/rhel7/productKey").put("value",
SOME_PRODUCT_KEY);
preferences.node("/os/rhel7/devices/audio").put("value", SOUND_DEVICE);
@@ -132,6 +133,11 @@
}
@Test
+ public void testIsBalloonDisabledByDefault() throws Exception {
+
assertFalse(OsRepositoryImpl.INSTANCE.getBalloonDisabledByDefaultMatrix().get(777).get(null));
+ }
+
+ @Test
public void testGetSysprepPath() throws Exception {
assertTrue(OsRepositoryImpl.INSTANCE.getSysprepPath(777,
null).equals(PATH_TO_SYSPREP));
}
diff --git a/packaging/conf/osinfo-defaults.properties
b/packaging/conf/osinfo-defaults.properties
index f3a436b..5abbe14 100644
--- a/packaging/conf/osinfo-defaults.properties
+++ b/packaging/conf/osinfo-defaults.properties
@@ -50,6 +50,7 @@
os.other.resources.minimum.disksize.value = 1
os.other.resources.minimum.numberOsCpus.value = 1
os.other.spiceSupport.value = true
+os.other.devices.balloonDisabledByDefault.value = false
os.other.devices.disk.hotpluggableInterfaces.value = VirtIO_SCSI, VirtIO
os.other.devices.disk.hotpluggableInterfaces.value.3.0 =
--
To view, visit http://gerrit.ovirt.org/22055
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1b048b3d54e5e1732f8a13de8c9d4c1df4b6d8e5
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Gustavo Frederico Temple Pedrosa <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches