relationship between libxl & hvmloader


Hvmloader provide boot services and run-time services for hvm ,It operates on the virtual devices provided by the  device models  the domain builder for HVM virtual machines uses the  tools/firmware/hvmloader  to create the necessary information that will enable a unmodified guest VM to work in Xen。
When we use libxl tools to create hvm domain ,it will build hvm info then step into hvmloader to load elf image.These paper introduce how the relationship between libxl &hvmloader.

xl.c
|-main.c
    |-libxl_read_file_contents()        // read  config file from parameter
    |-parse_global_config()            // parse config file decide which xl command
    |-cmdtable_lookup()                //look cmd from config file according cmd_table
        |- create_domain(&dom_info)    
            |-libxl_read_file_contents()   
            |- parse_config_data()         //parse config file 
            |-libxl_domain_create_new ()    //create a new domain according config data
                |- do_domain_create()
                    |- initiate_domain_create()
                         |-libxl__domain_make()
                         |- libxl__domain_build_info_setdefault()
                         |- libxl__bootloader_run ()       // runing bootloader
                         |- domcreate_bootloader_done   // after bootloader_run done , do callback
                            |- libxl__domain_build()
                                |- libxl__build_pre()   //
                                |- libxl__build_hvm() / libxl__build_pv     // according dom_type {HVM, PV}
                                    |-libxl__domain_firmware()
                                    |- xc_hvm_build()
                                    |-xc_read_image()   //the image is hvmloader which format is elf 
                                    |- setup_guest()      // copy hvmloader to special memory 【elf.pstart = 0x100000 (1M)   elf.pend= 
                                                                        0x171764  (1M + 435388)】
                                        |-elf_init()
                                        |-elf_parse_binary()
                                        |-modules_init()
                                        |-xc_domain_set_pod_target()   //Subtract 0x20 from target_pages for the VGA "hole"
                                        |- xc_domain_populate_physmap_exact() //allocate memory for HVM guest  ,skipping VGA 
                                                         hole 0xA0000-0xC0000. first alloc 1G, if fails , turn 2M , also fails, turn 4k eventuraly
                                        |- loadelfimage()    // copy elf image into memory 
                                            |-elf->dest_base = xc_map_foreign_ranges(pages = pfn_end - pfn_start)
                                            |- elf_load_binary()      //load initial elf image
                                        |-loadmodules()
                                        |-build_hvm_info()
                                        |-xc_set_hvm_param()    // include HVM_PARAM_STORE_PFN, HVM_PARAM_BUFIOREQ_PFN,  
                                                                                and HVM_PARAM_IOREQ_PFN
                                        |-xc_map_foreign_range()  //running with CR0.PG=0 when using Intel EPT. Create a 32-bit 
                                                                                    non-PAE page directory of superpages
                                        |-elf_uval()  //Insert JMP <rel32> instruction at address 0x0 to reach entry point
                                    |-hvm_build_set_params()
                                |-  libxl__build_post()   // write into xenstore entry
                            |- domcreate_rebuild_done()
            |- libxl_domain_unpause()     // begin to run vm
            |- autoconnect_vncviewer()
            |- do_daemonize)                   // create a fork for new domain
            |-libxl_create_logfile()
            while(1) : while the domain start
            |-domain_wait_event()           //after create the domain , wait event ,according the event->type ,[SHUTDOWN             
                                                               /DEATH/EJECT], do diff operation
            |-console_child_report()


In all, when use libxl to create hvm domain, the hvmloader provide a virtual BIOS functiong for hvm domain.Hvmloader is loaded at xl create ,the process as follow:

[libxl]create_domain()—> parse_config_data() —>do_domain_create() —>domcreate_bootloader_done  —>  

libxl_domain_build_pre()—>libxl_domain_build_hvm() —>setup_guest() —>load efl image to memory

                                                                                                 

                                                                                  |
[hvmloader]—>step into hvmloader.c ,call asm —>"call main" —>hvmloader.main() —>handler_post() , load into  [0xc0000 -0xfffff ] —>do_post() , call INT 0x19,boot Guest OS —>do_boot() —>boot_disk ,transfer control to Guest OS.







评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值