git: 4e10f8056b24 - stable/13 - bhyvectl: don't permit using --suspend and --checkpoint at same time
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 17 Mar 2023 10:29:35 UTC
The branch stable/13 has been updated by corvink:
URL: https://cgit.FreeBSD.org/src/commit/?id=4e10f8056b24df320fdc0c2d520461e3155597d3
commit 4e10f8056b24df320fdc0c2d520461e3155597d3
Author: Vitaliy Gusev <gusev.vitaliy@gmail.com>
AuthorDate: 2023-03-06 12:42:15 +0000
Commit: Corvin Köhne <corvink@FreeBSD.org>
CommitDate: 2023-03-17 10:26:35 +0000
bhyvectl: don't permit using --suspend and --checkpoint at same time
When using the --suspend and --checkpoint parameter, bhyvectl will
produce two checkpoint images and the exits. This is slightly ambiguous.
So, permit only one of theses parameters at the same time.
Reviewed by: corvink, markj
MFC after: 1 week
Sponsored by: vStack
Differential Revision: https://reviews.freebsd.org/D38887
(cherry picked from commit 062f2818c1ad35bdc3d520c7572e3cefda657770)
---
usr.sbin/bhyvectl/bhyvectl.c | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/usr.sbin/bhyvectl/bhyvectl.c b/usr.sbin/bhyvectl/bhyvectl.c
index 4aa235e00489..e5789eaf30e8 100644
--- a/usr.sbin/bhyvectl/bhyvectl.c
+++ b/usr.sbin/bhyvectl/bhyvectl.c
@@ -86,8 +86,7 @@ usage(bool cpu_intel)
" [--create]\n"
" [--destroy]\n"
#ifdef BHYVE_SNAPSHOT
- " [--checkpoint=<filename>]\n"
- " [--suspend=<filename>]\n"
+ " [--checkpoint=<filename> | --suspend=<filename>]\n"
#endif
" [--get-all]\n"
" [--get-stats]\n"
@@ -299,7 +298,6 @@ static int unassign_pptdev, bus, slot, func;
static int run;
static int get_cpu_topology;
#ifdef BHYVE_SNAPSHOT
-static int vm_checkpoint_opt;
static int vm_suspend_opt;
#endif
@@ -1743,7 +1741,7 @@ main(int argc, char *argv[])
struct tm tm;
struct option *opts;
#ifdef BHYVE_SNAPSHOT
- char *checkpoint_file, *suspend_file;
+ char *checkpoint_file = NULL;
#endif
cpu_intel = cpu_vendor_intel();
@@ -1905,12 +1903,12 @@ main(int argc, char *argv[])
break;
#ifdef BHYVE_SNAPSHOT
case SET_CHECKPOINT_FILE:
- vm_checkpoint_opt = 1;
- checkpoint_file = optarg;
- break;
case SET_SUSPEND_FILE:
- vm_suspend_opt = 1;
- suspend_file = optarg;
+ if (checkpoint_file != NULL)
+ usage(cpu_intel);
+
+ checkpoint_file = optarg;
+ vm_suspend_opt = (ch == SET_SUSPEND_FILE);
break;
#endif
default:
@@ -2385,11 +2383,8 @@ main(int argc, char *argv[])
vm_destroy(ctx);
#ifdef BHYVE_SNAPSHOT
- if (!error && vm_checkpoint_opt)
- error = snapshot_request(vmname, checkpoint_file, false);
-
- if (!error && vm_suspend_opt)
- error = snapshot_request(vmname, suspend_file, true);
+ if (!error && checkpoint_file)
+ error = snapshot_request(vmname, checkpoint_file, vm_suspend_opt);
#endif
free (opts);