From nobody Mon Feb 9 09:28:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1589556551; cv=none; d=zohomail.com; s=zohoarc; b=WFV7H3LaGoLONWGsbcW/UFXLfOaexRz+L5q7O/o/0+8et2D8fj6YIr0e5G06rMlrCSkH4Cjv3qZS0T9w1p3HiC06zs6dbUsB/PI9UcuOA6PjADM8cF8JP44NfevbI52apIAQzo0dWwkU4hUrqlMVFX4WH+Kb/H7tid72MlCZJWM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589556551; 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=s+vBExE3mYxQbNBCIr4ZpT9hh2sJPm7sCr6xUtPNkv8=; b=JqJDV9VwSVj+Y1llGpUtRp2U5a9pxt55EBnQjfaWDbxJWrJ/QxEVITsgfxJibdHrvPoVZA066AHKBKBy4n4fS9TJ2eIQkkxB0hRTaon1opOaArpPB1Nn/WrMwQXXejRKxfa/l6Yjg0qlkCqMFQy6b6ppPN2VojcKCZdBO6ssUkU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1589556551688145.87368795262012; Fri, 15 May 2020 08:29:11 -0700 (PDT) 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-373-JlaVWxY0PoaEZXxPJML58g-1; Fri, 15 May 2020 11:29:08 -0400 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 BEC86460; Fri, 15 May 2020 15:29:02 +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 A09E062491; Fri, 15 May 2020 15:29:02 +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 7021C180954D; Fri, 15 May 2020 15:29:02 +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 04FFT14v011298 for ; Fri, 15 May 2020 11:29:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0A1D55D9D7; Fri, 15 May 2020 15:29:01 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 789A95D9F5 for ; Fri, 15 May 2020 15:28:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589556550; 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=s+vBExE3mYxQbNBCIr4ZpT9hh2sJPm7sCr6xUtPNkv8=; b=F9rIz/Yw2hgqsXyaCaYaxeFmMoamDkfPGotYWEoepOy7ji3bcSQCpH7tS2dWEQsC20bIPk er6+wAr9NNOGkW1KRCoHW76Rs/cigsnmzuaEc5Pvfwk3Nv5zBR8uRuK5h7inVZsV5IFHuI hT3ZGmx+mwHusfCxoHjbrAUsScWHyng= X-MC-Unique: JlaVWxY0PoaEZXxPJML58g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/21] virCommand: Introduce virCommandGetArgList Date: Fri, 15 May 2020 17:27:55 +0200 Message-Id: <61711e0e2ac77569b0d91393c68dad6ef40cb7cd.1589556042.git.pkrempa@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.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The helper returns a list of arguments of a virCommand. This will be useful in tests where we'll inspect certain already formatted arguments. Signed-off-by: Peter Krempa Reviewed-by: Eric Blake --- src/libvirt_private.syms | 1 + src/util/vircommand.c | 23 +++++++++++++++++++++++ src/util/vircommand.h | 1 + 3 files changed, 25 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 935ef7303b..31813f177f 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1841,6 +1841,7 @@ virCommandDaemonize; virCommandDoAsyncIO; virCommandExec; virCommandFree; +virCommandGetArgList; virCommandGetGID; virCommandGetUID; virCommandHandshakeNotify; diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 20f196104f..aae0ddb730 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -2132,6 +2132,29 @@ virCommandToString(virCommandPtr cmd, bool linebreak= s) } +int +virCommandGetArgList(virCommandPtr cmd, + char ***args, + size_t *nargs) +{ + size_t i; + + if (cmd->has_error) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("invalid use of command API")); + return -1; + } + + *args =3D g_new0(char *, cmd->nargs); + *nargs =3D cmd->nargs - 1; + + for (i =3D 1; i < cmd->nargs; i++) + (*args)[i - 1] =3D g_strdup(cmd->args[i]); + + return 0; +} + + #ifndef WIN32 /* * Manage input and output to the child process. diff --git a/src/util/vircommand.h b/src/util/vircommand.h index e2be5bcf1c..ff8a785dbe 100644 --- a/src/util/vircommand.h +++ b/src/util/vircommand.h @@ -170,6 +170,7 @@ void virCommandWriteArgLog(virCommandPtr cmd, int logfd); char *virCommandToString(virCommandPtr cmd, bool linebreaks) G_GNUC_WARN_U= NUSED_RESULT; +int virCommandGetArgList(virCommandPtr cmd, char ***args, size_t *nargs); int virCommandExec(virCommandPtr cmd, gid_t *groups, int ngroups) G_GNUC_W= ARN_UNUSED_RESULT; --=20 2.26.2