Re: [Qemu-discuss] How to run qemu with -nographic and -monitor but still be able to send Ctrl+C to the guest?

2018-04-11 Thread Ciro Santilli
On Wed, Apr 11, 2018 at 2:11 PM, Peter Maydell  wrote:
> On 11 April 2018 at 13:33, Ciro Santilli  wrote:
>> There is now just one minor quirk which I can live with: for arm and
>> aarch64, if I hit Ctrl + C while the kernel is booting and spitting
>> out dmesg messages, then the userland terminal is dead: it does not
>> show any characters when I type, nor any output.
>
> This sounds like maybe you're running into a known guest
> kernel bug. There's a patch which fixes that here:
> https://patchwork.kernel.org/patch/10192149/
> which doesn't seem to have been applied yet, but maybe you
> could test it?
>

Awesome, I've tested the patch, and with it my problem is gone on arm
and aarch64.

Testing setup at: https://github.com/cirosantilli/qemu-test/blob/master/arm/min

> thanks
> -- PMM



Re: [Qemu-discuss] How to run qemu with -nographic and -monitor but still be able to send Ctrl+C to the guest?

2018-04-11 Thread Peter Maydell
On 11 April 2018 at 13:33, Ciro Santilli  wrote:
> There is now just one minor quirk which I can live with: for arm and
> aarch64, if I hit Ctrl + C while the kernel is booting and spitting
> out dmesg messages, then the userland terminal is dead: it does not
> show any characters when I type, nor any output.

This sounds like maybe you're running into a known guest
kernel bug. There's a patch which fixes that here:
https://patchwork.kernel.org/patch/10192149/
which doesn't seem to have been applied yet, but maybe you
could test it?

thanks
-- PMM



Re: [Qemu-discuss] How to run qemu with -nographic and -monitor but still be able to send Ctrl+C to the guest?

2018-04-11 Thread Ciro Santilli
On Tue, Apr 10, 2018 at 9:54 PM, Thomas Huth  wrote:
> On 10.04.2018 16:06, Ciro Santilli wrote:
>> On Tue, Apr 10, 2018 at 6:27 AM, Thomas Huth  wrote:
>>> On 10.04.2018 02:10, Ciro Santilli wrote:
 On Mon, Apr 9, 2018 at 1:33 PM, Thomas Huth  wrote:
> On 08.04.2018 12:39, Ciro Santilli wrote:
>>> [...]
>> Is there a way to both keep my `Ctrl-C` and `-monitor` working with
>> `-nographic`?
>>
>> Full QEMU command:
>>
>> qemu-system-x86_64 -append 'root=/dev/vda console=ttyS0' -kernel
>> 'bzImage' -drive file='rootfs.ext2.qcow2,if=virtio,format=qcow2'
>> -nographic -monitor telnet::45454,server,nowait
>
> I think you need a chardev with signal=off for that. Try something like:
>
> qemu-system-x86_64  -nographic -monitor telnet::45454,server,nowait \
>   -chardev stdio,id=s1,signal=off \
>   -serial none -device isa-serial,chardev=s1
>

 I tried that and Ctrl+C does get passed to the guest as I wanted.

 However, when I do this, I noticed that I can't pass Ctrl+A X to
 easily quit QEMU (I know I can do quit on the monitor).

 Is there a way to also keep Ctrl+A X working, in addition to having
 Ctrl+C passed to the guest?
>>>
>>> Yes, you need to multiplex the stdio output with a HMP monitor:
>>>
>>> qemu-system-x86_64  -nographic -monitor telnet::45454,server,nowait \
>>>  -chardev stdio,id=s1,signal=off,mux=on -serial none \
>>>  -device isa-serial,chardev=s1 -mon chardev=s1,mode=readline
>>>
>>
>> Thanks, that worked perfectly!
>>
>> Do you know how to do the same thing for `qemu-system-arm -M
>> versatilepb` or `qemu-system-aarch64 -M virt`?
>
> Not sure ... at least versatilepb seems to use an embedded UART, so
> -device likely does not work there.
>
> But you could try to simply use "-serial mon:stdio" here. Actually, now
> that I remembered that option ... that might even also work on x86
> instead of all that complicated stuff that I told you before:
>
> qemu-system-x86_64 -nographic -monitor telnet::45454,server,nowait \
>-serial mon:stdio
>
> (I initially didn't know that you also wanted to have a HMP monitor /
> Ctrl-A X here, too, that's why I did not think of this solution in my
> first mail)
>

