Jason Liao has uploaded a new change for review. Change subject: engine: NUMA feature transaction support ......................................................................
engine: NUMA feature transaction support Add transaction support for add/update VM NUMA nodes 1. add/update VM 2. add/update VM template Change-Id: If84e59fa38c9174fe7150116bf3c8832f7fac1dd Bug-Url: https://bugzilla.redhat.com/1069303 Signed-off-by: Jason Liao <chuan.l...@hp.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java 3 files changed, 58 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/41/28241/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java index 251de54..a76fbb1 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java @@ -48,10 +48,12 @@ import org.ovirt.engine.core.common.businessentities.VDSGroup; import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.businessentities.VMStatus; +import org.ovirt.engine.core.common.businessentities.VdsNumaNode; import org.ovirt.engine.core.common.businessentities.VmDevice; import org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType; import org.ovirt.engine.core.common.businessentities.VmDeviceId; import org.ovirt.engine.core.common.businessentities.VmDynamic; +import org.ovirt.engine.core.common.businessentities.VmNumaNode; import org.ovirt.engine.core.common.businessentities.VmPayload; import org.ovirt.engine.core.common.businessentities.VmRngDevice; import org.ovirt.engine.core.common.businessentities.VmStatic; @@ -723,6 +725,7 @@ addVmStatic(); addVmDynamic(); addVmNetwork(); + addVmNumaNodes(); addVmStatistics(); addActiveSnapshot(); addVmPermission(); @@ -889,6 +892,14 @@ } } + protected void addVmNumaNodes() { + List<VdsNumaNode> numaNodes = new ArrayList<VdsNumaNode>(); + for (VmNumaNode vnode : getParameters().getVmStaticData().getvNumaNodeList()) { + numaNodes.add(vnode); + } + DbFacade.getInstance().getVmNumaNodeDAO().massSaveNumaNode(numaNodes, null, getVmId()); + } + protected void addVmInit() { VmHandler.addVmInitToDB(getParameters().getVmStaticData()); } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java index 5d79cf0..e60016e 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java @@ -32,8 +32,10 @@ import org.ovirt.engine.core.common.businessentities.StorageDomainStatus; import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.businessentities.VMStatus; +import org.ovirt.engine.core.common.businessentities.VdsNumaNode; import org.ovirt.engine.core.common.businessentities.VmDynamic; import org.ovirt.engine.core.common.businessentities.VmEntityType; +import org.ovirt.engine.core.common.businessentities.VmNumaNode; import org.ovirt.engine.core.common.businessentities.VmStatic; import org.ovirt.engine.core.common.businessentities.VmTemplate; import org.ovirt.engine.core.common.businessentities.VmTemplateStatus; @@ -253,6 +255,7 @@ addPermission(); addVmTemplateImages(srcDeviceIdToTargetDeviceIdMapping); addVmInterfaces(srcDeviceIdToTargetDeviceIdMapping); + addVmNumaNodes(); if (isVmInDb) { VmDeviceUtils.copyVmDevices(getVmId(), getVmTemplateId(), @@ -566,6 +569,18 @@ } } + protected void addVmNumaNodes() { + List<VdsNumaNode> numaNodes = new ArrayList<VdsNumaNode>(); + for (VmNumaNode vnode : DbFacade.getInstance().getVmNumaNodeDAO().getAllVmNumaNodeByVmId(getVmId())) { + for (Pair<Guid, Pair<Boolean, Integer>> pair : vnode.getVdsNumaNodeList()) { + pair.setFirst(null); + pair.getSecond().setFirst(false); + } + numaNodes.add(vnode); + } + DbFacade.getInstance().getVmNumaNodeDAO().massSaveNumaNode(numaNodes, null, getVmTemplateId()); + } + protected void addVmTemplateImages(Map<Guid, Guid> srcDeviceIdToTargetDeviceIdMapping) { for (DiskImage diskImage : mImages) { // The return value of this action is the 'copyImage' task GUID: diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java index 9ff2891..93b3f1b 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java @@ -36,9 +36,11 @@ import org.ovirt.engine.core.common.businessentities.Snapshot; import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.businessentities.VMStatus; +import org.ovirt.engine.core.common.businessentities.VdsNumaNode; import org.ovirt.engine.core.common.businessentities.VmDevice; import org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType; import org.ovirt.engine.core.common.businessentities.VmDeviceId; +import org.ovirt.engine.core.common.businessentities.VmNumaNode; import org.ovirt.engine.core.common.businessentities.VmPayload; import org.ovirt.engine.core.common.businessentities.VmRngDevice; import org.ovirt.engine.core.common.businessentities.VmStatic; @@ -65,6 +67,7 @@ import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableBase; import org.ovirt.engine.core.dao.SnapshotDao; import org.ovirt.engine.core.dao.VmDeviceDAO; +import org.ovirt.engine.core.dao.VmNumaNodeDAO; import org.ovirt.engine.core.utils.linq.LinqUtils; import org.ovirt.engine.core.utils.linq.Predicate; @@ -126,6 +129,7 @@ } UpdateVmNetworks(); + UpdateVmNumaNodes(); if (!getParameters().isApplyChangesLater()) { hotSetCpus(cpuPerSocket); } @@ -334,6 +338,34 @@ } } + private void UpdateVmNumaNodes() { + VmNumaNodeDAO dao = DbFacade.getInstance().getVmNumaNodeDAO(); + List<VdsNumaNode> addList = new ArrayList<VdsNumaNode>(); + List<VdsNumaNode> updateList = new ArrayList<VdsNumaNode>(); + List<Guid> removeList = new ArrayList<Guid>(); + List<VmNumaNode> oldList = dao.getAllVmNumaNodeByVmId(getVmId()); + for (VmNumaNode oldNode : oldList) { + removeList.add(oldNode.getId()); + } + for (VmNumaNode newNode : getParameters().getVmStaticData().getvNumaNodeList()) { + boolean found = false; + Guid newId = newNode.getId(); + for (VmNumaNode oldNode : oldList) { + if (oldNode.getId().equals(newId)) { + updateList.add(newNode); + removeList.remove(oldNode.getId()); + found = true; + break; + } + } + if (!found) { + addList.add(newNode); + } + } + dao.massSaveNumaNode(addList, null, getVmId()); + dao.massUpdateNumaNode(updateList); + dao.massRemoveNumaNodeByNumaNodeId(removeList); + } @Override protected List<Class<?>> getValidationGroups() { -- To view, visit http://gerrit.ovirt.org/28241 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If84e59fa38c9174fe7150116bf3c8832f7fac1dd Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Jason Liao <chuan.l...@hp.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches