[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V2 16/22] chardev: cpr for pty
From: |
Steve Sistare |
Subject: |
[PATCH V2 16/22] chardev: cpr for pty |
Date: |
Tue, 5 Jan 2021 07:42:04 -0800 |
Save and restore pty descriptors across cprsave and cprload.
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
chardev/char-pty.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/chardev/char-pty.c b/chardev/char-pty.c
index 1cc501a..0916f9e 100644
--- a/chardev/char-pty.c
+++ b/chardev/char-pty.c
@@ -30,6 +30,7 @@
#include "qemu/sockets.h"
#include "qemu/error-report.h"
#include "qemu/module.h"
+#include "qemu/env.h"
#include "qemu/qemu-print.h"
#include "chardev/char-io.h"
@@ -188,12 +189,14 @@ static void char_pty_finalize(Object *obj)
Chardev *chr = CHARDEV(obj);
PtyChardev *s = PTY_CHARDEV(obj);
+ unsetenv_fd(chr->label);
pty_chr_state(chr, 0);
object_unref(OBJECT(s->ioc));
pty_chr_timer_cancel(s);
qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
}
+
static void char_pty_open(Chardev *chr,
ChardevBackend *backend,
bool *be_opened,
@@ -204,19 +207,28 @@ static void char_pty_open(Chardev *chr,
char pty_name[PATH_MAX];
char *name;
+ master_fd = getenv_fd(chr->label);
+ if (master_fd >= 0) {
+ chr->filename = g_strdup_printf("pty:unknown");
+ goto have_fd;
+ }
+
master_fd = qemu_openpty_raw(&slave_fd, pty_name);
if (master_fd < 0) {
error_setg_errno(errp, errno, "Failed to create PTY");
return;
}
-
+ if (!chr->close_on_cpr) {
+ setenv_fd(chr->label, master_fd);
+ }
close(slave_fd);
qemu_set_nonblock(master_fd);
-
chr->filename = g_strdup_printf("pty:%s", pty_name);
qemu_printf("char device redirected to %s (label %s)\n",
pty_name, chr->label);
+have_fd:
+ qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_CPR);
s = PTY_CHARDEV(chr);
s->ioc = QIO_CHANNEL(qio_channel_file_new_fd(master_fd));
name = g_strdup_printf("chardev-pty-%s", chr->label);
--
1.8.3.1
- [PATCH V2 08/22] cpr: QMP interfaces, (continued)
- [PATCH V2 08/22] cpr: QMP interfaces, Steve Sistare, 2021/01/05
- [PATCH V2 09/22] cpr: HMP interfaces, Steve Sistare, 2021/01/05
- [PATCH V2 10/22] pci: export functions for cpr, Steve Sistare, 2021/01/05
- [PATCH V2 07/22] cpr, Steve Sistare, 2021/01/05
- [PATCH V2 05/22] vl: memfd-alloc option, Steve Sistare, 2021/01/05
[PATCH V2 12/22] vfio-pci: cpr, Steve Sistare, 2021/01/05
[PATCH V2 16/22] chardev: cpr for pty,
Steve Sistare <=
[PATCH V2 18/22] chardev: cpr for sockets, Steve Sistare, 2021/01/05
[PATCH V2 19/22] monitor: cpr support, Steve Sistare, 2021/01/05
[PATCH V2 17/22] chardev: socket accept subroutine, Steve Sistare, 2021/01/05
[PATCH V2 20/22] cpr: only-cpr-capable option, Steve Sistare, 2021/01/05
[PATCH V2 22/22] simplify savevm, Steve Sistare, 2021/01/05
[PATCH V2 14/22] chardev: cpr framework, Steve Sistare, 2021/01/05
[PATCH V2 21/22] cpr: maintainers, Steve Sistare, 2021/01/05
[PATCH V2 02/22] qemu_ram_volatile, Steve Sistare, 2021/01/05