mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-14 15:05:48 +00:00
Freeze/unfreeze when checkpointing, stop the container when specified with '-s' option
This commit is contained in:
parent
975878a9ea
commit
893c6f54ef
@ -38,13 +38,18 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
char opt;
|
||||
char *name = NULL;
|
||||
int stop = 0;
|
||||
int nbargs = 0;
|
||||
int ret = 1;
|
||||
|
||||
while ((opt = getopt(argc, argv, "n:")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "sn:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'n':
|
||||
name = optarg;
|
||||
break;
|
||||
case 's':
|
||||
stop = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
nbargs++;
|
||||
@ -53,10 +58,30 @@ int main(int argc, char *argv[])
|
||||
if (!name)
|
||||
usage(argv[0]);
|
||||
|
||||
if (lxc_freeze(name)) {
|
||||
fprintf(stderr, "failed to freeze '%s'\n", name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (lxc_checkpoint(name, STDOUT_FILENO, 0)) {
|
||||
fprintf(stderr, "failed to checkpoint %s\n", name);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (stop) {
|
||||
if (lxc_stop(name)) {
|
||||
fprintf(stderr, "failed to stop '%s'\n", name);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
out:
|
||||
if (lxc_unfreeze(name)) {
|
||||
fprintf(stderr, "failed to unfreeze '%s'\n", name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user