mirror of https://gitee.com/openkylin/libvirt.git
tools: rename console.[ch] to virsh-console.[ch] and fix coding style
This commit is contained in:
parent
1dc5dea7d6
commit
40f1d18fea
2
cfg.mk
2
cfg.mk
|
@ -913,7 +913,7 @@ exclude_file_name_regexp--sc_avoid_strcase = ^tools/virsh\.h$$
|
||||||
_src1=libvirt|fdstream|qemu/qemu_monitor|util/(vircommand|virfile)|xen/xend_internal|rpc/virnetsocket|lxc/lxc_controller|locking/lock_daemon
|
_src1=libvirt|fdstream|qemu/qemu_monitor|util/(vircommand|virfile)|xen/xend_internal|rpc/virnetsocket|lxc/lxc_controller|locking/lock_daemon
|
||||||
_test1=shunloadtest|virnettlscontexttest|virnettlssessiontest|vircgroupmock
|
_test1=shunloadtest|virnettlscontexttest|virnettlssessiontest|vircgroupmock
|
||||||
exclude_file_name_regexp--sc_avoid_write = \
|
exclude_file_name_regexp--sc_avoid_write = \
|
||||||
^(src/($(_src1))|daemon/libvirtd|tools/console|tests/($(_test1)))\.c$$
|
^(src/($(_src1))|daemon/libvirtd|tools/virsh-console|tests/($(_test1)))\.c$$
|
||||||
|
|
||||||
exclude_file_name_regexp--sc_bindtextdomain = ^(tests|examples)/
|
exclude_file_name_regexp--sc_bindtextdomain = ^(tests|examples)/
|
||||||
|
|
||||||
|
|
|
@ -213,10 +213,10 @@ src/xenapi/xenapi_driver.c
|
||||||
src/xenapi/xenapi_utils.c
|
src/xenapi/xenapi_utils.c
|
||||||
src/xenxs/xen_sxpr.c
|
src/xenxs/xen_sxpr.c
|
||||||
src/xenxs/xen_xm.c
|
src/xenxs/xen_xm.c
|
||||||
tools/console.c
|
|
||||||
tools/libvirt-guests.sh.in
|
tools/libvirt-guests.sh.in
|
||||||
tools/virsh.c
|
tools/virsh.c
|
||||||
tools/virsh.h
|
tools/virsh.h
|
||||||
|
tools/virsh-console.c
|
||||||
tools/virsh-domain-monitor.c
|
tools/virsh-domain-monitor.c
|
||||||
tools/virsh-domain.c
|
tools/virsh-domain.c
|
||||||
tools/virsh-edit.c
|
tools/virsh-edit.c
|
||||||
|
|
|
@ -169,8 +169,8 @@ virt_login_shell_CFLAGS = \
|
||||||
$(COVERAGE_CFLAGS)
|
$(COVERAGE_CFLAGS)
|
||||||
|
|
||||||
virsh_SOURCES = \
|
virsh_SOURCES = \
|
||||||
console.c console.h \
|
|
||||||
virsh.c virsh.h \
|
virsh.c virsh.h \
|
||||||
|
virsh-console.c virsh-console.h \
|
||||||
virsh-domain.c virsh-domain.h \
|
virsh-domain.c virsh-domain.h \
|
||||||
virsh-domain-monitor.c virsh-domain-monitor.h \
|
virsh-domain-monitor.c virsh-domain-monitor.h \
|
||||||
virsh-host.c virsh-host.h \
|
virsh-host.c virsh-host.h \
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* console.c: A dumb serial console client
|
* virsh-console.c: A dumb serial console client
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2008, 2010-2012 Red Hat, Inc.
|
* Copyright (C) 2007-2008, 2010-2013 Red Hat, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -17,7 +17,8 @@
|
||||||
* License along with this library. If not, see
|
* License along with this library. If not, see
|
||||||
* <http://www.gnu.org/licenses/>.
|
* <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* Daniel Berrange <berrange@redhat.com>
|
* Authors:
|
||||||
|
* Daniel Berrange <berrange@redhat.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
@ -37,7 +38,7 @@
|
||||||
# include <c-ctype.h>
|
# include <c-ctype.h>
|
||||||
|
|
||||||
# include "internal.h"
|
# include "internal.h"
|
||||||
# include "console.h"
|
# include "virsh-console.h"
|
||||||
# include "virlog.h"
|
# include "virlog.h"
|
||||||
# include "virfile.h"
|
# include "virfile.h"
|
||||||
# include "viralloc.h"
|
# include "viralloc.h"
|
||||||
|
@ -58,6 +59,7 @@ struct virConsoleBuffer {
|
||||||
char *data;
|
char *data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef struct virConsole virConsole;
|
typedef struct virConsole virConsole;
|
||||||
typedef virConsole *virConsolePtr;
|
typedef virConsole *virConsolePtr;
|
||||||
struct virConsole {
|
struct virConsole {
|
||||||
|
@ -75,11 +77,15 @@ struct virConsole {
|
||||||
char escapeChar;
|
char escapeChar;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static int got_signal = 0;
|
static int got_signal = 0;
|
||||||
static void do_signal(int sig ATTRIBUTE_UNUSED) {
|
static void
|
||||||
|
virConsoleHandleSignal(int sig ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
got_signal = 1;
|
got_signal = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# ifndef HAVE_CFMAKERAW
|
# ifndef HAVE_CFMAKERAW
|
||||||
static void
|
static void
|
||||||
cfmakeraw(struct termios *attr)
|
cfmakeraw(struct termios *attr)
|
||||||
|
@ -93,6 +99,7 @@ cfmakeraw(struct termios *attr)
|
||||||
}
|
}
|
||||||
# endif /* !HAVE_CFMAKERAW */
|
# endif /* !HAVE_CFMAKERAW */
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
virConsoleShutdown(virConsolePtr con)
|
virConsoleShutdown(virConsolePtr con)
|
||||||
{
|
{
|
||||||
|
@ -114,6 +121,21 @@ virConsoleShutdown(virConsolePtr con)
|
||||||
virCondSignal(&con->cond);
|
virCondSignal(&con->cond);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
virConsoleFree(virConsolePtr con)
|
||||||
|
{
|
||||||
|
if (!con)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (con->st)
|
||||||
|
virStreamFree(con->st);
|
||||||
|
virMutexDestroy(&con->lock);
|
||||||
|
virCondDestroy(&con->cond);
|
||||||
|
VIR_FREE(con);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
virConsoleEventOnStream(virStreamPtr st,
|
virConsoleEventOnStream(virStreamPtr st,
|
||||||
int events, void *opaque)
|
int events, void *opaque)
|
||||||
|
@ -171,9 +193,8 @@ virConsoleEventOnStream(virStreamPtr st,
|
||||||
|
|
||||||
avail = con->terminalToStream.length - con->terminalToStream.offset;
|
avail = con->terminalToStream.length - con->terminalToStream.offset;
|
||||||
if (avail > 1024) {
|
if (avail > 1024) {
|
||||||
if (VIR_REALLOC_N(con->terminalToStream.data,
|
ignore_value(VIR_REALLOC_N(con->terminalToStream.data,
|
||||||
con->terminalToStream.offset + 1024) < 0)
|
con->terminalToStream.offset + 1024));
|
||||||
{}
|
|
||||||
con->terminalToStream.length = con->terminalToStream.offset + 1024;
|
con->terminalToStream.length = con->terminalToStream.offset + 1024;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,6 +208,7 @@ virConsoleEventOnStream(virStreamPtr st,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
virConsoleEventOnStdin(int watch ATTRIBUTE_UNUSED,
|
virConsoleEventOnStdin(int watch ATTRIBUTE_UNUSED,
|
||||||
int fd ATTRIBUTE_UNUSED,
|
int fd ATTRIBUTE_UNUSED,
|
||||||
|
@ -242,6 +264,7 @@ virConsoleEventOnStdin(int watch ATTRIBUTE_UNUSED,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
virConsoleEventOnStdout(int watch ATTRIBUTE_UNUSED,
|
virConsoleEventOnStdout(int watch ATTRIBUTE_UNUSED,
|
||||||
int fd,
|
int fd,
|
||||||
|
@ -270,9 +293,8 @@ virConsoleEventOnStdout(int watch ATTRIBUTE_UNUSED,
|
||||||
|
|
||||||
avail = con->streamToTerminal.length - con->streamToTerminal.offset;
|
avail = con->streamToTerminal.length - con->streamToTerminal.offset;
|
||||||
if (avail > 1024) {
|
if (avail > 1024) {
|
||||||
if (VIR_REALLOC_N(con->streamToTerminal.data,
|
ignore_value(VIR_REALLOC_N(con->streamToTerminal.data,
|
||||||
con->streamToTerminal.offset + 1024) < 0)
|
con->streamToTerminal.offset + 1024));
|
||||||
{}
|
|
||||||
con->streamToTerminal.length = con->streamToTerminal.offset + 1024;
|
con->streamToTerminal.length = con->streamToTerminal.offset + 1024;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -296,6 +318,7 @@ vshGetEscapeChar(const char *s)
|
||||||
return *s;
|
return *s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
vshMakeStdinRaw(struct termios *ttyattr, bool report_errors)
|
vshMakeStdinRaw(struct termios *ttyattr, bool report_errors)
|
||||||
{
|
{
|
||||||
|
@ -322,10 +345,12 @@ vshMakeStdinRaw(struct termios *ttyattr, bool report_errors)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int vshRunConsole(virDomainPtr dom,
|
|
||||||
const char *dev_name,
|
int
|
||||||
const char *escape_seq,
|
vshRunConsole(virDomainPtr dom,
|
||||||
unsigned int flags)
|
const char *dev_name,
|
||||||
|
const char *escape_seq,
|
||||||
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
struct termios ttyattr;
|
struct termios ttyattr;
|
||||||
|
@ -348,11 +373,11 @@ int vshRunConsole(virDomainPtr dom,
|
||||||
the original terminal settings on STDIN before the
|
the original terminal settings on STDIN before the
|
||||||
process exits - people don't like being left with a
|
process exits - people don't like being left with a
|
||||||
messed up terminal ! */
|
messed up terminal ! */
|
||||||
old_sigquit = signal(SIGQUIT, do_signal);
|
old_sigquit = signal(SIGQUIT, virConsoleHandleSignal);
|
||||||
old_sigterm = signal(SIGTERM, do_signal);
|
old_sigterm = signal(SIGTERM, virConsoleHandleSignal);
|
||||||
old_sigint = signal(SIGINT, do_signal);
|
old_sigint = signal(SIGINT, virConsoleHandleSignal);
|
||||||
old_sighup = signal(SIGHUP, do_signal);
|
old_sighup = signal(SIGHUP, virConsoleHandleSignal);
|
||||||
old_sigpipe = signal(SIGPIPE, do_signal);
|
old_sigpipe = signal(SIGPIPE, virConsoleHandleSignal);
|
||||||
got_signal = 0;
|
got_signal = 0;
|
||||||
|
|
||||||
if (VIR_ALLOC(con) < 0)
|
if (VIR_ALLOC(con) < 0)
|
||||||
|
@ -396,15 +421,8 @@ int vshRunConsole(virDomainPtr dom,
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
virConsoleFree(con);
|
||||||
if (con) {
|
|
||||||
if (con->st)
|
|
||||||
virStreamFree(con->st);
|
|
||||||
virMutexDestroy(&con->lock);
|
|
||||||
virCondDestroy(&con->cond);
|
|
||||||
VIR_FREE(con);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Restore original signal handlers */
|
/* Restore original signal handlers */
|
||||||
signal(SIGPIPE, old_sigpipe);
|
signal(SIGPIPE, old_sigpipe);
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* console.c: A dumb serial console client
|
* virsh-console.h: A dumb serial console client
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007, 2010, 2012 Red Hat, Inc.
|
* Copyright (C) 2007, 2010, 2012-2013 Red Hat, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -17,7 +17,8 @@
|
||||||
* License along with this library. If not, see
|
* License along with this library. If not, see
|
||||||
* <http://www.gnu.org/licenses/>.
|
* <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* Daniel Berrange <berrange@redhat.com>
|
* Authors:
|
||||||
|
* Daniel Berrange <berrange@redhat.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __VIR_CONSOLE_H__
|
#ifndef __VIR_CONSOLE_H__
|
|
@ -41,7 +41,6 @@
|
||||||
#include "virbuffer.h"
|
#include "virbuffer.h"
|
||||||
#include "c-ctype.h"
|
#include "c-ctype.h"
|
||||||
#include "conf/domain_conf.h"
|
#include "conf/domain_conf.h"
|
||||||
#include "console.h"
|
|
||||||
#include "viralloc.h"
|
#include "viralloc.h"
|
||||||
#include "vircommand.h"
|
#include "vircommand.h"
|
||||||
#include "virfile.h"
|
#include "virfile.h"
|
||||||
|
@ -50,6 +49,7 @@
|
||||||
#include "virmacaddr.h"
|
#include "virmacaddr.h"
|
||||||
#include "virprocess.h"
|
#include "virprocess.h"
|
||||||
#include "virstring.h"
|
#include "virstring.h"
|
||||||
|
#include "virsh-console.h"
|
||||||
#include "virsh-domain-monitor.h"
|
#include "virsh-domain-monitor.h"
|
||||||
#include "virerror.h"
|
#include "virerror.h"
|
||||||
#include "virtypedparam.h"
|
#include "virtypedparam.h"
|
||||||
|
|
|
@ -57,7 +57,6 @@
|
||||||
#include "virerror.h"
|
#include "virerror.h"
|
||||||
#include "base64.h"
|
#include "base64.h"
|
||||||
#include "virbuffer.h"
|
#include "virbuffer.h"
|
||||||
#include "console.h"
|
|
||||||
#include "viralloc.h"
|
#include "viralloc.h"
|
||||||
#include "virxml.h"
|
#include "virxml.h"
|
||||||
#include <libvirt/libvirt-qemu.h>
|
#include <libvirt/libvirt-qemu.h>
|
||||||
|
@ -73,6 +72,7 @@
|
||||||
#include "virtypedparam.h"
|
#include "virtypedparam.h"
|
||||||
#include "virstring.h"
|
#include "virstring.h"
|
||||||
|
|
||||||
|
#include "virsh-console.h"
|
||||||
#include "virsh-domain.h"
|
#include "virsh-domain.h"
|
||||||
#include "virsh-domain-monitor.h"
|
#include "virsh-domain-monitor.h"
|
||||||
#include "virsh-host.h"
|
#include "virsh-host.h"
|
||||||
|
|
Loading…
Reference in New Issue