From nobody Mon Nov 25 08:41:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1606226655; cv=none; d=zohomail.com; s=zohoarc; b=Wu9u7+MrKqcThMX8Ngeh9MMDmltbzvusDEdlIV6vegbdx6i4Eq+WU7lXYPEiiq1KopAG7e/llil5e5mUoJQn5zWuRv9cdWisgTCn+iOQ/NGqTuFyrWU5z+ncIwKkbO5zVrrnzoA/UyTIpiBmurtU+l7AHIfXMSxUxT0wu8UwZ7A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606226655; 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=v1BbZjRwG4Tay7Z/QAhFTrpNmDmsHoDfZjfIG+QDA88=; b=Ywt1QijPfr75oQAWdk6R5xjTOjt4eRuaieel7I3cnAzPIk0oytRq0AvMrqT1I/1vncfqfcbUivmJwhR5L2RYIJw7eWS35pKNaL7nqXUJ7aaxoYf6poPQZa/gVh6hoNOgzBj04w/JeUUzAItBrzX+Fl6tcud6o9XJtLsLoHhI7Sg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1606226655492427.14748517489363; Tue, 24 Nov 2020 06:04:15 -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-208-R6-6uOgDPSCd5bGezyIC1w-1; Tue, 24 Nov 2020 09:02:45 -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 EDC6CAFA88; Tue, 24 Nov 2020 14:02:39 +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 C872160C66; Tue, 24 Nov 2020 14:02:39 +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 89FFA1809CA3; Tue, 24 Nov 2020 14:02:39 +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 0AOE2Z2Z023720 for ; Tue, 24 Nov 2020 09:02:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id 95FCA5D9E3; Tue, 24 Nov 2020 14:02:35 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1DC385D9CC for ; Tue, 24 Nov 2020 14:02:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606226652; 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=v1BbZjRwG4Tay7Z/QAhFTrpNmDmsHoDfZjfIG+QDA88=; b=YAxfqOBzQEqH30JoDbHBXnfXEztH9WApGseDTfGNTDWOCUZrMs6BmcKGjlhqLILqZw26TO IeTBTAl7cbVB7HTGkhcQA9RNLc1JugZqhvxlm0HSMh4cv8AoUVQCL+apa/a9fdZyGhA0JK 7e4BEbux3zajYlt88K063hmDJJJpm4Y= X-MC-Unique: R6-6uOgDPSCd5bGezyIC1w-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 1/3] util: introduce virCommandPassFDIndex Date: Tue, 24 Nov 2020 15:02:25 +0100 Message-Id: <0db55f37a89ef9769de9010c721d91a58257a9e3.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.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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Just like virCommandPassFD, but it also returns an index of the passed FD in the FD set. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Peter Krempa --- src/libvirt_private.syms | 1 + src/util/vircommand.c | 28 ++++++++++++++++++++++++++-- src/util/vircommand.h | 5 +++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 79a23f34cb..08f16eedb4 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1883,6 +1883,7 @@ virCommandNewVAList; virCommandNonblockingFDs; virCommandPassFD; virCommandPassFDGetFDIndex; +virCommandPassFDIndex; virCommandRawStatus; virCommandRequireHandshake; virCommandRun; diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 9a4f3d7f32..2b9f28a918 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -999,10 +999,11 @@ virCommandNewVAList(const char *binary, va_list list) VIR_FORCE_CLOSE(fd) =20 /** - * virCommandPassFD: + * virCommandPassFDIndex: * @cmd: the command to modify * @fd: fd to reassign to the child * @flags: extra flags; binary-OR of virCommandPassFDFlags + * @idx: pointer to fill with the index of the FD in the transfer set * * Transfer the specified file descriptor to the child, instead * of closing it on exec. @fd must not be one of the three @@ -1013,7 +1014,7 @@ virCommandNewVAList(const char *binary, va_list list) * should cease using the @fd when this call completes */ void -virCommandPassFD(virCommandPtr cmd, int fd, unsigned int flags) +virCommandPassFDIndex(virCommandPtr cmd, int fd, unsigned int flags, size_= t *idx) { int ret =3D 0; =20 @@ -1037,6 +1038,29 @@ virCommandPassFD(virCommandPtr cmd, int fd, unsigned= int flags) VIR_COMMAND_MAYBE_CLOSE_FD(fd, flags); return; } + + if (idx) + *idx =3D cmd->npassfd - 1; +} + +/** + * virCommandPassFD: + * @cmd: the command to modify + * @fd: fd to reassign to the child + * @flags: extra flags; binary-OR of virCommandPassFDFlags + * + * Transfer the specified file descriptor to the child, instead + * of closing it on exec. @fd must not be one of the three + * standard streams. + * + * If the flag VIR_COMMAND_PASS_FD_CLOSE_PARENT is set then fd will + * be closed in the parent no later than Run/RunAsync/Free. The parent + * should cease using the @fd when this call completes + */ +void +virCommandPassFD(virCommandPtr cmd, int fd, unsigned int flags) +{ + virCommandPassFDIndex(cmd, fd, flags, NULL); } =20 /* diff --git a/src/util/vircommand.h b/src/util/vircommand.h index e12c88bcc3..0ea6c8229f 100644 --- a/src/util/vircommand.h +++ b/src/util/vircommand.h @@ -57,6 +57,11 @@ void virCommandPassFD(virCommandPtr cmd, int fd, unsigned int flags) G_GNUC_NO_INLINE; =20 +void virCommandPassFDIndex(virCommandPtr cmd, + int fd, + unsigned int flags, + size_t *idx) G_GNUC_NO_INLINE; + int virCommandPassFDGetFDIndex(virCommandPtr cmd, int fd); =20 --=20 2.26.2 From nobody Mon Nov 25 08:41:26 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 Reviewed-by: Peter Krempa --- 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 From nobody Mon Nov 25 08:41:26 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=1606226908; cv=none; d=zohomail.com; s=zohoarc; b=FluXA+88MBThCqqKsfetLlXQJQYWF25+PxfVrk90YHy51mmsZTHF+OTwZG4ao9I59VkYv3UEn7byMg5KFnDFKqwxbV+7HCCgNGVFfhEwCFNmp1lX6En63mRy+D8B5Lj/NxKSrfs6HO1z4bbP54YuMptqwB5qj9sjlBQnyKCViOY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606226908; 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=KnA7dBpb/tBz+9vI51FR7gPKqHoFZdmi2HUVawshOAg=; b=HUhwN3MQ10OUleExrsmv628NVP2iBhIg+P27dsxWRJiI67DoyevQDMsuJh4bfe4xk/gzJv9wUS06uOdM2CwIIxpRHInvflE4zpcdg1dhGxLqOtLDSmFI/DVgA7M60Hl02G+JLdEThXqQzv5NCGVZryitnKQniZw+DoszKXZX/58= 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 1606226908367105.42068079183764; Tue, 24 Nov 2020 06:08:28 -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-318-IWYWauHKPMyELEgAUXuWlQ-1; Tue, 24 Nov 2020 09:02:51 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 40169805BE0; Tue, 24 Nov 2020 14:02:41 +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 0E29019C71; Tue, 24 Nov 2020 14:02:41 +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 C6F6B57682; Tue, 24 Nov 2020 14:02:40 +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 0AOE2buN023732 for ; Tue, 24 Nov 2020 09:02:37 -0500 Received: by smtp.corp.redhat.com (Postfix) id 35AC05D9CD; Tue, 24 Nov 2020 14:02:37 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id B2D3E5D9CC for ; Tue, 24 Nov 2020 14:02:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606226575; 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=KnA7dBpb/tBz+9vI51FR7gPKqHoFZdmi2HUVawshOAg=; b=Av9KJOLAPsfTbk/WvWdmEPm7aCvf8Jn3Z85AV3QFHLyXHW2umXy0DS8K/gxj0ur2aVAchx JFRbRFm67/CljZvvuCkjV4VhHZ7YurlW4U31z6CPBnLt0t26rtQBsXLox5lJawRjaQdTrw r3EcIMrDqMS/sEDLxmNs/vFQt5B8MaI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606226907; 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=KnA7dBpb/tBz+9vI51FR7gPKqHoFZdmi2HUVawshOAg=; b=cq1h0klVs3jhYIHnIk6A+I6XHpVwOQSS6ncyqUiaZp4loneF8woPeWjnlpSfylZHETxnYX SAyRN9iOLSQSy+W4gM0+aZpj1pAwS1rxaYH+L9REkGvohgqAYIBVoCZUJUJwn985Ijbnbi f8wuAL2ZZ3GBm5cUwj1qBzKC6M7+mSU= X-MC-Unique: IWYWauHKPMyELEgAUXuWlQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 3/3] qemu: use qemuVirCommandGetDevSet less Date: Tue, 24 Nov 2020 15:02:27 +0100 Message-Id: <6076ad81b8530022d15db0117ca8c53a04a6989d.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.84 on 10.5.11.23 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) (identity @redhat.com) Do not look up the index of the passed FD in places where we already have it. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Peter Krempa --- src/qemu/qemu_command.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index d9c6c4bc43..33f9b96bf8 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4628,7 +4628,6 @@ qemuBuildChrChardevFileStr(virLogManagerPtr logManage= r, { if (logManager) { g_autofree char *fdset =3D NULL; - g_autofree char *fdpath =3D NULL; int flags =3D 0; int logfd; size_t idx; @@ -4652,10 +4651,7 @@ qemuBuildChrChardevFileStr(virLogManagerPtr logManag= er, virCommandAddArg(cmd, "-add-fd"); virCommandAddArg(cmd, fdset); =20 - if (!(fdpath =3D qemuVirCommandGetDevSet(cmd, logfd))) - return -1; - - virBufferAsprintf(buf, ",%s=3D%s,%s=3Don", filearg, fdpath, append= arg); + virBufferAsprintf(buf, ",%s=3D/dev/fdset/%zu,%s=3Don", filearg, id= x, appendarg); } else { virBufferAsprintf(buf, ",%s=3D", filearg); virQEMUBuildBufferEscapeComma(buf, fileval); @@ -8204,7 +8200,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, =20 virCommandPassFDIndex(cmd, vdpafd, VIR_COMMAND_PASS_FD_CLOSE_PAREN= T, &idx); fdset =3D qemuBuildFDSet(vdpafd, idx); - vdpafdName =3D qemuVirCommandGetDevSet(cmd, vdpafd); + vdpafdName =3D g_strdup_printf("/dev/fdset/%zu", idx); /* set opaque to the devicepath so that we can look up the fdset l= ater * if necessary */ addfdarg =3D g_strdup_printf("%s,opaque=3D%s", fdset, --=20 2.26.2