From nobody Mon Feb 9 01:22:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1644422718; cv=none; d=zohomail.com; s=zohoarc; b=DhUSoOG6PQQJee0RC53JwO/cQwhQis+k3mTWcqcsp/BRbfJnyz8ek7Ea3c+fbGcdyf6itc7jOzGbdZjswERaDqE85kvq2hp94KMxXpTfQPeawMOkUyuQ/BAkNm5HXyugohb+66ZO4+Z1sfkWE2KrT5nentU6Vv0Y8yrobPRNXbU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644422718; 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=Wm7FrGVImJ4G8WfPx6n0eSWfJXFysN+ano23/nnapLI=; b=LwE4UnYUa/wQu2/Rf4aIrNKAhicO7qbXpdvnpPoE0ugfArPiun0lW/sFeI6sPkzFcx0J8szrgYweWW6E7nsM4LBQDilX3pnu4VSyi6eyNYKoUDbffZ1P1IgfGDMM4h5e+UNzmdLFh9ZHQWz1QShlGV3ktN2TXoAxl+P+rznZUTA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1644422718174988.8448024441165; Wed, 9 Feb 2022 08:05:18 -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-496-iBqVz1DtOJS8eXHq5msXww-1; Wed, 09 Feb 2022 11:03:47 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C0B5683DE6D; Wed, 9 Feb 2022 16:03:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8BDF37DE40; Wed, 9 Feb 2022 16:03:05 +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 581581802FE9; Wed, 9 Feb 2022 16:03:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 219G2fAS012277 for ; Wed, 9 Feb 2022 11:02:41 -0500 Received: by smtp.corp.redhat.com (Postfix) id DF8AE7DE42; Wed, 9 Feb 2022 16:02:41 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 500367DE40 for ; Wed, 9 Feb 2022 16:02:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644422717; 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=Wm7FrGVImJ4G8WfPx6n0eSWfJXFysN+ano23/nnapLI=; b=HlL3j/sGo5okV3DfLnYgCXgKLgPGUF8T1t+ASstMTltIJvwa+GBG1esTxwDPNMfunJ7Cxm Gg0WJLcLc0sTgdgrlezZVs3zhG3a20qjtRxtkeMQ15w0gGT2r12+tiyp+DMOCS2Q+7JqF/ SKckH/X8ragDv21uhrS1z8LRDRFrrKI= X-MC-Unique: iBqVz1DtOJS8eXHq5msXww-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/27] qemu: domain: Add helper for generating 'fdset' ids for VM startup Date: Wed, 9 Feb 2022 17:02:00 +0100 Message-Id: <4038fc826722f1be992f1dc77070ea6a0a7104f4.1644422239.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.16 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: 1644422719974100003 Content-Type: text/plain; charset="utf-8" When starting a VM we must assign unique IDs for fdsets we add via '-add-fd'. For now it was done by using the index of the filedescriptor passed to the virCommand. That approach is not very flexible, because you need to have already passed the 'fd' to virCommand before generating the fdset path, and also won't nicely work with fdsets containing two or more fds. This patch introduces a counter into the private data of a qemu domain so that we can allocate unique ids without relying on virCommand. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 29 +++++++++++++++++++++++++++++ src/qemu/qemu_domain.h | 4 ++++ 2 files changed, 33 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 64be39d49f..d0abf76e4a 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -683,6 +683,33 @@ qemuDomainStorageIdReset(qemuDomainObjPrivate *priv) } +/** + * qemuDomainFDSetIdNew: + * @priv: qemu VM private data object. + * + * Generate a new unique id for a fdset. Note that this is necessary only = for + * startup. When running qemu auto-assigns id for added fdset. + */ +unsigned int +qemuDomainFDSetIdNew(qemuDomainObjPrivate *priv) +{ + return ++priv->fdsetindex; +} + + +/** + * qemuDomainFDSetIdReset: + * @priv: qemu VM private data object. + * + * Resets the data for the fdset ID generator. + */ +static void +qemuDomainFDSetIdReset(qemuDomainObjPrivate *priv) +{ + priv->fdsetindex =3D 0; +} + + static void qemuDomainSecretInfoClear(qemuDomainSecretInfo *secinfo, bool keepAlias) @@ -1683,6 +1710,8 @@ qemuDomainObjPrivateDataClear(qemuDomainObjPrivate *p= riv) /* reset node name allocator */ qemuDomainStorageIdReset(priv); + qemuDomainFDSetIdReset(priv); + priv->dbusDaemonRunning =3D false; if (priv->dbusVMStateIds) diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 7ec337e9ae..b7d0f5d2d5 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -207,6 +207,9 @@ struct _qemuDomainObjPrivate { /* counter for generating node names for qemu disks */ unsigned long long nodenameindex; + /* counter for generating IDs of fdsets - only relevant during startup= */ + unsigned int fdsetindex; + /* qemuProcessStartCPUs stores the reason for starting vCPUs here for = the * RESUME event handler to use it */ virDomainRunningReason runningReason; @@ -970,6 +973,7 @@ char * qemuDomainGetManagedPRSocketPath(qemuDomainObjPr= ivate *priv); bool qemuDomainDefHasManagedPR(virDomainObj *vm); unsigned int qemuDomainStorageIdNew(qemuDomainObjPrivate *priv); +unsigned int qemuDomainFDSetIdNew(qemuDomainObjPrivate *priv); virDomainEventResumedDetailType qemuDomainRunningReasonToResumeEvent(virDomainRunningReason reason); --=20 2.34.1