From nobody Mon Feb 9 08:30:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1639053365; cv=none; d=zohomail.com; s=zohoarc; b=eUGiZqQq9Gq6QuU0CpNK94Zw4K4d8YXgU/AaTgA0gfcVzqibseB8qUor84uc4BLYobFxLLJ9+Iv4aB49wADEyBnIGR56uQM7h7KqprjCI3+StzOFmOUyCfz4BbxkPHJ2phr20IDY3XT6m08XyiB/OCpFT0nUMVFMWyYwyBreCTo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639053365; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PAJFdARJLjiKdYn6YgQ7Eq/xiBmOwBq3Ymo0cghYak0=; b=bKBfFj+s/Lbz0ay1PGnvigXOdjigEtU6V0B49Hy9Gf9GqZNi3aAzaW0EuYdHsBCL1q638L02h6BFENSN6rEB2hv9jLUMwnwK0QSRjaayIT4viPdFNDfvepSFGAmJ8MKzhVtt76k80g/DDQxI5kXzsKbki+TzFKPFvOBtoNyRn9Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1639053365599321.9220600928421; Thu, 9 Dec 2021 04:36:05 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-7-q0khyRT9MfG5a40Sxbctdg-1; Thu, 09 Dec 2021 07:33:52 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 51EA21017977; Thu, 9 Dec 2021 12:33:46 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 316B660C04; Thu, 9 Dec 2021 12:33:46 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 062B24A70B; Thu, 9 Dec 2021 12:33:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1B9CV8Kw017654 for ; Thu, 9 Dec 2021 07:31:08 -0500 Received: by smtp.corp.redhat.com (Postfix) id E4E0B4ABA1; Thu, 9 Dec 2021 12:31:08 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43EC11B472 for ; Thu, 9 Dec 2021 12:31:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639053364; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=PAJFdARJLjiKdYn6YgQ7Eq/xiBmOwBq3Ymo0cghYak0=; b=YmFY12FJQ4YedYPgkqryDhxNrCswhmFbtRIQvSEdr0ofcxO6Z1awNwVJ/jLp9JiE4zwDum EYMxjZsbWks1fOxP6LwslV1kbaUrlXQ+WIz8CZCaJUCwe5ASP3zAb+OSW85GlSjg6qbUTJ L49+ENWuWVsI8kMhGCgabWbdk4p711M= X-MC-Unique: q0khyRT9MfG5a40Sxbctdg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/24] qemu: Store chardev 'wait' flag in chardev source private data Date: Thu, 9 Dec 2021 13:30:42 +0100 Message-Id: <722de4aab7474c2747581600ee01988787ff09e4.1639052639.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639053366895100001 Content-Type: text/plain; charset="utf-8" We have just one case when we wish to wait for incomming connections for a listening socket and that is for vhost-user network devices. Passing this via a flag to qemuBuildChrChardevStr is unwieldy. Add a field to qemuDomainChrSourcePrivate and populate it for our special case inside of qemuDomainPrepareChardevSourceOne. Since we wait for incomming connections only on startup of a new VM we also need to pass in a flag whether qemuDomainPrepareChardevSourceOne is called on a new start or on hotplug. Signed-off-by: Peter Krempa --- src/qemu/qemu_command.c | 6 +++--- src/qemu/qemu_domain.c | 8 +++++++- src/qemu/qemu_domain.h | 2 ++ src/qemu/qemu_driver.c | 3 ++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index b637cd2bf5..0baf3acde6 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5051,7 +5051,7 @@ qemuBuildChrChardevStr(virLogManager *logManager G_GN= UC_UNUSED, const virDomainChrSourceDef *dev, const char *alias, virQEMUCaps *qemuCaps, - unsigned int cdevflags) + unsigned int cdevflags G_GNUC_UNUSED) { qemuDomainChrSourcePrivate *chrSourcePriv =3D QEMU_DOMAIN_CHR_SOURCE_P= RIVATE(dev); g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; @@ -5148,7 +5148,7 @@ qemuBuildChrChardevStr(virLogManager *logManager G_GN= UC_UNUSED, if (dev->data.tcp.listen) { virBufferAddLit(&buf, ",server=3Don"); - if (cdevflags & QEMU_BUILD_CHARDEV_TCP_NOWAIT) + if (!chrSourcePriv->wait) virBufferAddLit(&buf, ",wait=3Doff"); } @@ -5199,7 +5199,7 @@ qemuBuildChrChardevStr(virLogManager *logManager G_GN= UC_UNUSED, } if (dev->data.nix.listen) { virBufferAddLit(&buf, ",server=3Don"); - if (cdevflags & QEMU_BUILD_CHARDEV_TCP_NOWAIT) + if (!chrSourcePriv->wait) virBufferAddLit(&buf, ",wait=3Doff"); } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 550afca36e..e6d6bf10f1 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9735,6 +9735,7 @@ qemuDomainPrepareChardevSourceOne(virDomainDeviceDef = *dev, void *opaque) { struct qemuDomainPrepareChardevSourceData *data =3D opaque; + qemuDomainChrSourcePrivate *charpriv =3D QEMU_DOMAIN_CHR_SOURCE_PRIVAT= E(charsrc); switch ((virDomainDeviceType) dev->type) { @@ -9750,8 +9751,13 @@ qemuDomainPrepareChardevSourceOne(virDomainDeviceDef= *dev, } break; - case VIR_DOMAIN_DEVICE_DISK: case VIR_DOMAIN_DEVICE_NET: + /* when starting a fresh VM, vhost-user network sockets wait for c= onnection */ + if (!data->hotplug) + charpriv->wait =3D true; + break; + + case VIR_DOMAIN_DEVICE_DISK: case VIR_DOMAIN_DEVICE_SHMEM: case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index f84acf408b..2d93cf2253 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -344,6 +344,7 @@ struct _qemuDomainChrSourcePrivate { int fd; /* file descriptor of the chardev source */ int logfd; /* file descriptor of the logging source */ + bool wait; /* wait for incomming connections on chardev */ }; @@ -866,6 +867,7 @@ int qemuDomainPrepareChannel(virDomainChrDef *chr, struct qemuDomainPrepareChardevSourceData { virQEMUDriverConfig *cfg; + bool hotplug; }; int diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 10feb606ad..4301f3f89e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6794,7 +6794,8 @@ qemuDomainAttachDeviceLive(virDomainObj *vm, int ret =3D -1; const char *alias =3D NULL; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); - struct qemuDomainPrepareChardevSourceData chardevBackendData =3D { .cf= g =3D cfg }; + struct qemuDomainPrepareChardevSourceData chardevBackendData =3D { .cf= g =3D cfg, + .hotp= lug =3D true }; if (qemuDomainDeviceBackendChardevForeachOne(dev, qemuDomainPrepareChardevS= ourceOne, --=20 2.31.1