From nobody Sat May 4 13:32:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1564975779; cv=none; d=zoho.com; s=zohoarc; b=b7XVSimrGlzhxiqA07/7m8m+rarHpKAogtDHgq4Jn5iG+A5+Njlf2vB4zRCas69zV9z3veqHGP1TDLfImO+EOB/nBOVDDsWMDkQZRURGgzm5mMql33unPxEEzsk1+5kd3fswuJzn7Xdvu8udmLzIo9aH0LoxEfHpvEAbWfuq5oQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564975779; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=HW83bYAAogH2aOFkBOlEdSErDUzXIu9LKTMS+aM0CLo=; b=fdSVQ5KKDqjzQBc86WQVfGloytyY9eYoVte1kJCCfIu+yaPznmdB/UAYAp4+wVy+A4InaCqeynC9XbB25PoWVRk6xiNnEkOZdFgvZKzlEXnxLpvMjvzOpMeyK9E2UzkruoViGyuiTQgp7eUjdtFnfLZugH4ZwF1HahnzKysVjB4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564975778292571.002435668045; Sun, 4 Aug 2019 20:29:38 -0700 (PDT) Received: from localhost ([::1]:50462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huTgn-0007hZ-1c for importer@patchew.org; Sun, 04 Aug 2019 23:29:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59751) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1huTgO-0007Ho-M4 for qemu-devel@nongnu.org; Sun, 04 Aug 2019 23:29:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1huTgL-00010u-Co for qemu-devel@nongnu.org; Sun, 04 Aug 2019 23:29:12 -0400 Received: from mx7.zte.com.cn ([202.103.147.169]:56408 helo=mxct.zte.com.cn) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1huTgL-0000oU-32 for qemu-devel@nongnu.org; Sun, 04 Aug 2019 23:29:09 -0400 Received: from mse-fl2.zte.com.cn (unknown [10.30.14.239]) by Forcepoint Email with ESMTPS id 636F42CFC92B58FF29D0; Mon, 5 Aug 2019 11:28:55 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse-fl2.zte.com.cn with ESMTP id x753Su4E003451; Mon, 5 Aug 2019 11:28:56 +0800 (GMT-8) (envelope-from ning.bo9@zte.com.cn) Received: from kvm-146.localdomain ([10.74.120.146]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2019080511284630-2753121 ; Mon, 5 Aug 2019 11:28:46 +0800 From: Ning Bo To: qemu-devel@nongnu.org, eblake@redhat.com, armbru@redhat.com Date: Mon, 5 Aug 2019 11:32:31 +0800 Message-Id: <1564975951-29263-1-git-send-email-ning.bo9@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2019-08-05 11:28:46, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2019-08-05 11:28:44, Serialize complete at 2019-08-05 11:28:44 X-MAIL: mse-fl2.zte.com.cn x753Su4E003451 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 202.103.147.169 Subject: [Qemu-devel] [PATCH v2] vhost-vsock: report QMP event when set running 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: Ning Bo , mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If a program in host communicates with a vsock device in guest via 'vsock://', but the device is not ready, the 'connect' syscall will block and then timeout after 2 second default.(the timeout is defined in kernel: #define VSOCK_DEFAULT_CONNECT_TIMEOUT (2 * HZ)). We can avoid this case if qemu reports an event when the vsock is ready and the program waits the event before connecting. Report vsock running event so that the upper application can control boot sequence. see https://github.com/kata-containers/runtime/pull/1918 Signed-off-by: Ning Bo --- v2: fix typo --- hw/virtio/vhost-vsock.c | 3 +++ qapi/char.json | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index 0371493..a5920fd 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -22,6 +22,7 @@ #include "qemu/iov.h" #include "qemu/module.h" #include "monitor/monitor.h" +#include "qapi/qapi-events-char.h" =20 enum { VHOST_VSOCK_SAVEVM_VERSION =3D 0, @@ -68,6 +69,8 @@ static int vhost_vsock_set_running(VHostVSock *vsock, int= start) if (ret < 0) { return -errno; } + qapi_event_send_vsock_running(vsock->conf.guest_cid, start !=3D 0); + return 0; } =20 diff --git a/qapi/char.json b/qapi/char.json index a6e81ac..4cfbcf2 100644 --- a/qapi/char.json +++ b/qapi/char.json @@ -570,3 +570,25 @@ { 'event': 'VSERPORT_CHANGE', 'data': { 'id': 'str', 'open': 'bool' } } + +## +# @VSOCK_RUNNING: +# +# Emitted when the guest changes the vsock status. +# +# @cid: guest context ID +# +# @running: true if the vsock is running +# +# Since: 4.2 +# +# Example: +# +# <- { "event": "VSOCK_RUNNING", +# "data": { "cid": "123456", "running": true }, +# "timestamp": { "seconds": 1401385907, "microseconds": 422329 } } +# +## +{ 'event': 'VSOCK_RUNNING', + 'data': { 'cid': 'uint64', + 'running': 'bool' } } --=20 2.9.5