代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/libvirt 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 58121fbc3085296364e6b90bc16cb56eeaf36f77 Mon Sep 17 00:00:00 2001
From: AlexChen <alex.chen@huawei.com>
Date: Fri, 9 Jul 2021 10:50:07 +0800
Subject: [PATCH] hotpatch: check vm id and pid before using hotpatch api
Check if the vm is alive before using hotpatch api by calling
virDomainObjCheckActive() to check vm id and calling
qemuDomainHotpatchCheckPid() to check vm pid.
Signed-off-by: Bihong Yu <yubihong@huawei.com>
Signed-off-by: AlexChen <alex.chen@huawei.com>
---
src/qemu/qemu_driver.c | 3 +++
src/qemu/qemu_hotpatch.c | 36 ++++++++++++++++++++++++++++++------
2 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d4c5f073bb..2b24881f75 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -23196,6 +23196,9 @@ qemuDomainHotpatchManage(virDomainPtr domain,
VIR_DOMAIN_JOB_OPERATION_HOTPATCH, 0) < 0)
goto cleanup;
+ if (virDomainObjCheckActive(vm) < 0)
+ goto endjob;
+
qemuDomainObjSetAsyncJobMask(vm, QEMU_JOB_DEFAULT_MASK);
switch (action) {
diff --git a/src/qemu/qemu_hotpatch.c b/src/qemu/qemu_hotpatch.c
index 45796b3f24..03e63c1341 100644
--- a/src/qemu/qemu_hotpatch.c
+++ b/src/qemu/qemu_hotpatch.c
@@ -37,12 +37,25 @@
VIR_LOG_INIT("qemu_hotpatch");
+static int
+qemuDomainHotpatchCheckPid(pid_t pid)
+{
+ if (pid <= 0) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ "%s", _("Invalid pid"));
+ return -1;
+ }
+
+ return 0;
+}
+
char *
qemuDomainHotpatchQuery(virDomainObjPtr vm)
{
g_autoptr(virCommand) cmd = NULL;
g_autofree char *binary = NULL;
char *output = NULL;
+ pid_t pid = vm->pid;
int ret = -1;
if (!(binary = virFindFileInPath(LIBCARE_CTL))) {
@@ -51,12 +64,15 @@ qemuDomainHotpatchQuery(virDomainObjPtr vm)
return NULL;
}
+ if (qemuDomainHotpatchCheckPid(pid) < 0)
+ return NULL;
+
cmd = virCommandNewArgList(binary, "info", "-p", NULL);
- virCommandAddArgFormat(cmd, "%d", vm->pid);
+ virCommandAddArgFormat(cmd, "%d", pid);
virCommandSetOutputBuffer(cmd, &output);
VIR_DEBUG("Querying hotpatch for domain %s. (%s info -p %d)",
- vm->def->name, binary, vm->pid);
+ vm->def->name, binary, pid);
if (virCommandRun(cmd, &ret) < 0)
goto error;
@@ -80,6 +96,7 @@ qemuDomainHotpatchApply(virDomainObjPtr vm,
g_autoptr(virCommand) cmd = NULL;
g_autofree char *binary = NULL;
char *output = NULL;
+ pid_t pid = vm->pid;
int ret = -1;
if (!patch || !virFileExists(patch)) {
@@ -94,13 +111,16 @@ qemuDomainHotpatchApply(virDomainObjPtr vm,
return NULL;
}
+ if (qemuDomainHotpatchCheckPid(pid) < 0)
+ return NULL;
+
cmd = virCommandNewArgList(binary, "patch", "-p", NULL);
- virCommandAddArgFormat(cmd, "%d", vm->pid);
+ virCommandAddArgFormat(cmd, "%d", pid);
virCommandAddArgList(cmd, patch, NULL);
virCommandSetOutputBuffer(cmd, &output);
VIR_DEBUG("Applying hotpatch for domain %s. (%s patch -p %d %s)",
- vm->def->name, binary, vm->pid, patch);
+ vm->def->name, binary, pid, patch);
if (virCommandRun(cmd, &ret) < 0)
goto error;
@@ -144,6 +164,7 @@ qemuDomainHotpatchUnapply(virDomainObjPtr vm,
g_autoptr(virCommand) cmd = NULL;
g_autofree char *binary = NULL;
char *output = NULL;
+ pid_t pid = vm->pid;
int ret = -1;
if (!id || !qemuDomainHotpatchIsPatchidValid(id)) {
@@ -158,13 +179,16 @@ qemuDomainHotpatchUnapply(virDomainObjPtr vm,
return NULL;
}
+ if (qemuDomainHotpatchCheckPid(pid) < 0)
+ return NULL;
+
cmd = virCommandNewArgList(binary, "unpatch", "-p", NULL);
- virCommandAddArgFormat(cmd, "%d", vm->pid);
+ virCommandAddArgFormat(cmd, "%d", pid);
virCommandAddArgList(cmd, "-i", id, NULL);
virCommandSetOutputBuffer(cmd, &output);
VIR_DEBUG("Unapplying hotpatch for domain %s. (%s unpatch -p %d -i %s)",
- vm->def->name, binary, vm->pid, id);
+ vm->def->name, binary, pid, id);
if (virCommandRun(cmd, &ret) < 0)
goto error;
--
2.27.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。