1 Star 0 Fork 126

ganqx/src-qemu

forked from src-openEuler/qemu 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
target-i386-csv-Add-support-to-migrate-the-incoming--new.patch 4.05 KB
一键复制 编辑 原始数据 按行查看 历史
Jiabo Feng 提交于 2024-12-12 17:01 . QEMU update to version 8.2.0-26:
From b31be8b06440deccdf00de2a7886d04fe87dc802 Mon Sep 17 00:00:00 2001
From: jiangxin <jiangxin@hygon.cn>
Date: Fri, 17 Jun 2022 10:00:46 +0800
Subject: [PATCH] target/i386: csv: Add support to migrate the incoming context
for CSV3 guest
The csv3_load_incoming_context() provides the method to read incoming
guest's context from socket. It loads them into guest private memory.
This is the last step during migration and RECEIVE FINISH command is
performed by then to complete the whole migration.
Signed-off-by: Jiang Xin <jiangxin@hygon.cn>
Signed-off-by: hanliyang <hanliyang@hygon.cn>
---
target/i386/csv.c | 45 ++++++++++++++++++++++++++++++++++++++++
target/i386/csv.h | 1 +
target/i386/trace-events | 1 +
3 files changed, 47 insertions(+)
diff --git a/target/i386/csv.c b/target/i386/csv.c
index cc90b57e5b..571beeb61f 100644
--- a/target/i386/csv.c
+++ b/target/i386/csv.c
@@ -47,6 +47,7 @@ struct ConfidentialGuestMemoryEncryptionOps csv3_memory_encryption_ops = {
.queue_incoming_page = NULL,
.load_queued_incoming_pages = NULL,
.save_outgoing_cpu_state = csv3_save_outgoing_context,
+ .load_incoming_cpu_state = csv3_load_incoming_context,
};
#define CSV3_OUTGOING_PAGE_NUM \
@@ -644,6 +645,42 @@ err:
return ret;
}
+static int
+csv3_receive_encrypt_context(Csv3GuestState *s, QEMUFile *f)
+{
+ int ret = 1, fw_error = 0;
+ gchar *hdr = NULL, *trans = NULL;
+ struct kvm_csv3_receive_encrypt_context update = {};
+
+ /* get packet header */
+ update.hdr_len = qemu_get_be32(f);
+
+ hdr = g_new(gchar, update.hdr_len);
+ qemu_get_buffer(f, (uint8_t *)hdr, update.hdr_len);
+ update.hdr_uaddr = (uintptr_t)hdr;
+
+ /* get transport buffer */
+ update.trans_len = qemu_get_be32(f);
+
+ trans = g_new(gchar, update.trans_len);
+ update.trans_uaddr = (uintptr_t)trans;
+ qemu_get_buffer(f, (uint8_t *)update.trans_uaddr, update.trans_len);
+
+ trace_kvm_csv3_receive_encrypt_context(trans, update.trans_len, hdr, update.hdr_len);
+
+ ret = csv3_ioctl(KVM_CSV3_RECEIVE_ENCRYPT_CONTEXT, &update, &fw_error);
+ if (ret) {
+ error_report("Error RECEIVE_ENCRYPT_CONTEXT ret=%d fw_error=%d '%s'",
+ ret, fw_error, fw_error_to_str(fw_error));
+ goto err;
+ }
+
+err:
+ g_free(trans);
+ g_free(hdr);
+ return ret;
+}
+
int csv3_save_outgoing_context(QEMUFile *f, uint64_t *bytes_sent)
{
Csv3GuestState *s = &csv3_guest;
@@ -651,3 +688,11 @@ int csv3_save_outgoing_context(QEMUFile *f, uint64_t *bytes_sent)
/* send csv3 context. */
return csv3_send_encrypt_context(s, f, bytes_sent);
}
+
+int csv3_load_incoming_context(QEMUFile *f)
+{
+ Csv3GuestState *s = &csv3_guest;
+
+ /* receive csv3 context. */
+ return csv3_receive_encrypt_context(s, f);
+}
diff --git a/target/i386/csv.h b/target/i386/csv.h
index 9f83a271fd..8621f0b6fd 100644
--- a/target/i386/csv.h
+++ b/target/i386/csv.h
@@ -123,6 +123,7 @@ int csv3_load_data(uint64_t gpa, uint8_t *ptr, uint64_t len, Error **errp);
int csv3_shared_region_dma_map(uint64_t start, uint64_t end);
void csv3_shared_region_dma_unmap(uint64_t start, uint64_t end);
int csv3_load_incoming_page(QEMUFile *f, uint8_t *ptr);
+int csv3_load_incoming_context(QEMUFile *f);
int csv3_queue_outgoing_page(uint8_t *ptr, uint32_t sz, uint64_t addr);
int csv3_save_queued_outgoing_pages(QEMUFile *f, uint64_t *bytes_sent);
int csv3_save_outgoing_context(QEMUFile *f, uint64_t *bytes_sent);
diff --git a/target/i386/trace-events b/target/i386/trace-events
index 043412c569..ad3cfb9612 100644
--- a/target/i386/trace-events
+++ b/target/i386/trace-events
@@ -25,3 +25,4 @@ kvm_csv3_launch_encrypt_data(uint64_t gpa, void *addr, uint64_t len) "gpa 0x%" P
kvm_csv3_send_encrypt_data(void *dst, int len) "trans %p len %d"
kvm_csv3_send_encrypt_context(void *dst, int len) "trans %p len %d"
kvm_csv3_receive_encrypt_data(void *dst, int len, void *hdr, int hdr_len) "trans %p len %d hdr %p hdr_len %d"
+kvm_csv3_receive_encrypt_context(void *dst, int len, void *hdr, int hdr_len) "trans %p len %d hdr %p hdr_len %d"
--
2.41.0.windows.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ganqx/src-qemu.git
git@gitee.com:ganqx/src-qemu.git
ganqx
src-qemu
src-qemu
master

搜索帮助