[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V6 25/27] chardev: cpr for pty
From: |
Steve Sistare |
Subject: |
[PATCH V6 25/27] chardev: cpr for pty |
Date: |
Fri, 6 Aug 2021 14:43:59 -0700 |
Save and restore pty descriptors across cpr-save and cpr-load.
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
chardev/char-pty.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/chardev/char-pty.c b/chardev/char-pty.c
index a2d1e7c..721cee9 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,7 @@ static void char_pty_finalize(Object *obj)
Chardev *chr = CHARDEV(obj);
PtyChardev *s = PTY_CHARDEV(obj);
+ cpr_delete_fd(chr->label, 0);
pty_chr_state(chr, 0);
object_unref(OBJECT(s->ioc));
pty_chr_timer_cancel(s);
@@ -207,12 +209,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 +230,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 V6 17/27] pci: export functions for cpr, (continued)
- [PATCH V6 17/27] pci: export functions for cpr, Steve Sistare, 2021/08/06
- [PATCH V6 18/27] vfio-pci: refactor for cpr, Steve Sistare, 2021/08/06
- [PATCH V6 20/27] vfio-pci: cpr part 2 (msi), Steve Sistare, 2021/08/06
- [PATCH V6 19/27] vfio-pci: cpr part 1 (fd and dma), Steve Sistare, 2021/08/06
- [PATCH V6 22/27] vhost: reset vhost devices for cpr, Steve Sistare, 2021/08/06
- [PATCH V6 23/27] chardev: cpr framework, Steve Sistare, 2021/08/06
- [PATCH V6 25/27] chardev: cpr for pty,
Steve Sistare <=
- [PATCH V6 26/27] chardev: cpr for sockets, Steve Sistare, 2021/08/06
- [PATCH V6 27/27] cpr: only-cpr-capable option, Steve Sistare, 2021/08/06
- [PATCH V6 01/27] memory: qemu_check_ram_volatile, Steve Sistare, 2021/08/06
- [PATCH V6 21/27] vfio-pci: cpr part 3 (intx), Steve Sistare, 2021/08/06
- [PATCH V6 24/27] chardev: cpr for simple devices, Steve Sistare, 2021/08/06
- Re: [PATCH V6 00/27] Live Update, Steven Sistare, 2021/08/09
- Re: [PATCH V6 00/27] Live Update, Zheng Chuan, 2021/08/21