1 Star 0 Fork 71

wangyangdahai/libvirt

forked from src-openEuler/libvirt 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
hotpatch-implement-hotpatch-virsh-api.patch 2.95 KB
一键复制 编辑 原始数据 按行查看 历史
From cf380e22898f70f5782bcea8b0d22027ff7d86af Mon Sep 17 00:00:00 2001
From: AlexChen <alex.chen@huawei.com>
Date: Wed, 20 Oct 2021 11:07:34 +0800
Subject: [PATCH] hotpatch: implement hotpatch virsh api
Signed-off-by: Hao Wang <wanghao232@huawei.com>
Signed-off-by: Bihong Yu <yubihong@huawei.com>
Signed-off-by: AlexChen <alex.chen@huawei.com>
---
tools/virsh-domain.c | 78 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 78 insertions(+)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index f643bd403e..813be4a0db 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -14326,6 +14326,78 @@ cmdGuestInfo(vshControl *ctl, const vshCmd *cmd)
return ret;
}
+/*
+ * "hotpatch" command
+ */
+static const vshCmdInfo info_hotpatch[] = {
+ {.name = "help",
+ .data = N_("Manage hotpatch of a live domain")
+ },
+ {.name = "desc",
+ .data = N_("Manage hotpatch of a live domain")
+ },
+ {.name = NULL}
+};
+
+static const vshCmdOptDef opts_hotpatch[] = {
+ VIRSH_COMMON_OPT_DOMAIN_FULL(0),
+ {.name = "action",
+ .type = VSH_OT_DATA,
+ .flags = VSH_OFLAG_REQ,
+ .help = N_("hotpatch action, choose from <apply>, <unapply> and <query>")
+ },
+ {.name = "patch",
+ .type = VSH_OT_STRING,
+ .help = N_("the absolute path of the hotpatch file, mandatory when action=apply")
+ },
+ {.name = "id",
+ .type = VSH_OT_STRING,
+ .help = N_("the unique id of the target patch, mandatory when action=unapply")
+ },
+ {.name = NULL}
+};
+
+VIR_ENUM_DECL(virDomainHotpatchAction);
+VIR_ENUM_IMPL(virDomainHotpatchAction,
+ VIR_DOMAIN_HOTPATCH_LAST,
+ "none",
+ "apply",
+ "unapply",
+ "query");
+
+static bool
+cmdHotpatch(vshControl *ctl,
+ const vshCmd *cmd)
+{
+ g_autoptr(virshDomain) dom = NULL;
+ const char *patch = NULL;
+ const char *id = NULL;
+ const char *actionstr = NULL;
+ int action = -1;
+ g_autofree char *ret = NULL;
+
+ if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+ return false;
+
+ if (vshCommandOptStringReq(ctl, cmd, "action", &actionstr) < 0)
+ return false;
+
+ if (actionstr)
+ action = virDomainHotpatchActionTypeFromString(actionstr);
+
+ if (vshCommandOptStringReq(ctl, cmd, "patch", &patch) < 0)
+ return false;
+
+ if (vshCommandOptStringReq(ctl, cmd, "id", &id) < 0)
+ return false;
+
+ if (!(ret = virDomainHotpatchManage(dom, action, patch, id, 0)))
+ return false;
+
+ vshPrint(ctl, _("%s"), ret);
+ return true;
+}
+
const vshCmdDef domManagementCmds[] = {
{.name = "attach-device",
.handler = cmdAttachDevice,
@@ -14953,5 +15025,11 @@ const vshCmdDef domManagementCmds[] = {
.info = info_guestinfo,
.flags = 0
},
+ {.name = "hotpatch",
+ .handler = cmdHotpatch,
+ .opts = opts_hotpatch,
+ .info = info_hotpatch,
+ .flags = 0
+ },
{.name = NULL}
};
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wangyangdahai/libvirt.git
git@gitee.com:wangyangdahai/libvirt.git
wangyangdahai
libvirt
libvirt
master

搜索帮助