Yes sorry, I only remembered Ctrl+X A halfway (because I was quitting
QEMU with Ctrl+C before).

OK! -serial mon:stdio instead of the previous options worked perfectly
on all arches!

There is now just one minor quirk which I can live with: for arm and
aarch64, if I hit Ctrl + C while the kernel is booting and spitting
out dmesg messages, then the userland terminal is dead: it does not
show any characters when I type, nor any output. This is my full
aarch64 command for example:

```
./aarch64-softmmu/qemu-system-aarch64 \
-M virt \
-append 'root=/dev/vda nokaslr norandmaps printk.devkmsg=on printk.time=y' \
-cpu cortex-a57 \
-drive 
file="${dir}/out/aarch64/buildroot/images/rootfs.ext2.qcow2,if=virtio,format=qcow2"
\
-kernel "${dir}/out/aarch64/buildroot/images/Image" \
-monitor telnet::45454,server,nowait \
-nographic \
-serial mon:stdio \
```

images at: 
https://github.com/cirosantilli/linux-kernel-module-cheat/releases/tag/uploads

@pete maybe you have some arm insight on this?

>  HTH,
>   Thomas



Re: [Qemu-discuss] How to run qemu with -nographic and -monitor but still be able to send Ctrl+C to the guest?

2018-04-10 Thread Thomas Huth
On 10.04.2018 16:06, Ciro Santilli wrote:
> On Tue, Apr 10, 2018 at 6:27 AM, Thomas Huth  wrote:
>> On 10.04.2018 02:10, Ciro Santilli wrote:
>>> On Mon, Apr 9, 2018 at 1:33 PM, Thomas Huth  wrote:
 On 08.04.2018 12:39, Ciro Santilli wrote:
>> [...]
> Is there a way to both keep my `Ctrl-C` and `-monitor` working with
> `-nographic`?
>
> Full QEMU command:
>
> qemu-system-x86_64 -append 'root=/dev/vda console=ttyS0' -kernel
> 'bzImage' -drive file='rootfs.ext2.qcow2,if=virtio,format=qcow2'
> -nographic -monitor telnet::45454,server,nowait

 I think you need a chardev with signal=off for that. Try something like:

 qemu-system-x86_64  -nographic -monitor telnet::45454,server,nowait \
   -chardev stdio,id=s1,signal=off \
   -serial none -device isa-serial,chardev=s1

>>>
>>> I tried that and Ctrl+C does get passed to the guest as I wanted.
>>>
>>> However, when I do this, I noticed that I can't pass Ctrl+A X to
>>> easily quit QEMU (I know I can do quit on the monitor).
>>>
>>> Is there a way to also keep Ctrl+A X working, in addition to having
>>> Ctrl+C passed to the guest?
>>
>> Yes, you need to multiplex the stdio output with a HMP monitor:
>>
>> qemu-system-x86_64  -nographic -monitor telnet::45454,server,nowait \
>>  -chardev stdio,id=s1,signal=off,mux=on -serial none \
>>  -device isa-serial,chardev=s1 -mon chardev=s1,mode=readline
>>
> 
> Thanks, that worked perfectly!
> 
> Do you know how to do the same thing for `qemu-system-arm -M
> versatilepb` or `qemu-system-aarch64 -M virt`?

Not sure ... at least versatilepb seems to use an embedded UART, so
-device likely does not work there.

But you could try to simply use "-serial mon:stdio" here. Actually, now
that I remembered that option ... that might even also work on x86
instead of all that complicated stuff that I told you before:

