Mir

Merge lp:~mlankhorst/mir/setsid into lp:~mir-team/mir/trunk

Proposed by Maarten Lankhorst
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 942
Proposed branch: lp:~mlankhorst/mir/setsid
Merge into: lp:~mir-team/mir/trunk
Diff against target: 217 lines (+97/-4)
4 files modified
src/server/graphics/gbm/gbm_platform.cpp (+10/-0)
src/server/graphics/gbm/linux_virtual_terminal.cpp (+55/-2)
src/server/graphics/gbm/linux_virtual_terminal.h (+5/-0)
tests/unit-tests/graphics/gbm/test_linux_virtual_terminal.cpp (+27/-2)
To merge this branch: bzr merge lp:~mlankhorst/mir/setsid
Reviewer Review Type Date Requested Status
Daniel van Vugt Approve
Chris Halse Rogers Approve
Robert Ancell Approve
Alexandros Frantzis (community) Needs Information
Alan Griffiths Abstain
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+177800@code.launchpad.net

Commit message

Re-introduce console support, and ignore control characters

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:900
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~mlankhorst/mir/setsid/+merge/177800/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/mir-ci/1140/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-saucy-i386-build/1498
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-saucy-amd64-build/1383
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-saucy-amd64-ci/378
        deb: http://jenkins.qa.ubuntu.com/job/mir-saucy-amd64-ci/378/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-vm-ci-build/./distribution=quantal,flavor=amd64/741

Click here to trigger a rebuild:
http://s-jenkins:8080/job/mir-ci/1140/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Robert Ancell (robert-ancell) wrote :

Code looks good, haven't tested it for behaviour.

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

No style issues with the code, but I'm unfamiliar with the APIs and the issue being addressed

review: Abstain
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

54 + if (fops->ioctl(vt_fd.fd(), KDSKBMODE, K_OFF) < 0)

Doesn't this turn off input completely? If so, we need to be able to handle VT switching through another mechanism before this lands (handling the keypresses ourselves and changing VT).

review: Needs Information
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Tested it myself. This does indeed break VT switching, though clients get input as they should.

Once you start the server you can't switch away from it, or kill it (without an ssh login).

So needs fixing:
  1. Add support for VT switching out of Mir (maybe Ctrl+Alt+Fn).
  2. Add support for killing the server, since Ctrl+C doesn't any more (maybe use Ctrl+Alt+Backspace)

review: Needs Fixing
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Though it's possible that XMir requires neither of those new key combos. So maybe they need to be implemented in examples/demo_server.cpp and examples/demo-shell/*

I'm not sure. Do we want VT switching and emergency exit to be a generic thing implemented in libmirserver? If not then it would go in the examples/ servers.

Revision history for this message
Chris Halse Rogers (raof) wrote :

I don't believe that we want VT switching to be a core thing at all; don't we plan to remove VT switching entirely at some point?

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Fair point. But to avoid blocking other developers from doing their thing, VT switching should be reimplemented in demo_server_shell at least. And maybe demo_server.

Similarly, being able to kill the demo server is critical for us. I suggest Ctrl+Alt+Backspace.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Put it this way... We need to be capable of running a demo server and client(s) on a single machine. Otherwise development is extremely difficult.

This means (1) VT switching support; and (2) the ability to kill the server. Though if (1) is working well enough then you can use that in place of (2).

Revision history for this message
Robert Ancell (robert-ancell) wrote :

> Fair point. But to avoid blocking other developers from doing their thing, VT
> switching should be reimplemented in demo_server_shell at least. And maybe
> demo_server.
>
> Similarly, being able to kill the demo server is critical for us. I suggest
> Ctrl+Alt+Backspace.

https://code.launchpad.net/~robert-ancell/mir/alt-ctrl-backspace/+merge/178036

Revision history for this message
Robert Ancell (robert-ancell) wrote :

> I don't believe that we want VT switching to be a core thing at all; don't we
> plan to remove VT switching entirely at some point?

Certainly not in the 13.10 timeframe.

Revision history for this message
Robert Ancell (robert-ancell) wrote :

