- hotpatch: if hotpatch_path not in qemu.conf,the hotpatch doesn't antoload - remote: check for negative array lengths before allocation - Fix off-by-one error in udevListInterfacesByStatus - Fix warnings found by clang - hotpatch: virsh support autoload mode - domain: add logs for virDomainHotpatchManage - hotpatch: check vm id and pid before using hotpatch api - hotpatch: implement hotpatch virsh api - hotpatch: introduce hotpatch async job flag - hotpatch: Implement qemuDomainHotpatchManage - Hotpatch: introduce DomainHotpatchManage API Signed-off-by: Jiabo Feng <fengjiabo1@huawei.com>
111 lines
2.9 KiB
Diff
111 lines
2.9 KiB
Diff
From d56a3df418b90f4a6f303a3830732b5fde8d3a10 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 9d22e219f7..d88ac3cca6 100644
|
|
--- a/tools/virsh-domain.c
|
|
+++ b/tools/virsh-domain.c
|
|
@@ -13556,6 +13556,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;
|
|
+}
|
|
+
|
|
/*
|
|
* "get-user-sshkeys" command
|
|
*/
|
|
@@ -14456,5 +14528,11 @@ const vshCmdDef domManagementCmds[] = {
|
|
.info = info_dom_fd_associate,
|
|
.flags = 0
|
|
},
|
|
+ {.name = "hotpatch",
|
|
+ .handler = cmdHotpatch,
|
|
+ .opts = opts_hotpatch,
|
|
+ .info = info_hotpatch,
|
|
+ .flags = 0
|
|
+ },
|
|
{.name = NULL}
|
|
};
|
|
--
|
|
2.27.0
|
|
|