def __render_template(self): for target in ["startcmd", "setbootcmd", "stopcmd", "resetcmd"]: if not has_option(self.__bmc, target): src = os.path.join(config.infrasim_template, target) dst = os.path.join(self.get_workspace(), "scripts", target) with open(src, "r")as f: src_text = f.read() template = jinja2.Template(src_text) dst_text = template.render( yml_file=os.path.join(self.get_workspace(), "etc/infrasim.yml") ) with open(dst, "w") as f: f.write(dst_text) os.chmod(dst, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) if not has_option(self.__bmc, "startcmd"): self.__startcmd_script = os.path.join(self.get_workspace(), "scripts", "startcmd") if not has_option(self.__bmc, "chassiscontrol"): path_startcmd = os.path.join(self.get_workspace(), "scripts/startcmd") path_stopcmd = os.path.join(self.get_workspace(), "scripts/stopcmd") path_resetcmd = os.path.join(self.get_workspace(), "scripts/resetcmd") path_setbootcmd = os.path.join(self.get_workspace(), "scripts/setbootcmd") path_bootdev = os.path.join(self.get_workspace(), "bootdev") path_qemu_pid = os.path.join(self.get_workspace(), ".{}-node.pid".format(self.__node_name)) src = os.path.join(config.infrasim_template, "chassiscontrol") dst = os.path.join(self.get_workspace(), "scripts/chassiscontrol") with open(src, "r") as f: src_text = f.read() template = jinja2.Template(src_text) dst_text = template.render(startcmd=path_startcmd, stopcmd=path_stopcmd, resetcmd=path_resetcmd, setbootcmd=path_setbootcmd, qemu_pid_file=path_qemu_pid, bootdev=path_bootdev) with open(dst, "w") as f: f.write(dst_text) os.chmod(dst, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) self.__chassiscontrol_script = dst if not has_option(self.__bmc, "lancontrol"): shutil.copy(os.path.join(config.infrasim_template, "lancontrol"), os.path.join(self.get_workspace(), "scripts", "lancontrol")) self.__lancontrol_script = os.path.join(self.get_workspace(), "scripts", "lancontrol")
def __render_template(self): for target in ["startcmd", "setbootcmd", "stopcmd", "resetcmd"]: if not has_option(self.__bmc, target): src = os.path.join(config.infrasim_template, target) dst = os.path.join(self.get_workspace(), "scripts", target) with open(src, "r") as f: src_text = f.read() template = jinja2.Template(src_text) dst_text = template.render(yml_file=os.path.join( self.get_workspace(), "etc/infrasim.yml")) with open(dst, "w") as f: f.write(dst_text) os.chmod(dst, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) if not has_option(self.__bmc, "startcmd"): self.__startcmd_script = os.path.join(self.get_workspace(), "scripts", "startcmd") if not has_option(self.__bmc, "chassiscontrol"): path_startcmd = os.path.join(self.get_workspace(), "scripts/startcmd") path_stopcmd = os.path.join(self.get_workspace(), "scripts/stopcmd") path_resetcmd = os.path.join(self.get_workspace(), "scripts/resetcmd") path_setbootcmd = os.path.join(self.get_workspace(), "scripts/setbootcmd") path_bootdev = os.path.join(self.get_workspace(), "bootdev") path_qemu_pid = os.path.join( self.get_workspace(), ".{}-node.pid".format(self.__node_name)) src = os.path.join(config.infrasim_template, "chassiscontrol") dst = os.path.join(self.get_workspace(), "scripts/chassiscontrol") with open(src, "r") as f: src_text = f.read() template = jinja2.Template(src_text) dst_text = template.render(startcmd=path_startcmd, stopcmd=path_stopcmd, resetcmd=path_resetcmd, setbootcmd=path_setbootcmd, qemu_pid_file=path_qemu_pid, bootdev=path_bootdev) with open(dst, "w") as f: f.write(dst_text) os.chmod(dst, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) self.__chassiscontrol_script = dst if not has_option(self.__bmc, "lancontrol"): shutil.copy( os.path.join(config.infrasim_template, "lancontrol"), os.path.join(self.get_workspace(), "scripts", "lancontrol")) self.__lancontrol_script = os.path.join(self.get_workspace(), "scripts", "lancontrol")
def bind_cpus(self): if not self.__bind_cpus: return if has_option(self.__cpu_binding_info, "main_loop"): self.__cpu_binding_info["main_loop"]["threads"] = [self.owner.get_task_pid()] if has_option(self.__cpu_binding_info, "vcpu"): self.__cpu_binding_info["vcpu"]["threads"] = self.get_thread_id() for _, value in self.__cpu_binding_info.items(): self.bind_cpus_with_policy(value["threads"], value["cores"], value.get("policy")) self.run_vm()
def init(self): if not helper.check_kvm_existence(): self.__enable_kvm = False else: self.__enable_kvm = self.__compute.get('kvm_enabled', True) if 'smbios' in self.__compute: self.__smbios = self.__compute['smbios'] elif self.get_workspace(): self.__smbios = os.path.join(self.get_workspace(), "data", "{}_smbios.bin". format(self.__vendor_type)) else: self.__smbios = os.path.join(config.infrasim_data, "{0}/{0}_smbios.bin".format(self.__vendor_type)) self.__bios = self.__compute.get('bios') if 'boot' in self.__compute: self.__boot_order = self.__compute['boot'].get('boot_order', "ncd") if 'menu' in self.__compute['boot']: self.__boot_menu = "on" if self.__compute['boot']['menu'] in [True, 'on'] else "off" self.__boot_splash_name = self.__compute['boot'].get('splash', None) self.__boot_splash_time = self.__compute['boot'].get('splash-time', None) else: self.__boot_order = "ncd" self.__cdrom_file = self.__compute.get('cdrom') self.__numactl_info = self.__compute.get("numa_control") if self.__numactl_info and os.path.exists("/usr/bin/numactl"): self.__numactl_mode = self.__numactl_info.get("mode", "auto") if self.__class__.numactl is None: self.__class__.numactl = NumaCtl() self.logger.info('[compute] infrasim has ' 'enabled numa control') else: self.logger.info('[compute] infrasim can\'t ' 'find numactl in this environment') self.__display = self.__compute.get('vnc_display', 1) self.__kernel = self.__compute.get('kernel') self.__initrd = self.__compute.get('initrd') self.__cmdline = self.__compute.get("cmdline") self.__mem_path = self.__compute.get("mem_path") self.__extra_option = self.__compute.get("extra_option") self.__qemu_bin = self.__compute.get("qemu_bin", self.__qemu_bin) self.__iommu = self.__compute.get("iommu") self.__force_shutdown = self.__compute.get("force_shutdown", True) cpu_obj = CCPU(self.__compute['cpu']) cpu_obj.logger = self.logger self.__element_list.append(cpu_obj) self.__cpu_obj = cpu_obj memory_obj = CMemory(self.__compute['memory']) memory_obj.logger = self.logger self.__element_list.append(memory_obj) # If PCI device wants to sit on one specific PCI bus, the bus should be # created first prior to using the bus, here we always create the PCI # bus prior to other PCI devices' creation pci_topology_manager_obj = None if 'pci_bridge_topology' in self.__compute: pci_topology_manager_obj = CPCITopologyManager(self.__compute['pci_bridge_topology']) pci_topology_manager_obj.logger = self.logger self.__element_list.append(pci_topology_manager_obj) backend_storage_obj = CBackendStorage(self.__compute['storage_backend']) backend_storage_obj.logger = self.logger backend_storage_obj.owner = self if pci_topology_manager_obj: backend_storage_obj.set_pci_topology_mgr(pci_topology_manager_obj) backend_storage_obj.owner = self self.__element_list.append(backend_storage_obj) backend_network_obj = CBackendNetwork(self.__compute['networks']) backend_network_obj.logger = self.logger self.__element_list.append(backend_network_obj) if has_option(self.__compute, "ipmi"): ipmi_obj = CIPMI(self.__compute['ipmi']) else: ipmi_info = { 'interface': 'kcs', 'chardev': { 'backend': 'socket', 'host': '127.0.0.1', } } ipmi_obj = CIPMI(ipmi_info) ipmi_obj.logger = self.logger ipmi_obj.set_bmc_conn_port(self.__port_qemu_ipmi) self.__element_list.append(ipmi_obj) if self.__compute.get('monitor', ''): self.__monitor = CMonitor(self.__compute['monitor']) else: self.__monitor = CMonitor({ 'mode': 'readline', 'chardev': { 'backend': 'socket', 'host': '127.0.0.1', 'port': 2345, 'server': True, 'wait': False } }) self.__monitor.set_workspace(self.get_workspace()) self.__monitor.logger = self.logger self.__element_list.append(self.__monitor) for element in self.__element_list: element.init()
def init(self): if not helper.check_kvm_existence(): self.__enable_kvm = False else: self.__enable_kvm = self.__compute.get('kvm_enabled', True) if 'smbios' in self.__compute: self.__smbios = self.__compute['smbios'] elif self.get_workspace(): self.__smbios = os.path.join( self.get_workspace(), "data", "{}_smbios.bin".format(self.__vendor_type)) else: self.__smbios = os.path.join( config.infrasim_data, "{0}/{0}_smbios.bin".format(self.__vendor_type)) self.__bios = self.__compute.get('bios') if 'boot' in self.__compute: self.__boot_order = self.__compute['boot'].get('boot_order', "ncd") if 'menu' in self.__compute['boot']: self.__boot_menu = "on" if self.__compute['boot']['menu'] in [ True, 'on' ] else "off" self.__boot_splash_name = self.__compute['boot'].get( 'splash', None) self.__boot_splash_time = self.__compute['boot'].get( 'splash-time', None) else: self.__boot_order = "ncd" self.__cdrom_file = self.__compute.get('cdrom') self.__numactl_info = self.__compute.get("numa_control") if self.__numactl_info and os.path.exists("/usr/bin/numactl"): self.__numactl_mode = self.__numactl_info.get("mode", "auto") if self.__class__.numactl is None: self.__class__.numactl = NumaCtl() self.logger.info('[compute] infrasim has ' 'enabled numa control') else: self.logger.info('[compute] infrasim can\'t ' 'find numactl in this environment') self.__display = self.__compute.get('vnc_display', 1) self.__kernel = self.__compute.get('kernel') self.__initrd = self.__compute.get('initrd') self.__cmdline = self.__compute.get("cmdline") self.__mem_path = self.__compute.get("mem_path") self.__machine = self.__compute.get("machine") self.__extra_option = self.__compute.get("extra_option") self.__qemu_bin = self.__compute.get("qemu_bin", self.__qemu_bin) self.__force_shutdown = self.__compute.get("force_shutdown", True) self.__shm_key = self.__compute.get("communicate", {}).get("shm_key") machine_obj = CMachine(self.__machine) machine_obj.logger = self.logger self.__element_list.append(machine_obj) cpu_obj = CCPU(self.__compute['cpu']) cpu_obj.logger = self.logger self.__element_list.append(cpu_obj) self.__cpu_obj = cpu_obj memory_obj = CMemory(self.__compute['memory']) memory_obj.logger = self.logger self.__element_list.append(memory_obj) # If PCI device wants to sit on one specific PCI bus, the bus should be # created first prior to using the bus, here we always create the PCI # bus prior to other PCI devices' creation pci_topology_manager_obj = None if 'pci_bridge_topology' in self.__compute: pci_topology_manager_obj = CPCITopologyManager( self.__compute['pci_bridge_topology']) pci_topology_manager_obj.logger = self.logger self.__element_list.append(pci_topology_manager_obj) if 'pcie_topology' in self.__compute: pcie_topology_obj = CPCIETopology(self.__compute['pcie_topology']) pcie_topology_obj.logger = self.logger self.__element_list.append(pcie_topology_obj) if 'sec_bus' in str(self.__compute.get('pcie_topology')): fw_cfg_obj = CPCIEFwcfg() fw_cfg_obj.logger = self.logger fw_cfg_obj.set_workspace(self.get_workspace()) pcie_topology_obj.set_fw_cfg_obj(fw_cfg_obj) self.__element_list.append(fw_cfg_obj) backend_storage_obj = CBackendStorage( self.__compute['storage_backend']) backend_storage_obj.logger = self.logger backend_storage_obj.owner = self if pci_topology_manager_obj: backend_storage_obj.set_pci_topology_mgr(pci_topology_manager_obj) backend_storage_obj.owner = self self.__element_list.append(backend_storage_obj) backend_network_obj = CBackendNetwork(self.__compute['networks']) backend_network_obj.logger = self.logger self.__element_list.append(backend_network_obj) if has_option(self.__compute, "ipmi"): ipmi_obj = CIPMI(self.__compute['ipmi']) else: ipmi_info = { 'interface': 'kcs', 'chardev': { 'backend': 'socket', 'host': '127.0.0.1', } } ipmi_obj = CIPMI(ipmi_info) ipmi_obj.logger = self.logger ipmi_obj.set_bmc_conn_port(self.__port_qemu_ipmi) self.__element_list.append(ipmi_obj) if self.__enable_monitor: self.__monitor = CQemuMonitor({ 'mode': 'control', 'chardev': { 'backend': 'socket', 'path': os.path.join(self.get_workspace(), '.monitor'), 'server': True, 'wait': False } }) self.__monitor.set_workspace(self.get_workspace()) self.__monitor.logger = self.logger self.__element_list.append(self.__monitor) for element in self.__element_list: element.init()
def init(self): if not helper.check_kvm_existence(): self.__enable_kvm = False else: self.__enable_kvm = self.__compute.get('kvm_enabled', True) if self.get_workspace(): # this file copy is performed in workspace.init() self.__smbios = os.path.join(self.get_workspace(), "data", "{}_smbios.bin".format(self.__vendor_type)) else: default = os.path.join(config.infrasim_data, "{0}/{0}_smbios.bin".format(self.__vendor_type)) if isinstance(self.__compute.get("smbios"), dict): self.__smbios = self.__compute["smbios"].get("file", default) else: self.__smbios = self.__compute.get("smbios", default) if os.path.exists(self.__smbios): if 'serial_number' in self.__compute: self.__serial_number = self.__compute['serial_number'] set_option(self.__compute, "smbios", "type1", "sn", self.__serial_number) if 'uuid' in self.__compute: set_option(self.__compute, "smbios", "type1", "uuid", self.__compute["uuid"]) bios = SMBios(self.__smbios) # safe check for compatible with previous version. if isinstance(self.__compute.get("smbios"), dict): bios.ModifyData(self.__compute["smbios"]) bios.save(self.__smbios) self.__bios = self.__compute.get('bios') if 'boot' in self.__compute: self.__boot_order = self.__compute['boot'].get('boot_order', "ncd") if 'menu' in self.__compute['boot']: self.__boot_menu = "on" if self.__compute['boot']['menu'] in [True, 'on'] else "off" self.__boot_splash_name = self.__compute['boot'].get('splash', None) self.__boot_splash_time = self.__compute['boot'].get('splash-time', None) self.checking_time = self.__compute['boot'].get('checking_time', 1) else: self.__boot_order = "ncd" self.__numactl_info = self.__compute.get("numa_control") if self.__numactl_info and os.path.exists("/usr/bin/numactl"): self.__numactl_mode = self.__numactl_info.get("mode", "auto") if self.__class__.numactl is None: self.__class__.numactl = NumaCtl() self.logger.info('[compute] infrasim has ' 'enabled numa control') else: self.logger.info('[compute] infrasim can\'t ' 'find numactl in this environment') self.__display = self.__compute.get('vnc_display', 1) self.__kernel = self.__compute.get('kernel') self.__initrd = self.__compute.get('initrd') self.__cmdline = self.__compute.get("cmdline") self.__mem_path = self.__compute.get("mem_path") self.__machine = self.__compute.get("machine") self.__extra_option = self.__compute.get("extra_option") self.__extra_device = self.__compute.get("extra_device", "") self.__qemu_bin = self.__compute.get("qemu_bin", self.__qemu_bin) self.__force_shutdown = self.__compute.get("force_shutdown", True) self.__shm_key = self.__compute.get("communicate", {}).get("shm_key") if "uuid" in self.__compute: self.__uuid = self.__compute.get("uuid") machine_obj = CMachine(self.__machine) machine_obj.logger = self.logger self.__element_list.append(machine_obj) cpu_obj = CCPU(self.__compute['cpu']) cpu_obj.logger = self.logger self.__element_list.append(cpu_obj) self.__cpu_obj = cpu_obj memory_obj = CMemory(self.__compute['memory']) memory_obj.logger = self.logger self.__element_list.append(memory_obj) # If PCI device wants to sit on one specific PCI bus, the bus should be # created first prior to using the bus, here we always create the PCI # bus prior to other PCI devices' creation pci_topology_manager_obj = None if 'pci_bridge_topology' in self.__compute: pci_topology_manager_obj = CPCITopologyManager(self.__compute['pci_bridge_topology']) pci_topology_manager_obj.logger = self.logger self.__element_list.append(pci_topology_manager_obj) if 'pcie_topology' in self.__compute: pcie_topology_obj = CPCIETopology(self.__compute['pcie_topology']) pcie_topology_obj.logger = self.logger self.__element_list.append(pcie_topology_obj) if 'sec_bus' in str(self.__compute.get('pcie_topology')): fw_cfg_obj = CPCIEFwcfg() fw_cfg_obj.logger = self.logger fw_cfg_obj.set_workspace(self.get_workspace()) pcie_topology_obj.set_fw_cfg_obj(fw_cfg_obj) self.__element_list.append(fw_cfg_obj) backend_network_obj = CBackendNetwork(self.__compute['networks']) backend_network_obj.logger = self.logger self.__element_list.append(backend_network_obj) for imc_element in self.__compute.get("imc", []): imc_obj = CPCIIMC(imc_element) self.__element_list.append(imc_obj) for pcu_element in self.__compute.get("pcu", []): pcu_obj = CPCIPCU(pcu_element) self.__element_list.append(pcu_obj) cdrom_info = self.__compute.get("cdrom") backend_storage_obj = CBackendStorage(self.__compute['storage_backend'], (cdrom_info is not None)) backend_storage_obj.logger = self.logger backend_storage_obj.owner = self if pci_topology_manager_obj: backend_storage_obj.set_pci_topology_mgr(pci_topology_manager_obj) backend_storage_obj.owner = self self.__element_list.append(backend_storage_obj) for ntb in self.__compute.get("ntb", []): ntb_obj = CNTB(ntb) self.__element_list.append(ntb_obj) for dma_engine in self.__compute.get("dma_engine", []): dma_engine_obj = CDMAEngine(dma_engine) self.__element_list.append(dma_engine_obj) if has_option(self.__compute, "ipmi"): ipmi_obj = CIPMI(self.__compute['ipmi']) else: ipmi_info = { 'interface': 'kcs', 'chardev': { 'backend': 'socket', 'host': '127.0.0.1', } } ipmi_obj = CIPMI(ipmi_info) ipmi_obj.logger = self.logger ipmi_obj.set_bmc_conn_port(self.__port_qemu_ipmi) self.__element_list.append(ipmi_obj) if self.__enable_monitor: self.__monitor = CQemuMonitor({ 'mode': 'control', 'chardev': { 'backend': 'socket', 'path': os.path.join(self.get_workspace(), '.monitor'), 'server': True, 'wait': False } }) self.__monitor.set_workspace(self.get_workspace()) self.__monitor.logger = self.logger self.__element_list.append(self.__monitor) if has_option(self.__compute, "cpu_binding"): self.__cpu_binding_obj = CCPUBinding(self.__compute["cpu_binding"]) self.__cpu_binding_obj.monitor = self.__monitor self.__cpu_binding_obj.logger = self.logger self.__cpu_binding_obj.owner = self self.__cpu_binding_obj.vcpu_quantities = self.__compute["cpu"].get("quantities", 0) self.__element_list.append(self.__cpu_binding_obj) # create cdrom if exits if cdrom_info: cdrom_obj = IDECdrom(cdrom_info) cdrom_obj.logger = self.logger cdrom_obj.index = 0 cdrom_obj.owner = cdrom_obj cdrom_obj.set_bus(0) cdrom_obj.set_scsi_id(0) self.__element_list.append(cdrom_obj) # create channel for guest agent has_guest_agent = self.__compute.get('guest-agent') if has_guest_agent or has_guest_agent == 'on': self.__element_list.append(GuestAgent(self.get_workspace())) # add debug option trace_info = self.__compute.get("trace") if trace_info: self.__element_list.append(QTrace(trace_info, self.get_workspace())) for ppi in self.__compute.get("pcie-passthrough", []): ppi_obj = CPCIEPassthrough(ppi) self.__element_list.append(ppi_obj) for element in self.__element_list: element.init()
def init(self): if not helper.check_kvm_existence(): self.__enable_kvm = False else: self.__enable_kvm = self.__compute.get('kvm_enabled', True) if self.get_workspace(): # this file copy is performed in workspace.init() self.__smbios = os.path.join( self.get_workspace(), "data", "{}_smbios.bin".format(self.__vendor_type)) else: default = os.path.join( config.infrasim_data, "{0}/{0}_smbios.bin".format(self.__vendor_type)) if isinstance(self.__compute.get("smbios"), dict): self.__smbios = self.__compute["smbios"].get("file", default) else: self.__smbios = self.__compute.get("smbios", default) if os.path.exists(self.__smbios): if 'serial_number' in self.__compute: self.__serial_number = self.__compute['serial_number'] set_option(self.__compute, "smbios", "type1", "sn", self.__serial_number) if 'uuid' in self.__compute: set_option(self.__compute, "smbios", "type1", "uuid", self.__compute["uuid"]) bios = SMBios(self.__smbios) # safe check for compatible with previous version. if isinstance(self.__compute.get("smbios"), dict): bios.ModifyData(self.__compute["smbios"]) bios.save(self.__smbios) self.__bios = self.__compute.get('bios') if 'boot' in self.__compute: self.__boot_order = self.__compute['boot'].get('boot_order', "ncd") if 'menu' in self.__compute['boot']: self.__boot_menu = "on" if self.__compute['boot']['menu'] in [ True, 'on' ] else "off" self.__boot_splash_name = self.__compute['boot'].get( 'splash', None) self.__boot_splash_time = self.__compute['boot'].get( 'splash-time', None) self.checking_time = self.__compute['boot'].get('checking_time', 1) else: self.__boot_order = "ncd" self.__numactl_info = self.__compute.get("numa_control") if self.__numactl_info and os.path.exists("/usr/bin/numactl"): self.__numactl_mode = self.__numactl_info.get("mode", "auto") if self.__class__.numactl is None: self.__class__.numactl = NumaCtl() self.logger.info('[compute] infrasim has ' 'enabled numa control') else: self.logger.info('[compute] infrasim can\'t ' 'find numactl in this environment') self.__display = self.__compute.get('vnc_display', 1) self.__kernel = self.__compute.get('kernel') self.__initrd = self.__compute.get('initrd') self.__cmdline = self.__compute.get("cmdline") self.__mem_path = self.__compute.get("mem_path") self.__machine = self.__compute.get("machine") self.__extra_option = self.__compute.get("extra_option") self.__extra_device = self.__compute.get("extra_device", "") self.__qemu_bin = self.__compute.get("qemu_bin", self.__qemu_bin) self.__force_shutdown = self.__compute.get("force_shutdown", True) self.__shm_key = self.__compute.get("communicate", {}).get("shm_key") if "uuid" in self.__compute: self.__uuid = self.__compute.get("uuid") machine_obj = CMachine(self.__machine) machine_obj.logger = self.logger self.__element_list.append(machine_obj) cpu_obj = CCPU(self.__compute['cpu']) cpu_obj.logger = self.logger self.__element_list.append(cpu_obj) self.__cpu_obj = cpu_obj memory_obj = CMemory(self.__compute['memory']) memory_obj.logger = self.logger self.__element_list.append(memory_obj) # If PCI device wants to sit on one specific PCI bus, the bus should be # created first prior to using the bus, here we always create the PCI # bus prior to other PCI devices' creation pci_topology_manager_obj = None if 'pci_bridge_topology' in self.__compute: pci_topology_manager_obj = CPCITopologyManager( self.__compute['pci_bridge_topology']) pci_topology_manager_obj.logger = self.logger self.__element_list.append(pci_topology_manager_obj) if 'pcie_topology' in self.__compute: pcie_topology_obj = CPCIETopology(self.__compute['pcie_topology']) pcie_topology_obj.logger = self.logger self.__element_list.append(pcie_topology_obj) if 'sec_bus' in str(self.__compute.get('pcie_topology')): fw_cfg_obj = CPCIEFwcfg() fw_cfg_obj.logger = self.logger fw_cfg_obj.set_workspace(self.get_workspace()) pcie_topology_obj.set_fw_cfg_obj(fw_cfg_obj) self.__element_list.append(fw_cfg_obj) backend_network_obj = CBackendNetwork(self.__compute['networks']) backend_network_obj.logger = self.logger self.__element_list.append(backend_network_obj) for imc_element in self.__compute.get("imc", []): imc_obj = CPCIIMC(imc_element) self.__element_list.append(imc_obj) for pcu_element in self.__compute.get("pcu", []): pcu_obj = CPCIPCU(pcu_element) self.__element_list.append(pcu_obj) cdrom_info = self.__compute.get("cdrom") backend_storage_obj = CBackendStorage( self.__compute['storage_backend'], (cdrom_info is not None)) backend_storage_obj.logger = self.logger backend_storage_obj.owner = self if pci_topology_manager_obj: backend_storage_obj.set_pci_topology_mgr(pci_topology_manager_obj) backend_storage_obj.owner = self self.__element_list.append(backend_storage_obj) for ntb in self.__compute.get("ntb", []): ntb_obj = CNTB(ntb) self.__element_list.append(ntb_obj) for dma_engine in self.__compute.get("dma_engine", []): dma_engine_obj = CDMAEngine(dma_engine) self.__element_list.append(dma_engine_obj) if has_option(self.__compute, "ipmi"): ipmi_obj = CIPMI(self.__compute['ipmi']) else: ipmi_info = { 'interface': 'kcs', 'chardev': { 'backend': 'socket', 'host': '127.0.0.1', } } ipmi_obj = CIPMI(ipmi_info) ipmi_obj.logger = self.logger ipmi_obj.set_bmc_conn_port(self.__port_qemu_ipmi) self.__element_list.append(ipmi_obj) if self.__enable_monitor: self.__monitor = CQemuMonitor({ 'mode': 'control', 'chardev': { 'backend': 'socket', 'path': os.path.join(self.get_workspace(), '.monitor'), 'server': True, 'wait': False } }) self.__monitor.set_workspace(self.get_workspace()) self.__monitor.logger = self.logger self.__element_list.append(self.__monitor) if has_option(self.__compute, "cpu_binding"): self.__cpu_binding_obj = CCPUBinding(self.__compute["cpu_binding"]) self.__cpu_binding_obj.monitor = self.__monitor self.__cpu_binding_obj.logger = self.logger self.__cpu_binding_obj.owner = self self.__cpu_binding_obj.vcpu_quantities = self.__compute["cpu"].get( "quantities", 0) self.__element_list.append(self.__cpu_binding_obj) # create cdrom if exits if cdrom_info: cdrom_obj = IDECdrom(cdrom_info) cdrom_obj.logger = self.logger cdrom_obj.index = 0 cdrom_obj.owner = cdrom_obj cdrom_obj.set_bus(0) cdrom_obj.set_scsi_id(0) self.__element_list.append(cdrom_obj) # create channel for guest agent has_guest_agent = self.__compute.get('guest-agent') if has_guest_agent or has_guest_agent == 'on': self.__element_list.append(GuestAgent(self.get_workspace())) # add debug option trace_info = self.__compute.get("trace") if trace_info: self.__element_list.append(QTrace(trace_info, self.get_workspace())) for ppi in self.__compute.get("pcie-passthrough", []): ppi_obj = CPCIEPassthrough(ppi) self.__element_list.append(ppi_obj) for element in self.__element_list: element.init()