Skip to content

Commit d710fb3

Browse files
shwstpprdhslove
authored andcommitted
server: set VirtualMachineTO arch from template if present (apache#11530)
* server: set VirtualMachineTO arch from template if present Fixes apache#11529 Signed-off-by: Abhishek Kumar <[email protected]> * refactor Signed-off-by: Abhishek Kumar <[email protected]> --------- Signed-off-by: Abhishek Kumar <[email protected]>
1 parent bd1a3d3 commit d710fb3

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

server/src/main/java/com/cloud/hypervisor/HypervisorGuruBase.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import javax.inject.Inject;
2525

2626
import com.cloud.agent.api.to.GPUDeviceTO;
27+
import com.cloud.cpu.CPU;
2728
import com.cloud.dc.DataCenter;
2829
import com.cloud.dc.dao.DataCenterDao;
2930
import com.cloud.domain.Domain;
@@ -323,12 +324,15 @@ protected VirtualMachineTO toVirtualMachineTO(VirtualMachineProfile vmProfile) {
323324
to.setNics(nics);
324325
to.setDisks(vmProfile.getDisks().toArray(new DiskTO[vmProfile.getDisks().size()]));
325326

326-
if (vmProfile.getTemplate().getBits() == 32) {
327-
to.setArch("i686");
328-
} else if("s390x".equals(System.getProperty("os.arch"))) {
329-
to.setArch("s390x");
327+
CPU.CPUArch templateArch = vmProfile.getTemplate().getArch();
328+
if (templateArch != null) {
329+
to.setArch(templateArch.getType());
330330
} else {
331-
to.setArch("x86_64");
331+
if (vmProfile.getTemplate().getBits() == 32) {
332+
to.setArch(CPU.CPUArch.x86.getType());
333+
} else {
334+
to.setArch(CPU.CPUArch.amd64.getType());
335+
}
332336
}
333337

334338
Map<String, String> detailsInVm = _vmInstanceDetailsDao.listDetailsKeyPairs(vm.getId());

0 commit comments

Comments
 (0)