Skip to content

Commit 6b5bf82

Browse files
author
gitlab
committed
Merge branch 'zsv-ldap-3' into 'feature-zsv-5.0.0-vm-support-vtpm-and-secuceboot'
<feature>[kvm]: persist machine type to system tag See merge request zstackio/zstack!9515
2 parents 09131e7 + 458fcb8 commit 6b5bf82

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

plugin/kvm/src/main/java/org/zstack/kvm/BootKvmStartVmExtension.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ public void startVmOnKvmSuccess(KVMHostInventory host, VmInstanceSpec spec) {
2929
VmSystemTags.BOOT_ORDER.delete(spec.getVmInventory().getUuid());
3030
VmSystemTags.CDROM_BOOT_ONCE.delete(spec.getVmInventory().getUuid());
3131
}
32+
33+
final String machineType = spec.getOsSpec().getMachineType();
34+
if (StringUtils.isEmpty(machineType)) {
35+
VmSystemTags.MACHINE_TYPE.delete(spec.getVmInventory().getUuid());
36+
} else {
37+
SystemTagCreator creator = VmSystemTags.MACHINE_TYPE.newSystemTagCreator(spec.getVmInventory().getUuid());
38+
creator.setTagByTokens(map(e(VmSystemTags.MACHINE_TYPE_TOKEN, machineType)));
39+
creator.inherent = false;
40+
creator.recreate = true;
41+
creator.create();
42+
}
3243
}
3344

3445
@Override

plugin/kvm/src/main/java/org/zstack/kvm/KVMHost.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4440,6 +4440,7 @@ protected void startVm(final VmInstanceSpec spec, final NeedReplyMessage msg, fi
44404440
String machineType = VmSystemTags.MACHINE_TYPE.getTokenByResourceUuid(cmd.getVmInstanceUuid(),
44414441
VmInstanceVO.class, VmSystemTags.MACHINE_TYPE_TOKEN);
44424442
cmd.setMachineType(StringUtils.isNotEmpty(machineType) ? machineType : "pc");
4443+
spec.getOsSpec().setMachineType(cmd.getMachineType());
44434444
} else {
44444445
cmd.setMachineType(spec.getOsSpec().getMachineType());
44454446
}

0 commit comments

Comments
 (0)