[PATCH] Fix console= persistence, remove serial (#928269)

Vratislav Podzimek vpodzime at redhat.com
Thu Apr 11 09:10:46 UTC 2013


On Tue, 2013-04-09 at 17:20 -0400, Will Woods wrote:
> -def isConsoleOnVirtualTerminal():
> -    # XXX PJFIX is there some way to ask the kernel this instead?
> -    # XXX we don't want to have to import storage from here
> -    if os.uname()[4].startswith("s390"):
> -        return False
> -    return not flags.serial
> +def get_active_console(dev="console"):
> +    while True:
> +        try:
> +            dev = open("/sys/class/tty/%s/active" % dev).read().split()[-1]
> +        except (IOError, IndexError):
> +            break
> +    return dev
> +
> +def isConsoleOnVirtualTerminal(dev="console"):
> +    console = get_active_console(dev)
> +    return console.rstrip('01243456789') == 'tty'
I believe you guys completely understand what is going on in these two
functions, but to be honest I have no idea. while-true cycle repeating
the same action again and again until an exception is raised is
something that really is worth a comment per se.

Then rstrip with this nice "phone-number" ('4' is listed twice). However
are regular expressions cryptic and slow I think using them here would
improve the readability of the code a lot. Or at least add a comment,
please.

-- 
Vratislav Podzimek

Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic



More information about the anaconda-patches mailing list