conf: Rename console-specific identifiers to be more generic

The functionality provided in virchrdev.c (previously virconsole.c) is
applicable to other types of character devices besides consoles, such
as channels.  This patch is just code motion, renaming things such as
"console" or "pty", instead using more general terms such as
"character device" or "device path".
This commit is contained in:
John Eckersberg 2013-01-02 10:38:52 -05:00 committed by Eric Blake
parent 4c85421c6c
commit 3c971c675a
8 changed files with 156 additions and 156 deletions

View File

@ -432,12 +432,12 @@ AC_ARG_WITH([remote],
AC_HELP_STRING([--with-remote], [add remote driver support @<:@default=yes@:>@]),[],[with_remote=yes]) AC_HELP_STRING([--with-remote], [add remote driver support @<:@default=yes@:>@]),[],[with_remote=yes])
AC_ARG_WITH([libvirtd], AC_ARG_WITH([libvirtd],
AC_HELP_STRING([--with-libvirtd], [add libvirtd support @<:@default=yes@:>@]),[],[with_libvirtd=yes]) AC_HELP_STRING([--with-libvirtd], [add libvirtd support @<:@default=yes@:>@]),[],[with_libvirtd=yes])
AC_ARG_WITH([console-lock-files], AC_ARG_WITH([chrdev-lock-files],
AC_HELP_STRING([--with-console-lock-files], AC_HELP_STRING([--with-chrdev-lock-files],
[location for UUCP style lock files for console PTYs [location for UUCP style lock files for character devices
(use auto for default paths on some platforms) (use auto for default paths on some platforms)
@<:@default=auto@:>@]), @<:@default=auto@:>@]),
[],[with_console_lock_files=auto]) [],[with_chrdev_lock_files=auto])
AC_ARG_WITH([libssh2_transport], AC_ARG_WITH([libssh2_transport],
AC_HELP_STRING([--with-libssh2_transport], [libssh2 location @<:@default=check@:>@]),[],[with_libssh2_transport=check]) AC_HELP_STRING([--with-libssh2_transport], [libssh2 location @<:@default=check@:>@]),[],[with_libssh2_transport=check])
@ -1437,25 +1437,25 @@ AM_CONDITIONAL([HAVE_AUDIT], [test "$with_audit" = "yes"])
AC_SUBST([AUDIT_CFLAGS]) AC_SUBST([AUDIT_CFLAGS])
AC_SUBST([AUDIT_LIBS]) AC_SUBST([AUDIT_LIBS])
dnl UUCP style file locks for PTY consoles dnl UUCP style file locks for character devices
if test "$with_console_lock_files" != "no"; then if test "$with_chrdev_lock_files" != "no"; then
case $with_console_lock_files in case $with_chrdev_lock_files in
yes | auto) yes | auto)
dnl Default locations for platforms, or disable if unknown dnl Default locations for platforms, or disable if unknown
if test "$with_linux" = "yes"; then if test "$with_linux" = "yes"; then
with_console_lock_files=/var/lock with_chrdev_lock_files=/var/lock
elif test "$with_console_lock_files" = "auto"; then elif test "$with_chrdev_lock_files" = "auto"; then
with_console_lock_files=no with_chrdev_lock_files=no
fi ;; fi ;;
esac esac
if test "$with_console_lock_files" = "yes"; then if test "$with_chrdev_lock_files" = "yes"; then
AC_MSG_ERROR([You must specify path for the lock files on this AC_MSG_ERROR([You must specify path for the lock files on this
platform]) platform])
fi fi
AC_DEFINE_UNQUOTED([VIR_PTY_LOCK_FILE_PATH], "$with_console_lock_files", AC_DEFINE_UNQUOTED([VIR_CHRDEV_LOCK_FILE_PATH], "$with_chrdev_lock_files",
[path to directory containing UUCP pty lock files]) [path to directory containing UUCP device lock files])
fi fi
AM_CONDITIONAL([VIR_PTY_LOCK_FILE_PATH], [test "$with_console_lock_files" != "no"]) AM_CONDITIONAL([VIR_CHRDEV_LOCK_FILE_PATH], [test "$with_chrdev_lock_files" != "no"])
dnl SELinux dnl SELinux
@ -3293,16 +3293,16 @@ AC_MSG_NOTICE([ Alloc OOM: $enable_oom])
AC_MSG_NOTICE([]) AC_MSG_NOTICE([])
AC_MSG_NOTICE([Miscellaneous]) AC_MSG_NOTICE([Miscellaneous])
AC_MSG_NOTICE([]) AC_MSG_NOTICE([])
AC_MSG_NOTICE([ Debug: $enable_debug]) AC_MSG_NOTICE([ Debug: $enable_debug])
AC_MSG_NOTICE([ Use -Werror: $set_werror]) AC_MSG_NOTICE([ Use -Werror: $set_werror])
AC_MSG_NOTICE([Warning Flags: $WARN_CFLAGS]) AC_MSG_NOTICE([ Warning Flags: $WARN_CFLAGS])
AC_MSG_NOTICE([ Readline: $lv_use_readline]) AC_MSG_NOTICE([ Readline: $lv_use_readline])
AC_MSG_NOTICE([ Python: $with_python]) AC_MSG_NOTICE([ Python: $with_python])
AC_MSG_NOTICE([ DTrace: $with_dtrace]) AC_MSG_NOTICE([ DTrace: $with_dtrace])
AC_MSG_NOTICE([ numad: $with_numad]) AC_MSG_NOTICE([ numad: $with_numad])
AC_MSG_NOTICE([ XML Catalog: $XML_CATALOG_FILE]) AC_MSG_NOTICE([ XML Catalog: $XML_CATALOG_FILE])
AC_MSG_NOTICE([ Init script: $with_init_script]) AC_MSG_NOTICE([ Init script: $with_init_script])
AC_MSG_NOTICE([Console locks: $with_console_lock_files]) AC_MSG_NOTICE([Char device locks: $with_chrdev_lock_files])
AC_MSG_NOTICE([]) AC_MSG_NOTICE([])
AC_MSG_NOTICE([Privileges]) AC_MSG_NOTICE([Privileges])
AC_MSG_NOTICE([]) AC_MSG_NOTICE([])

