小白最近在看KVM相关的资料,发现一个拓扑图,觉得很帅,于是就用PIC工具使用代码的方式把它给绘制出来了。不过这种方式的绘图,比较耗时,这幅拓扑图小白花费了一个小时才绘制出来,如果使用图形化的工具,估计十分钟左右就搞定了,小白还是喜欢这种方式的绘图。
使用此方法绘制图形的缺点:
- 绘制比较复杂的图形,此种方式就更耗时了;
- 需要规划好各个图形元素之间的相对位置。需要使用相对位置而不是绝对位置;
- 不支持中文(这是比较蛋疼的。可以使用asymptote、metapost、tikz等方式代替);
废话少说,直接上代码:
.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
编译后的效果图为:
时间: 2024-10-29 19:11:13