Merge lp:~jeffmarcom/checkbox/kvm_console_hijack_fix into lp:checkbox

Proposed by Jeff Marcom
Status: Merged
Approved by: Zygmunt Krynicki
Approved revision: 2036
Merged at revision: 2032
Proposed branch: lp:~jeffmarcom/checkbox/kvm_console_hijack_fix
Merge into: lp:checkbox
Diff against target: 57 lines (+17/-4)
2 files modified
debian/changelog (+5/-1)
scripts/virtualization (+12/-3)
To merge this branch: bzr merge lp:~jeffmarcom/checkbox/kvm_console_hijack_fix
Reviewer Review Type Date Requested Status
Zygmunt Krynicki (community) Approve
Jeff Lane  Approve
Jeff Marcom (community) Needs Resubmitting
Review via email: mp+157450@code.launchpad.net

Description of the change

So the console terminal was being hijacked by the KVM boot process and not letting go, even after the running KVM instance is terminated in the script. This simply calls a 'reset' command to regain access of terminal. This also includes a fix so that the instance will actual terminate at the end of the script successfully.

To post a comment you must log in.
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

53 + # Reset Console window to regain control from VM Serial I/0
54 + try:
55 + check_call('reset')
56 + except CalledProcessError:
57 + pass

just use call(), no need to check if you discard the check anyway

review: Needs Fixing
Revision history for this message
Jeff Lane  (bladernr) wrote :

well, it may be unnecessary anyway... via SSH, this successfully runs without hijacking the session, but when run locally, it still fails.

The difference, other than the obvious ssh bit is that the ssh session is running in xterm while the local is running in a different console.

I'm wondering if running the VM using the libvirt stuff wouldn't be cleaner... not sure though. So need to try it out.

review: Needs Fixing
Revision history for this message
Jeff Marcom (jeffmarcom) wrote :

I tried this test again with the latest fix in checkbox-certification-server in a linux terminal (not xterm) and I did not lose the console.

review: Needs Resubmitting
Revision history for this message
Jeff Lane  (bladernr) wrote :

I too tried the latest fix (including the change to call() from check_call()) and it does seem to resolve the problem of console hijacking.

I was able to run the KVM test, the reboot manual test, and then the followin Xen test from my own branches successfully .

review: Approve
2034. By Jeff Marcom

Fixed issue where a terminal would sometimes return non 0 on reset command

Signed-off-by: Jeff Marcom <email address hidden>

2035. By Jeff Marcom

Changed subprocess to PIPE stdin and changed subprocess call

Signed-off-by: Jeff Marcom <email address hidden>

2036. By Jeff Marcom

Removed try and except block from subprocess call

Signed-off-by: Jeff Marcom <email address hidden>

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Let's land this.

There's a longer story that we talked about on IRC about using PIPE vs DEVNULL for stdin but since testing this is expensive and PIPE was tested to work okay it should land as is. If possible we should see if using DEVNULL works as it's cleaner conceptually

review: Approve
Revision history for this message
Jeff Marcom (jeffmarcom) wrote :

> Let's land this.
>
> There's a longer story that we talked about on IRC about using PIPE vs DEVNULL
> for stdin but since testing this is expensive and PIPE was tested to work okay
> it should land as is. If possible we should see if using DEVNULL works as it's
> cleaner conceptually

I tested pushing stdin to dev null by changing it to:
stdin=open(os.devnull, 'wb')

This causes the test to always fail as the KVM I/O messages are never properly forwarded to the log file. Instead doing stdin=PIPE works fine.

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

> > Let's land this.
> >
> > There's a longer story that we talked about on IRC about using PIPE vs
> DEVNULL
> > for stdin but since testing this is expensive and PIPE was tested to work
> okay
> > it should land as is. If possible we should see if using DEVNULL works as
> it's
> > cleaner conceptually
>
> I tested pushing stdin to dev null by changing it to:
> stdin=open(os.devnull, 'wb')
>
> This causes the test to always fail as the KVM I/O messages are never properly
> forwarded to the log file. Instead doing stdin=PIPE works fine.

You used devnull incorrectly. I literally meant call(stdin=subprocess.DEVNULL). If you open /dev/null yourself then the correct way would be to open it for _reading_ not writing as the child process tries to read from it, not write to it.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2013-04-08 15:56:09 +0000
3+++ debian/changelog 2013-04-08 23:04:21 +0000
4@@ -13,7 +13,11 @@
5 [ Jeff Lane ]
6 * jobs/info.txt.in: fixed bad driver name in audio_codecs job (LP: #1165215)
7
8- -- Brendan Donegan <brendan.donegan@canonical.com> Thu, 04 Apr 2013 17:04:44 +0100
9+ [ Jeff Marcom ]
10+ * scripts/virtualization - Fixes issue where console terminal would
11+ remain hijacked by child kvm process (LP: #1164028)
12+
13+ -- Jeff Marcom <jeff.marcom@canonical.com> Fri, 05 Apr 2013 17:04:44 +0100
14
15 checkbox (0.15.6) raring; urgency=low
16
17
18=== modified file 'scripts/virtualization'
19--- scripts/virtualization 2013-03-18 18:46:06 +0000
20+++ scripts/virtualization 2013-04-08 23:04:21 +0000
21@@ -27,8 +27,15 @@
22 import os
23 import logging
24 import lsb_release
25+import shlex
26 import signal
27-from subprocess import Popen, PIPE, CalledProcessError, check_output
28+from subprocess import (
29+ Popen,
30+ PIPE,
31+ CalledProcessError,
32+ check_output,
33+ call
34+)
35 import sys
36 import tempfile
37 import time
38@@ -123,8 +130,8 @@
39
40 # Start Virtual machine
41 self.process = Popen(
42- params, stderr=file, stdout=file,
43- universal_newlines=True, shell=True)
44+ shlex.split(params), stdin=PIPE, stderr=file, stdout=file,
45+ universal_newlines=True, shell=False)
46
47 @classmethod
48 def create_cloud_disk(cls):
49@@ -184,6 +191,8 @@
50
51 if instance is not False:
52 time.sleep(self.timeout)
53+ # Reset Console window to regain control from VM Serial I/0
54+ call('reset')
55 # Check to be sure VM boot was successful
56 if "END SSH HOST KEY KEYS" \
57 in open(self.debug_file, 'r').read():

Subscribers

People subscribed via source and target branches