cli: --idmap: use predictable cli subarg names

To match the XML schema, rename these subarguments and add aliases
to preserve compatibility:

* gid_count -> gid.count
* gid_start -> gid.start
* gid_target -> gid.target
* uid_count -> uid.count
* uid_start -> uid.start
* uid_target -> uid.target
This commit is contained in:
Cole Robinson 2019-05-11 19:50:09 -04:00
parent 8d26a08d25
commit 6aa9c6eecf
2 changed files with 17 additions and 10 deletions

View File

@ -555,10 +555,9 @@ the 'user' namespace will be enabled to apply these.
A suitably configured UID/GID mapping is a pre-requisite to
make containers secure, in the absence of sVirt confinement.
--idmap can be specified to enable user namespace for LXC containers
--idmap can be specified to enable user namespace for LXC containers. Example:
Example:
--idmap uid_start=0,uid_target=1000,uid_count=10,gid_start=0,gid_target=1000,gid_count=10
--idmap uid.start=0,uid.target=1000,uid.count=10,gid.start=0,gid.target=1000,gid.count=10
Use --idmap=? to see a list of all available sub options. Complete details at L<https://libvirt.org/formatdomain.html#elementsOSContainer>

View File

@ -829,7 +829,7 @@ def add_boot_options(insg):
ParserIdmap.register()
insg.add_argument("--idmap", action="append",
help=_("Enable user namespace for LXC container. Ex:\n"
"--idmap uid_start=0,uid_target=1000,uid_count=10"))
"--idmap uid.start=0,uid.target=1000,uid.count=10"))
def add_disk_option(stog, editexample=False):
@ -2076,16 +2076,24 @@ class ParserBoot(VirtCLIParser):
class ParserIdmap(VirtCLIParser):
cli_arg_name = "idmap"
guest_propname = "idmap"
aliases = {
"uid.start": "uid_start",
"uid.target": "uid_target",
"uid.count": "uid_count",
"gid.start": "gid_start",
"gid.target": "gid_target",
"gid.count": "gid_count",
}
@classmethod
def _init_class(cls, **kwargs):
VirtCLIParser._init_class(**kwargs)
cls.add_arg("uid_start", "uid_start")
cls.add_arg("uid_target", "uid_target")
cls.add_arg("uid_count", "uid_count")
cls.add_arg("gid_start", "gid_start")
cls.add_arg("gid_target", "gid_target")
cls.add_arg("gid_count", "gid_count")
cls.add_arg("uid.start", "uid_start")
cls.add_arg("uid.target", "uid_target")
cls.add_arg("uid.count", "uid_count")
cls.add_arg("gid.start", "gid_start")
cls.add_arg("gid.target", "gid_target")
cls.add_arg("gid.count", "gid_count")
######################