mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
Introduce virFDStreamOpenPTY
Add virFDStreamOpenPTY() function which is a wrapper around virFDStreamOpenFileInternal() with putting the device it opens into a raw mode. Make virChrdevOpen() use virFDStreamOpenPTY() for VIR_DOMAIN_CHR_TYPE_PTY devices. This fixes mangled console output when libvirt runs on FreeBSD as it requires device it opens to be placed into a raw mode explicitly.
This commit is contained in:
parent
80fb32c320
commit
4dae396f5a
@ -410,7 +410,7 @@ int virChrdevOpen(virChrdevsPtr devs,
|
|||||||
/* open the character device */
|
/* open the character device */
|
||||||
switch (source->type) {
|
switch (source->type) {
|
||||||
case VIR_DOMAIN_CHR_TYPE_PTY:
|
case VIR_DOMAIN_CHR_TYPE_PTY:
|
||||||
if (virFDStreamOpenFile(st, path, 0, 0, O_RDWR) < 0)
|
if (virFDStreamOpenPTY(st, path, 0, 0, O_RDWR) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
break;
|
break;
|
||||||
case VIR_DOMAIN_CHR_TYPE_UNIX:
|
case VIR_DOMAIN_CHR_TYPE_UNIX:
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
# include <sys/un.h>
|
# include <sys/un.h>
|
||||||
#endif
|
#endif
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
#include <termios.h>
|
||||||
|
|
||||||
#include "fdstream.h"
|
#include "fdstream.h"
|
||||||
#include "virerror.h"
|
#include "virerror.h"
|
||||||
@ -716,6 +717,58 @@ int virFDStreamCreateFile(virStreamPtr st,
|
|||||||
oflags | O_CREAT, mode);
|
oflags | O_CREAT, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_CFMAKERAW
|
||||||
|
int virFDStreamOpenPTY(virStreamPtr st,
|
||||||
|
const char *path,
|
||||||
|
unsigned long long offset,
|
||||||
|
unsigned long long length,
|
||||||
|
int oflags)
|
||||||
|
{
|
||||||
|
struct virFDStreamData *fdst = NULL;
|
||||||
|
struct termios rawattr;
|
||||||
|
|
||||||
|
if (virFDStreamOpenFileInternal(st, path,
|
||||||
|
offset, length,
|
||||||
|
oflags | O_CREAT, 0) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
fdst = st->privateData;
|
||||||
|
|
||||||
|
if (tcgetattr(fdst->fd, &rawattr) < 0) {
|
||||||
|
virReportSystemError(errno,
|
||||||
|
_("unable to get tty attributes: %s"),
|
||||||
|
path);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
cfmakeraw(&rawattr);
|
||||||
|
|
||||||
|
if (tcsetattr(fdst->fd, TCSANOW, &rawattr) < 0) {
|
||||||
|
virReportSystemError(errno,
|
||||||
|
_("unable to set tty attributes: %s"),
|
||||||
|
path);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
virFDStreamClose(st);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#else /* !HAVE_CFMAKERAW */
|
||||||
|
int virFDStreamOpenPTY(virStreamPtr st,
|
||||||
|
const char *path,
|
||||||
|
unsigned long long offset,
|
||||||
|
unsigned long long length,
|
||||||
|
int oflags)
|
||||||
|
{
|
||||||
|
return virFDStreamOpenFileInternal(st, path,
|
||||||
|
offset, length,
|
||||||
|
oflags | O_CREAT, 0);
|
||||||
|
}
|
||||||
|
#endif /* !HAVE_CFMAKERAW */
|
||||||
|
|
||||||
int virFDStreamSetInternalCloseCb(virStreamPtr st,
|
int virFDStreamSetInternalCloseCb(virStreamPtr st,
|
||||||
virFDStreamInternalCloseCb cb,
|
virFDStreamInternalCloseCb cb,
|
||||||
void *opaque,
|
void *opaque,
|
||||||
|
@ -54,6 +54,11 @@ int virFDStreamCreateFile(virStreamPtr st,
|
|||||||
unsigned long long length,
|
unsigned long long length,
|
||||||
int oflags,
|
int oflags,
|
||||||
mode_t mode);
|
mode_t mode);
|
||||||
|
int virFDStreamOpenPTY(virStreamPtr st,
|
||||||
|
const char *path,
|
||||||
|
unsigned long long offset,
|
||||||
|
unsigned long long length,
|
||||||
|
int oflags);
|
||||||
|
|
||||||
int virFDStreamSetInternalCloseCb(virStreamPtr st,
|
int virFDStreamSetInternalCloseCb(virStreamPtr st,
|
||||||
virFDStreamInternalCloseCb cb,
|
virFDStreamInternalCloseCb cb,
|
||||||
|
@ -800,6 +800,7 @@ virFDStreamConnectUNIX;
|
|||||||
virFDStreamCreateFile;
|
virFDStreamCreateFile;
|
||||||
virFDStreamOpen;
|
virFDStreamOpen;
|
||||||
virFDStreamOpenFile;
|
virFDStreamOpenFile;
|
||||||
|
virFDStreamOpenPTY;
|
||||||
virFDStreamSetIOHelper;
|
virFDStreamSetIOHelper;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user