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

Bật truy cập Console Guest Xen: Hướng dẫn từng bước

Thông thường, khi chạy VM làm domU guests trong Xen, bạn view console qua virt-manager hoặc virt-viewer. Với mọi practical purposes, console buffer là animated image không interact trực tiếp, ít nhất cho đến boot vào GUI, nếu có.

Làm sao nếu muốn console output available mọi lúc? Có thể redirect console output về host và biến thành usable, parsable text? Câu trả lời yes. Có thể, nhưng không trivial. Tôi chỉ cách achieve cho cả fully virtualized và paravirtualized guests.

Paravirtualized guests

Mặc định console nên work không cần config/tweak đặc biệt. Rất tiếc, cuộc sống hiếm khi fair, bạn có thể cần tweak/hack. Có several workarounds.

Edit configuration file

Thêm variations sau vào VM config file:

extra="console=hvc0 xencons=tty"

Có thể specify xvc0 thay hvc0 và dùng một trong hai extra options one key value pair tại một thời điểm. Có thể cần vài changes và test trước khi tìm best, nếu có.

Edit inittab trên guest

Cần add new console vào guest. Edit /etc/inittab, kiểu:

x0:12345:respawn:/sbin/agetty -L 9600 xvc0 xterm

Adjust console name dựa trên config VM. Có thể phải đổi /etc/securetty include new console. Mở file add x0. Backup trước khi change. Tùy chọn: pass extra parameters đến kernel command line hoặc edit GRUB menu. Xem ví dụ khác bên dưới. Should work, nhưng có thể không. Có thể thấy error sequence trong /var/log/messages:

init: Id "x0" respawning too fast: disabled for 5 minutes
init: Id "x0" respawning too fast: disabled for 5 minutes
init: Id "x0" respawning too fast: disabled for 5 minutes
init: Id "x0" respawning too fast: disabled for 5 minutes

Nếu xảy ra, guest OS udev có thể không tạo device, phải tạo thủ công dưới /dev. Không ideal workaround, nhưng giúp gain console nếu các tweak khác fail.

Cuối cùng, thử: virsh console <domain id>. Lấy domain id bằng xm list.

Fully virtualized guests

Theo man pages, xm console không available cho fully virtualized guests, nhưng workaround. Hai việc cần làm. Trên host (dom0), trong config file guest, add directive:

serial="pty"

Trong guest, edit /boot/grub/menu.lst hoặc /boot/grub/grub.conf với lines sau, add ở đâu đó above first kernel entry, probably just below default và timeout directives:

serial --unit=0 --speed=9600
terminal --timeout=5 serial console

Trong relevant GRUB entry add vào kernel line: console=ttyS0. Reboot guest, should have console. Check: attach console đến guest từ dom0:

#xm console <domain name>

Line drop, terminal appears hung. Reboot guest, thấy shutdown/startup messages. Exit: Ctrl + ]. Ví dụ boot/shutdown và kernel crash triggered Magic Keys:

#xm console test1
INIT: Switching to runlevel: 6
INIT: Sending processes the TERM signal
INIT: Sending processes the KILL signal
Boot logging started on /dev/ttyS0(/dev/console) at Thu Dec 1 2011
Master Resource Control: previous runlevel: 3, switching to runlevel: 6
Shutting down service at daemon done
Shutting down auditd done
Shutting down automount (force) done

Some images:

Lưu ý: console redirected bây giờ, không show trong guest. Cần add console=tty1 vào GRUB menu để thấy console messages trong guest nữa.

Tài liệu tham khảo thêm

  • Xen troubleshooting
  • More Xen troubleshooting
  • Installing SLES11 under Xen
  • Xen guest console hangs at boot

Kết luận

Đó là tất cả. Topic fairly not-trivial, nhưng useful. Ít nhất bạn học thêm chút về Xen command line, invoke commands, check parameters, edit system config files, including boot menu. Last but not least, several solutions/workaround cho cả paravirtualized và fully virtualized guests. Much ado about Xen console.

All right. Enough for today. Stay sweet.

Cheers.