From nobody Sat Apr 27 20:59:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; 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 205.139.110.61 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=1587574362; cv=none; d=zohomail.com; s=zohoarc; b=C/GZFnTlKEfYNc+zTASRPFmi11EmPbthLnxcBbAOlSiCoKELphBWNAt7Q7bC1IKjxfEbGdj3y0wl5QV/E8WiNMXl8xx/ineO6IEQoWamnEqCNTobXpi3qBgDA3w/WE9kVIwsFBjPEiPsmzV70Lo9gFo1pUKITzUmFmg3MEMZ+08= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587574362; 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=qi+9A+eBFw0fRw9L8nUqkznNmjW995c1KRB2okY1IZU=; b=OCUqCYexqSCl0xowfzDxSmBcuRfcEMlhTk/MJb+ZLYpfFSBwArFGpr0Q7p9JEG3FIYcwR15ginX2EOoKjd3+lnkgwZvSU9phBXD1miMuiutYrra9qw2Bytlo7ioEYW7ObxmJlPO8uvrkT8PLhttWJPde6Vy9cT96cwkCz+s/jKg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1587574362732943.0528009707391; Wed, 22 Apr 2020 09:52:42 -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-196-dIuXezZ6NVGZNpZ6OxK_vA-1; Wed, 22 Apr 2020 12:52:33 -0400 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 0F07B8010FB; Wed, 22 Apr 2020 16:52:28 +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 D6BCF19C70; Wed, 22 Apr 2020 16:52:27 +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 7A88B941C3; Wed, 22 Apr 2020 16:52:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 03MGqOKW023220 for ; Wed, 22 Apr 2020 12:52:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id CA95C5D710; Wed, 22 Apr 2020 16:52:24 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.40.208.78]) by smtp.corp.redhat.com (Postfix) with ESMTP id 13CE65D70A for ; Wed, 22 Apr 2020 16:52:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587574361; 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=qi+9A+eBFw0fRw9L8nUqkznNmjW995c1KRB2okY1IZU=; b=hJsjuFqcUj0ebX/ZtYGFgxbb66GKkMdRQ2XoCnGuPBlvJyjaXkplHcFlZBVGgG9DDnWcMh 2bdwD5jJXcBElVqjHcjPnDLn3RWHEM/lc2n6hOU+vcn95dJSIfs9HanDQaCrlzvc2ISgCg 6JIg2QS8FqcMHB+JswcNllkj3jw14V8= X-MC-Unique: dIuXezZ6NVGZNpZ6OxK_vA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 1/5] openvz: switch from virRun to virCommand Date: Wed, 22 Apr 2020 18:52:16 +0200 Message-Id: <65f50ef15984324683263f9e6202621589fbf5c4.1587574318.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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 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" Construct the command in multiple steps instead of using a sentinel in the args array. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/openvz/openvz_driver.c | 96 +++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 54 deletions(-) diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 1a189dbbe7..0a08c63b1b 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -481,30 +481,11 @@ static char *openvzDomainGetXMLDesc(virDomainPtr dom,= unsigned int flags) { } =20 =20 -/* - * Convenient helper to target a command line argv - * and fill in an empty slot with the supplied - * key value. This lets us declare the argv on the - * stack and just splice in the domain name after - */ -#define PROGRAM_SENTINEL ((char *)0x1) -static void openvzSetProgramSentinal(const char **prog, const char *key) -{ - const char **tmp =3D prog; - while (tmp && *tmp) { - if (*tmp =3D=3D PROGRAM_SENTINEL) { - *tmp =3D key; - break; - } - tmp++; - } -} - static int openvzDomainSuspend(virDomainPtr dom) { + g_autoptr(virCommand) cmd =3D virCommandNewArgList(VZCTL, "--quiet", "= chkpnt", NULL); struct openvz_driver *driver =3D dom->conn->privateData; virDomainObjPtr vm; - const char *prog[] =3D {VZCTL, "--quiet", "chkpnt", PROGRAM_SENTINEL, = "--suspend", NULL}; int ret =3D -1; =20 if (!(vm =3D openvzDomObjFromDomain(driver, dom->uuid))) @@ -514,8 +495,8 @@ static int openvzDomainSuspend(virDomainPtr dom) goto cleanup; =20 if (virDomainObjGetState(vm, NULL) !=3D VIR_DOMAIN_PAUSED) { - openvzSetProgramSentinal(prog, vm->def->name); - if (virRun(prog, NULL) < 0) + virCommandAddArgList(cmd, vm->def->name, "--suspend", NULL); + if (virCommandRun(cmd, NULL) < 0) goto cleanup; virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_USER= ); } @@ -529,9 +510,9 @@ static int openvzDomainSuspend(virDomainPtr dom) =20 static int openvzDomainResume(virDomainPtr dom) { + g_autoptr(virCommand) cmd =3D virCommandNewArgList(VZCTL, "--quiet", "= chkpnt", NULL); struct openvz_driver *driver =3D dom->conn->privateData; virDomainObjPtr vm; - const char *prog[] =3D {VZCTL, "--quiet", "chkpnt", PROGRAM_SENTINEL, = "--resume", NULL}; int ret =3D -1; =20 if (!(vm =3D openvzDomObjFromDomain(driver, dom->uuid))) @@ -541,8 +522,8 @@ static int openvzDomainResume(virDomainPtr dom) goto cleanup; =20 if (virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_PAUSED) { - openvzSetProgramSentinal(prog, vm->def->name); - if (virRun(prog, NULL) < 0) + virCommandAddArgList(cmd, vm->def->name, "--resume", NULL); + if (virCommandRun(cmd, NULL) < 0) goto cleanup; virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_UN= PAUSED); } @@ -558,9 +539,9 @@ static int openvzDomainShutdownFlags(virDomainPtr dom, unsigned int flags) { + g_autoptr(virCommand) cmd =3D virCommandNewArgList(VZCTL, "--quiet", "= stop", NULL); struct openvz_driver *driver =3D dom->conn->privateData; virDomainObjPtr vm; - const char *prog[] =3D {VZCTL, "--quiet", "stop", PROGRAM_SENTINEL, NU= LL}; int ret =3D -1; int status; =20 @@ -572,14 +553,15 @@ openvzDomainShutdownFlags(virDomainPtr dom, if (openvzGetVEStatus(vm, &status, NULL) =3D=3D -1) goto cleanup; =20 - openvzSetProgramSentinal(prog, vm->def->name); if (status !=3D VIR_DOMAIN_RUNNING) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("domain is not in running state")); goto cleanup; } =20 - if (virRun(prog, NULL) < 0) + virCommandAddArg(cmd, vm->def->name); + + if (virCommandRun(cmd, NULL) < 0) goto cleanup; =20 vm->def->id =3D -1; @@ -613,9 +595,9 @@ openvzDomainDestroyFlags(virDomainPtr dom, unsigned int= flags) static int openvzDomainReboot(virDomainPtr dom, unsigned int flags) { + g_autoptr(virCommand) cmd =3D virCommandNewArgList(VZCTL, "--quiet", "= restart", NULL); struct openvz_driver *driver =3D dom->conn->privateData; virDomainObjPtr vm; - const char *prog[] =3D {VZCTL, "--quiet", "restart", PROGRAM_SENTINEL,= NULL}; int ret =3D -1; int status; =20 @@ -627,15 +609,16 @@ static int openvzDomainReboot(virDomainPtr dom, if (openvzGetVEStatus(vm, &status, NULL) =3D=3D -1) goto cleanup; =20 - openvzSetProgramSentinal(prog, vm->def->name); if (status !=3D VIR_DOMAIN_RUNNING) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("domain is not in running state")); goto cleanup; } =20 - if (virRun(prog, NULL) < 0) + virCommandAddArg(cmd, vm->def->name); + if (virCommandRun(cmd, NULL) < 0) goto cleanup; + ret =3D 0; =20 virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_BOOTED= ); @@ -935,11 +918,11 @@ static virDomainPtr openvzDomainCreateXML(virConnectPtr conn, const char *xml, unsigned int flags) { + g_autoptr(virCommand) cmd =3D virCommandNewArgList(VZCTL, "--quiet", "= start", NULL); struct openvz_driver *driver =3D conn->privateData; virDomainDefPtr vmdef =3D NULL; virDomainObjPtr vm =3D NULL; virDomainPtr dom =3D NULL; - const char *progstart[] =3D {VZCTL, "--quiet", "start", PROGRAM_SENTIN= EL, NULL}; unsigned int parse_flags =3D VIR_DOMAIN_DEF_PARSE_INACTIVE; =20 virCheckFlags(VIR_DOMAIN_START_VALIDATE, NULL); @@ -986,9 +969,9 @@ openvzDomainCreateXML(virConnectPtr conn, const char *x= ml, if (openvzDomainSetNetworkConfig(conn, vm->def) < 0) goto cleanup; =20 - openvzSetProgramSentinal(progstart, vm->def->name); + virCommandAddArg(cmd, vm->def->name); =20 - if (virRun(progstart, NULL) < 0) + if (virCommandRun(cmd, NULL) < 0) goto cleanup; =20 vm->pid =3D strtoI(vm->def->name); @@ -1016,9 +999,9 @@ openvzDomainCreateXML(virConnectPtr conn, const char *= xml, static int openvzDomainCreateWithFlags(virDomainPtr dom, unsigned int flags) { + g_autoptr(virCommand) cmd =3D virCommandNewArgList(VZCTL, "--quiet", "= start", NULL); struct openvz_driver *driver =3D dom->conn->privateData; virDomainObjPtr vm; - const char *prog[] =3D {VZCTL, "--quiet", "start", PROGRAM_SENTINEL, N= ULL }; int ret =3D -1; int status; =20 @@ -1043,8 +1026,9 @@ openvzDomainCreateWithFlags(virDomainPtr dom, unsigne= d int flags) goto cleanup; } =20 - openvzSetProgramSentinal(prog, vm->def->name); - if (virRun(prog, NULL) < 0) + virCommandAddArg(cmd, vm->def->name); + + if (virCommandRun(cmd, NULL) < 0) goto cleanup; =20 vm->pid =3D strtoI(vm->def->name); @@ -1068,9 +1052,9 @@ static int openvzDomainUndefineFlags(virDomainPtr dom, unsigned int flags) { + g_autoptr(virCommand) cmd =3D virCommandNewArgList(VZCTL, "--quiet", "= start", "destroy", NULL); struct openvz_driver *driver =3D dom->conn->privateData; virDomainObjPtr vm; - const char *prog[] =3D { VZCTL, "--quiet", "destroy", PROGRAM_SENTINEL= , NULL }; int ret =3D -1; int status; =20 @@ -1083,8 +1067,9 @@ openvzDomainUndefineFlags(virDomainPtr dom, if (openvzGetVEStatus(vm, &status, NULL) =3D=3D -1) goto cleanup; =20 - openvzSetProgramSentinal(prog, vm->def->name); - if (virRun(prog, NULL) < 0) + virCommandAddArg(cmd, vm->def->name); + + if (virCommandRun(cmd, NULL) < 0) goto cleanup; =20 if (virDomainObjIsActive(vm)) @@ -1110,17 +1095,19 @@ openvzDomainSetAutostart(virDomainPtr dom, int auto= start) { struct openvz_driver *driver =3D dom->conn->privateData; virDomainObjPtr vm; - const char *prog[] =3D { VZCTL, "--quiet", "set", PROGRAM_SENTINEL, - "--onboot", autostart ? "yes" : "no", - "--save", NULL }; + g_autoptr(virCommand) cmd =3D virCommandNewArgList(VZCTL, "--quiet", N= ULL); int ret =3D -1; =20 if (!(vm =3D openvzDomObjFromDomain(driver, dom->uuid))) return -1; =20 - openvzSetProgramSentinal(prog, vm->def->name); - if (virRun(prog, NULL) < 0) + virCommandAddArgList(cmd, "set", vm->def->name, + "--onboot", autostart ? "yes" : "no", + "--save", NULL); + + if (virCommandRun(cmd, NULL) < 0) goto cleanup; + ret =3D 0; =20 cleanup: @@ -1191,9 +1178,8 @@ static int openvzDomainSetVcpusInternal(virDomainObjP= tr vm, unsigned int nvcpus, virDomainXMLOptionPtr xmlopt) { + g_autoptr(virCommand) cmd =3D virCommandNewArgList(VZCTL, "--quiet", N= ULL); char str_vcpus[32]; - const char *prog[] =3D { VZCTL, "--quiet", "set", PROGRAM_SENTINEL, - "--cpus", str_vcpus, "--save", NULL }; unsigned int pcpus; pcpus =3D virHostCPUGetCount(); if (pcpus > 0 && pcpus < nvcpus) @@ -1201,8 +1187,10 @@ static int openvzDomainSetVcpusInternal(virDomainObj= Ptr vm, =20 g_snprintf(str_vcpus, sizeof(str_vcpus), "%d", nvcpus); =20 - openvzSetProgramSentinal(prog, vm->def->name); - if (virRun(prog, NULL) < 0) + virCommandAddArgList(cmd, "set", vm->def->name, + "--cpus", str_vcpus, "--save", NULL); + + if (virCommandRun(cmd, NULL) < 0) return -1; =20 if (virDomainDefSetVcpusMax(vm->def, nvcpus, xmlopt) < 0) @@ -1544,16 +1532,16 @@ static int openvzDomainSetMemoryInternal(virDomainObjPtr vm, unsigned long long mem) { + g_autoptr(virCommand) cmd =3D virCommandNewArgList(VZCTL, "--quiet", N= ULL); char str_mem[16]; - const char *prog[] =3D { VZCTL, "--quiet", "set", PROGRAM_SENTINEL, - "--kmemsize", str_mem, "--save", NULL - }; =20 /* memory has to be changed its format from kbyte to byte */ g_snprintf(str_mem, sizeof(str_mem), "%llu", mem * 1024); =20 - openvzSetProgramSentinal(prog, vm->def->name); - if (virRun(prog, NULL) < 0) + virCommandAddArgList(cmd, "set", vm->def->name, + "--kmemsize", str_mem, "--save", NULL); + + if (virCommandRun(cmd, NULL) < 0) return -1; =20 return 0; --=20 2.25.1 From nobody Sat Apr 27 20:59:51 2024 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=1587574365; cv=none; d=zohomail.com; s=zohoarc; b=bq81r7mNMaLtSZIWqSQPQxs8y8tbyF1U4QgZuDZVVhcrlwpMnVLjajJ2auKPGjfXsGDZsYmqZimYruS34H9MIQwSB8LQd3OBj58w1M5D1scVFySvHHSvMOydqT+VjhaKRgc36WbXSfmCYCcB89r9JMJyijIu8k2XpVxa2VvIOLI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587574365; 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=Mdwr2N6WWbLbBRZvL+DLkcuxG07zuyt/Xo3JlWZ1NPw=; b=DWwLW9e9A/XqV2Rb0UjPKTxEs55/BgY15fQwypfQ6lnXT9hcb+d3XVQVdFg4h3ymz9TD/Ob8kd40RmRryYHlWUt+wj5DHl8HjEzwxJdCuDral+O4lj8rS/7iDQFstrEi8LEOqSAijzQ+FOP2S+nyjPl+jyCFirHWcH34ZAzd9kk= 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 1587574365519571.3654392188128; Wed, 22 Apr 2020 09:52:45 -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-393-5q7qf_JIMBKSYS0d94Y2Zw-1; Wed, 22 Apr 2020 12:52:41 -0400 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 2940019251A3; Wed, 22 Apr 2020 16:52:32 +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 EF00919C70; Wed, 22 Apr 2020 16:52:31 +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 9FD2C180954D; Wed, 22 Apr 2020 16:52:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 03MGqPKX023233 for ; Wed, 22 Apr 2020 12:52:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id B68695D710; Wed, 22 Apr 2020 16:52:25 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.40.208.78]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2C5255D70A for ; Wed, 22 Apr 2020 16:52:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587574364; 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=Mdwr2N6WWbLbBRZvL+DLkcuxG07zuyt/Xo3JlWZ1NPw=; b=adPEGl6dBG0FiutMM4lOdNBUVD77g20M+qUczBfcx1HbscQkQB15yiH2r2e7MT4FGZdXpw gmOUjDkq00r+f2pYxr4M74h1B1fTS1ynM5xjneiptahC0xekqUqlDaQRtWhCG4NswDH4++ /CTIPYshZDCcXWICpxkTNM0s4apEpMQ= X-MC-Unique: 5q7qf_JIMBKSYS0d94Y2Zw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 2/5] vmware: use virCommand instead of virRun Date: Wed, 22 Apr 2020 18:52:17 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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 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" Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/vmware/vmware_conf.c | 9 +++-- src/vmware/vmware_driver.c | 69 ++++++++++++++++---------------------- 2 files changed, 32 insertions(+), 46 deletions(-) diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c index fd62bb96f7..8bea9c3b12 100644 --- a/src/vmware/vmware_conf.c +++ b/src/vmware/vmware_conf.c @@ -436,8 +436,7 @@ vmwareVmxPath(virDomainDefPtr vmdef, char **vmxPath) int vmwareMoveFile(char *srcFile, char *dstFile) { - const char *cmdmv[] =3D - { "mv", PROGRAM_SENTINEL, PROGRAM_SENTINEL, NULL }; + g_autoptr(virCommand) cmd =3D NULL; =20 if (!virFileExists(srcFile)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("file %s does not exist"), @@ -448,9 +447,9 @@ vmwareMoveFile(char *srcFile, char *dstFile) if (STREQ(srcFile, dstFile)) return 0; =20 - vmwareSetSentinal(cmdmv, srcFile); - vmwareSetSentinal(cmdmv, dstFile); - if (virRun(cmdmv, NULL) < 0) { + cmd =3D virCommandNewArgList("mv", srcFile, dstFile, NULL); + + if (virCommandRun(cmd, NULL) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to move file to %s "), dstFile); return -1; diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index d5dd6e4f5e..5b4057a8f6 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -347,15 +347,12 @@ vmwareStopVM(struct vmware_driver *driver, virDomainObjPtr vm, virDomainShutoffReason reason) { - const char *cmd[] =3D { - driver->vmrun, "-T", PROGRAM_SENTINEL, "stop", - PROGRAM_SENTINEL, "soft", NULL - }; + g_autoptr(virCommand) cmd =3D virCommandNew(driver->vmrun); =20 - vmwareSetSentinal(cmd, vmwareDriverTypeToString(driver->type)); - vmwareSetSentinal(cmd, ((vmwareDomainPtr) vm->privateData)->vmxPath); + virCommandAddArgList(cmd, "-T", vmwareDriverTypeToString(driver->type), + "stop", ((vmwareDomainPtr) vm->privateData)->vmxPath, "soft", NULL= ); =20 - if (virRun(cmd, NULL) < 0) + if (virCommandRun(cmd, NULL) < 0) return -1; =20 vm->def->id =3D -1; @@ -367,26 +364,22 @@ vmwareStopVM(struct vmware_driver *driver, static int vmwareStartVM(struct vmware_driver *driver, virDomainObjPtr vm) { - const char *cmd[] =3D { - driver->vmrun, "-T", PROGRAM_SENTINEL, "start", - PROGRAM_SENTINEL, PROGRAM_SENTINEL, NULL - }; + g_autoptr(virCommand) cmd =3D virCommandNew(driver->vmrun); const char *vmxPath =3D ((vmwareDomainPtr) vm->privateData)->vmxPath; =20 + virCommandAddArgList(cmd, "-T", vmwareDriverTypeToString(driver->type), + "start", vmxPath, NULL); + if (virDomainObjGetState(vm, NULL) !=3D VIR_DOMAIN_SHUTOFF) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("domain is not in shutoff state")); return -1; } =20 - vmwareSetSentinal(cmd, vmwareDriverTypeToString(driver->type)); - vmwareSetSentinal(cmd, vmxPath); if (!((vmwareDomainPtr) vm->privateData)->gui) - vmwareSetSentinal(cmd, NOGUI); - else - vmwareSetSentinal(cmd, NULL); + virCommandAddArg(cmd, NOGUI); =20 - if (virRun(cmd, NULL) < 0) + if (virCommandRun(cmd, NULL) < 0) return -1; =20 if ((vm->def->id =3D vmwareExtractPid(vmxPath)) < 0) { @@ -543,12 +536,9 @@ static int vmwareDomainSuspend(virDomainPtr dom) { struct vmware_driver *driver =3D dom->conn->privateData; + g_autoptr(virCommand) cmd =3D virCommandNew(driver->vmrun); =20 virDomainObjPtr vm; - const char *cmd[] =3D { - driver->vmrun, "-T", PROGRAM_SENTINEL, "pause", - PROGRAM_SENTINEL, NULL - }; int ret =3D -1; =20 if (driver->type =3D=3D VMWARE_DRIVER_PLAYER) { @@ -561,15 +551,17 @@ vmwareDomainSuspend(virDomainPtr dom) if (!(vm =3D vmwareDomObjFromDomain(driver, dom->uuid))) return -1; =20 - vmwareSetSentinal(cmd, vmwareDriverTypeToString(driver->type)); - vmwareSetSentinal(cmd, ((vmwareDomainPtr) vm->privateData)->vmxPath); if (virDomainObjGetState(vm, NULL) !=3D VIR_DOMAIN_RUNNING) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("domain is not in running state")); goto cleanup; } =20 - if (virRun(cmd, NULL) < 0) + virCommandAddArgList(cmd, "-T", vmwareDriverTypeToString(driver->type), + "pause", ((vmwareDomainPtr) vm->privateData)->vmx= Path, + NULL); + + if (virCommandRun(cmd, NULL) < 0) goto cleanup; =20 virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_USER); @@ -584,12 +576,9 @@ static int vmwareDomainResume(virDomainPtr dom) { struct vmware_driver *driver =3D dom->conn->privateData; + g_autoptr(virCommand) cmd =3D virCommandNew(driver->vmrun); =20 virDomainObjPtr vm; - const char *cmd[] =3D { - driver->vmrun, "-T", PROGRAM_SENTINEL, "unpause", PROGRAM_SENTINEL, - NULL - }; int ret =3D -1; =20 if (driver->type =3D=3D VMWARE_DRIVER_PLAYER) { @@ -602,15 +591,17 @@ vmwareDomainResume(virDomainPtr dom) if (!(vm =3D vmwareDomObjFromDomain(driver, dom->uuid))) return -1; =20 - vmwareSetSentinal(cmd, vmwareDriverTypeToString(driver->type)); - vmwareSetSentinal(cmd, ((vmwareDomainPtr) vm->privateData)->vmxPath); if (virDomainObjGetState(vm, NULL) !=3D VIR_DOMAIN_PAUSED) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("domain is not in suspend state")); goto cleanup; } =20 - if (virRun(cmd, NULL) < 0) + virCommandAddArgList(cmd, "-T", vmwareDriverTypeToString(driver->type), + "unpause", ((vmwareDomainPtr) vm->privateData)->v= mxPath, + NULL); + + if (virCommandRun(cmd, NULL) < 0) goto cleanup; =20 virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_UNPAUS= ED); @@ -625,12 +616,8 @@ static int vmwareDomainReboot(virDomainPtr dom, unsigned int flags) { struct vmware_driver *driver =3D dom->conn->privateData; - const char * vmxPath =3D NULL; + g_autoptr(virCommand) cmd =3D virCommandNew(driver->vmrun); virDomainObjPtr vm; - const char *cmd[] =3D { - driver->vmrun, "-T", PROGRAM_SENTINEL, - "reset", PROGRAM_SENTINEL, "soft", NULL - }; int ret =3D -1; =20 virCheckFlags(0, -1); @@ -638,10 +625,6 @@ vmwareDomainReboot(virDomainPtr dom, unsigned int flag= s) if (!(vm =3D vmwareDomObjFromDomain(driver, dom->uuid))) return -1; =20 - vmxPath =3D ((vmwareDomainPtr) vm->privateData)->vmxPath; - vmwareSetSentinal(cmd, vmwareDriverTypeToString(driver->type)); - vmwareSetSentinal(cmd, vmxPath); - if (vmwareUpdateVMStatus(driver, vm) < 0) goto cleanup; =20 @@ -651,7 +634,11 @@ vmwareDomainReboot(virDomainPtr dom, unsigned int flag= s) goto cleanup; } =20 - if (virRun(cmd, NULL) < 0) + virCommandAddArgList(cmd, "-T", vmwareDriverTypeToString(driver->type), + "reset", ((vmwareDomainPtr) vm->privateData)->vmx= Path, + "soft", NULL); + + if (virCommandRun(cmd, NULL) < 0) goto cleanup; =20 ret =3D 0; --=20 2.25.1 From nobody Sat Apr 27 20:59:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1587574367; cv=none; d=zohomail.com; s=zohoarc; b=oL9l94pJuz6ecoNnO4+l8rmNCnrv9X73q4OziX2cP8BSVcY6c+uQXHlWi2Y/40CjT7qMqYVF7q5v7z6YWSpj5N8As2d8w50nBoZ39gcqwNdkDhAtD0/ivLxWcaj9iJ/s/XmkNilWpDCfBYGvSU/hBlFtARcfz8TR0wZuRRFHpjY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587574367; 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=tNU1IFVa4iyIfIIAKHs3/YyeHjuIsVrPMU5yJQktIB4=; b=jc/4RrI03DWpXZMrn1uxvB6kHscJLUw79dSzaIos7LvtmdHNYq+iJK6ZncFfRuFzSKh6u/NGesDiJ7NqDD7Wp33HkrHjGMR3wp72/8EnaqfINCF2wEbvXjzNMr+NZvRo0h+MuF43hozLkTZMk8TPJzwfDuKAOxPoamlD/01CwT0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1587574367010418.533694356786; Wed, 22 Apr 2020 09:52:47 -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-504-qcF3_sHVPY6PISiWzlgcZg-1; Wed, 22 Apr 2020 12:52:39 -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 84CCEDB25; Wed, 22 Apr 2020 16:52:31 +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 5E1395D714; Wed, 22 Apr 2020 16:52:31 +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 0F4D01809541; Wed, 22 Apr 2020 16:52:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 03MGqRso023243 for ; Wed, 22 Apr 2020 12:52:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 03DB05D715; Wed, 22 Apr 2020 16:52:27 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.40.208.78]) by smtp.corp.redhat.com (Postfix) with ESMTP id 17C8A5D70A for ; Wed, 22 Apr 2020 16:52:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587574365; 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=tNU1IFVa4iyIfIIAKHs3/YyeHjuIsVrPMU5yJQktIB4=; b=NFatezgWQDirSfKfF75W805jtGMQ0tg64cSWojmsn82FkgFGXGefBCOIuOh+s1mDo3NtcF wP23uEFs/jNAngdxYeRpjlHHG9ugpTILzZ4HiywJZU2Ubb35vEi8oxlEdgYr++y+nzeAPa B1vwQo+bTyZCZ0Q3qOPxylTearlkb/c= X-MC-Unique: qcF3_sHVPY6PISiWzlgcZg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 3/5] Remove all usage of virRun Date: Wed, 22 Apr 2020 18:52:18 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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" Catch the individual usage not removed in previous commits. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/lxc/lxc_driver.c | 5 +++-- src/qemu/qemu_domain.c | 16 ++++++++-------- src/security/security_apparmor.c | 11 +++-------- src/util/virnetdev.c | 24 ++++++++---------------- 4 files changed, 22 insertions(+), 34 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 851894c459..61dd35360a 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1423,10 +1423,11 @@ lxcDomainDestroy(virDomainPtr dom) =20 static int lxcCheckNetNsSupport(void) { - const char *argv[] =3D {"ip", "link", "set", "lo", "netns", "-1", NULL= }; + g_autoptr(virCommand) cmd =3D virCommandNewArgList("ip", "link", "set"= , "lo", + "netns", "-1", NULL); int ip_rc; =20 - if (virRun(argv, &ip_rc) < 0 || ip_rc =3D=3D 255) + if (virCommandRun(cmd, &ip_rc) < 0 || ip_rc =3D=3D 255) return 0; =20 if (virProcessNamespaceAvailable(VIR_PROCESS_NAMESPACE_NET) < 0) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 98ffd23a71..3d075bca26 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7553,20 +7553,20 @@ qemuDomainSnapshotForEachQcow2Raw(virQEMUDriverPtr = driver, bool try_all, int ndisks) { - const char *qemuimgarg[] =3D { NULL, "snapshot", NULL, NULL, NULL, NUL= L }; + const char *qemuimgbin; size_t i; bool skipped =3D false; =20 - qemuimgarg[0] =3D qemuFindQemuImgBinary(driver); - if (qemuimgarg[0] =3D=3D NULL) { + qemuimgbin =3D qemuFindQemuImgBinary(driver); + if (qemuimgbin =3D=3D NULL) { /* qemuFindQemuImgBinary set the error */ return -1; } =20 - qemuimgarg[2] =3D op; - qemuimgarg[3] =3D name; - for (i =3D 0; i < ndisks; i++) { + g_autoptr(virCommand) cmd =3D virCommandNewArgList(qemuimgbin, "sn= apshot", + op, name, NULL); + /* FIXME: we also need to handle LVM here */ if (def->disks[i]->device =3D=3D VIR_DOMAIN_DISK_DEVICE_DISK) { int format =3D virDomainDiskGetFormat(def->disks[i]); @@ -7593,9 +7593,9 @@ qemuDomainSnapshotForEachQcow2Raw(virQEMUDriverPtr dr= iver, return -1; } =20 - qemuimgarg[4] =3D virDomainDiskGetSource(def->disks[i]); + virCommandAddArg(cmd, virDomainDiskGetSource(def->disks[i])); =20 - if (virRun(qemuimgarg, NULL) < 0) { + if (virCommandRun(cmd, NULL) < 0) { if (try_all) { VIR_WARN("skipping snapshot action on %s", def->disks[i]->dst); diff --git a/src/security/security_apparmor.c b/src/security/security_appar= mor.c index ca02631f7f..55eb110522 100644 --- a/src/security/security_apparmor.c +++ b/src/security/security_apparmor.c @@ -203,15 +203,10 @@ load_profile(virSecurityManagerPtr mgr G_GNUC_UNUSED, static int remove_profile(const char *profile) { - int rc =3D -1; - const char * const argv[] =3D { - VIRT_AA_HELPER, "-D", "-u", profile, NULL - }; + g_autoptr(virCommand) cmd =3D virCommandArgList(VIRT_AA_HELPER, "-D", = "-u", + profile, NULL); =20 - if (virRun(argv, NULL) =3D=3D 0) - rc =3D 0; - - return rc; + return virCommandRun(cmd, NULL); } =20 static char * diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index dea0bccd57..1d024b8b97 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -508,6 +508,7 @@ int virNetDevSetNamespace(const char *ifname, pid_t pid= InNs) g_autofree char *pid =3D NULL; g_autofree char *phy =3D NULL; g_autofree char *phy_path =3D NULL; + g_autoptr(virCommand) cmd =3D NULL; int len; =20 pid =3D g_strdup_printf("%lld", (long long) pidInNs); @@ -518,28 +519,19 @@ int virNetDevSetNamespace(const char *ifname, pid_t p= idInNs) =20 if ((len =3D virFileReadAllQuiet(phy_path, 1024, &phy)) <=3D 0) { /* Not a wireless device. */ - const char *argv[] =3D { - "ip", "link", "set", ifname, "netns", NULL, NULL - }; - - argv[5] =3D pid; - if (virRun(argv, NULL) < 0) - return -1; - + cmd =3D virCommandNewArgList("ip", "link", + "set", ifname, "netns", pid, NULL); } else { - const char *argv[] =3D { - "iw", "phy", NULL, "set", "netns", NULL, NULL - }; - /* Remove a line break. */ phy[len - 1] =3D '\0'; =20 - argv[2] =3D phy; - argv[5] =3D pid; - if (virRun(argv, NULL) < 0) - return -1; + cmd =3D virCommandNewArgList("iw", "phy", phy, + "set", "netns", pid, NULL); } =20 + if (virCommandRun(cmd, NULL) < 0) + return -1; + return 0; } =20 --=20 2.25.1 From nobody Sat Apr 27 20:59:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1587574387; cv=none; d=zohomail.com; s=zohoarc; b=UKu00k0dyZv0VVE16WPPc9Ccv7C1C+oddTp5iGZ2n1CsPPLmD6/Pb8/gfMSyUVdSuS4X/qSeRujBrnW6fHWlP8OgTXcWSIvFibNTZTVUs1lAEmQWa9FcknK8BZhvndBT5oghhsWANLqyfn6f6m8+yUdEvCdBwdb1KjHvRGjbmy0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587574387; 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=vRzHdojW0cIDu3AkOKZTebBzyrKGi/AsuIJOz82WKsc=; b=G077yEJFg4aDHddySzaYdYCjOUoxFRD+mabsLukOC4bJ3kSERMLExgtkwHDBkcS6XP4DuL3V55dgfe9n+tEFcOW8UkCJZlZ68Er7edBIZTd1X6rxzYNNmqpqIu5ZpI2qgQduxdf2xBtdUOa+zdlNxIcyGleP+79OXw1PuKk+OUo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1587574387278699.3042765862599; Wed, 22 Apr 2020 09:53:07 -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-453-q_K6wMVvOniEIhRFFeSPlw-1; Wed, 22 Apr 2020 12:52:43 -0400 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 08D5819251A1; Wed, 22 Apr 2020 16:52:33 +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 C5F216084B; Wed, 22 Apr 2020 16:52:32 +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 6742E941C9; Wed, 22 Apr 2020 16:52:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 03MGqRCG023255 for ; Wed, 22 Apr 2020 12:52:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id B2CD15D70A; Wed, 22 Apr 2020 16:52:27 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.40.208.78]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E75A5D710 for ; Wed, 22 Apr 2020 16:52:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587574386; 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=vRzHdojW0cIDu3AkOKZTebBzyrKGi/AsuIJOz82WKsc=; b=JKIVpxbEVGPbagmMz5HeF4tWgxIP44nO1nIKEDwnQ4ic3dYInmrj/FlNTGQCrY+JkUcZIs 5NXehBo/46wH7PhS1xUCOJUgejcFD3EGAUnvYIRHgWaOAflWASPMdqUGXU8xJ9pVdYUH33 POCSsGcpe/TWTYdtIP3c+7ryx0ZU6Kg= X-MC-Unique: q_K6wMVvOniEIhRFFeSPlw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 4/5] util: remove references to virRun/virExec Date: Wed, 22 Apr 2020 18:52:19 +0200 Message-Id: <218da7f883d946bb7595c5f7510c4ff73fe5c7c2.1587574318.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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 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" virCommand is now used everywhere. Signed-off-by: J=C3=A1n Tomko Suggested-by: Sebastian Mitterle Reviewed-by: Michal Privoznik --- src/util/virprocess.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/virprocess.c b/src/util/virprocess.c index b126c3c9af..afb1f9b79f 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -129,7 +129,7 @@ VIR_ENUM_IMPL(virProcessSchedPolicy, * @status: child exit status to translate * * Translate an exit status into a malloc'd string. Generic helper - * for virCommandRun(), virCommandWait(), virRun(), and virProcessWait() + * for virCommandRun(), virCommandWait() and virProcessWait() * status argument, as well as raw waitpid(). */ char * @@ -1190,7 +1190,7 @@ virProcessRunInForkHelper(int errfd, * particular no mutexes should be used in @cb, unless steps were * taken before forking to guarantee a predictable state. @cb * must not exec any external binaries, instead - * virCommand/virExec should be used for that purpose. + * virCommand should be used for that purpose. * * On return, the returned value is either -1 with error message * reported if something went bad in the parent, if child has --=20 2.25.1 From nobody Sat Apr 27 20:59:51 2024 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=1587574417; cv=none; d=zohomail.com; s=zohoarc; b=j6b/0MqYDLfBr/8CqfAODHcO2mhsQp06BN9zlJ40BhQF8fN1hfN4IwUnpXZacfm4DrnwaMvfKZ0pvZEhRUDvZ0FridyKefIEdoLBqUF5UDStoXmHUL95ZE3b71msRHnLrHa/uKSaRW449Cw/uynEXW8wPUIXQIRdMSJxwkIOcCA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587574417; 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=i8/aTjeOpMTVVFw6dtQjRKy8df0Fd/e8LGxZp4MaSpc=; b=EwHdPMLE0mxsZg/fX5SwNiAuKANp/5AnkSsPfe86xAZkML9O98X2bc1fGRU5A2Sob0TafS5t/ImfFqqxA+iBVxDDnKvKkHiOAqXwbHAeqrUA9c+49Wd5hAQgdErq8dF5/SUVDuqGOjMR31QVCgLjvEyM6MAk2pzdRW/dsucyg+0= 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-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1587574417105316.38572023170093; Wed, 22 Apr 2020 09:53:37 -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-105-DLfHPJiHOXyDVZ48wdvmjA-1; Wed, 22 Apr 2020 12:52:46 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E540C19251D4; Wed, 22 Apr 2020 16:52:36 +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 BAE6A600E7; Wed, 22 Apr 2020 16:52:36 +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 680BE1809554; Wed, 22 Apr 2020 16:52:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 03MGqSBn023265 for ; Wed, 22 Apr 2020 12:52:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 920BE5D710; Wed, 22 Apr 2020 16:52:28 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.40.208.78]) by smtp.corp.redhat.com (Postfix) with ESMTP id F01FA5D70A for ; Wed, 22 Apr 2020 16:52:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587574415; 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=i8/aTjeOpMTVVFw6dtQjRKy8df0Fd/e8LGxZp4MaSpc=; b=Q0E7JBR7RACIWD21PK9BH3L9J0O3WlkGLZRh8q14h9fJE/DHqf7UbFKA87v1DW6e/indMi 6bDKuKYmwP2AoJmHZnNX+C21EJ9dTbw5R67mZQaQ902tkKFfxB5N2E4udpfjNIDAU1V1m6 yJ2KCeJTdy1i9iGo1KoVnO7lsL8wZl4= X-MC-Unique: DLfHPJiHOXyDVZ48wdvmjA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 5/5] util: remove virRun Date: Wed, 22 Apr 2020 18:52:20 +0200 Message-Id: <238b9d5344a00df7544985703e169df73918969f.1587574318.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.11 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" Everything is using virCommand now. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/libvirt_private.syms | 1 - src/util/vircommand.c | 35 ----------------------------------- src/util/vircommand.h | 2 -- 3 files changed, 38 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 28610a837e..7f497898eb 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1874,7 +1874,6 @@ virCommandToString; virCommandWait; virCommandWriteArgLog; virFork; -virRun; =20 =20 # util/virconf.h diff --git a/src/util/vircommand.c b/src/util/vircommand.c index b84fb40948..20f196104f 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -893,43 +893,8 @@ virExec(virCommandPtr cmd) } =20 =20 -/** - * virRun: - * @argv NULL terminated argv to run - * @status optional variable to return exit status in - * - * Run a command without using the shell. - * - * If status is NULL, then return 0 if the command run and - * exited with 0 status; Otherwise return -1 - * - * If status is not-NULL, then return 0 if the command ran. - * The status variable is filled with the command exit status - * and should be checked by caller for success. Return -1 - * only if the command could not be run. - */ -int -virRun(const char *const*argv, int *status) -{ - g_autoptr(virCommand) cmd =3D virCommandNewArgs(argv); - - return virCommandRun(cmd, status); -} - #else /* WIN32 */ =20 -int -virRun(const char *const *argv G_GNUC_UNUSED, - int *status) -{ - if (status) - *status =3D ENOTSUP; - else - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("virRun is not implemented for WIN32")); - return -1; -} - pid_t virFork(void) { diff --git a/src/util/vircommand.h b/src/util/vircommand.h index 9086f9a90c..e2be5bcf1c 100644 --- a/src/util/vircommand.h +++ b/src/util/vircommand.h @@ -34,8 +34,6 @@ typedef int (*virExecHook)(void *data); =20 pid_t virFork(void) G_GNUC_WARN_UNUSED_RESULT; =20 -int virRun(const char *const*argv, int *status) G_GNUC_WARN_UNUSED_RESULT; - virCommandPtr virCommandNew(const char *binary) ATTRIBUTE_NONNULL(1); =20 virCommandPtr virCommandNewArgs(const char *const*args) ATTRIBUTE_NONNULL(= 1); --=20 2.25.1