[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-discuss] How to use qemu for non-interactive testing

From: Jakob Bohm
Subject: Re: [Qemu-discuss] How to use qemu for non-interactive testing
Date: Mon, 21 Dec 2015 13:02:31 +0100
User-agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0

There is a monitor and/or qmp command to simulate a "soft"
press on the power button, which would trigger any OS
provided clean shut down logic via ACPI/APM.

There is a different monitor and/or qmp command to simulate
a hard power off while still keeping the virtualization
aspect of e.g. qcow2 files consistent.

Finally, there is the option to simply kill the qemu

On 19/12/2015 00:39, Wink Saville wrote:

I ended up using the first technique for VersatilePB and works just fine.

Now I want to be able "power off" a qemu-system-i386 and I was wondering what you might suggest? I'm hoping there might be something "easy".

-- Wink

On Mon, Oct 19, 2015 at 1:49 PM Wink Saville <address@hidden <mailto:address@hidden>> wrote:

    THANKS, I'll give those things a try!

    On Mon, Oct 19, 2015, 1:46 PM Peter Maydell
    <address@hidden <mailto:address@hidden>> wrote:

        On 19 October 2015 at 20:30, Wink Saville <address@hidden
        <mailto:address@hidden>> wrote:
        > I would like to use qemu in a test environment where I give
        a "kernel" image
        > to qmeu have it execute it and then when complete have qemu
        exit. Currently
        > when
        > executing:
        >   $ qemu-system-arm -M versatilepb -m 128M -nographic
        -kernel test.bin
        >   ...
        >   Hi
        >   $
        > After test.bin prints "Hi" via the "Uart in VersatilePB" I
        have to
        > interactively press ctrl-a then press 'x' to have it return
        to the command
        > prompt. Is there a way for test.bin to cause qemu to exit
        without having to
        > type commands in the terminal.

        That depends on the machine you're using (in this case
        Basically if the guest binary tells the emulated hardware "please
        power down" via whatever that hardware's mechanism is, then QEMU
        will exit. For versatilepb there isn't any way to do that, but you
        can use QEMU's "-no-reboot" option (which turns resets into power
        downs) and then tell the emulated hardware to do a reset. For info
        on how to do a reset on the versatilepb board see the h/w docs:
        You need to write to SYS_LOCKCTL to unlock the register and then
        to SYS_RESETCTL to actually request the reset.

        Other options you can use:
         * an ARM-specific option is to use the -semihosting command line
        option, and then you can use the semihosting ABI to exit.
        You need to do an angel_SWIreason_ReportException:
        (which is to say, set r0 to 0x18, r1 to 0x20026 and do a
        swi 0x123456 in ARM mode or swi 0xab (Thumb mode) or
        bkpt 0xab (M profile).
        Semihosting also lets you conveniently output to the terminal,
        read files or look at the command line, so it's handy for
        writing test cases.

         * use the 'expect' utility to script up the "make QEMU exit
        when it's printed the result" handling. It's generally nicer
        to avoid this, but as a last resort it's nice to have: a
        handful of lines of expect scripting are sufficient to do
        basic "start this program, then exit when some string appears
        in its output" control.

        PS: you might prefer '-display none' over '-nographic';
        that gives you the serial output to standard output, but
        doesn't do the 'monitor on alternate screen, ctrl-a <whatever>'
        behaviour. You can just ctrl-c to exit qemu then.
        Basically -nographic is a magic combination of a bunch
        of options and sometimes you only want one of them.

        -- PMM

Enjoy and Merry Christmas

Jakob Bohm, CIO, Partner, WiseMo A/S.  https://www.wisemo.com
Transformervej 29, 2860 Søborg, Denmark.  Direct +45 31 13 16 10
This public discussion message is non-binding and may contain errors.
WiseMo - Remote Service Management for PCs, Phones and Embedded

reply via email to

[Prev in Thread] Current Thread [Next in Thread]