def setup_controller_xml(): """ Prepare controller devices of VM XML according to params. """ if cntlr_type is None: return ctrl = Controller(type_name=cntlr_type) if model is not None: ctrl.model = model if pcihole is not None: ctrl.pcihole64 = pcihole if vectors is not None: ctrl.vectors = vectors if index is not None: ctrl.index = index if addr_str is not None: match = re.match( r"(?P<bus>[0-9]*):(?P<slot>[0-9]*).(?P<function>[0-9])", addr_str) if match: addr_dict = match.groupdict() addr_dict['bus'] = hex(int(addr_dict['bus'])) addr_dict['slot'] = hex(int(addr_dict['slot'])) addr_dict['function'] = hex(int(addr_dict['function'])) addr_dict['domain'] = '0x0000' ctrl.address = ctrl.new_controller_address(attrs=addr_dict) logging.debug("Controller XML is:%s", ctrl) vm_xml.add_device(ctrl) if usb_cntlr_model is not None: ctrl = Controller(type_name='usb') ctrl.model = usb_cntlr_model if usb_cntlr_addr is not None: match = re.match( r"(?P<bus>[0-9]*):(?P<slot>[0-9]*).(?P<function>[0-9])", usb_cntlr_addr) if match: addr_dict = match.groupdict() addr_dict['bus'] = hex(int(addr_dict['bus'])) addr_dict['slot'] = hex(int(addr_dict['slot'])) addr_dict['function'] = hex(int(addr_dict['function'])) addr_dict['domain'] = '0x0000' ctrl.address = ctrl.new_controller_address(attrs=addr_dict) vm_xml.add_device(ctrl)
def setup_controller_xml(index, addr_target=None): """ Prepare controller devices of VM XML. :param index: The index of controller :param addr_target: The controller address """ ctrl = Controller(type_name=cntlr_type) if model: ctrl.model = model if pcihole: ctrl.pcihole64 = pcihole if vectors: ctrl.vectors = vectors if index: ctrl.index = index if chassisNr: ctrl.target = {'chassisNr': chassisNr} if model_name: ctrl.model_name = {'name': model_name} if addr_target: match = re.match( r"(?P<bus>[0-9]*):(?P<slot>[0-9a-f]*).(?P<function>[0-9])", addr_target) if match: addr_dict = match.groupdict() addr_dict['bus'] = hex(int(addr_dict['bus'], 16)) addr_dict['slot'] = hex(int(addr_dict['slot'], 16)) addr_dict['function'] = hex(int(addr_dict['function'], 16)) addr_dict['domain'] = '0x0000' ctrl.address = ctrl.new_controller_address(attrs=addr_dict) logging.debug("Controller XML is:%s", ctrl) vm_xml.add_device(ctrl) if cmpnn_cntlr_model is not None: for num in range(int(cmpnn_cntlr_num)): ctrl = Controller(type_name=cntlr_type) ctrl.model = cmpnn_cntlr_model + str(num + 1) ctrl.index = index logging.debug("Controller XML is:%s", ctrl) vm_xml.add_device(ctrl)
def setup_controller_xml(): """ Prepare controller devices of VM XML according to params. """ if cntlr_type is None: return ctrl = Controller(type_name=cntlr_type) if model is not None: ctrl.model = model if pcihole is not None: ctrl.pcihole64 = pcihole if vectors is not None: ctrl.vectors = vectors if index is not None: ctrl.index = index if addr_str is not None: match = re.match(r"(?P<bus>[0-9]*):(?P<slot>[0-9]*).(?P<function>[0-9])", addr_str) if match: addr_dict = match.groupdict() addr_dict['bus'] = hex(int(addr_dict['bus'])) addr_dict['slot'] = hex(int(addr_dict['slot'])) addr_dict['function'] = hex(int(addr_dict['function'])) addr_dict['domain'] = '0x0000' ctrl.address = ctrl.new_controller_address(attrs=addr_dict) logging.debug("Controller XML is:%s", ctrl) vm_xml.add_device(ctrl) if usb_cntlr_model is not None: ctrl = Controller(type_name='usb') ctrl.model = usb_cntlr_model if usb_cntlr_addr is not None: match = re.match(r"(?P<bus>[0-9]*):(?P<slot>[0-9]*).(?P<function>[0-9])", usb_cntlr_addr) if match: addr_dict = match.groupdict() addr_dict['bus'] = hex(int(addr_dict['bus'])) addr_dict['slot'] = hex(int(addr_dict['slot'])) addr_dict['function'] = hex(int(addr_dict['function'])) addr_dict['domain'] = '0x0000' ctrl.address = ctrl.new_controller_address(attrs=addr_dict) vm_xml.add_device(ctrl)