From nobody Mon Feb 9 01:31:04 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=1643899952; cv=none; d=zohomail.com; s=zohoarc; b=cW2SUqXw8QgweqktisxR260sqG3kQlWSPWogUbCbF9CjW4YumvHuP1lA5U4Ub+aRDayTqz5tlPCX4+GJ9hBFRLO9v7f9I285KRvX73UnCp2gcEFmwZBN4hGge6+OyRiDG1MRukd3t2i645GyosNkPUgKOXx79oPF7d7fUCWbjsg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643899952; 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=iGKvT+NDzAJRn6wxyDNYBILdyuPx/qKiqk3CL+/LWlM=; b=Jf2HVvEHCTA7QZRqTLx6LroNT+E0s9JMfdWD2DxSNeonvlk2JTfWvJnqYuzOffma1zEz3qUxiQyyRIhX/i3tXoBB2X3yOeEadiJ9xo5HjpYjbV6PqfiwakRe8XEortZ6ZFOezwAVzlIBLustQXJd5e9TH7BIE/v+1xsGfVi0l7Q= 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 1643899952881137.5588868109436; Thu, 3 Feb 2022 06:52:32 -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-73-29WgSQTtOmGQh61QtzcsvA-1; Thu, 03 Feb 2022 09:52:30 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6715283DC22; Thu, 3 Feb 2022 14:52:25 +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 1CF2B747B3; Thu, 3 Feb 2022 14:52:25 +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 D80D31809CBA; Thu, 3 Feb 2022 14:52:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 213EqCsP029437 for ; Thu, 3 Feb 2022 09:52:12 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6450270D35; Thu, 3 Feb 2022 14:52:12 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9707370D33 for ; Thu, 3 Feb 2022 14:52:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643899952; 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=iGKvT+NDzAJRn6wxyDNYBILdyuPx/qKiqk3CL+/LWlM=; b=B149dSa+z2YjniMW3IDlawkqI0jWrMiwcsiesFSJ5AswKgxk5fI20QYKdLqVknS0hRnoo7 bfdDD021Z+bk/IC/KzTpH8dSUhhJXygus0L5VWiV0LWsO95XAL92wpkgx3dIhDc/KRqLuG poOt2PAjiewu4MuxuyqKCI8XeiludsM= X-MC-Unique: 29WgSQTtOmGQh61QtzcsvA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/5] virsh-domain: Move and rename cmdStartGetFDs to virshFetchPassFdsList Date: Thu, 3 Feb 2022 15:51:57 +0100 Message-Id: <9be807b9f838d0c242d4520fa4961eaba0905af6.1643899820.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.15 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: 1643899954418100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa --- tools/virsh-domain.c | 86 +++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 40 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index b4cb7193a7..0bf4bb8dad 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -225,6 +225,50 @@ virshAddressFormat(virBuffer *buf, } +/** + * virshFetchPassFdsList + * + * Helper to process the 'pass-fds' argument. + */ +static int +virshFetchPassFdsList(vshControl *ctl, + const vshCmd *cmd, + size_t *nfdsret, + int **fdsret) +{ + const char *fdopt; + g_auto(GStrv) fdlist =3D NULL; + g_autofree int *fds =3D NULL; + size_t nfds =3D 0; + size_t i; + + *nfdsret =3D 0; + *fdsret =3D NULL; + + if (vshCommandOptStringQuiet(ctl, cmd, "pass-fds", &fdopt) <=3D 0) + return 0; + + if (!(fdlist =3D g_strsplit(fdopt, ",", -1))) { + vshError(ctl, _("Unable to split FD list '%s'"), fdopt); + return -1; + } + + nfds =3D g_strv_length(fdlist); + fds =3D g_new0(int, nfds); + + for (i =3D 0; fdlist[i] !=3D NULL; i++) { + if (virStrToLong_i(fdlist[i], NULL, 10, fds + i) < 0) { + vshError(ctl, _("Unable to parse FD number '%s'"), fdlist[i]); + return -1; + } + } + + *fdsret =3D g_steal_pointer(&fds); + *nfdsret =3D nfds; + return 0; +} + + #define VIRSH_COMMON_OPT_DOMAIN_PERSISTENT \ {.name =3D "persistent", \ .type =3D VSH_OT_BOOL, \ @@ -4013,44 +4057,6 @@ static const vshCmdOptDef opts_start[] =3D { {.name =3D NULL} }; -static int -cmdStartGetFDs(vshControl *ctl, - const vshCmd *cmd, - size_t *nfdsret, - int **fdsret) -{ - const char *fdopt; - g_auto(GStrv) fdlist =3D NULL; - g_autofree int *fds =3D NULL; - size_t nfds =3D 0; - size_t i; - - *nfdsret =3D 0; - *fdsret =3D NULL; - - if (vshCommandOptStringQuiet(ctl, cmd, "pass-fds", &fdopt) <=3D 0) - return 0; - - if (!(fdlist =3D g_strsplit(fdopt, ",", -1))) { - vshError(ctl, _("Unable to split FD list '%s'"), fdopt); - return -1; - } - - nfds =3D g_strv_length(fdlist); - fds =3D g_new0(int, nfds); - - for (i =3D 0; fdlist[i] !=3D NULL; i++) { - if (virStrToLong_i(fdlist[i], NULL, 10, fds + i) < 0) { - vshError(ctl, _("Unable to parse FD number '%s'"), fdlist[i]); - return -1; - } - } - - *fdsret =3D g_steal_pointer(&fds); - *nfdsret =3D nfds; - return 0; -} - static bool cmdStart(vshControl *ctl, const vshCmd *cmd) { @@ -4072,7 +4078,7 @@ cmdStart(vshControl *ctl, const vshCmd *cmd) return false; } - if (cmdStartGetFDs(ctl, cmd, &nfds, &fds) < 0) + if (virshFetchPassFdsList(ctl, cmd, &nfds, &fds) < 0) return false; if (vshCommandOptBool(cmd, "paused")) @@ -8112,7 +8118,7 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd) if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) return false; - if (cmdStartGetFDs(ctl, cmd, &nfds, &fds) < 0) + if (virshFetchPassFdsList(ctl, cmd, &nfds, &fds) < 0) return false; if (vshCommandOptBool(cmd, "paused")) --=20 2.34.1