From nobody Mon Nov 25 10:44:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1606226588; cv=none; d=zohomail.com; s=zohoarc; b=mTkrvQINpjyC5B9MXPPRatCzd3MEi8c7VYlyJC8G/RPAl279B0SzWbOfHBsZo92P8VOgQGqAByLIAYFHb6sL2xlgUoyyr/CgUoGkuezwdWGxG7+N95R0tmXZEW0BUK43dTgRP3EgOIgZA57+nM8J1RYoF1kkqs8sQi5sdQGs4VU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606226588; 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=Bk35r5FhzYNlDF74rIZpQcUDacaWYfaw7HwtM9sqrnk=; b=AL/w5dDtnh7ZNcZT2+FK5b5OcqaV4POEb1BYdJvfYdvyhn6BLVuKrJ/G5rmRuios0C1WSbkv0XVyXR3CX3usbmjdN5FtVFzXMBPIciPbZBkjSskpgSZmrvz/g+e2KL7N+mWEeTuuw0sTNOAf3uIdoV3VrgE/t9CR5kkyy77VdkQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1606226588477548.2076431653369; Tue, 24 Nov 2020 06:03:08 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-176-Olu2mpCKOseyP6aLDuilYg-1; Tue, 24 Nov 2020 09:02:43 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 32F8DAFA97; Tue, 24 Nov 2020 14:02:38 +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 1011A60873; Tue, 24 Nov 2020 14:02:38 +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 C9F601809CA0; Tue, 24 Nov 2020 14:02:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0AOE2a61023727 for ; Tue, 24 Nov 2020 09:02:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id 65D1E5D9CD; Tue, 24 Nov 2020 14:02:36 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2F6F5D9CC for ; Tue, 24 Nov 2020 14:02:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606226566; 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=Bk35r5FhzYNlDF74rIZpQcUDacaWYfaw7HwtM9sqrnk=; b=Al6Ph8m8DuZu5YBtL4S9zY4b3FVXbO4LNDfgnCvBnGGJYTHPOjaMLyQH3FSE+7AbYXfWrE BWPrNSvQ16tmDk+GUYy3BPeOkKCDkj2Cxqe3ITc9wzKQDY8bg/ygyccl49KLbUPgh/UiZq QnfesYn9BI2X5ZSg5npYUHkO15HWh6U= X-MC-Unique: Olu2mpCKOseyP6aLDuilYg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 2/3] qemu: introduce qemuBuildFDSet Date: Tue, 24 Nov 2020 15:02:26 +0100 Message-Id: <804d6035495f44ab1b13b09c74cea2b1fe681296.1606226180.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.13 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) An alternative to qemuVirCommandGetFDSet that takes the index into the passed FD set as an argument and does not try to look it up. Use it as well ass virCommandPassFDIndex in qemuBuildChrChardevFileStr and qemuBuildInterfaceCommandLine. Signed-off-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 479bcc0b0c..d9c6c4bc43 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -224,6 +224,23 @@ qemuBuildMasterKeyCommandLine(virCommandPtr cmd, } =20 =20 +/** + * qemuBuildFDSet: + * @fd: fd to reassign to the child + * @idx: index in the fd set + * + * Format the parameters for the -add-fd command line option + * for the given file descriptor. The file descriptor must previously + * have been 'transferred' in a virCommandPassFDIndex() call, + * and @idx is the value returned by that call. + */ +static char * +qemuBuildFDSet(int fd, size_t idx) +{ + return g_strdup_printf("set=3D%zu,fd=3D%d", idx, fd); +} + + /** * qemuVirCommandGetFDSet: * @cmd: the command to modify @@ -4614,6 +4631,7 @@ qemuBuildChrChardevFileStr(virLogManagerPtr logManage= r, g_autofree char *fdpath =3D NULL; int flags =3D 0; int logfd; + size_t idx; =20 if (appendval =3D=3D VIR_TRISTATE_SWITCH_ABSENT || appendval =3D=3D VIR_TRISTATE_SWITCH_OFF) @@ -4628,9 +4646,8 @@ qemuBuildChrChardevFileStr(virLogManagerPtr logManage= r, NULL, NULL)) < 0) return -1; =20 - virCommandPassFD(cmd, logfd, VIR_COMMAND_PASS_FD_CLOSE_PARENT); - if (!(fdset =3D qemuVirCommandGetFDSet(cmd, logfd))) - return -1; + virCommandPassFDIndex(cmd, logfd, VIR_COMMAND_PASS_FD_CLOSE_PARENT= , &idx); + fdset =3D qemuBuildFDSet(logfd, idx); =20 virCommandAddArg(cmd, "-add-fd"); virCommandAddArg(cmd, fdset); @@ -8183,11 +8200,10 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driv= er, if (vdpafd > 0) { g_autofree char *fdset =3D NULL; g_autofree char *addfdarg =3D NULL; + size_t idx; =20 - virCommandPassFD(cmd, vdpafd, VIR_COMMAND_PASS_FD_CLOSE_PARENT); - fdset =3D qemuVirCommandGetFDSet(cmd, vdpafd); - if (!fdset) - goto cleanup; + virCommandPassFDIndex(cmd, vdpafd, VIR_COMMAND_PASS_FD_CLOSE_PAREN= T, &idx); + fdset =3D qemuBuildFDSet(vdpafd, idx); vdpafdName =3D qemuVirCommandGetDevSet(cmd, vdpafd); /* set opaque to the devicepath so that we can look up the fdset l= ater * if necessary */ --=20 2.26.2