View File

@ -244,8 +244,8 @@ ENCRYPTION_CONF_SOURCES = \
CPU_CONF_SOURCES = \ CPU_CONF_SOURCES = \
conf/cpu_conf.c conf/cpu_conf.h conf/cpu_conf.c conf/cpu_conf.h
# Safe console handling helper APIs # Safe character device handling helper APIs
CONSOLE_CONF_SOURCES = \ CHRDEV_CONF_SOURCES = \
conf/virchrdev.c conf/virchrdev.h conf/virchrdev.c conf/virchrdev.h
# Device Helper APIs # Device Helper APIs
@ -264,7 +264,7 @@ CONF_SOURCES = \
$(INTERFACE_CONF_SOURCES) \ $(INTERFACE_CONF_SOURCES) \
$(SECRET_CONF_SOURCES) \ $(SECRET_CONF_SOURCES) \
$(CPU_CONF_SOURCES) \ $(CPU_CONF_SOURCES) \
$(CONSOLE_CONF_SOURCES) \ $(CHRDEV_CONF_SOURCES) \
$(DEVICE_CONF_SOURCES) $(DEVICE_CONF_SOURCES)
# The remote RPC driver, covering domains, storage, networks, etc # The remote RPC driver, covering domains, storage, networks, etc

View File

