1 Star 0 Fork 121

Jiabo Feng/qemu

forked from src-openEuler/qemu 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
cvm-Implement-command-blacklist-for-cvm-security-enh.patch 3.62 KB
一键复制 编辑 原始数据 按行查看 历史
Jiabo Feng 提交于 2024-09-18 15:20 . QEMU update to version 8.2.0-18:
From 384b3f41fd69ed6f5bf376ff1aac1a12deeea0fb Mon Sep 17 00:00:00 2001
From: liupingwei <liupingwei0317@outlook.com>
Date: Fri, 16 Aug 2024 18:06:10 +0800
Subject: [PATCH] cvm : Implement command blacklist for cvm security
enhancement
Added a new feature to intercept and block specific virsh commands(virsh
save,virsh restore,virsh dump,virsh suspend,virsh resume)that can impact
the security of cvm.
Signed-off-by: liupingwei <liupingwei0317@outlook.com>
---
dump/dump.c | 7 +++++++
migration/migration-hmp-cmds.c | 6 ++++++
migration/savevm.c | 6 ++++++
monitor/qmp-cmds.c | 6 ++++++
4 files changed, 25 insertions(+)
diff --git a/dump/dump.c b/dump/dump.c
index 4819050764..787059ac2c 100644
--- a/dump/dump.c
+++ b/dump/dump.c
@@ -20,6 +20,7 @@
#include "sysemu/dump.h"
#include "sysemu/runstate.h"
#include "sysemu/cpus.h"
+#include "sysemu/kvm.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-dump.h"
#include "qapi/qapi-events-dump.h"
@@ -2065,6 +2066,12 @@ void qmp_dump_guest_memory(bool paging, const char *protocol,
Error **errp)
{
ERRP_GUARD();
+
+ if (virtcca_cvm_enabled()) {
+ error_setg(errp, "The dump-guest-memory command is temporarily unsupported in cvm.");
+ return;
+ }
+
const char *p;
int fd;
DumpState *s;
diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
index 1fa6a5f478..386ba7fc98 100644
--- a/migration/migration-hmp-cmds.c
+++ b/migration/migration-hmp-cmds.c
@@ -30,6 +30,7 @@
#include "sysemu/runstate.h"
#include "ui/qemu-spice.h"
#include "sysemu/sysemu.h"
+#include "sysemu/kvm.h"
#include "options.h"
#include "migration.h"
@@ -406,6 +407,11 @@ void hmp_loadvm(Monitor *mon, const QDict *qdict)
const char *name = qdict_get_str(qdict, "name");
Error *err = NULL;
+ if (virtcca_cvm_enabled()) {
+ error_setg(&err, "The loadvm command is temporarily unsupported in cvm.");
+ return;
+ }
+
vm_stop(RUN_STATE_RESTORE_VM);
if (load_snapshot(name, NULL, false, NULL, &err) && saved_vm_running) {
diff --git a/migration/savevm.c b/migration/savevm.c
index 477a19719f..cc65da605e 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -61,6 +61,7 @@
#include "sysemu/replay.h"
#include "sysemu/runstate.h"
#include "sysemu/sysemu.h"
+#include "sysemu/kvm.h"
#include "sysemu/xen.h"
#include "migration/colo.h"
#include "qemu/bitmap.h"
@@ -3044,6 +3045,11 @@ int qemu_loadvm_approve_switchover(void)
bool save_snapshot(const char *name, bool overwrite, const char *vmstate,
bool has_devices, strList *devices, Error **errp)
{
+ if (virtcca_cvm_enabled()) {
+ error_setg(errp, "The savevm command is temporarily unsupported in cvm.");
+ return false;
+ }
+
BlockDriverState *bs;
QEMUSnapshotInfo sn1, *sn = &sn1;
int ret = -1, ret2;
diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
index e78462b857..c0b66f11bf 100644
--- a/monitor/qmp-cmds.c
+++ b/monitor/qmp-cmds.c
@@ -23,6 +23,7 @@
#include "sysemu/runstate.h"
#include "sysemu/runstate-action.h"
#include "sysemu/block-backend.h"
+#include "sysemu/kvm.h"
#include "qapi/error.h"
#include "qapi/qapi-init-commands.h"
#include "qapi/qapi-commands-control.h"
@@ -50,6 +51,11 @@ void qmp_quit(Error **errp)
void qmp_stop(Error **errp)
{
+ if (virtcca_cvm_enabled()) {
+ error_setg(errp, "The stop command is temporarily unsupported in cvm.");
+ return;
+ }
+
/* if there is a dump in background, we should wait until the dump
* finished */
if (qemu_system_dump_in_progress()) {
--
2.41.0.windows.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/JiaboFeng/qemu.git
git@gitee.com:JiaboFeng/qemu.git
JiaboFeng
qemu
qemu
master

搜索帮助