[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V8 35/39] chardev: cpr for pty
From: |
Steve Sistare |
Subject: |
[PATCH V8 35/39] chardev: cpr for pty |
Date: |
Wed, 15 Jun 2022 07:52:22 -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 | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/chardev/char-pty.c b/chardev/char-pty.c
index 53f25c6..ff5b00a 100644
--- a/chardev/char-pty.c
+++ b/chardev/char-pty.c
@@ -29,6 +29,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"
@@ -190,6 +191,9 @@ static void char_pty_finalize(Object *obj)
Chardev *chr = CHARDEV(obj);
PtyChardev *s = PTY_CHARDEV(obj);
+ if (chr->cpr_enabled) {
+ cpr_delete_fd(chr->label, 0);
+ }
pty_chr_state(chr, 0);
object_unref(OBJECT(s->ioc));
pty_chr_timer_cancel(s);
@@ -317,12 +321,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->cpr_enabled) {
+ cpr_save_fd(chr->label, 0, master_fd);
+ }
close(slave_fd);
if (!g_unix_set_fd_nonblocking(master_fd, true, NULL)) {
error_setg_errno(errp, errno, "Failed to set FD nonblocking");
@@ -333,6 +345,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 V8 19/39] cpr: preserve extra state, (continued)
- [PATCH V8 19/39] cpr: preserve extra state, Steve Sistare, 2022/06/15
- [PATCH V8 21/39] cpr: restart HMP interfaces, Steve Sistare, 2022/06/15
- [PATCH V8 24/39] pci: export export msix_is_pending, Steve Sistare, 2022/06/15
- [PATCH V8 31/39] vhost: reset vhost devices for cpr, Steve Sistare, 2022/06/15
- [PATCH V8 26/39] vfio-pci: refactor for cpr, Steve Sistare, 2022/06/15
- [PATCH V8 36/39] chardev: cpr for sockets, Steve Sistare, 2022/06/15
- [PATCH V8 28/39] vfio-pci: cpr part 2 (msi), Steve Sistare, 2022/06/15
- [PATCH V8 33/39] chardev: cpr framework, Steve Sistare, 2022/06/15
- [PATCH V8 35/39] chardev: cpr for pty,
Steve Sistare <=
- [PATCH V8 32/39] loader: suppress rom_reset during cpr, Steve Sistare, 2022/06/15
- [PATCH V8 37/39] cpr: only-cpr-capable option, Steve Sistare, 2022/06/15
- [PATCH V8 27/39] vfio-pci: cpr part 1 (fd and dma), Steve Sistare, 2022/06/15
- [PATCH V8 34/39] chardev: cpr for simple devices, Steve Sistare, 2022/06/15
- [PATCH V8 39/39] tests/avocado: add cpr regression test, Steve Sistare, 2022/06/15
- [PATCH V8 30/39] vfio-pci: recover from unmap-all-vaddr failure, Steve Sistare, 2022/06/15
- [PATCH V8 38/39] python/machine: add QEMUMachine accessors, Steve Sistare, 2022/06/15