qemu-system-x86_64 -nographic -monitor telnet::45454,server,nowait \
   -serial mon:stdio

(I initially didn't know that you also wanted to have a HMP monitor /
Ctrl-A X here, too, that's why I did not think of this solution in my
first mail)

 HTH,
  Thomas



Re: [Qemu-discuss] How to run qemu with -nographic and -monitor but still be able to send Ctrl+C to the guest?

2018-04-10 Thread Ciro Santilli
On Tue, Apr 10, 2018 at 6:27 AM, Thomas Huth  wrote:
> On 10.04.2018 02:10, Ciro Santilli wrote:
>> On Mon, Apr 9, 2018 at 1:33 PM, Thomas Huth  wrote:
>>> On 08.04.2018 12:39, Ciro Santilli wrote:
> [...]
 Is there a way to both keep my `Ctrl-C` and `-monitor` working with
 `-nographic`?

 Full QEMU command:

 qemu-system-x86_64 -append 'root=/dev/vda console=ttyS0' -kernel
 'bzImage' -drive file='rootfs.ext2.qcow2,if=virtio,format=qcow2'
 -nographic -monitor telnet::45454,server,nowait
>>>
>>> I think you need a chardev with signal=off for that. Try something like:
>>>
>>> qemu-system-x86_64  -nographic -monitor telnet::45454,server,nowait \
>>>   -chardev stdio,id=s1,signal=off \
>>>   -serial none -device isa-serial,chardev=s1
>>>
>>
>> I tried that and Ctrl+C does get passed to the guest as I wanted.
>>
>> However, when I do this, I noticed that I can't pass Ctrl+A X to
>> easily quit QEMU (I know I can do quit on the monitor).
>>
>> Is there a way to also keep Ctrl+A X working, in addition to having
>> Ctrl+C passed to the guest?
>
> Yes, you need to multiplex the stdio output with a HMP monitor:
>
> qemu-system-x86_64  -nographic -monitor telnet::45454,server,nowait \
>  -chardev stdio,id=s1,signal=off,mux=on -serial none \
>  -device isa-serial,chardev=s1 -mon chardev=s1,mode=readline
>

Thanks, that worked perfectly!

Do you know how to do the same thing for `qemu-system-arm -M
versatilepb` or `qemu-system-aarch64 -M virt`?

If I try to pass the option `-device isa-serial,chardev=s1` it QEMU
fails to start with:

-device isa-serial,chardev=s1: No 'ISA' bus found for device 'isa-serial'

>   Thomas



Re: [Qemu-discuss] How to run qemu with -nographic and -monitor but still be able to send Ctrl+C to the guest?

2018-04-09 Thread Thomas Huth
On 10.04.2018 02:10, Ciro Santilli wrote:
> On Mon, Apr 9, 2018 at 1:33 PM, Thomas Huth  wrote:
>> On 08.04.2018 12:39, Ciro Santilli wrote:
[...]
>>> Is there a way to both keep my `Ctrl-C` and `-monitor` working with
>>> `-nographic`?
>>>
>>> Full QEMU command:
>>>
>>> qemu-system-x86_64 -append 'root=/dev/vda console=ttyS0' -kernel
>>> 'bzImage' -drive file='rootfs.ext2.qcow2,if=virtio,format=qcow2'
>>> -nographic -monitor telnet::45454,server,nowait
>>
>> I think you need a chardev with signal=off for that. Try something like:
>>
>> qemu-system-x86_64  -nographic -monitor telnet::45454,server,nowait \
>>   -chardev stdio,id=s1,signal=off \
>>   -serial none -device isa-serial,chardev=s1
>>
> 
> I tried that and Ctrl+C does get passed to the guest as I wanted.
> 
> However, when I do this, I noticed that I can't pass Ctrl+A X to
> easily quit QEMU (I know I can do quit on the monitor).
> 
> Is there a way to also keep Ctrl+A X working, in addition to having
> Ctrl+C passed to the guest?

