summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-10-14 19:17:12 +0200
committerLudovic Courtès <ludo@gnu.org>2015-10-14 21:39:06 +0200
commit6f305ea5fdb239bdac5ab9c1d7b837f3177a025a (patch)
treec501f75f264c5ec181997246247d3e18520fcd79
parent80a67734834a0981ca65cf1757a7d8408d02f1fd (diff)
guix system: Add 'dmd-graph' command.
* guix/scripts/system.scm (dmd-service-node-label, dmd-service-node-type, export-dmd-graph): New procedures. (show-help): Add 'dmd-graph'. (guix-system)[parse-sub-command]: Likewise. Honor it. * doc/guix.texi (Invoking guix system): Document it. (dmd Services): Add an illustration and explanation. * doc/images/dmd-graph.dot: New file. * doc.am (DOT_FILES): Add it.
-rw-r--r--.gitignore1
-rw-r--r--doc.am3
-rw-r--r--doc/guix.texi27
-rw-r--r--doc/images/dmd-graph.dot75
-rw-r--r--guix/scripts/system.scm34
5 files changed, 133 insertions, 7 deletions
diff --git a/.gitignore b/.gitignore
index e3f2ac2c21d..6e8bfaca95d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -132,3 +132,4 @@ GTAGS
132/doc/images/service-graph.png 132/doc/images/service-graph.png
133/doc/images/service-graph.eps 133/doc/images/service-graph.eps
134/doc/images/service-graph.pdf 134/doc/images/service-graph.pdf
135/doc/images/dmd-graph.png
diff --git a/doc.am b/doc.am
index 71a65ba0c47..1980cc870e8 100644
--- a/doc.am
+++ b/doc.am
@@ -23,7 +23,8 @@ DOT_FILES = \
23 doc/images/bootstrap-graph.dot \ 23 doc/images/bootstrap-graph.dot \
24 doc/images/coreutils-graph.dot \ 24 doc/images/coreutils-graph.dot \
25 doc/images/coreutils-bag-graph.dot \ 25 doc/images/coreutils-bag-graph.dot \
26 doc/images/service-graph.dot 26 doc/images/service-graph.dot \
27 doc/images/dmd-graph.dot
27 28
28DOT_VECTOR_GRAPHICS = \ 29DOT_VECTOR_GRAPHICS = \
29 $(DOT_FILES:%.dot=%.eps) \ 30 $(DOT_FILES:%.dot=%.eps) \
diff --git a/doc/guix.texi b/doc/guix.texi
index 0e0e507714a..fd0adfd2037 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -7004,6 +7004,12 @@ $ guix system extension-graph @var{file} | dot -Tpdf > services.pdf
7004 7004
7005produces a PDF file showing the extension relations among services. 7005produces a PDF file showing the extension relations among services.
7006 7006
7007@anchor{system-dmd-graph}
7008@item dmd-graph
7009Emit in Dot/Graphviz format to standard output the @dfn{dependency
7010graph} of dmd services of the operating system defined in @var{file}.
7011@xref{dmd Services}, for more information and for an example graph.
7012
7007@end table 7013@end table
7008 7014
7009 7015
@@ -7332,10 +7338,23 @@ setuid-root programs on the system (@pxref{Setuid Programs}).
7332The @code{(gnu services dmd)} provides a way to define services managed 7338The @code{(gnu services dmd)} provides a way to define services managed
7333by GNU@tie{}dmd, which is GuixSD initialization system---the first 7339by GNU@tie{}dmd, which is GuixSD initialization system---the first
7334process that is started when the system boots, aka. PID@tie{}1 7340process that is started when the system boots, aka. PID@tie{}1
7335(@pxref{Introduction,,, dmd, GNU dmd Manual}). The 7341(@pxref{Introduction,,, dmd, GNU dmd Manual}).
7336@var{%dmd-root-service} represents PID@tie{}1, of type 7342
7337@var{dmd-root-service-type}; it can be extended by passing it lists of 7343Services in dmd can depend on each other. For instance, the SSH daemon
7338@code{<dmd-service>} objects. 7344may need to be started after the syslog daemon has been started, which
7345in turn can only happen once all the file systems have been mounted.
7346The simple operating system defined earlier (@pxref{Using the
7347Configuration System}) results in a service graph like this:
7348
7349@image{images/dmd-graph,,5in,Typical dmd service graph.}
7350
7351You can actually generate such a graph for any operating system
7352definition using the @command{guix system dmd-graph} command
7353(@pxref{system-dmd-graph, @command{guix system dmd-graph}}).
7354
7355The @var{%dmd-root-service} is a service object representing PID@tie{}1,
7356of type @var{dmd-root-service-type}; it can be extended by passing it
7357lists of @code{<dmd-service>} objects.
7339 7358
7340@deftp {Data Type} dmd-service 7359@deftp {Data Type} dmd-service
7341The data type representing a service managed by dmd. 7360The data type representing a service managed by dmd.
diff --git a/doc/images/dmd-graph.dot b/doc/images/dmd-graph.dot
new file mode 100644
index 00000000000..220a2afca11
--- /dev/null
+++ b/doc/images/dmd-graph.dot
@@ -0,0 +1,75 @@
1digraph "Guix dmd-service" {
2 "user-file-systems" [label = "user-file-systems", shape = box, fontname = Helvetica];
3 "user-processes" -> "user-file-systems" [color = red];
4 "user-processes" [label = "user-processes", shape = box, fontname = Helvetica];
5 "nscd" -> "user-processes" [color = red];
6 "guix-daemon" -> "user-processes" [color = red];
7 "syslogd" -> "user-processes" [color = red];
8 "term-tty6" -> "user-processes" [color = red];
9 "term-tty5" -> "user-processes" [color = red];
10 "term-tty4" -> "user-processes" [color = red];
11 "term-tty3" -> "user-processes" [color = red];
12 "term-tty2" -> "user-processes" [color = red];
13 "term-tty1" -> "user-processes" [color = red];
14 "networking" -> "user-processes" [color = red];
15 "nscd" [label = "nscd", shape = box, fontname = Helvetica];
16 "guix-daemon" [label = "guix-daemon", shape = box, fontname = Helvetica];
17 "syslogd" [label = "syslogd", shape = box, fontname = Helvetica];
18 "ssh-daemon" -> "syslogd" [color = red];
19 "ssh-daemon" [label = "ssh-daemon", shape = box, fontname = Helvetica];
20 "term-tty6" [label = "term-tty6", shape = box, fontname = Helvetica];
21 "console-font-tty6" -> "term-tty6" [color = red];
22 "console-font-tty6" [label = "console-font-tty6", shape = box, fontname = Helvetica];
23 "term-tty5" [label = "term-tty5", shape = box, fontname = Helvetica];
24 "console-font-tty5" -> "term-tty5" [color = red];
25 "console-font-tty5" [label = "console-font-tty5", shape = box, fontname = Helvetica];
26 "term-tty4" [label = "term-tty4", shape = box, fontname = Helvetica];
27 "console-font-tty4" -> "term-tty4" [color = red];
28 "console-font-tty4" [label = "console-font-tty4", shape = box, fontname = Helvetica];
29 "term-tty3" [label = "term-tty3", shape = box, fontname = Helvetica];
30 "console-font-tty3" -> "term-tty3" [color = red];
31 "console-font-tty3" [label = "console-font-tty3", shape = box, fontname = Helvetica];
32 "term-tty2" [label = "term-tty2", shape = box, fontname = Helvetica];
33 "console-font-tty2" -> "term-tty2" [color = red];
34 "console-font-tty2" [label = "console-font-tty2", shape = box, fontname = Helvetica];
35 "term-tty1" [label = "term-tty1", shape = box, fontname = Helvetica];
36 "console-font-tty1" -> "term-tty1" [color = red];
37 "console-font-tty1" [label = "console-font-tty1", shape = box, fontname = Helvetica];
38 "networking" [label = "networking", shape = box, fontname = Helvetica];
39 "ssh-daemon" -> "networking" [color = red];
40 "root-file-system" [label = "root-file-system", shape = box, fontname = Helvetica];
41 "file-system-/run/user" -> "root-file-system" [color = red];
42 "file-system-/run/systemd" -> "root-file-system" [color = red];
43 "file-system-/gnu/store" -> "root-file-system" [color = red];
44 "file-system-/dev/shm" -> "root-file-system" [color = red];
45 "file-system-/dev/pts" -> "root-file-system" [color = red];
46 "user-processes" -> "root-file-system" [color = red];
47 "udev" -> "root-file-system" [color = red];
48 "file-system-/run/user" [label = "file-system-/run/user", shape = box, fontname = Helvetica];
49 "user-processes" -> "file-system-/run/user" [color = red];
50 "file-system-/run/systemd" [label = "file-system-/run/systemd", shape = box, fontname = Helvetica];
51 "user-processes" -> "file-system-/run/systemd" [color = red];
52 "file-system-/gnu/store" [label = "file-system-/gnu/store", shape = box, fontname = Helvetica];
53 "user-processes" -> "file-system-/gnu/store" [color = red];
54 "file-system-/dev/shm" [label = "file-system-/dev/shm", shape = box, fontname = Helvetica];
55 "user-processes" -> "file-system-/dev/shm" [color = red];
56 "file-system-/dev/pts" [label = "file-system-/dev/pts", shape = box, fontname = Helvetica];
57 "user-processes" -> "file-system-/dev/pts" [color = red];
58 "udev" [label = "udev", shape = box, fontname = Helvetica];
59 "term-tty6" -> "udev" [color = red];
60 "term-tty5" -> "udev" [color = red];
61 "term-tty4" -> "udev" [color = red];
62 "term-tty3" -> "udev" [color = red];
63 "term-tty2" -> "udev" [color = red];
64 "term-tty1" -> "udev" [color = red];
65 "networking" -> "udev" [color = red];
66 "host-name" [label = "host-name", shape = box, fontname = Helvetica];
67 "term-tty6" -> "host-name" [color = red];
68 "term-tty5" -> "host-name" [color = red];
69 "term-tty4" -> "host-name" [color = red];
70 "term-tty3" -> "host-name" [color = red];
71 "term-tty2" -> "host-name" [color = red];
72 "term-tty1" -> "host-name" [color = red];
73 "loopback" [label = "loopback", shape = box, fontname = Helvetica];
74
75}
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 9160969b952..b5da57a9cef 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -36,6 +36,7 @@
36 #:use-module (gnu system vm) 36 #:use-module (gnu system vm)
37 #:use-module (gnu system grub) 37 #:use-module (gnu system grub)
38 #:use-module (gnu services) 38 #:use-module (gnu services)
39 #:use-module (gnu services dmd)
39 #:use-module (gnu packages grub) 40 #:use-module (gnu packages grub)
40 #:use-module (srfi srfi-1) 41 #:use-module (srfi srfi-1)
41 #:use-module (srfi srfi-19) 42 #:use-module (srfi srfi-19)
@@ -282,7 +283,7 @@ it atomically, and then run OS's activation script."
282 283
283 284
284;;; 285;;;
285;;; Graph. 286;;; Graphs.
286;;; 287;;;
287 288
288(define (service-node-label service) 289(define (service-node-label service)
@@ -311,6 +312,18 @@ list of services."
311 (label service-node-label) 312 (label service-node-label)
312 (edges (lift1 (service-back-edges services) %store-monad)))) 313 (edges (lift1 (service-back-edges services) %store-monad))))
313 314
315(define (dmd-service-node-label service)
316 "Return a label for a node representing a <dmd-service>."
317 (string-join (map symbol->string (dmd-service-provision service))))
318
319(define (dmd-service-node-type services)
320 "Return a node type for SERVICES, a list of <dmd-service>."
321 (node-type
322 (name "dmd-service")
323 (description "the dependency graph of dmd services")
324 (identifier (lift1 dmd-service-node-label %store-monad))
325 (label dmd-service-node-label)
326 (edges (lift1 (dmd-service-back-edges services) %store-monad))))
314 327
315 328
316;;; 329;;;
@@ -410,6 +423,19 @@ building anything."
410 #:node-type (service-node-type services) 423 #:node-type (service-node-type services)
411 #:reverse-edges? #t))) 424 #:reverse-edges? #t)))
412 425
426(define (export-dmd-graph os port)
427 "Export the graph of dmd services of OS to PORT."
428 (let* ((services (operating-system-services os))
429 (pid1 (fold-services services
430 #:target-type dmd-root-service-type))
431 (dmds (service-parameters pid1)) ;the list of <dmd-service>
432 (sinks (filter (lambda (service)
433 (null? (dmd-service-requirement service)))
434 dmds)))
435 (export-graph sinks (current-output-port)
436 #:node-type (dmd-service-node-type dmds)
437 #:reverse-edges? #t)))
438
413 439
414;;; 440;;;
415;;; Options. 441;;; Options.
@@ -435,6 +461,8 @@ Build the operating system declared in FILE according to ACTION.\n"))
435 init initialize a root file system to run GNU\n")) 461 init initialize a root file system to run GNU\n"))
436 (display (_ "\ 462 (display (_ "\
437 extension-graph emit the service extension graph in Dot format\n")) 463 extension-graph emit the service extension graph in Dot format\n"))
464 (display (_ "\
465 dmd-graph emit the graph of dmd services in Dot format\n"))
438 466
439 (show-build-options-help) 467 (show-build-options-help)
440 (display (_ " 468 (display (_ "
@@ -543,7 +571,7 @@ Build the operating system declared in FILE according to ACTION.\n"))
543 (let ((action (string->symbol arg))) 571 (let ((action (string->symbol arg)))
544 (case action 572 (case action
545 ((build vm vm-image disk-image reconfigure init 573 ((build vm vm-image disk-image reconfigure init
546 extension-graph) 574 extension-graph dmd-graph)
547 (alist-cons 'action action result)) 575 (alist-cons 'action action result))
548 (else (leave (_ "~a: unknown action~%") action)))))) 576 (else (leave (_ "~a: unknown action~%") action))))))
549 577
@@ -611,6 +639,8 @@ Build the operating system declared in FILE according to ACTION.\n"))
611 (case action 639 (case action
612 ((extension-graph) 640 ((extension-graph)
613 (export-extension-graph os (current-output-port))) 641 (export-extension-graph os (current-output-port)))
642 ((dmd-graph)
643 (export-dmd-graph os (current-output-port)))
614 (else 644 (else
615 (perform-action action os 645 (perform-action action os
616 #:dry-run? dry? 646 #:dry-run? dry?