[libvirt] [PATCH 2/3] virsh: Rename vshMakeStdinRaw to vshTTYMakeRaw and move it to virsh.c

Martin Kletzander mkletzan at redhat.com
Tue Sep 3 10:02:52 UTC 2013


On 08/29/2013 06:36 PM, Peter Krempa wrote:
> Move the function to virsh.c to the rest of the TTY managing functions
> and change the code so that it mirrors the rest.
> ---
>  tools/virsh-console.c | 50 +++++---------------------------------------------
>  tools/virsh-console.h |  7 +++----
>  tools/virsh-domain.c  |  2 +-
>  tools/virsh.c         | 48 +++++++++++++++++++++++++++++++++++++++++++++---
>  tools/virsh.h         |  1 +
>  5 files changed, 55 insertions(+), 53 deletions(-)
> 
> diff --git a/tools/virsh-console.c b/tools/virsh-console.c
> index debf12c..cc9cc6a 100644
> --- a/tools/virsh-console.c
> +++ b/tools/virsh-console.c
[...]
> @@ -319,40 +306,13 @@ vshGetEscapeChar(const char *s)
> 
> 
>  int
> -vshMakeStdinRaw(struct termios *ttyattr, bool report_errors)
> -{
> -    struct termios rawattr;
> -    char ebuf[1024];
> -
> -    if (tcgetattr(STDIN_FILENO, ttyattr) < 0) {
> -        if (report_errors)
> -            VIR_ERROR(_("unable to get tty attributes: %s"),
> -                      virStrerror(errno, ebuf, sizeof(ebuf)));
> -        return -1;
> -    }
> -
> -    rawattr = *ttyattr;
> -    cfmakeraw(&rawattr);
> -
> -    if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &rawattr) < 0) {
> -        if (report_errors)
> -            VIR_ERROR(_("unable to set tty attributes: %s"),
> -                      virStrerror(errno, ebuf, sizeof(ebuf)));
> -        return -1;
> -    }
> -
> -    return 0;
> -}
> -
> -
> -int
> -vshRunConsole(virDomainPtr dom,
> +vshRunConsole(vshControl *ctl,
> +              virDomainPtr dom,
>                const char *dev_name,
>                const char *escape_seq,

You can get rid of this one since we call it with ctl->excapeChar only.

The rest looks ok, but Michal already ACK'd it, so...

Martin




More information about the libvir-list mailing list