Now fix resize command :D
parent
aa1e21dd99
commit
c3c2e68cc1
|
@ -103,7 +103,7 @@ void cli_tool_t::help()
|
||||||
"%s snap-create [-p|--pool <id|name>] <image>@<snapshot>\n"
|
"%s snap-create [-p|--pool <id|name>] <image>@<snapshot>\n"
|
||||||
" Create a snapshot of image <name>. May be used live if only a single writer is active.\n"
|
" Create a snapshot of image <name>. May be used live if only a single writer is active.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"%s modify <name> [--rename <new-name>] [-s|--size <size>] [--readonly | --readwrite] [-f|--force]\n"
|
"%s modify <name> [--rename <new-name>] [--resize <size>] [--readonly | --readwrite] [-f|--force]\n"
|
||||||
" Rename, resize image or change its readonly status. Images with children can't be made read-write.\n"
|
" Rename, resize image or change its readonly status. Images with children can't be made read-write.\n"
|
||||||
" If the new size is smaller than the old size, extra data will be purged.\n"
|
" If the new size is smaller than the old size, extra data will be purged.\n"
|
||||||
" You should resize file system in the image, if present, before shrinking it.\n"
|
" You should resize file system in the image, if present, before shrinking it.\n"
|
||||||
|
|
|
@ -63,6 +63,15 @@ struct image_changer_t
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ((!set_readwrite || !cfg.readonly) &&
|
||||||
|
(!set_readonly || cfg.readonly) &&
|
||||||
|
(!new_size || cfg.size == new_size) &&
|
||||||
|
(new_name == "" || new_name == image_name))
|
||||||
|
{
|
||||||
|
printf("No change\n");
|
||||||
|
state = 100;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (new_size != 0)
|
if (new_size != 0)
|
||||||
{
|
{
|
||||||
if (cfg.size >= new_size)
|
if (cfg.size >= new_size)
|
||||||
|
@ -201,11 +210,7 @@ std::function<bool(void)> cli_tool_t::start_modify(json11::Json cfg)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
changer->new_name = cfg["rename"].string_value();
|
changer->new_name = cfg["rename"].string_value();
|
||||||
if (changer->new_name == changer->image_name)
|
changer->new_size = parse_size(cfg["resize"].string_value());
|
||||||
{
|
|
||||||
changer->new_name = "";
|
|
||||||
}
|
|
||||||
changer->new_size = cfg["size"].uint64_value();
|
|
||||||
if (changer->new_size != 0 && (changer->new_size % 4096))
|
if (changer->new_size != 0 && (changer->new_size % 4096))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Image size should be a multiple of 4096\n");
|
fprintf(stderr, "Image size should be a multiple of 4096\n");
|
||||||
|
|
Loading…
Reference in New Issue