@ -1,6 +1,6 @@
/** /**
* virchrdev.c: api to guarantee mutually exclusive * virchrdev.c: api to guarantee mutually exclusive
* access to domain's consoles * access to domain's character devices
* *
* Copyright (C) 2011-2012 Red Hat, Inc. * Copyright (C) 2011-2012 Red Hat, Inc.
* *
@ -40,47 +40,47 @@
#define VIR_FROM_THIS VIR_FROM_NONE #define VIR_FROM_THIS VIR_FROM_NONE
/* structure holding information about consoles /* structure holding information about character devices
* open in a given domain */ * open in a given domain */
struct _virConsoles { struct _virChrdevs {
virMutex lock; virMutex lock;
virHashTablePtr hash; virHashTablePtr hash;
}; };
typedef struct _virConsoleStreamInfo virConsoleStreamInfo; typedef struct _virChrdevStreamInfo virChrdevStreamInfo;
typedef virConsoleStreamInfo *virConsoleStreamInfoPtr; typedef virChrdevStreamInfo *virChrdevStreamInfoPtr;
struct _virConsoleStreamInfo { struct _virChrdevStreamInfo {
virConsolesPtr cons; virChrdevsPtr devs;
const char *pty; const char *path;
}; };
#ifdef VIR_PTY_LOCK_FILE_PATH #ifdef VIR_CHRDEV_LOCK_FILE_PATH
/** /**
* Create a full filename with path to the lock file based on * Create a full filename with path to the lock file based on
* name/path of corresponding pty * name/path of corresponding device
* *
* @pty path of the console device * @dev path of the character device
* *
* Returns a modified name that the caller has to free, or NULL * Returns a modified name that the caller has to free, or NULL
* on error. * on error.
*/ */
static char *virConsoleLockFilePath(const char *pty) static char *virChrdevLockFilePath(const char *dev)
{ {
char *path = NULL; char *path = NULL;
char *sanitizedPath = NULL; char *sanitizedPath = NULL;
char *ptyCopy; char *devCopy;
char *filename; char *filename;
char *p; char *p;
if (!(ptyCopy = strdup(pty))) { if (!(devCopy = strdup(dev))) {
virReportOOMError(); virReportOOMError();
goto cleanup; goto cleanup;
} }
/* skip the leading "/dev/" */ /* skip the leading "/dev/" */
filename = STRSKIP(ptyCopy, "/dev"); filename = STRSKIP(devCopy, "/dev");
if (!filename) if (!filename)
filename = ptyCopy; filename = devCopy;
/* substitute path forward slashes for underscores */ /* substitute path forward slashes for underscores */
p = filename; p = filename;
@ -90,26 +90,26 @@ static char *virConsoleLockFilePath(const char *pty)
++p; ++p;
} }
if (virAsprintf(&path, "%s/LCK..%s", VIR_PTY_LOCK_FILE_PATH, filename) < 0) if (virAsprintf(&path, "%s/LCK..%s", VIR_CHRDEV_LOCK_FILE_PATH, filename) < 0)
goto cleanup; goto cleanup;
sanitizedPath = virFileSanitizePath(path); sanitizedPath = virFileSanitizePath(path);
cleanup: cleanup:
VIR_FREE(path); VIR_FREE(path);
VIR_FREE(ptyCopy); VIR_FREE(devCopy);
return sanitizedPath; return sanitizedPath;
} }
/** /**
* Verify and create a lock file for a console pty * Verify and create a lock file for a character device
* *
* @pty Path of the console device * @dev Path of the character device
* *
* Returns 0 on success, -1 on error * Returns 0 on success, -1 on error
*/ */
static int virConsoleLockFileCreate(const char *pty) static int virChrdevLockFileCreate(const char *dev)
{ {
char *path = NULL; char *path = NULL;
int ret = -1; int ret = -1;
@ -118,16 +118,16 @@ static int virConsoleLockFileCreate(const char *pty)
pid_t pid; pid_t pid;
/* build lock file path */ /* build lock file path */
if (!(path = virConsoleLockFilePath(pty))) if (!(path = virChrdevLockFilePath(dev)))
goto cleanup; goto cleanup;
/* check if a log file and process holding the lock still exists */ /* check if a log file and process holding the lock still exists */
if (virPidFileReadPathIfAlive(path, &pid, NULL) == 0 && pid >= 0) { if (virPidFileReadPathIfAlive(path, &pid, NULL) == 0 && pid >= 0) {
/* the process exists, the lockfile is valid */ /* the process exists, the lockfile is valid */
virReportError(VIR_ERR_OPERATION_FAILED, virReportError(VIR_ERR_OPERATION_FAILED,
_("Requested console pty '%s' is locked by " _("Requested device '%s' is locked by "
"lock file '%s' held by process %lld"), "lock file '%s' held by process %lld"),
pty, path, (long long) pid); dev, path, (long long) pid);
goto cleanup; goto cleanup;
} else { } else {
/* clean up the stale/corrupted/nonexistent lockfile */ /* clean up the stale/corrupted/nonexistent lockfile */
@ -148,15 +148,15 @@ static int virConsoleLockFileCreate(const char *pty)
* we run in daemon mode and thus privileged. * we run in daemon mode and thus privileged.
*/ */
if (errno == EACCES && geteuid() != 0) { if (errno == EACCES && geteuid() != 0) {
VIR_DEBUG("Skipping lock file creation for pty '%s in path '%s'.", VIR_DEBUG("Skipping lock file creation for device '%s in path '%s'.",
pty, path); dev, path);
ret = 0; ret = 0;
goto cleanup; goto cleanup;
} }
virReportSystemError(errno, virReportSystemError(errno,
_("Couldn't create lock file for " _("Couldn't create lock file for "
"pty '%s' in path '%s'"), "device '%s' in path '%s'"),
pty, path); dev, path);
goto cleanup; goto cleanup;
} }
@ -164,8 +164,8 @@ static int virConsoleLockFileCreate(const char *pty)
if (safewrite(lockfd, pidStr, strlen(pidStr)) < 0) { if (safewrite(lockfd, pidStr, strlen(pidStr)) < 0) {
virReportSystemError(errno, virReportSystemError(errno,
_("Couldn't write to lock file for " _("Couldn't write to lock file for "
"pty '%s' in path '%s'"), "device '%s' in path '%s'"),
pty, path); dev, path);
VIR_FORCE_CLOSE(lockfd); VIR_FORCE_CLOSE(lockfd);
unlink(path); unlink(path);
goto cleanup; goto cleanup;
@ -183,47 +183,47 @@ cleanup:
} }
/** /**
* Remove a lock file for a pty * Remove a lock file for a device
* *
* @pty Path of the pty device * @dev Path of the device
*/ */
static void virConsoleLockFileRemove(const char *pty) static void virChrdevLockFileRemove(const char *dev)
{ {
char *path = virConsoleLockFilePath(pty); char *path = virChrdevLockFilePath(dev);
if (path) if (path)
unlink(path); unlink(path);
VIR_FREE(path); VIR_FREE(path);
} }
#else /* #ifdef VIR_PTY_LOCK_FILE_PATH */ #else /* #ifdef VIR_CHRDEV_LOCK_FILE_PATH */
/* file locking for console devices is disabled */ /* file locking for character devices is disabled */
static int virConsoleLockFileCreate(const char *pty ATTRIBUTE_UNUSED) static int virChrdevLockFileCreate(const char *dev ATTRIBUTE_UNUSED)
{ {
return 0; return 0;
} }
static void virConsoleLockFileRemove(const char *pty ATTRIBUTE_UNUSED) static void virChrdevLockFileRemove(const char *dev ATTRIBUTE_UNUSED)
{ {
return; return;
} }
#endif /* #ifdef VIR_PTY_LOCK_FILE_PATH */ #endif /* #ifdef VIR_CHRDEV_LOCK_FILE_PATH */
/** /**
* Frees an entry from the hash containing domain's active consoles * Frees an entry from the hash containing domain's active devices
* *
* @data Opaque data, struct holding information about the console * @data Opaque data, struct holding information about the device
* @name Path of the pty. * @name Path of the device.
*/ */
static void virConsoleHashEntryFree(void *data, static void virChrdevHashEntryFree(void *data,
const void *name) const void *name)
{ {
const char *pty = name; const char *dev = name;
virStreamPtr st = data; virStreamPtr st = data;
/* free stream reference */ /* free stream reference */
virStreamFree(st); virStreamFree(st);
/* delete lock file */ /* delete lock file */
virConsoleLockFileRemove(pty); virChrdevLockFileRemove(dev);
} }
/** /**
@ -231,65 +231,65 @@ static void virConsoleHashEntryFree(void *data,
* *
* @opaque Data to be freed. * @opaque Data to be freed.
*/ */
static void virConsoleFDStreamCloseCbFree(void *opaque) static void virChrdevFDStreamCloseCbFree(void *opaque)
{ {
virConsoleStreamInfoPtr priv = opaque; virChrdevStreamInfoPtr priv = opaque;
VIR_FREE(priv->pty); VIR_FREE(priv->path);
VIR_FREE(priv); VIR_FREE(priv);
} }
/** /**
* Callback being called if a FDstream is closed. Frees console entries * Callback being called if a FDstream is closed. Frees device entries
* from data structures and removes lockfiles. * from data structures and removes lockfiles.
* *
* @st Pointer to stream being closed. * @st Pointer to stream being closed.
* @opaque Domain's console information structure. * @opaque Domain's device information structure.
*/ */
static void virConsoleFDStreamCloseCb(virStreamPtr st ATTRIBUTE_UNUSED, static void virChrdevFDStreamCloseCb(virStreamPtr st ATTRIBUTE_UNUSED,
void *opaque) void *opaque)
{ {
virConsoleStreamInfoPtr priv = opaque; virChrdevStreamInfoPtr priv = opaque;
virMutexLock(&priv->cons->lock); virMutexLock(&priv->devs->lock);
/* remove entry from hash */ /* remove entry from hash */
virHashRemoveEntry(priv->cons->hash, priv->pty); virHashRemoveEntry(priv->devs->hash, priv->path);
virMutexUnlock(&priv->cons->lock); virMutexUnlock(&priv->devs->lock);
} }
/** /**
* Allocate structures for storing information about active console streams * Allocate structures for storing information about active device streams
* in domain's private data section. * in domain's private data section.
* *
* Returns pointer to the allocated structure or NULL on error * Returns pointer to the allocated structure or NULL on error
*/ */
virConsolesPtr virConsoleAlloc(void) virChrdevsPtr virChrdevAlloc(void)
{ {
virConsolesPtr cons; virChrdevsPtr devs;
if (VIR_ALLOC(cons) < 0) if (VIR_ALLOC(devs) < 0)
return NULL; return NULL;
if (virMutexInit(&cons->lock) < 0) { if (virMutexInit(&devs->lock) < 0) {
VIR_FREE(cons); VIR_FREE(devs);
return NULL; return NULL;
} }
/* there will hardly be any consoles most of the time, the hash /* there will hardly be any devices most of the time, the hash
* does not have to be huge */ * does not have to be huge */
if (!(cons->hash = virHashCreate(3, virConsoleHashEntryFree))) if (!(devs->hash = virHashCreate(3, virChrdevHashEntryFree)))
goto error; goto error;
return cons; return devs;
error: error:
virConsoleFree(cons); virChrdevFree(devs);
return NULL; return NULL;
} }
/** /**
* Helper to clear stream callbacks when freeing the hash * Helper to clear stream callbacks when freeing the hash
*/ */
static void virConsoleFreeClearCallbacks(void *payload, static void virChrdevFreeClearCallbacks(void *payload,
const void *name ATTRIBUTE_UNUSED, const void *name ATTRIBUTE_UNUSED,
void *data ATTRIBUTE_UNUSED) void *data ATTRIBUTE_UNUSED)
{ {
@ -299,80 +299,80 @@ static void virConsoleFreeClearCallbacks(void *payload,
} }
/** /**
* Free structures for handling open console streams. * Free structures for handling open device streams.
* *
* @cons Pointer to the private structure. * @devs Pointer to the private structure.
*/ */
void virConsoleFree(virConsolesPtr cons) void virChrdevFree(virChrdevsPtr devs)
{ {
if (!cons || !cons->hash) if (!devs || !devs->hash)
return; return;
virMutexLock(&cons->lock); virMutexLock(&devs->lock);
virHashForEach(cons->hash, virConsoleFreeClearCallbacks, NULL); virHashForEach(devs->hash, virChrdevFreeClearCallbacks, NULL);
virHashFree(cons->hash); virHashFree(devs->hash);
virMutexUnlock(&cons->lock); virMutexUnlock(&devs->lock);
virMutexDestroy(&cons->lock); virMutexDestroy(&devs->lock);
VIR_FREE(cons); VIR_FREE(devs);
} }
/** /**
* Open a console stream for a domain ensuring that other streams are * Open a device stream for a domain ensuring that other streams are
* not using the console, nor any lockfiles exist. This ensures that * not using the device, nor any lockfiles exist. This ensures that
* the console stream does not get corrupted due to a race on reading * the device stream does not get corrupted due to a race on reading
* same FD by two processes. * same FD by two processes.
* *
* @cons Pointer to private structure holding data about console streams. * @devs Pointer to private structure holding data about device streams.
* @pty Path to the pseudo tty to be opened. * @path Path to the character device to be opened.
* @st Stream the client wishes to use for the console connection. * @st Stream the client wishes to use for the device connection.
* @force On true, close active console streams for the selected console pty * @force On true, close active device streams for the selected character
* before opening this connection. * device before opening this connection.
* *
* Returns 0 on success and st is connected to the selected pty and * Returns 0 on success and st is connected to the selected device and
* corresponding lock file is created (if configured). Returns -1 on * corresponding lock file is created (if configured). Returns -1 on
* error and 1 if the console stream is open and busy. * error and 1 if the device stream is open and busy.
*/ */
int virConsoleOpen(virConsolesPtr cons, int virChrdevOpen(virChrdevsPtr devs,
const char *pty, const char *path,
virStreamPtr st, virStreamPtr st,
bool force) bool force)
{ {
virConsoleStreamInfoPtr cbdata = NULL; virChrdevStreamInfoPtr cbdata = NULL;
virStreamPtr savedStream; virStreamPtr savedStream;
int ret; int ret;
virMutexLock(&cons->lock); virMutexLock(&devs->lock);
if ((savedStream = virHashLookup(cons->hash, pty))) { if ((savedStream = virHashLookup(devs->hash, path))) {
if (!force) { if (!force) {
/* entry found, console is busy */ /* entry found, device is busy */
virMutexUnlock(&cons->lock); virMutexUnlock(&devs->lock);
return 1; return 1;
} else { } else {
/* terminate existing connection */ /* terminate existing connection */
/* The internal close callback handler needs to lock cons->lock to /* The internal close callback handler needs to lock devs->lock to
* remove the aborted stream from the hash. This would cause a * remove the aborted stream from the hash. This would cause a
* deadlock as we would try to enter the lock twice from the very * deadlock as we would try to enter the lock twice from the very
* same thread. We need to unregister the callback and abort the * same thread. We need to unregister the callback and abort the
* stream manually before we create a new console connection. * stream manually before we create a new device connection.
*/ */
virFDStreamSetInternalCloseCb(savedStream, NULL, NULL, NULL); virFDStreamSetInternalCloseCb(savedStream, NULL, NULL, NULL);
virStreamAbort(savedStream); virStreamAbort(savedStream);
virHashRemoveEntry(cons->hash, pty); virHashRemoveEntry(devs->hash, path);
/* continue adding a new stream connection */ /* continue adding a new stream connection */
} }
} }
/* create the lock file */ /* create the lock file */
if ((ret = virConsoleLockFileCreate(pty)) < 0) { if ((ret = virChrdevLockFileCreate(path)) < 0) {
virMutexUnlock(&cons->lock); virMutexUnlock(&devs->lock);
return ret; return ret;
} }
/* obtain a reference to the stream */ /* obtain a reference to the stream */
if (virStreamRef(st) < 0) { if (virStreamRef(st) < 0) {
virMutexUnlock(&cons->lock); virMutexUnlock(&devs->lock);
return -1; return -1;
} }
@ -381,34 +381,34 @@ int virConsoleOpen(virConsolesPtr cons,
goto error; goto error;
} }
if (virHashAddEntry(cons->hash, pty, st) < 0) if (virHashAddEntry(devs->hash, path, st) < 0)
goto error; goto error;
cbdata->cons = cons; cbdata->devs = devs;
if (!(cbdata->pty = strdup(pty))) { if (!(cbdata->path = strdup(path))) {
virReportOOMError(); virReportOOMError();
goto error; goto error;
} }
/* open the console pty */ /* open the character device */
if (virFDStreamOpenFile(st, pty, 0, 0, O_RDWR) < 0) if (virFDStreamOpenFile(st, path, 0, 0, O_RDWR) < 0)
goto error; goto error;
/* add cleanup callback */ /* add cleanup callback */
virFDStreamSetInternalCloseCb(st, virFDStreamSetInternalCloseCb(st,
virConsoleFDStreamCloseCb, virChrdevFDStreamCloseCb,
cbdata, cbdata,
virConsoleFDStreamCloseCbFree); virChrdevFDStreamCloseCbFree);
virMutexUnlock(&cons->lock); virMutexUnlock(&devs->lock);
return 0; return 0;
error: error:
virStreamFree(st); virStreamFree(st);
virHashRemoveEntry(cons->hash, pty); virHashRemoveEntry(devs->hash, path);
if (cbdata) if (cbdata)
VIR_FREE(cbdata->pty); VIR_FREE(cbdata->path);
VIR_FREE(cbdata); VIR_FREE(cbdata);
virMutexUnlock(&cons->lock); virMutexUnlock(&devs->lock);
return -1; return -1;
} }

View File

@ -1,6 +1,6 @@
/** /**
* virchrdev.h: api to guarantee mutually exclusive * virchrdev.h: api to guarantee mutually exclusive
* access to domain's consoles * access to domain's character devices
* *
* Copyright (C) 2011-2012 Red Hat, Inc. * Copyright (C) 2011-2012 Red Hat, Inc.
* *
@ -20,17 +20,17 @@
* *
* Author: Peter Krempa <pkrempa@redhat.com> * Author: Peter Krempa <pkrempa@redhat.com>
*/ */
#ifndef __VIR_CONSOLE_H__ #ifndef __VIR_CHRDEV_H__
# define __VIR_CONSOLE_H__ # define __VIR_CHRDEV_H__
# include "internal.h" # include "internal.h"
typedef struct _virConsoles virConsoles; typedef struct _virChrdevs virChrdevs;
typedef virConsoles *virConsolesPtr; typedef virChrdevs *virChrdevsPtr;
virConsolesPtr virConsoleAlloc(void); virChrdevsPtr virChrdevAlloc(void);
void virConsoleFree(virConsolesPtr cons); void virChrdevFree(virChrdevsPtr devs);
int virConsoleOpen(virConsolesPtr cons, const char *pty, int virChrdevOpen(virChrdevsPtr devs, const char *path,
virStreamPtr st, bool force); virStreamPtr st, bool force);
#endif /*__VIR_DOMAIN_CONSOLE_LOCK_H__*/ #endif /*__VIR_CHRDEV_H__*/

View File

@ -1356,9 +1356,9 @@ virArchToString;
# virchrdev.h # virchrdev.h
virConsoleAlloc; virChrdevAlloc;
virConsoleFree; virChrdevFree;
virConsoleOpen; virChrdevOpen;
# virdbus.h # virdbus.h

View File

@ -215,7 +215,7 @@ static void *qemuDomainObjPrivateAlloc(void)
if (qemuDomainObjInitJob(priv) < 0) if (qemuDomainObjInitJob(priv) < 0)
goto error; goto error;
if (!(priv->cons = virConsoleAlloc())) if (!(priv->devs = virChrdevAlloc()))
goto error; goto error;
priv->migMaxBandwidth = QEMU_DOMAIN_MIG_BANDWIDTH_MAX; priv->migMaxBandwidth = QEMU_DOMAIN_MIG_BANDWIDTH_MAX;
@ -240,7 +240,7 @@ static void qemuDomainObjPrivateFree(void *data)
VIR_FREE(priv->lockState); VIR_FREE(priv->lockState);
VIR_FREE(priv->origname); VIR_FREE(priv->origname);
virConsoleFree(priv->cons); virChrdevFree(priv->devs);
/* This should never be non-NULL if we get here, but just in case... */ /* This should never be non-NULL if we get here, but just in case... */
if (priv->mon) { if (priv->mon) {

View File

@ -155,7 +155,7 @@ struct _qemuDomainObjPrivate {
unsigned long migMaxBandwidth; unsigned long migMaxBandwidth;
char *origname; char *origname;
virConsolesPtr cons; virChrdevsPtr devs;
qemuDomainCleanupCallback *cleanupCallbacks; qemuDomainCleanupCallback *cleanupCallbacks;
size_t ncleanupCallbacks; size_t ncleanupCallbacks;

View File

@ -12576,10 +12576,10 @@ qemuDomainOpenConsole(virDomainPtr dom,
} }
/* handle mutually exclusive access to console devices */ /* handle mutually exclusive access to console devices */
ret = virConsoleOpen(priv->cons, ret = virChrdevOpen(priv->devs,
chr->source.data.file.path, chr->source.data.file.path,
st, st,
(flags & VIR_DOMAIN_CONSOLE_FORCE) != 0); (flags & VIR_DOMAIN_CONSOLE_FORCE) != 0);
if (ret == 1) { if (ret == 1) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s", virReportError(VIR_ERR_OPERATION_FAILED, "%s",