From: Stefan Berger Subject: [PATCH] [Xend] [ACM] check for duplicate labels and types Date: Sat, 07 Jun 2008 11:49:41 -0400 Message-ID: <1212853781.28696.7.camel@gsal-3.watson.ibm.com> Reply-To: stefanb@us.ibm.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-5vasM35Eav70xTDpCCYg" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel Cc: Keir Fraser List-Id: xen-devel@lists.xenproject.org --=-5vasM35Eav70xTDpCCYg Content-Type: text/plain Content-Transfer-Encoding: 7bit This patch adds a check for duplicate label or type entries in the policy and returns an error if those are found. Signed-off-by: Stefan Berger --=-5vasM35Eav70xTDpCCYg Content-Disposition: attachment; filename=acm_policy_check_duplicate_entries.diff Content-Type: text/x-patch; name=acm_policy_check_duplicate_entries.diff; charset=UTF-8 Content-Transfer-Encoding: 7bit Index: root/xen-unstable.hg/tools/python/xen/util/acmpolicy.py =================================================================== --- root.orig/xen-unstable.hg/tools/python/xen/util/acmpolicy.py +++ root/xen-unstable.hg/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) Index: root/xen-unstable.hg/tools/python/xen/util/xsconstants.py =================================================================== --- root.orig/xen-unstable.hg/tools/python/xen/util/xsconstants.py +++ root/xen-unstable.hg/tools/python/xen/util/xsconstants.py @@ -59,7 +59,8 @@ XSERR_HV_OP_FAILED = 24 + XS 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): --=-5vasM35Eav70xTDpCCYg Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=-5vasM35Eav70xTDpCCYg--