cli: --panic: use predictable cli subarg names

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

* iobase -> address.iobase

Simplify model back compat handling as a result
This commit is contained in:
Cole Robinson
2019-05-12 09:20:53 -04:00
parent b0c3c8e12e
commit b92f1595a8

View File

@ -3060,28 +3060,24 @@ class ParserPanic(VirtCLIParser):
cli_arg_name = "panic"
guest_propname = "devices.panic"
remove_first = "model"
compat_mode = False
def set_model_cb(self, inst, val, virtarg):
if self.compat_mode and val.startswith("0x"):
inst.model = DevicePanic.MODEL_ISA
inst.address.iobase = val
else:
inst.model = val
aliases = {
"address.iobase": "iobase",
}
def _parse(self, inst):
if (len(self.optstr.split(",")) == 1 and
not self.optstr.startswith("model=")):
self.compat_mode = True
# Handle old style '--panic 0xFOO' to set the iobase value
if (len(self.optdict) == 1 and
self.optdict.get("model", "").startswith("0x")):
self.optdict["address.iobase"] = self.optdict["model"]
self.optdict["model"] = DevicePanic.MODEL_ISA
return super()._parse(inst)
@classmethod
def _init_class(cls, **kwargs):
VirtCLIParser._init_class(**kwargs)
_add_device_address_args(cls)
cls.add_arg("model", "model", cb=cls.set_model_cb,
ignore_default=True)
cls.add_arg("iobase", "address.iobase")
cls.add_arg("model", "model", ignore_default=True)
###################