小白最近在看KVM相關的資料,發現一個拓撲圖,以爲很帥,因而就用PIC工具使用代碼的方式把它給繪製出來了。不過這種方式的繪圖,比較耗時,這幅拓撲圖小白花費了一個小時才繪製出來,若是使用圖形化的工具,估計十分鐘左右就搞定了,不太小白仍是喜歡這種方式的繪圖。ide
先不說此種繪圖方式的優勢,先說一下此方法繪製圖形的缺點:工具
繪製比較複雜的圖形,此種方式就更耗時了;post
須要規劃好各個圖形元素之間的相對位置。須要使用相對位置而不是絕對位置;spa
不支持中文(這是比較蛋疼的。能夠使用asymptote、metapost、tikz等方式代替);
ip
那也說說優勢吧:ci
繪圖精確(確定比鼠標精確,能夠說是指哪打哪)文檔
生成的圖形是矢量格式(PDF或postscript格式)get
生成後的圖形能夠直接插入到LaTeX文檔中
it
廢話少說,直接上代碼:io
.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
編譯後的效果圖爲: