Computer >> Hướng Dẫn Máy Tính >  >> Phần Mềm >> Máy Ảo

Hướng dẫn Troubleshooting Xen nâng cao: Giải quyết vấn đề Display, Python, Service

Đã có tutorial về vài common Xen problems khi test Xen trong environment. Batch đầu tips/tricks focus: display issues, Python versions/modules, changing wrapper scripts, explicit commands, troubleshooting services.

Hôm nay dive deeper, hiểu, fix, workaround vài vấn đề hơn bạn có thể gặp hoặc không. Thừa nhận một số solutions hơi ad-hoc, đừng tin tuyệt đối, nhưng tôi tin chúng work well. Hy vọng Xen experience của bạn "zenny" hơn sau đọc.

Tip 1: VNC connection đến hypervisor host bị refused/disconnected

Sau khi start Virtual Machine Manager (virt-manager), option view VM contents qua VNC, hiển thị console relevant domain. Thỉnh thoảng console blank và throw error. Làm sao?

Kinh nghiệm: xảy ra bất cứ khi guest OS restart hoặc shutdown. Power on lại, phải reopen console inconveniently. Tương tự virt-viewer: virt-viewer <domain>. Domain reboot/reset/power off -> lose connection. Simple solution: reopen console window qua virt-manager hoặc virt-viewer.

Alternatively, establish connection:

virsh vncdisplay <domain>
vncviewer <hostname:port returned by virsh command>

Tip 2: vif biến mất khi guest running, no more networking

Có thể xảy ra: VM running, virtual network interface vifX.X biến mất từ ifconfig list, biến guest thành brick vô dụng.

Problem cũng manifest: MAC address network interface trong VM thành all zeros. Trên host (dom0), thấy entries trong /var/log/messages:

kernel: [ 109.743854] br0: port 2(vif1.0) entering learning state
kernel: [ 109.811880] br0: port 3(tap1.0) entering learning state
kernel: [ 117.369189] br0: port 3(tap1.0) entering disabled state
kernel: [ 117.398076] device tap1.0 left promiscuous mode
kernel: [ 117.398083] br0: port 3(tap1.0) entering disabled state
kernel: [ 117.815006] br0: port 2(vif1.0) entering disabled state
kernel: [ 117.850075] br0: port 2(vif1.0) entering disabled state

Fix như thế nào? Several options. Một: kernel upgrade mysteriously resolve. Không mysterious, hơn như fix race conditions Xen networking stack. Hai: tweak network settings trong Xen config file /etc/xen/xend-config.sxp. File chứa directives, bao gồm setup bridge và virtual network interfaces. Nhiều claim networking buggy, nên manually configure scripts.

Đặc biệt, thay đổi directives:

(network-script network-bridge) to (network-script )

Hơn nữa, manually configure bridge. Testing: dùng brctl và ifconfig, khi confident changes solid, permanently commit vào network scripts. RedHat/SUSE: tạo ifcfg-br<number> và change existing network scripts cho network cards dưới /etc/sysconfig/network. Debian-based: edit /etc/interfaces. Backups bắt buộc.

Ví dụ manual bridge config:

brctl addbr br0
brctl setfd br0 0
ifconfig br0 10.0.0.128 up netmask 255.255.255.0
brctl addif br0 eth0
route add -net default gw 10.0.0.254 br0
ifconfig eth0 0.0.0.0 up

Tiếp: increase/decrease netloops (số pairs virtual devices có thể tạo). Nếu hit upper limit, increase. Tạo file netloop dưới /etc/modprobe.d ghi:

option netloop nloopbacks=<some high number, e.g. 16, 32>

Hoặc add option vào /etc/modprobe.conf.

Đọc thêm nhiều về topic này:

  • Xen networking
  • Xen network bridges explained with troubleshooting notes
  • SLES networking under xen, troubleshooting and recommendations
  • Hassle-free Xen networking
  • Linux networking sucks. XEN networking sucks.
  • Creating additional Xen virtual network bridges

Nếu gặp kernel crashes khi này, hai link sau cũng interest, beware ultra-geekiness:

  • Kernel BUG at mm/vmalloc.c:2165
  • [PATCH] mm: sync vmalloc address space page tables in alloc_vm_area()

Problem thực sự có thể resolved bằng reduce netloops về zero.

Tip 3: Enable legacy HTTP access

libvirt làm HTTP redundant khi connect đến dom0 manage locally/remotely. Tuy nhiên một số bạn quan tâm option này, nhất là dùng tools như OpenXenManager (HTTP/HTTPS connect). Để Xen accessible từ Web, edit directives trong xend-config.sxp:

(xend-http-server yes)
(xend-port 8000)
(xend-address '')

Change no thành yes cho xend-http-server, specify correct port, xend-address chỉ IP interface Xend listen. Default empty quotes -> listen all interfaces. Reload config:

/etc/init.d/xend reload

Test Web access.

Tip 4: ERROR: unable to connect to 'localhost:8000': Connection refused

Corollary tip trên: ugly connection refused error khi connect dom0 qua virt-manager. Python notorious verbose, be prepared for ugliness.

Resolve: enable HTTP access. Hoặc tự hỏi tại sao xảy ra. Likely reason: một Xen service không running, force virt-manager fallback legacy access. Nếu không muốn HTTP protocol, đảm bảo system boot với all relevant Xen services, đặc biệt libvirtd và xend.

Tip 5: domU startup errors

Khi power on domains với xm create <domain> hoặc xm start <domain>, gặp error messages anger/confuse. Dissect vài cái hiểu problem.

#xm start test1
Error: Domain unable to be unpaused: an integer is required
Usage: xm start <DomainName>

Graphical equivalent:

Thường nghĩa: specified non-existent/unsupported hardware component (network card, sound card). Review domain config file (thường /etc/xen/vm) errors. Check /var/log/messages, Xen error log /var/log/xen/xend.log.

Error khác:

#xm create test1
Using config file "./test1".
Error: (2, 'Invalid kernel', "elf_xen_note_check: ERROR: Not a Xen-ELF image: No ELF notes or '__xen_guest' section found.\n")

Happen nếu power on paravirtualized guest dùng HVM kernel settings trong domain config. Trivial debug/resolve.

#xm create test1
Using config file "./test1".
Error: Device 768 (vbd) could not be connected.
File /tmp/disk.raw is loopback-mounted through /dev/loop1, which is mounted in a guest domain, and so cannot be mounted now.

Thấy nếu reuse hard disk file đã dùng bởi VM khác. Hoặc mount nó as loopback device để inspect.

VBD errors khác:

#xm create test1
Using config file "./test1".
Error: Device 5632 (vbd) could not be connected. Device not found.

Variation trong xend.log:

DEBUG (DevController:139) Waiting for devices vscsi.
DEBUG (DevController:139) Waiting for devices vbd.
DEBUG (DevController:144) Waiting for 768.
WARNING (XendDomain:1076) Failed to setup devices for <domain id=None name=test1 memory=4294967296 state=halted>: Device 768 (vbd) could not be connected. Device not found.

Lý do: badly specified hard disk file, hoặc bad use device (spelling error). Tương tự error đầu.

Câu hỏi: làm sao biết vbd là device gì? Workaround đơn giản: verify trên booted Xen domU. Devices dưới /sys/devices/xen/. Ví dụ:

#cat /sys/devices/xen/vbd-768/block/hda/hda1/dev
3:1

vbd-768 là block device major number 3. hda1 = 3:1, logic. Complete listing cho VM:

#ll
total 0
drwxr-xr-x 2 root root 0 Dec 18 12:07 power
-rw-r--r-- 1 root root 4096 Dec 18 12:07 uevent
drwxr-xr-x 4 root root 0 Dec 18 12:05 vbd-5632
drwxr-xr-x 4 root root 0 Dec 18 12:05 vbd-768
drwxr-xr-x 3 root root 0 Dec 18 12:05 vfb-0
drwxr-xr-x 4 root root 0 Dec 18 12:05 vif-0

Cách complex: translate số sang hex, two least significant bits = minor number, remaining higher bits = major number, refer devices.txt online hoặc /usr/src/linux/Documentation. Ví dụ: 768 decimal = 0x0300 hex -> major 3, minor 0 -> first IDE device (hda). 5632 = 0x1600 -> major 22, minor 0 -> CD-ROM. Jolly well. Old Xen mailing list thread cũng interest.

Tip 6: Advanced settings

Cuối, lightweight. Boot guests, tweak advanced settings. Ví dụ: PAE hoặc OpenGL. Mark correct options trong VM wizard, hoặc nếu rành command line/VM files, add correct strings.

Last unlisted tip: setup multi-boot systems với GRUB2 in charge. Nothing new, discussed intro article, hop đó xem.

End here today.

Kết luận

Tôi tin tool viết bằng Python designed với error verbosity nhiều nhất để spite admins và annoy họ. Xen rơi category này, với messages profuse, inelegant. Not trivial.

Vẫn hy vọng tutorial useful. Thừa nhận margin for error lớn. Bạn apply suggestions và fail miserably, feel anger/disappointment. Vì hundreds different scenarios inflict bạn, mỗi cái slightly different. Regardless, some tips useful: workaround VNC disconnects, investigate network problems, various errors/config problems. Done, see you around.

Cheers.