[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V5 22/25] chardev: cpr for pty
From: |
Steve Sistare |
Subject: |
[PATCH V5 22/25] chardev: cpr for pty |
Date: |
Wed, 7 Jul 2021 10:20:31 -0700 |
Save and restore pty descriptors across cprsave and cprload.
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
chardev/char-pty.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/chardev/char-pty.c b/chardev/char-pty.c
index a2d1e7c..c91151d 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"
@@ -191,6 +192,7 @@ 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);
@@ -207,19 +209,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 V5 17/25] vfio-pci: cpr part 2, (continued)
- [PATCH V5 17/25] vfio-pci: cpr part 2, Steve Sistare, 2021/07/07
- [PATCH V5 14/25] pci: export functions for cpr, Steve Sistare, 2021/07/07
- [PATCH V5 15/25] vfio-pci: refactor for cpr, Steve Sistare, 2021/07/07
- [PATCH V5 18/25] vhost: reset vhost devices upon cprsave, Steve Sistare, 2021/07/07
- [PATCH V5 24/25] cpr: only-cpr-capable option, Steve Sistare, 2021/07/07
- [PATCH V5 22/25] chardev: cpr for pty,
Steve Sistare <=
- [PATCH V5 21/25] chardev: cpr for simple devices, Steve Sistare, 2021/07/07
- [PATCH V5 23/25] chardev: cpr for sockets, Steve Sistare, 2021/07/07
- [PATCH V5 25/25] simplify savevm, Steve Sistare, 2021/07/07
- [PATCH V5 02/25] cpr: reboot mode, Steve Sistare, 2021/07/07
- [PATCH V5 08/25] vl: add helper to request re-exec, Steve Sistare, 2021/07/07