Lines Matching +full:interface +full:- +full:node

35     char *extra_device_opts;  /* added to -device option, "," is
38 char *before_cmd_line; /* added before node cmd_line */
39 char *after_cmd_line; /* added after -device options */
51 QOSGraphNode *node; member
57 /* Each entry in these hash table will consist of <string, node/edge> pair. */
67 * from @source to @dest node, and inserts it in the
72 * edge->edge_name is used as identifier for get_device relationships,
93 edge->type = type; in add_edge()
94 edge->dest = g_strdup(dest); in add_edge()
95 edge->edge_name = g_strdup(opts->edge_name ?: dest); in add_edge()
96 edge->arg = g_memdup2(opts->arg, opts->size_arg); in add_edge()
98 edge->before_cmd_line = in add_edge()
99 opts->before_cmd_line ? g_strconcat(" ", opts->before_cmd_line, NULL) : NULL; in add_edge()
100 edge->extra_device_opts = in add_edge()
101 opts->extra_device_opts ? g_strconcat(",", opts->extra_device_opts, NULL) : NULL; in add_edge()
102 edge->after_cmd_line = in add_edge()
103 opts->after_cmd_line ? g_strconcat(" ", opts->after_cmd_line, NULL) : NULL; in add_edge()
117 g_free(temp->dest); in destroy_edges()
118 g_free(temp->before_cmd_line); in destroy_edges()
119 g_free(temp->after_cmd_line); in destroy_edges()
120 g_free(temp->extra_device_opts); in destroy_edges()
121 g_free(temp->edge_name); in destroy_edges()
122 g_free(temp->arg); in destroy_edges()
129 * create_node(): creates a node @name of type @type
131 * By default, node is not available.
136 g_printerr("Node %s already created\n", name); in create_node()
140 QOSGraphNode *node = g_new0(QOSGraphNode, 1); in create_node() local
141 node->type = type; in create_node()
142 node->available = false; in create_node()
143 node->name = g_strdup(name); in create_node()
144 g_hash_table_insert(node_table, node->name, node); in create_node()
145 return node; in create_node()
149 * destroy_node(): frees a node @val from the nodes hash table.
150 * Note that node->name is not free'd since it will represent the
155 QOSGraphNode *node = val; in destroy_node() local
156 g_free(node->qemu_name); in destroy_node()
157 g_free(node->command_line); in destroy_node()
158 g_free(node); in destroy_node()
163 * Actually frees the node->name
171 * search_node(): search for a node @key in the nodes hash table
207 if (g_strcmp0(tmp->dest, dest) == 0) { in search_list_edges()
215 * search_machine(): search for a machine @name in the node hash
216 * table. A machine is the child of the root node.
218 * to check the node is a proper machine
231 n = search_node(e->dest); in search_machine()
232 if (n->type == QNODE_MACHINE) { in search_machine()
240 * a node @node in the node hash table, if not
241 * creates a node @node of type #QNODE_INTERFACE
245 static void create_interface(const char *node) in create_interface() argument
247 QOSGraphNode *interface; in create_interface() local
248 interface = search_node(node); in create_interface()
249 if (!interface) { in create_interface()
250 create_node(node, QNODE_INTERFACE); in create_interface()
251 } else if (interface->type != QNODE_INTERFACE) { in create_interface()
252 fprintf(stderr, "Error: Node %s is not an interface\n", node); in create_interface()
259 * @node. The node name must be a valid qemu identifier, since it
265 * For machines, prepend -M to the machine name. ", @rgs" is added
266 * after the -M <machine> command.
268 static void build_machine_cmd_line(QOSGraphNode *node, const char *args) in build_machine_cmd_line() argument
270 char *machine = qos_get_machine_type(node->name); in build_machine_cmd_line()
272 node->command_line = g_strconcat("-M ", machine, ",", args, NULL); in build_machine_cmd_line()
274 node->command_line = g_strconcat("-M ", machine, " ", NULL); in build_machine_cmd_line()
280 * @node. The node name must be a valid qemu identifier, since it
286 * For drivers, prepend -device to the node name.
288 static void build_driver_cmd_line(QOSGraphNode *node) in build_driver_cmd_line() argument
290 const char *name = node->qemu_name ?: node->name; in build_driver_cmd_line()
291 node->command_line = g_strconcat(" -device ", name, NULL); in build_driver_cmd_line()
304 while (path->path_edge) { in qos_print_cb()
305 printf("%s ", path->name); in qos_print_cb()
306 switch (path->path_edge->type) { in qos_print_cb()
308 printf("--PRODUCES--> "); in qos_print_cb()
311 printf("--CONSUMED_BY--> "); in qos_print_cb()
314 printf("--CONTAINS--> "); in qos_print_cb()
317 path = search_node(path->path_edge->dest); in qos_print_cb()
320 printf("%s\n\n", path->name); in qos_print_cb()
324 /* qos_push(): push a node @el and edge @e in the qos_node_stack */
335 len = parent->length + 1; in qos_push()
338 .node = el, in qos_push()
348 return &qos_node_stack[qos_node_tos - 1]; in qos_tos()
359 e->node->visited = false; in qos_pop()
360 qos_node_tos--; in qos_pop()
366 * test-to-machine to machine-to-test
374 el->node->path_edge = NULL; in qos_reverse_path()
376 while (el->parent) { in qos_reverse_path()
377 el->parent->node->path_edge = el->parent_edge; in qos_reverse_path()
378 el = el->parent; in qos_reverse_path()
381 return el->node; in qos_reverse_path()
385 * qos_traverse_graph(): graph-walking algorithm, using Depth First Search it
387 * reaches a test node.
405 v = s_el->node; in qos_traverse_graph()
406 if (v->visited) { in qos_traverse_graph()
410 v->visited = true; in qos_traverse_graph()
411 list = get_edgelist(v->name); in qos_traverse_graph()
414 if (v->type == QNODE_TEST) { in qos_traverse_graph()
415 v->visited = false; in qos_traverse_graph()
417 callback(path, s_el->length); in qos_traverse_graph()
421 dest_node = search_node(e->dest); in qos_traverse_graph()
424 fprintf(stderr, "node %s in %s -> %s does not exist\n", in qos_traverse_graph()
425 e->dest, v->name, e->dest); in qos_traverse_graph()
429 if (!dest_node->visited && dest_node->available) { in qos_traverse_graph()
444 bool qos_graph_has_node(const char *node) in qos_graph_has_node() argument
446 QOSGraphNode *n = search_node(node); in qos_graph_has_node()
450 QOSNodeType qos_graph_get_node_type(const char *node) in qos_graph_get_node_type() argument
452 QOSGraphNode *n = search_node(node); in qos_graph_get_node_type()
454 return n->type; in qos_graph_get_node_type()
456 return -1; in qos_graph_get_node_type()
459 bool qos_graph_get_node_availability(const char *node) in qos_graph_get_node_availability() argument
461 QOSGraphNode *n = search_node(node); in qos_graph_get_node_availability()
463 return n->available; in qos_graph_get_node_availability()
468 QOSGraphEdge *qos_graph_get_edge(const char *node, const char *dest) in qos_graph_get_edge() argument
470 QOSGraphEdgeList *list = get_edgelist(node); in qos_graph_get_edge()
477 return -1; in qos_graph_edge_get_type()
479 return edge->type; in qos_graph_edge_get_type()
487 return edge->dest; in qos_graph_edge_get_dest()
495 return edge->arg; in qos_graph_edge_get_arg()
503 return edge->after_cmd_line; in qos_graph_edge_get_after_cmd_line()
511 return edge->before_cmd_line; in qos_graph_edge_get_before_cmd_line()
519 return edge->extra_device_opts; in qos_graph_edge_get_extra_device_opts()
527 return edge->edge_name; in qos_graph_edge_get_name()
537 QOSGraphNode *qos_graph_get_machine(const char *node) in qos_graph_get_machine() argument
539 return search_machine(node); in qos_graph_get_machine()
542 bool qos_graph_has_machine(const char *node) in qos_graph_has_machine() argument
544 QOSGraphNode *m = search_machine(node); in qos_graph_has_machine()
591 void qos_add_test(const char *name, const char *interface, in qos_add_test() argument
594 QOSGraphNode *node; in qos_add_test() local
595 char *test_name = g_strdup_printf("%s-tests/%s", interface, name); in qos_add_test()
601 node = create_node(test_name, QNODE_TEST); in qos_add_test()
602 node->u.test.function = test_func; in qos_add_test()
603 node->u.test.arg = opts->arg; in qos_add_test()
604 assert(!opts->edge.arg); in qos_add_test()
605 assert(!opts->edge.size_arg); in qos_add_test()
607 node->u.test.before = opts->before; in qos_add_test()
608 node->u.test.subprocess = opts->subprocess; in qos_add_test()
609 node->available = true; in qos_add_test()
610 add_edge(interface, test_name, QEDGE_CONSUMED_BY, &opts->edge); in qos_add_test()
623 QOSGraphNode *node = create_node(name, QNODE_MACHINE); in qos_node_create_machine_args() local
624 build_machine_cmd_line(node, opts); in qos_node_create_machine_args()
625 node->u.machine.constructor = function; in qos_node_create_machine_args()
631 QOSGraphNode *node = create_node(name, QNODE_DRIVER); in qos_node_create_driver() local
632 build_driver_cmd_line(node); in qos_node_create_driver()
633 node->u.driver.constructor = function; in qos_node_create_driver()
639 QOSGraphNode *node = create_node(name, QNODE_DRIVER); in qos_node_create_driver_named() local
640 node->qemu_name = g_strdup(qemu_name); in qos_node_create_driver_named()
641 build_driver_cmd_line(node); in qos_node_create_driver_named()
642 node->u.driver.constructor = function; in qos_node_create_driver_named()
664 void qos_node_produces(const char *producer, const char *interface) in qos_node_produces() argument
666 create_interface(interface); in qos_node_produces()
667 add_edge(producer, interface, QEDGE_PRODUCES, NULL); in qos_node_produces()
670 void qos_node_consumes(const char *consumer, const char *interface, in qos_node_consumes() argument
673 create_interface(interface); in qos_node_consumes()
674 add_edge(interface, consumer, QEDGE_CONSUMED_BY, opts); in qos_node_consumes()
677 static void qos_graph_node_set_availability_explicit(const char *node, bool av) in qos_graph_node_set_availability_explicit() argument
680 QOSGraphNode *n = search_node(node); in qos_graph_node_set_availability_explicit()
685 n->available = av; in qos_graph_node_set_availability_explicit()
686 elist = get_edgelist(node); in qos_graph_node_set_availability_explicit()
691 if (e->type == QEDGE_CONTAINS || e->type == QEDGE_PRODUCES) { in qos_graph_node_set_availability_explicit()
692 qos_graph_node_set_availability_explicit(e->dest, av); in qos_graph_node_set_availability_explicit()
699 * former always matches by node name only, whereas this function matches both
700 * by node name and node's optional 'qemu_name' field.
702 void qos_graph_node_set_availability(const char *node, bool av) in qos_graph_node_set_availability() argument
710 for (l = keys; l != NULL; l = l->next) { in qos_graph_node_set_availability()
711 const gchar *key = l->data; in qos_graph_node_set_availability()
714 * node's 'qemu_name' is set if there is more than one device with in qos_graph_node_set_availability()
717 const char *node_name = n->qemu_name ?: n->name; in qos_graph_node_set_availability()
718 if (g_strcmp0(node_name, node) == 0) { in qos_graph_node_set_availability()
719 n->available = av; in qos_graph_node_set_availability()
720 elist = get_edgelist(n->name); in qos_graph_node_set_availability()
723 if (e->type == QEDGE_CONTAINS || e->type == QEDGE_PRODUCES) in qos_graph_node_set_availability()
725 qos_graph_node_set_availability_explicit(e->dest, av); in qos_graph_node_set_availability()
740 QOSGraphObject *qos_machine_new(QOSGraphNode *node, QTestState *qts) in qos_machine_new() argument
744 g_assert(node->type == QNODE_MACHINE); in qos_machine_new()
745 obj = node->u.machine.constructor(qts); in qos_machine_new()
746 obj->free = g_free; in qos_machine_new()
750 QOSGraphObject *qos_driver_new(QOSGraphNode *node, QOSGraphObject *parent, in qos_driver_new() argument
755 g_assert(node->type == QNODE_DRIVER); in qos_driver_new()
756 obj = node->u.driver.constructor(parent, alloc, arg); in qos_driver_new()
757 obj->free = g_free; in qos_driver_new()
766 if (obj->destructor) { in qos_object_destroy()
767 obj->destructor(obj); in qos_object_destroy()
769 if (obj->free) { in qos_object_destroy()
770 obj->free(obj); in qos_object_destroy()
781 if (obj->start_hw) { in qos_object_start_hw()
782 obj->start_hw(obj); in qos_object_start_hw()
802 QOSGraphNode *node = search_node(name); in qos_delete_cmd_line() local
803 if (node) { in qos_delete_cmd_line()
804 g_free(node->command_line); in qos_delete_cmd_line()
805 node->command_line = NULL; in qos_delete_cmd_line()
815 QOSGraphNode *dest_node, *node; in qos_dump_graph() local
819 for (l = keys; l != NULL; l = l->next) { in qos_dump_graph()
820 const gchar *key = l->data; in qos_dump_graph()
824 dest_node = g_hash_table_lookup(node_table, e->dest); in qos_dump_graph()
825 qos_printf("\t\t|-> dest='%s' type=%d (node=%p)", in qos_dump_graph()
826 e->dest, e->type, dest_node); in qos_dump_graph()
828 qos_printf_literal(" <------- ERROR !"); in qos_dump_graph()
838 for (l = keys; l != NULL; l = l->next) { in qos_dump_graph()
839 const gchar *key = l->data; in qos_dump_graph()
840 node = g_hash_table_lookup(node_table, key); in qos_dump_graph()
842 if (node->qemu_name) { in qos_dump_graph()
843 qos_printf_literal("qemu_name='%s' ", node->qemu_name); in qos_dump_graph()
846 node->type, node->command_line, in qos_dump_graph()
847 node->available ? "available" : "UNAVAILABLE" in qos_dump_graph()