Yes, you need to multiplex the stdio output with a HMP monitor:

qemu-system-x86_64  -nographic -monitor telnet::45454,server,nowait \
 -chardev stdio,id=s1,signal=off,mux=on -serial none \
 -device isa-serial,chardev=s1 -mon chardev=s1,mode=readline

  Thomas



Re: [Qemu-discuss] How to run qemu with -nographic and -monitor but still be able to send Ctrl+C to the guest?

2018-04-09 Thread Ciro Santilli
On Mon, Apr 9, 2018 at 1:33 PM, Thomas Huth  wrote:
> On 08.04.2018 12:39, Ciro Santilli wrote:
>> https://stackoverflow.com/questions/49716931/how-to-run-qemu-with-nographic-and-monitor-but-still-be-able-to-send-ctrlc-to
>>
>> I have just found out that if you run QEMU with `-monitor
>> telnet::45454,server,nowait -nographic`, then Ctrl-C kills the QEMU VM
>> instead of generating SIGINT on the guest:
>> https://unix.stackexchange.com/questions/167165/how-to-pass-ctrl-c-to-the-guest-when-running-qemu-with-nographic/436321#436321
>>
>> However, I don't want to remove `-monitor` because it is convenient to
>> automate monitor commands, e.g. it allows me to create a helper script
>> that does:
>>
>> echo 'savevm my_snap_id' |  telnet localhost 45454
>>
>> Is there a way to both keep my `Ctrl-C` and `-monitor` working with
>> `-nographic`?
>>
>> Full QEMU command:
>>
>> qemu-system-x86_64 -append 'root=/dev/vda console=ttyS0' -kernel
>> 'bzImage' -drive file='rootfs.ext2.qcow2,if=virtio,format=qcow2'
>> -nographic -monitor telnet::45454,server,nowait
>
> I think you need a chardev with signal=off for that. Try something like:
>
> qemu-system-x86_64  -nographic -monitor telnet::45454,server,nowait \
>   -chardev stdio,id=s1,signal=off \
>   -serial none -device isa-serial,chardev=s1
>

I tried that and Ctrl+C does get passed to the guest as I wanted.

However, when I do this, I noticed that I can't pass Ctrl+A X to
easily quit QEMU (I know I can do quit on the monitor).

Is there a way to also keep Ctrl+A X working, in addition to having
Ctrl+C passed to the guest?

>  HTH,
>   Thomas



Re: [Qemu-discuss] How to run qemu with -nographic and -monitor but still be able to send Ctrl+C to the guest?

2018-04-09 Thread Thomas Huth
On 08.04.2018 12:39, Ciro Santilli wrote:
> https://stackoverflow.com/questions/49716931/how-to-run-qemu-with-nographic-and-monitor-but-still-be-able-to-send-ctrlc-to
> 
> I have just found out that if you run QEMU with `-monitor
> telnet::45454,server,nowait -nographic`, then Ctrl-C kills the QEMU VM
> instead of generating SIGINT on the guest:
> https://unix.stackexchange.com/questions/167165/how-to-pass-ctrl-c-to-the-guest-when-running-qemu-with-nographic/436321#436321
> 
> However, I don't want to remove `-monitor` because it is convenient to
> automate monitor commands, e.g. it allows me to create a helper script
> that does:
> 
> echo 'savevm my_snap_id' |  telnet localhost 45454
> 
> Is there a way to both keep my `Ctrl-C` and `-monitor` working with
> `-nographic`?
> 
> Full QEMU command:
> 
> qemu-system-x86_64 -append 'root=/dev/vda console=ttyS0' -kernel
> 'bzImage' -drive file='rootfs.ext2.qcow2,if=virtio,format=qcow2'
> -nographic -monitor telnet::45454,server,nowait

I think you need a chardev with signal=off for that. Try something like:

qemu-system-x86_64  -nographic -monitor telnet::45454,server,nowait \
  -chardev stdio,id=s1,signal=off \
  -serial none -device isa-serial,chardev=s1

 HTH,
  Thomas