From: Keir Fraser Date: Mon, 9 Jun 2008 08:37:56 +0000 (+0100) Subject: acm: check for duplicate labels and types X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14200^2~88 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=a7cd0e3f9160308f27f95c12826e56465fa8a9fe;p=xen.git acm: check for duplicate labels and types Signed-off-by: Stefan Berger --- diff --git a/tools/python/xen/util/acmpolicy.py b/tools/python/xen/util/acmpolicy.py index b7ccb194b5..5d4711c52d 100644 --- a/tools/python/xen/util/acmpolicy.py +++ b/tools/python/xen/util/acmpolicy.py @@ -1323,6 +1323,13 @@ class ACMPolicy(XSPolicy): if ACM_LABEL_UNLABELED in resnames: resnames.remove(ACM_LABEL_UNLABELED) + # check for duplicate labels + if len(vmlabels) != len(set(vmlabels)) or \ + len(resnames) != len(set(resnames)) or \ + len(stes) != len(set(stes)) or \ + len(chws) != len(set(chws)): + return -xsconstants.XSERR_POLICY_HAS_DUPLICATES, "", "" + max_chw_ssids = 1 + len(vms_with_chws) max_chw_types = 1 + len(vms_with_chws) max_ste_ssids = 1 + len(vms_with_stes) + len(resnames) diff --git a/tools/python/xen/util/xsconstants.py b/tools/python/xen/util/xsconstants.py index 730d66fbf5..88fb8fdecc 100644 --- a/tools/python/xen/util/xsconstants.py +++ b/tools/python/xen/util/xsconstants.py @@ -59,7 +59,8 @@ XSERR_HV_OP_FAILED = 24 + XSERR_BASE XSERR_BOOTPOLICY_INSTALL_ERROR = 25 + XSERR_BASE XSERR_VM_NOT_AUTHORIZED = 26 + XSERR_BASE XSERR_VM_IN_CONFLICT = 27 + XSERR_BASE -XSERR_LAST = 27 + XSERR_BASE ## KEEP LAST +XSERR_POLICY_HAS_DUPLICATES = 28 + XSERR_BASE +XSERR_LAST = 28 + XSERR_BASE ## KEEP LAST XSERR_MESSAGES = [ '', @@ -89,7 +90,8 @@ XSERR_MESSAGES = [ 'Operation failed in hypervisor', 'Boot policy installation error', 'VM is not authorized to run', - 'VM label conflicts with another VM' + 'VM label conflicts with another VM', + 'Duplicate labels or types in policy' ] def xserr2string(err):