I tried to make the demo server do VT switching itself, but it locks up in the same way that the current trunk does (i.e. video stops updating showing last frame - can't switch back).

Code is lp:~robert-ancell/mir/setsid-alt-ctrl-Fn

Given we can't VT switch on trunk I don't think this blocks this MP.

Revision history for this message
Robert Ancell (robert-ancell) wrote :

Actually, with further testing I can VT switch from trunk, and not from this branch (even once merged with trunk). So there is an issue in it that stops VT switching.

review: Needs Fixing
Revision history for this message
Robert Ancell (robert-ancell) wrote :

With some more work in lp:~robert-ancell/mir/setsid-alt-ctrl-Fn I can now VT switch with this patch. So now we just need:
- This branch to support quitting and/or VT switching in the example servers
- Unity System Compositor to support VT switching

Revision history for this message
Robert Ancell (robert-ancell) wrote :
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Robert,

Can you propose lp:~robert-ancell/mir/setsid-alt-ctrl-Fn for merging into this one, when ready?

Revision history for this message
Robert Ancell (robert-ancell) wrote :

I've got alt+ctrl+Fn keys working in https://code.launchpad.net/~robert-ancell/mir/vt-switch-keys/+merge/179067. That can be landed separately from this.

Revision history for this message
Robert Ancell (robert-ancell) :
review: Approve
Revision history for this message
Chris Halse Rogers (raof) wrote :

In conjunction with vt-switch-keys, +1

review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

This looks a bit old school... 9600 bps?

65 + cfsetispeed(&tcattr, B9600);
66 + tcattr.c_oflag = 0;
67 + cfsetospeed(&tcattr, B9600);

But anyway, it works and my previous concerns are resolved by the sister branch: lp:~robert-ancell/mir/vt-switch-keys

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/server/graphics/gbm/gbm_platform.cpp'
--- src/server/graphics/gbm/gbm_platform.cpp 2013-07-30 13:56:22 +0000
+++ src/server/graphics/gbm/gbm_platform.cpp 2013-07-31 10:50:37 +0000
@@ -78,6 +78,16 @@
78 {78 {
79 return ::ioctl(d, request, p_val);79 return ::ioctl(d, request, p_val);
80 }80 }
81
82 int tcsetattr(int d, int acts, const struct termios *tcattr)
83 {
84 return ::tcsetattr(d, acts, tcattr);
85 }
86
87 int tcgetattr(int d, struct termios *tcattr)
88 {
89 return ::tcgetattr(d, tcattr);
90 }
81};91};
8292
83}93}
8494
=== modified file 'src/server/graphics/gbm/linux_virtual_terminal.cpp'
--- src/server/graphics/gbm/linux_virtual_terminal.cpp 2013-07-30 16:19:14 +0000
+++ src/server/graphics/gbm/linux_virtual_terminal.cpp 2013-07-31 10:50:37 +0000
@@ -45,8 +45,11 @@
45 vt_fd{fops, open_vt(vt_number)},45 vt_fd{fops, open_vt(vt_number)},
46 prev_kd_mode{0},46 prev_kd_mode{0},
47 prev_vt_mode(),47 prev_vt_mode(),
48 prev_tty_mode(),
49 prev_tcattr(),
48 active{true}50 active{true}
49{51{
52 struct termios tcattr;
50 if (fops->ioctl(vt_fd.fd(), KDGETMODE, &prev_kd_mode) < 0)53 if (fops->ioctl(vt_fd.fd(), KDGETMODE, &prev_kd_mode) < 0)
51 {54 {
52 BOOST_THROW_EXCEPTION(55 BOOST_THROW_EXCEPTION(
@@ -59,14 +62,44 @@
59 {62 {
60 BOOST_THROW_EXCEPTION(63 BOOST_THROW_EXCEPTION(
61 boost::enable_error_info(64 boost::enable_error_info(
62 std::runtime_error("Failed to get the current VT")) << boost::errinfo_errno(errno));65 std::runtime_error("Failed to get the current VT"))
63 }66 << boost::errinfo_errno(errno));
67 }
68
69 if (fops->ioctl(vt_fd.fd(), KDGKBMODE, &prev_tty_mode) < 0)
70 {
71 BOOST_THROW_EXCEPTION(
72 boost::enable_error_info(
73 std::runtime_error("Failed to get the current TTY mode"))
74 << boost::errinfo_errno(errno));
75 }
76 if (fops->ioctl(vt_fd.fd(), KDSKBMODE, K_OFF) < 0)
77 {
78 BOOST_THROW_EXCEPTION(
79 boost::enable_error_info(
80 std::runtime_error("Failed to mute keyboard"))
81 << boost::errinfo_errno(errno));
82 }
83
84 fops->tcgetattr(vt_fd.fd(), &prev_tcattr);
85 tcattr = prev_tcattr;
86 tcattr.c_iflag = IGNPAR | IGNBRK;
87 cfsetispeed(&tcattr, B9600);
88 tcattr.c_oflag = 0;
89 cfsetospeed(&tcattr, B9600);
90 tcattr.c_cflag = CREAD | CS8;
91 tcattr.c_lflag = 0;
92 tcattr.c_cc[VTIME] = 0;
93 tcattr.c_cc[VMIN] = 1;
94 fops->tcsetattr(vt_fd.fd(), TCSANOW, &tcattr);
64}95}
6596
66mgg::LinuxVirtualTerminal::~LinuxVirtualTerminal() noexcept(true)97mgg::LinuxVirtualTerminal::~LinuxVirtualTerminal() noexcept(true)
67{98{
68 if (vt_fd.fd() > 0)99 if (vt_fd.fd() > 0)
69 {100 {
101 fops->tcsetattr(vt_fd.fd(), TCSANOW, &prev_tcattr);
102 fops->ioctl(vt_fd.fd(), KDSKBMODE, prev_tty_mode);
70 fops->ioctl(vt_fd.fd(), KDSETMODE, prev_kd_mode);103 fops->ioctl(vt_fd.fd(), KDSETMODE, prev_kd_mode);
71 fops->ioctl(vt_fd.fd(), VT_SETMODE, &prev_vt_mode);104 fops->ioctl(vt_fd.fd(), VT_SETMODE, &prev_vt_mode);
72 }105 }
@@ -186,6 +219,26 @@
186219
187 std::string const active_vt_path{vt_path_stream.str()};220 std::string const active_vt_path{vt_path_stream.str()};
188221
222 if (activate)
223 {
224 if (getpid() == getpgid(0) && setpgid(0, getpgid(getppid())) < 0)
225 {
226 BOOST_THROW_EXCEPTION(
227 boost::enable_error_info(
228 std::runtime_error("Failed to stop being a process group"))
229 << boost::errinfo_errno(errno));
230 }
231
232 /* become process group leader */
233 if (setsid() < 0)
234 {
235 BOOST_THROW_EXCEPTION(
236 boost::enable_error_info(
237 std::runtime_error("Failed to become session leader"))
238 << boost::errinfo_errno(errno));
239 }
240 }
241
189 auto vt_fd = fops->open(active_vt_path.c_str(), O_RDONLY | O_NDELAY);242 auto vt_fd = fops->open(active_vt_path.c_str(), O_RDONLY | O_NDELAY);
190243
191 if (vt_fd < 0)244 if (vt_fd < 0)
192245
=== modified file 'src/server/graphics/gbm/linux_virtual_terminal.h'
--- src/server/graphics/gbm/linux_virtual_terminal.h 2013-06-20 02:16:09 +0000
+++ src/server/graphics/gbm/linux_virtual_terminal.h 2013-07-31 10:50:37 +0000
@@ -24,6 +24,7 @@
24#include <memory>24#include <memory>
2525
26#include <linux/vt.h>26#include <linux/vt.h>
27#include <termios.h>
27#include <unistd.h>28#include <unistd.h>
2829
29namespace mir30namespace mir
@@ -45,6 +46,8 @@
45 virtual int close(int fd) = 0;46 virtual int close(int fd) = 0;
46 virtual int ioctl(int d, int request, int val) = 0;47 virtual int ioctl(int d, int request, int val) = 0;
47 virtual int ioctl(int d, int request, void* p_val) = 0;48 virtual int ioctl(int d, int request, void* p_val) = 0;
49 virtual int tcsetattr(int d, int acts, const struct termios *tcattr) = 0;
50 virtual int tcgetattr(int d, struct termios *tcattr) = 0;
4851
49protected:52protected:
50 VTFileOperations() = default;53 VTFileOperations() = default;
@@ -90,6 +93,8 @@
90 FDWrapper const vt_fd;93 FDWrapper const vt_fd;
91 int prev_kd_mode;94 int prev_kd_mode;
92 struct vt_mode prev_vt_mode;95 struct vt_mode prev_vt_mode;
96 int prev_tty_mode;
97 struct termios prev_tcattr;
93 bool active;98 bool active;
94};99};
95100
96101
=== modified file 'tests/unit-tests/graphics/gbm/test_linux_virtual_terminal.cpp'
--- tests/unit-tests/graphics/gbm/test_linux_virtual_terminal.cpp 2013-06-28 15:16:39 +0000
+++ tests/unit-tests/graphics/gbm/test_linux_virtual_terminal.cpp 2013-07-31 10:50:37 +0000
@@ -47,6 +47,8 @@
47 MOCK_METHOD1(close, int(int));47 MOCK_METHOD1(close, int(int));
48 MOCK_METHOD3(ioctl, int(int, int, int));48 MOCK_METHOD3(ioctl, int(int, int, int));
49 MOCK_METHOD3(ioctl, int(int, int, void*));49 MOCK_METHOD3(ioctl, int(int, int, void*));
50 MOCK_METHOD3(tcsetattr, int(int, int, const struct termios*));
51 MOCK_METHOD2(tcgetattr, int(int, struct termios*));
50};52};
5153
52class MockMainLoop : public mir::MainLoop54class MockMainLoop : public mir::MainLoop
@@ -73,6 +75,13 @@
73 *static_cast<T*>(arg2) = param;75 *static_cast<T*>(arg2) = param;
74}76}
7577
78ACTION_TEMPLATE(SetTcAttrPointee,
79 HAS_1_TEMPLATE_PARAMS(typename, T),
80 AND_1_VALUE_PARAMS(param))
81{
82 *static_cast<T*>(arg1) = param;
83}
84
76MATCHER_P(ModeUsesSignal, sig, "")85MATCHER_P(ModeUsesSignal, sig, "")
77{86{
78 auto vtm = static_cast<vt_mode*>(arg);87 auto vtm = static_cast<vt_mode*>(arg);
@@ -90,7 +99,9 @@
90 LinuxVirtualTerminalTest()99 LinuxVirtualTerminalTest()
91 : fake_vt_fd{5},100 : fake_vt_fd{5},
92 fake_kd_mode{KD_TEXT},101 fake_kd_mode{KD_TEXT},
93 fake_vt_mode{VT_AUTO, 0, 0, 0, 0}102 fake_vt_mode{VT_AUTO, 0, 0, 0, 0},
103 fake_kb_mode{K_RAW},
104 fake_tc_attr()
94 {105 {
95 }106 }
96107
@@ -142,6 +153,14 @@
142 .WillOnce(DoAll(SetIoctlPointee<int>(fake_kd_mode), Return(0)));153 .WillOnce(DoAll(SetIoctlPointee<int>(fake_kd_mode), Return(0)));
143 EXPECT_CALL(mock_fops, ioctl(fake_vt_fd, VT_GETMODE, An<void*>()))154 EXPECT_CALL(mock_fops, ioctl(fake_vt_fd, VT_GETMODE, An<void*>()))
144 .WillOnce(DoAll(SetIoctlPointee<vt_mode>(fake_vt_mode), Return(0)));155 .WillOnce(DoAll(SetIoctlPointee<vt_mode>(fake_vt_mode), Return(0)));
156 EXPECT_CALL(mock_fops, ioctl(fake_vt_fd, KDGKBMODE, An<void*>()))
157 .WillOnce(DoAll(SetIoctlPointee<int>(fake_kb_mode), Return(0)));
158 EXPECT_CALL(mock_fops, ioctl(fake_vt_fd, KDSKBMODE, K_OFF))
159 .WillOnce(Return(0));
160 EXPECT_CALL(mock_fops, tcgetattr(fake_vt_fd, An<struct termios *>()))
161 .WillOnce(DoAll(SetTcAttrPointee<struct termios>(fake_tc_attr), Return(0)));
162 EXPECT_CALL(mock_fops, tcsetattr(fake_vt_fd, TCSANOW, An<const struct termios *>()))
163 .WillOnce(Return(0));
145 }164 }
146165
147 void set_up_expectations_for_switch_handler(int sig)166 void set_up_expectations_for_switch_handler(int sig)
@@ -158,9 +177,13 @@
158 {177 {
159 using namespace testing;178 using namespace testing;
160179
180 EXPECT_CALL(mock_fops, tcsetattr(fake_vt_fd, TCSANOW, An<const struct termios *>()))
181 .WillOnce(Return(0));
182 EXPECT_CALL(mock_fops, ioctl(fake_vt_fd, KDSKBMODE, fake_kb_mode))
183 .WillOnce(Return(0));
161 EXPECT_CALL(mock_fops, ioctl(fake_vt_fd, KDSETMODE, fake_kd_mode))184 EXPECT_CALL(mock_fops, ioctl(fake_vt_fd, KDSETMODE, fake_kd_mode))
162 .WillOnce(Return(0));185 .WillOnce(Return(0));
163 EXPECT_CALL(mock_fops, ioctl(fake_vt_fd, VT_SETMODE,An<void*>()))186 EXPECT_CALL(mock_fops, ioctl(fake_vt_fd, VT_SETMODE, An<void*>()))
164 .WillOnce(Return(0));187 .WillOnce(Return(0));
165 EXPECT_CALL(mock_fops, close(fake_vt_fd))188 EXPECT_CALL(mock_fops, close(fake_vt_fd))
166 .WillOnce(Return(0));189 .WillOnce(Return(0));
@@ -169,6 +192,8 @@
169 int const fake_vt_fd;192 int const fake_vt_fd;
170 int const fake_kd_mode;193 int const fake_kd_mode;
171 vt_mode fake_vt_mode;194 vt_mode fake_vt_mode;
195 int const fake_kb_mode;
196 struct termios fake_tc_attr;
172 std::function<void(int)> sig_handler;197 std::function<void(int)> sig_handler;
173 MockVTFileOperations mock_fops;198 MockVTFileOperations mock_fops;
174 MockMainLoop mock_main_loop;199 MockMainLoop mock_main_loop;

Subscribers

People subscribed via source and target branches