From nobody Tue Feb 10 12:43:10 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1620391416; cv=none; d=zohomail.com; s=zohoarc; b=ictyLPhijJjo1Y/MYS7noLzFUffn8tRELJjtBlsEpD769+hYVQK5tFCtWpRCo6INJN7ozBqKz1cKdBpyVuW2/DCfW9HZ1iFClsqLFtYKlCF88tDfE2hQrXm4wrqmV+kdSLjOk+a9wiibp2XVepNMtzCuDIoeSt+C3Zf7rmzoDsA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620391416; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=z5xKbEJAlAVR4RVNr9CaGx/H1ESy+tpLGhwVIjQTbp4=; b=OX1p5vTYwb6IJXQ073uiVR+BK9UBhXPUNfE2OC5FHD76IwjK7lwejKJsaVoPI4/veFk51m2f8kOCqSsi0j9gM5X8fMLcmeFBDQxigIDdRA8MDWbOwu4//R9y4YUc2iZ6ZQ0jSIZS2EPJUMfk8u7hI5HcyizQ/+28WMwHFoC1kkQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1620391416758686.8747336230153; Fri, 7 May 2021 05:43:36 -0700 (PDT) Received: from localhost ([::1]:37692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lezpP-0004Sj-Q0 for importer@patchew.org; Fri, 07 May 2021 08:43:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57480) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lezbZ-0000ua-Oe for qemu-devel@nongnu.org; Fri, 07 May 2021 08:29:18 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:40668) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lezbV-0001Xn-G8 for qemu-devel@nongnu.org; Fri, 07 May 2021 08:29:17 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 147CEE7C096919; Fri, 7 May 2021 12:29:09 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 38ctd89d1x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 07 May 2021 12:29:09 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 147CGOWk173606; Fri, 7 May 2021 12:29:08 GMT Received: from pps.reinject (localhost [127.0.0.1]) by aserp3020.oracle.com with ESMTP id 38csrtb6c4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 07 May 2021 12:29:08 +0000 Received: from aserp3020.oracle.com (aserp3020.oracle.com [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 147CT8Pk028387; Fri, 7 May 2021 12:29:08 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 38csrtb6bd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 07 May 2021 12:29:08 +0000 Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 147CT6Dn011732; Fri, 7 May 2021 12:29:06 GMT Received: from ca-dev63.us.oracle.com (/10.211.8.221) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 07 May 2021 05:29:05 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=z5xKbEJAlAVR4RVNr9CaGx/H1ESy+tpLGhwVIjQTbp4=; b=ucgSLJwtjalz/rES225hRJgiOyJZxW0KC0mCj/uHyFLW1/AEQWg/2QkDI/XeNy+PFcKG 5ixkK1d5xfbMeVnWRJN9zdwyvIkiJ3gnXT02pzLXH9GDDWSoILCaGrrllWfNa15FZg8y dUK9BqR2ctKm6Z56lCggTMVjhPJP4w6G6SQk3CkWXu6VQP/rXDQmhe/2k8xeqBmz3UKa Q5ZU2rpW6sqqn1HeRlfdC6uHSi7mE9oJ7dBKOWZczHiA2n3Pz1fRk3LqnPVTZR0tqLzW 3Wp1OK5YEwDbsCfYl+H1FOx5WDtHF+Rl/ifEkoePG2b2f5c6e234WNgd+Vemp994v+YX 1w== From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V3 19/22] chardev: cpr for sockets Date: Fri, 7 May 2021 05:25:17 -0700 Message-Id: <1620390320-301716-20-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1620390320-301716-1-git-send-email-steven.sistare@oracle.com> References: <1620390320-301716-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-GUID: KMl-NKj3bJhg7O_XqHwJIg1g7qu8gPWE X-Proofpoint-ORIG-GUID: KMl-NKj3bJhg7O_XqHwJIg1g7qu8gPWE X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9976 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 adultscore=0 clxscore=1015 spamscore=0 mlxlogscore=999 priorityscore=1501 lowpriorityscore=0 phishscore=0 suspectscore=0 impostorscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105070085 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=156.151.31.86; envelope-from=steven.sistare@oracle.com; helo=userp2130.oracle.com X-Spam_score_int: -50 X-Spam_score: -5.1 X-Spam_bar: ----- X-Spam_report: (-5.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.699, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Save accepted socket fds in the environment before cprsave, and look for fds in the environment after cprload. Reject cprsave if a socket enables the TLS or websocket option. Allow a monitor socket by closing it on exec. Signed-off-by: Mark Kanda Signed-off-by: Steve Sistare --- chardev/char-socket.c | 31 +++++++++++++++++++++++++++++++ monitor/hmp.c | 3 +++ monitor/qmp.c | 3 +++ 3 files changed, 37 insertions(+) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index daa89fe..110f263 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -27,7 +27,9 @@ #include "io/channel-socket.h" #include "io/channel-tls.h" #include "io/channel-websock.h" +#include "qemu/env.h" #include "io/net-listener.h" +#include "qemu/env.h" #include "qemu/error-report.h" #include "qemu/module.h" #include "qemu/option.h" @@ -414,6 +416,7 @@ static void tcp_chr_free_connection(Chardev *chr) SocketChardev *s =3D SOCKET_CHARDEV(chr); int i; =20 + unsetenv_fd(chr->label); if (s->read_msgfds_num) { for (i =3D 0; i < s->read_msgfds_num; i++) { close(s->read_msgfds[i]); @@ -976,6 +979,10 @@ static void tcp_chr_accept(QIONetListener *listener, QIO_CHANNEL(cioc)); } tcp_chr_new_client(chr, cioc); + + if (s->sioc && !chr->close_on_cpr) { + setenv_fd(chr->label, s->sioc->fd); + } } =20 =20 @@ -1231,6 +1238,24 @@ static gboolean socket_reconnect_timeout(gpointer op= aque) return false; } =20 +static void load_char_socket_fd(Chardev *chr, Error **errp) +{ + SocketChardev *sockchar =3D SOCKET_CHARDEV(chr); + QIOChannelSocket *sioc; + int fd =3D getenv_fd(chr->label); + + if (fd !=3D -1) { + sockchar =3D SOCKET_CHARDEV(chr); + sioc =3D qio_channel_socket_new_fd(fd, errp); + if (sioc) { + tcp_chr_accept(sockchar->listener, sioc, chr); + object_unref(OBJECT(sioc)); + } else { + error_setg(errp, "error: could not restore socket for %s", + chr->label); + } + } +} =20 static int qmp_chardev_open_socket_server(Chardev *chr, bool is_telnet, @@ -1441,6 +1466,10 @@ static void qmp_chardev_open_socket(Chardev *chr, } s->registered_yank =3D true; =20 + if (!s->tls_creds && !s->is_websock) { + qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_CPR); + } + /* be isn't opened until we get a connection */ *be_opened =3D false; =20 @@ -1456,6 +1485,8 @@ static void qmp_chardev_open_socket(Chardev *chr, return; } } + + load_char_socket_fd(chr, errp); } =20 static void qemu_chr_parse_socket(QemuOpts *opts, ChardevBackend *backend, diff --git a/monitor/hmp.c b/monitor/hmp.c index 6c0b33a..63700b3 100644 --- a/monitor/hmp.c +++ b/monitor/hmp.c @@ -1451,4 +1451,7 @@ void monitor_init_hmp(Chardev *chr, bool use_readline= , Error **errp) qemu_chr_fe_set_handlers(&mon->common.chr, monitor_can_read, monitor_r= ead, monitor_event, NULL, &mon->common, NULL, true= ); monitor_list_append(&mon->common); + + /* monitor cannot yet be preserved across cpr */ + chr->close_on_cpr =3D true; } diff --git a/monitor/qmp.c b/monitor/qmp.c index 2b0308f..495d68f 100644 --- a/monitor/qmp.c +++ b/monitor/qmp.c @@ -531,4 +531,7 @@ void monitor_init_qmp(Chardev *chr, bool pretty, Error = **errp) NULL, &mon->common, NULL, true); monitor_list_append(&mon->common); } + + /* Monitor cannot yet be preserved across cpr */ + chr->close_on_cpr =3D true; } --=20 1.8.3.1