hyperhq / runv

Hypervisor-based Runtime for OCI
Apache License 2.0
828 stars 129 forks source link

issues of runv terminal #546

Closed laijs closed 7 years ago

laijs commented 7 years ago

1) echo twice. (it should be only once)

/ # ls
ls
bin      etc      lib      linuxrc  mnt      proc     run      sys      usr
dev      home     lib64    media    opt      root     sbin     tmp      var

2) 0x0d appended correct:

[root@sbox runv]# hexdump -C <(echo /usr)
00000000  2f 75 73 72 0a                                    |/usr.|
00000005

but runv:

[root@sbox runv]# hexdump -C <(runv exec  bbb echo /usr)
00000000  2f 75 73 72 0d 0a                                 |/usr..|
00000006

3 window changing is not working

gnawux commented 7 years ago

looks like tty related? did hyperstart get the spec with tty=true?

laijs commented 7 years ago

it got tty=true @gnawux

laijs commented 7 years ago

I think it is related to runv-shim

bergwolf commented 7 years ago

I don't see this when testing with containerd ctr client.

[hypervsock@containerd]$sudo ctr run -t docker.io/library/busybox:latest foobar10 sh
/ # ls
bin   dev   etc   home  lib   proc  root  sys   tmp   usr   var
/ # pwd
/

How did you reproduce it? Could it be related to your test method?

laijs commented 7 years ago

This happens when directly use runv. it is related to runv-shim which is a background process but accesses to foreground stdio.

how about hexdump -C <(ctr tasks exec containername echo /usr)?

bergwolf commented 7 years ago

It works correctly as well.

[hypervsock@runv]$hexdump -C <(sudo ctr exec --exec-id 1 foobar12 echo /usr)
I0814 21:22:57.497654   60766 hypervisor.go:94] VM vm-lkIQhDfrUP trying to reload with serialized data: {"PersistVersion":20170611,"Id":"vm-lkIQhDfrUP","Paused":false,"DriverInfo":{"hypervisor":"qemu","log":{"name":"/var/log/hyper/qemu/vm-lkIQhDfrU.log","offset":91},"pid":60253,"qmpSock":"/var/run/hyper/vm-lkIQhDfrUP/qmp.sock"},"VmSpec":{"hostname":"","containers":[{"id":"foobar12","rootfs":"rootfs","image":"foobar12","sysctl":{"vm.overcommit_memory":"1"},"process":{"id":"init","terminal":true,"args":["sh"],"envs":[{"env":"PATH","value":"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"},{"env":"TERM","value":"xterm"}],"workdir":"/"},"restartPolicy":"never","initialize":false,"readOnly":false}],"shareDir":"share_dir"},"HwStat":{"PciAddr":5,"ScsiId":0,"AttachId":0,"GuestCid":0},"VolumeList":[{"Name":"foobar12","Filename":"foobar12","Format":"vfs","Fstype":"dir","DeviceName":"","ScsiId":0,"ContainerIds":["foobar12"],"IsRootVol":true,"Containers":null,"MontPoints":null}],"NetworkList":[],"PortList":[]}
I0814 21:22:57.498244   60766 hypervisor.go:103] VM vm-lkIQhDfrUP trying to reload with deserialized pinfo: &hypervisor.PersistInfo{PersistVersion:20170611, Id:"vm-lkIQhDfrUP", Paused:false, DriverInfo:map[string]interface {}{"pid":60253, "qmpSock":"/var/run/hyper/vm-lkIQhDfrUP/qmp.sock", "hypervisor":"qemu", "log":map[string]interface {}{"name":"/var/log/hyper/qemu/vm-lkIQhDfrU.log", "offset":91}}, VmSpec:(*json.Pod)(0xc42008c240), HwStat:(*hypervisor.VmHwStatus)(0xc42017d280), VolumeList:[]*hypervisor.PersistVolumeInfo{(*hypervisor.PersistVolumeInfo)(0xc4200b5130)}, NetworkList:[]*hypervisor.PersistNetworkInfo{}, PortList:[]*api.PortDescription{}}
I0814 21:22:57.498344   60766 sandbox.go:219] newHyperstart() on socket: /var/run/hyper/vm-lkIQhDfrUP/hyperstartgrpc.sock
I0814 21:22:57.498724   60766 vm_console.go:56] SB[vm-lkIQhDfrUP] fail to enable vmLogd: dial unix /var/run/vmlogd.sock: connect: no such file or directory
I0814 21:22:57.498758   60766 hypervisor.go:41] SB[vm-lkIQhDfrUP] watch hyperstart
I0814 21:22:57.498770   60766 hypervisor.go:44] SB[vm-lkIQhDfrUP] issue VERSION request for keep-alive test
I0814 21:22:57.519224   60766 qmp_handler.go:169] connected to /var/run/hyper/vm-lkIQhDfrUP/qmp.sock
I0814 21:22:57.519251   60766 qmp_handler.go:179] begin qmp init...
I0814 21:22:57.519662   60766 qmp_handler.go:188] got qmp welcome, now sending command qmp_capabilities
I0814 21:22:57.519702   60766 qmp_handler.go:203] waiting for response
I0814 21:22:57.521242   60766 qmp_handler.go:103] got a message {"return": {}}
I0814 21:22:57.521289   60766 qmp_handler.go:212] got for response
I0814 21:22:57.521300   60766 qmp_handler.go:215] QMP connection initialized
I0814 21:22:57.521343   60766 qmp_handler.go:349] QMP initialzed, go into main QMP loop
I0814 21:22:57.521358   60766 qmp_handler.go:137] Begin receive QMP message
I0814 21:22:57.621924   60766 container.go:58] SB[vm-lkIQhDfrUP] Con[foobar12] generate vm container &json.Container{Id:"foobar12", Rootfs:"rootfs", Fstype:"", Image:"foobar12", Addr:"", Volumes:[]*json.VolumeDescriptor(nil), Fsmap:[]*json.FsmapDescriptor(nil), Sysctl:map[string]string{"vm.overcommit_memory":"1"}, Process:(*json.Process)(0xc42008c300), RestartPolicy:"never", Initialize:false, ReadOnly:false, Ports:[]json.Port(nil)}
I0814 21:22:57.622415   60766 hypervisor.go:23] SB[vm-lkIQhDfrUP] main event loop got message 9(COMMAND_RELEASE)
I0814 21:22:57.622437   60766 vm_states.go:274] SB[vm-lkIQhDfrUP] pod is running, got release command, let VM fly
I0814 21:22:57.622461   60766 context.go:225] SB[vm-lkIQhDfrUP] state change from RUNNING to 'NONE'
I0814 21:22:57.622498   60766 hypervisor.go:31] SB[vm-lkIQhDfrUP] main event loop exiting
00000000  2f 75 73 72 0a                                    |/usr.|
00000005
laijs commented 7 years ago

OK, when non -d, we should use io.Pipe()s or create new pty for runv-shim, rather than inherit the current stdio.

laijs commented 7 years ago

add a new issue: window changing is not working

laijs commented 7 years ago

555 fixes it, but it still keeps on "inherit-way" rather than use io.Pipe()s or create new pty