小白最近在看KVM相关的资料,发现一个拓扑图,觉得很帅,于是就用PIC工具使用代码的方式把它给绘制出来了。不过这种方式的绘图,比较耗时,这幅拓扑图小白花费了一个小时才绘制出来,如果使用图形化的工具,估计十分钟左右就搞定了,不过小白还是喜欢这种方式的绘图。
先不说此种绘图方式的优点,先说一下此方法绘制图形的缺点:
-
绘制比较复杂的图形,此种方式就更耗时了;
-
需要规划好各个图形元素之间的相对位置。需要使用相对位置而不是绝对位置;
-
不支持中文(这是比较蛋疼的。可以使用asymptote、metapost、tikz等方式代替);
那也说说优点吧:
-
绘图精确(肯定比鼠标精确,可以说是指哪打哪)
-
生成的图形是矢量格式(PDF或postscript格式)
-
生成后的图形可以直接插入到LaTeX文档中
废话少说,直接上代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
.PS
h = .1
dh = .02
dw = .1
[
Userspacetools: [
boxht = 2.5*h; boxwid = 8*dw; boxrad = dh
movewid = 2*dh
A: box
"virsh"
; move
B: box
"virt-manager"
; move
C: box
"virt-viewer"
; move
D: box
"virt-install"
; move
E: box
"other tools"
]
Userspace: [
boxht = 7*h; boxwid = 50*dw; boxrad = 2*dh
AA: box
] with .c at Userspacetools.c + (0,h/1.8)
F:
"Userspace Management Tools"
at last [].n - (0,h+2*dh)
Libvirt: box ht 4*h wid 25*dw
"Libvirt"
"(Libvirt API)"
with .n at last [].s - (0,3*h)
Hypervisoroutline: [
Virtualtype: [
boxht = 2*h; boxwid = 12*dw; boxrad = dh
movewid = 2*dh
A: box
"VMware"
; move
B: box
"Xen"
; move
C: box
"KVM"
; move
D: box
"Hyper-V"
]
Hypervisor: [
boxht = 5*h; boxwid = 50*dw; boxrad = 2*dh
AA: box
] with .c at Virtualtype.c + (0,h/1.8)
F:
"Hypervisor Layer"
at last [].n - (0,h+2*dh)
] with .n at Libvirt.s - (0,3*h)
XXX: [
VMwareoutline: [
VMware: [
boxht = 3.5*h; boxwid = 5*dw; boxrad = dh
movewid = 2*dh
VM1: box
"Guest 1"
; move
VM2: box
"Guest 2"
] with .n at Hypervisoroutline.Virtualtype.A.s - (0,3*h)
box dashed ht last [].ht+dw wid last [].wid+dw at last []
]
move 5*dh
Xenoutline: [
Xen: [
boxht = 3.5*h; boxwid = 5*dw; boxrad = dh
movewid = 2*dh
VM1: box
"Dom0"
"Guest"
; move
VM2: box
"DomU"
"Guest"
]
box dashed ht last [].ht+dw wid last [].wid+dw at last []
]
move 5*dh
Kvmoutline: [
Kvm: [
boxht = 1.75*h; boxwid = 5*dw; boxrad = dh
movewid = 2*dh
VM1: [
Qemu1: box
"Qemu"
Guest01: box
"Guest 1"
with .n at Qemu1.s
]
move
VM2: [
Qemu1: box
"Qemu"
Guest01: box
"Guest 2"
with .n at Qemu1.s
]
]
box dashed ht last [].ht+dw wid last [].wid+dw at last []
]
move 5*dh
Hypervoutline: [
Hyperv: [
boxht = 3.5*h; boxwid = 5*dw; boxrad = dh
movewid = 2*dh
VM1: box
"Guest 1"
; move
VM2: box
"Guest 2"
]
box dashed ht last [].ht+dw wid last [].wid+dw at last []
]
] with .n at last [].s - (0,3*h)
arrow from Userspacetools.A.s to Libvirt.nw
arrow from Userspacetools.B.s to 1/2 <Libvirt.nw,Libvirt.n>
arrow from Userspacetools.C.s to Libvirt.n
arrow from Userspacetools.D.s to 1/2 <Libvirt.n,Libvirt.ne>
arrow from Userspacetools.E.s to Libvirt.ne
arrow from Libvirt.s to 3rd [].Hypervisor.n
arrow from Hypervisoroutline.Virtualtype.A.s to XXX.VMwareoutline.VMware.n
arrow from Hypervisoroutline.Virtualtype.B.s to XXX.Xenoutline.Xen.n
arrow from Hypervisoroutline.Virtualtype.C.s to XXX.Kvmoutline.Kvm.n
arrow from Hypervisoroutline.Virtualtype.D.s to XXX.Hypervoutline.Hyperv.n
]
.PE
|
编译后的效果图为:
版权声明:原创作品,如需转载,请注明出处。否则将追究法律责任