forked from zstackio/zstack
-
Notifications
You must be signed in to change notification settings - Fork 0
<feature>[kvm]: support clone for TPM Vm #3473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
zstack-robot-1
wants to merge
4
commits into
feature-zsv-5.0.0-vm-support-vtpm-and-secuceboot
Choose a base branch
from
sync/wenhao.zhang/zsv-ldap@@2
base: feature-zsv-5.0.0-vm-support-vtpm-and-secuceboot
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
header/src/main/java/org/zstack/header/vm/additions/VmHostBackupFileVO.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| package org.zstack.header.vm.additions; | ||
|
|
||
| import org.zstack.header.vm.VmInstanceEO; | ||
| import org.zstack.header.vo.EntityGraph; | ||
| import org.zstack.header.vo.ForeignKey; | ||
| import org.zstack.header.vo.ResourceVO; | ||
|
|
||
| import javax.persistence.Column; | ||
| import javax.persistence.Entity; | ||
| import javax.persistence.EnumType; | ||
| import javax.persistence.Enumerated; | ||
| import javax.persistence.Table; | ||
| import java.sql.Timestamp; | ||
|
|
||
| /** | ||
| * Virtual Machine Host-side File Value Object (Backup files) | ||
| * | ||
| * Include: NvRam / TpmState files | ||
| */ | ||
| @Entity | ||
| @Table | ||
| @EntityGraph( | ||
| friends = { | ||
| @EntityGraph.Neighbour(type = VmInstanceEO.class, myField = "vmInstanceUuid", targetField = "uuid"), | ||
| } | ||
| ) | ||
| public class VmHostBackupFileVO extends ResourceVO { | ||
| @Column | ||
| @ForeignKey(parentEntityClass = VmInstanceEO.class, onDeleteAction = ForeignKey.ReferenceOption.CASCADE) | ||
| private String vmInstanceUuid; | ||
| @Column | ||
| @Enumerated(EnumType.STRING) | ||
| private VmHostFileType type; | ||
| @Column | ||
| private Timestamp createDate; | ||
| @Column | ||
| private Timestamp lastOpDate; | ||
|
|
||
| public String getVmInstanceUuid() { | ||
| return vmInstanceUuid; | ||
| } | ||
|
|
||
| public void setVmInstanceUuid(String vmInstanceUuid) { | ||
| this.vmInstanceUuid = vmInstanceUuid; | ||
| } | ||
|
|
||
| public VmHostFileType getType() { | ||
| return type; | ||
| } | ||
|
|
||
| public void setType(VmHostFileType type) { | ||
| this.type = type; | ||
| } | ||
|
|
||
| public Timestamp getCreateDate() { | ||
| return createDate; | ||
| } | ||
|
|
||
| public void setCreateDate(Timestamp createDate) { | ||
| this.createDate = createDate; | ||
| } | ||
|
|
||
| public Timestamp getLastOpDate() { | ||
| return lastOpDate; | ||
| } | ||
|
|
||
| public void setLastOpDate(Timestamp lastOpDate) { | ||
| this.lastOpDate = lastOpDate; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "VmHostBackupFileVO{" + | ||
| "vmInstanceUuid='" + vmInstanceUuid + '\'' + | ||
| ", type=" + type + | ||
| ", createDate=" + createDate + | ||
| ", lastOpDate=" + lastOpDate + | ||
| '}'; | ||
| } | ||
| } |
15 changes: 15 additions & 0 deletions
15
header/src/main/java/org/zstack/header/vm/additions/VmHostBackupFileVO_.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package org.zstack.header.vm.additions; | ||
|
|
||
| import org.zstack.header.vo.ResourceVO_; | ||
|
|
||
| import javax.persistence.metamodel.SingularAttribute; | ||
| import javax.persistence.metamodel.StaticMetamodel; | ||
| import java.sql.Timestamp; | ||
|
|
||
| @StaticMetamodel(VmHostBackupFileVO.class) | ||
| public class VmHostBackupFileVO_ extends ResourceVO_ { | ||
| public static volatile SingularAttribute<VmHostBackupFileVO, String> vmInstanceUuid; | ||
| public static volatile SingularAttribute<VmHostBackupFileVO, VmHostFileType> type; | ||
| public static volatile SingularAttribute<VmHostBackupFileVO, Timestamp> createDate; | ||
| public static volatile SingularAttribute<VmHostBackupFileVO, Timestamp> lastOpDate; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,4 @@ | |
| public enum VmHostFileType { | ||
| NvRam, | ||
| TpmState, | ||
| NvRamBackup, | ||
| TpmStateBackup, | ||
| } | ||
35 changes: 35 additions & 0 deletions
35
plugin/kvm/src/main/java/org/zstack/kvm/efi/CloneVmHostFileMsg.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package org.zstack.kvm.efi; | ||
|
|
||
| import org.zstack.header.message.NeedReplyMessage; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public class CloneVmHostFileMsg extends NeedReplyMessage { | ||
| private String srcVmUuid; | ||
| private List<String> dstVmUuidList; | ||
| private Boolean resetTpm; | ||
|
|
||
| public String getSrcVmUuid() { | ||
| return srcVmUuid; | ||
| } | ||
|
|
||
| public void setSrcVmUuid(String srcVmUuid) { | ||
| this.srcVmUuid = srcVmUuid; | ||
| } | ||
|
|
||
| public List<String> getDstVmUuidList() { | ||
| return dstVmUuidList; | ||
| } | ||
|
|
||
| public void setDstVmUuidList(List<String> dstVmUuidList) { | ||
| this.dstVmUuidList = dstVmUuidList; | ||
| } | ||
|
|
||
| public Boolean getResetTpm() { | ||
| return resetTpm; | ||
| } | ||
|
|
||
| public void setResetTpm(Boolean resetTpm) { | ||
| this.resetTpm = resetTpm; | ||
| } | ||
| } |
6 changes: 6 additions & 0 deletions
6
plugin/kvm/src/main/java/org/zstack/kvm/efi/CloneVmHostFileReply.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package org.zstack.kvm.efi; | ||
|
|
||
| import org.zstack.header.message.MessageReply; | ||
|
|
||
| public class CloneVmHostFileReply extends MessageReply { | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
缺少升级迁移,老库上的备份文件会卡在旧模型里。
这里新增了
VmHostBackupFileVO,同时把VmHostFileContentVO的关联语义切到了ResourceVO,但当前写法只会影响全新库。对已升级环境,已存在的VmHostFileContentVO不会被重建,外键仍然指向旧的VmHostFileVO;另外旧表里的NvRamBackup/TpmStateBackup历史记录也没有迁到新表。结果就是升级后备份文件元数据/内容可能一部分还留在旧模型里,新的 clone/TPM 路径会出现查不到或插入失败。建议补一段幂等迁移:条件式创建新表、把旧
VmHostFileVO中的 backup 类型搬到VmHostBackupFileVO(并做类型映射)、再按information_schema条件式重建VmHostFileContentVO的外键到ResourceVO。As per coding guidelines,
**/*.sql: Review the SQL code, make sure has no errors and confirm that: Upgrading scene has been carefully handled.🤖 Prompt for AI Agents