def _on_staged(self, op): if not isinstance(op, DOp_SetAttr): return if op.attr != "name": return desc = self.p.find1(__sn__=op.sn) if QOMDevice not in getmro(desc.__qom_template__): return prev_type = QemuTypeName(desc.name).type_macro new_type = QemuTypeName(op.val).type_macro seq = self.gpht.begin() for mach in self.p.descriptions: if not isinstance(mach, MachineNode): continue for nid, node in mach.id2node.items(): if not isinstance(node, DeviceNode): continue if node.qom_type != prev_type: continue seq.stage(MOp_SetDevQOMType, new_type, nid, mach.__sn__) seq.commit(sequence_description=_( "Automatic update of QOM type for devices in all machines."))
def main(): # automatic search while QTN_AUTO_SEARCH: test_len = randrange(3, 10) test = "".join(chr(randrange(32, 126)) for _ in range(test_len)) # print the test to prevent loss when crashing print("Current test: %s" % test) qtn_new = names(QemuTypeName(test)) qtn_old = names(QemuTypeNameOld(test)) if qtn_new != qtn_old: print("DIFFER: ", qtn_new, qtn_old) # manual debug test = "a_2/2" print(names(QemuTypeName(test)))
def names(base): qtn = QemuTypeName(base) return ( qtn.for_id_name, qtn.for_header_name, qtn.for_struct_name, qtn.type_macro )
def __add_qtype_for_description(self, desc): proj = self.p try: parent = proj.qom_tree except AttributeError: # QOM tree is not available without QEMU source return if isinstance(desc, SysBusDeviceDescription): parent = next(parent.find(name="sys-bus-device")) elif isinstance(desc, PCIExpressDeviceDescription): parent = next(parent.find(name="pci-device")) qtn = QemuTypeName(desc.name) QType(qtn.for_id_name, parent).macro = ["TYPE_" + qtn.for_macros]
def on_project_changed(self, op): if isinstance(op, POp_AddDesc): self.tv_descs.update() desc_name = op.get_arg("name") try: desc = next(self.p.find(name=desc_name)) except StopIteration: # removed try: lys = self.p.layouts[desc_name] except KeyError: pass else: for l in lys.values(): if l.widget is not None: l.widget.destroy() l.widget = None l.shown = False try: qt = self.p.qom_tree except AttributeError: pass else: qtn = QemuTypeName(desc_name) t = next(qt.find(name=qtn.for_id_name)) t.unparent() else: # added self.__add_qtype_for_description(desc) elif isinstance(op, DOp_SetAttr): self.tv_descs.update() elif isinstance(op, POp_SetDescLayout): # remove all tabs that are not cached in current layouts for tab_id in self.nb_descriptions.tabs(): desc_name = self.nb_descriptions.tab(tab_id)["text"] lys = self.p.get_layout_objects(desc_name) w = self.nametowidget(tab_id) for l in lys: if l.widget is w: break else: w.destroy() elif isinstance(op, GUIPOp_SetBuildPath): try: self.__account_build_path except AttributeError: self.__account_build_path = self.after(1, self.account_build_path)
def qom_type_to_var_base(qom_type): type_base = qom_type[5:] if qom_type[0:5] == "TYPE_" else qom_type qtn = QemuTypeName(type_base) return qtn.for_id_name
def __var_base__(self): return "%s_l%s" % (QemuTypeName(self.desc_name).for_header_name, "" if self.lid is None else self.lid)
def name_to_var_base(name): type_base = "sas" if "System address space" in name else name qtn = QemuTypeName(type_base) return qtn.for_id_name
def test_empty(self): QemuTypeName("")