[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V7 27/29] chardev: cpr for pty
From: |
Steve Sistare |
Subject: |
[PATCH V7 27/29] chardev: cpr for pty |
Date: |
Wed, 22 Dec 2021 11:05:32 -0800 |
Save and restore pty descriptors across cpr-save and cpr-load.
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
chardev/char-pty.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/chardev/char-pty.c b/chardev/char-pty.c
index a2d1e7c..9801a4f 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 "migration/cpr.h"
#include "qemu/qemu-print.h"
#include "chardev/char-io.h"
@@ -191,6 +192,9 @@ static void char_pty_finalize(Object *obj)
Chardev *chr = CHARDEV(obj);
PtyChardev *s = PTY_CHARDEV(obj);
+ if (!chr->reopen_on_cpr) {
+ cpr_delete_fd(chr->label, 0);
+ }
pty_chr_state(chr, 0);
object_unref(OBJECT(s->ioc));
pty_chr_timer_cancel(s);
@@ -207,12 +211,20 @@ static void char_pty_open(Chardev *chr,
char pty_name[PATH_MAX];
char *name;
+ master_fd = cpr_find_fd(chr->label, 0);
+ 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->reopen_on_cpr) {
+ cpr_save_fd(chr->label, 0, master_fd);
+ }
close(slave_fd);
qemu_set_nonblock(master_fd);
@@ -220,6 +232,8 @@ static void char_pty_open(Chardev *chr,
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 V7 16/29] hostmem-memfd: cpr for memory-backend-memfd, (continued)
- [PATCH V7 16/29] hostmem-memfd: cpr for memory-backend-memfd, Steve Sistare, 2021/12/22
- [PATCH V7 14/29] cpr: restart mode, Steve Sistare, 2021/12/22
- [PATCH V7 18/29] vfio-pci: refactor for cpr, Steve Sistare, 2021/12/22
- [PATCH V7 25/29] chardev: cpr framework, Steve Sistare, 2021/12/22
- [PATCH V7 26/29] chardev: cpr for simple devices, Steve Sistare, 2021/12/22
- [PATCH V7 29/29] cpr: only-cpr-capable option, Steve Sistare, 2021/12/22
- [PATCH V7 21/29] vfio-pci: cpr part 3 (intx), Steve Sistare, 2021/12/22
- [PATCH V7 22/29] vfio-pci: recover from unmap-all-vaddr failure, Steve Sistare, 2021/12/22
- [PATCH V7 24/29] loader: suppress rom_reset during cpr, Steve Sistare, 2021/12/22
- [PATCH V7 23/29] vhost: reset vhost devices for cpr, Steve Sistare, 2021/12/22
- [PATCH V7 27/29] chardev: cpr for pty,
Steve Sistare <=
- [PATCH V7 10/29] machine: memfd-alloc option, Steve Sistare, 2021/12/22
- [PATCH V7 08/29] memory: flat section iterator, Steve Sistare, 2021/12/22
- [PATCH V7 28/29] chardev: cpr for sockets, Steve Sistare, 2021/12/22