0

DomainU 中调用 do_console_io

 2 years ago
source link: https://blog.yxwang.me/2008/09/calling-do_console_io-from-domainu/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

DomainU 中调用 do_console_io

Thu, Sep 25, 2008 • Computer System

The Definitive Guide to Xen Hypervisor 第二章的 Exercise,通过调用 hypercall page 中的 console_io 项输出Hello World。

void start_kernel(start_info_t * start_info)
{
    HYPERVISOR_console_io(CONSOLEIO_write,12,"Hello Worldn");
    while(1);
}

但是默认选项编译和启动的Xen是不会保留DomainU中输出的信息。参考 drivers/char/console.c,可以看到主要有两个选项控制了 DomainU 的 do_console_io 输出:

#ifndef VERBOSE
    /* Only domain 0 may access the emergency console. */
    if ( current->domain->domain_id != 0 )
        return -EPERM;
#endif
if ( opt_console_to_ring )
{
    for ( kptr = kbuf; *kptr != ''; kptr++ )
        putchar_console_ring(*kptr);
    send_guest_global_virq(dom0, VIRQ_CON_RING);
}

在编译 Xen 的时候开启 debug 选项即可置上 VERBOSE,而 opt_console_to_ring 则是一个启动选项,在 grub 的启动选项中增加 loglvl=all guest_loglvl=all console_to_ring 即可。

重启 Xen 后就能通过 xm dmesg 看到 Hello World 了。

本作品采用知识共享署名-非商业性使用 3.0 版本许可协议进行许可,欢迎转载,演绎,但是必须保留本文的署名 zellux(包含链接),且不得用于商业目的。

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK