From nobody Thu May 15 09:25:40 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1524003266556244.74352450527704; Tue, 17 Apr 2018 15:14:26 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 50A583182F34; Tue, 17 Apr 2018 22:14: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 2A72319E69; Tue, 17 Apr 2018 22:14: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 D46E6180BAD3; Tue, 17 Apr 2018 22:14:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3HMDqWi012385 for ; Tue, 17 Apr 2018 18:13:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 25C5588810; Tue, 17 Apr 2018 22:13:52 +0000 (UTC) Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1D94088824 for ; Tue, 17 Apr 2018 22:13:50 +0000 (UTC) Received: from smtp.lse.epita.fr (lse.epita.fr [163.5.55.17]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ECB095D697 for ; Tue, 17 Apr 2018 22:13:48 +0000 (UTC) Received: from clem.lse.epita.fr (unknown [192.168.103.23]) by smtp.lse.epita.fr (Postfix) with ESMTP id 5A57B60978; Wed, 18 Apr 2018 00:13:44 +0200 (CEST) From: Clementine Hayat To: libvir-list@redhat.com Date: Tue, 17 Apr 2018 22:13:31 +0000 Message-Id: <20180417221334.13845-7-clem@lse.epita.fr> In-Reply-To: <20180417221334.13845-1-clem@lse.epita.fr> References: <20180412194915.818-1-clem@lse.fr> <20180417221334.13845-1-clem@lse.epita.fr> X-Greylist: Sender passed SPF test, ACL 227 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 17 Apr 2018 22:13:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 17 Apr 2018 22:13:49 +0000 (UTC) for IP:'163.5.55.17' DOMAIN:'lse.epita.fr' HELO:'smtp.lse.epita.fr' FROM:'clem@lse.epita.fr' RCPT:'' X-RedHat-Spam-Score: -0.001 (SPF_PASS) 163.5.55.17 lse.epita.fr 163.5.55.17 lse.epita.fr X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Clementine Hayat Subject: [libvirt] [PATCH v2 6/9] lxc: start using virDomainObjCheckActive 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 17 Apr 2018 22:14:25 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Clementine Hayat --- src/lxc/lxc_driver.c | 60 +++++++++----------------------------------- 1 file changed, 12 insertions(+), 48 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 4097cef93..008e41bda 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1508,11 +1508,8 @@ lxcDomainDestroyFlags(virDomainPtr dom, if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("Domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 priv =3D vm->privateData; ret =3D virLXCProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_DESTROYED); @@ -2382,11 +2379,8 @@ lxcDomainBlockStats(virDomainPtr dom, if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_QUERY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_BLKIO)= ) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", @@ -2468,11 +2462,8 @@ lxcDomainBlockStatsFlags(virDomainPtr dom, if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_QUERY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_BLKIO)= ) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", @@ -2876,11 +2867,8 @@ lxcDomainInterfaceStats(virDomainPtr dom, if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_QUERY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("Domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 if (!(net =3D virDomainNetFind(vm->def, device))) goto endjob; @@ -3100,11 +3088,8 @@ static int lxcDomainSuspend(virDomainPtr dom) if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("Domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 if (virDomainObjGetState(vm, NULL) !=3D VIR_DOMAIN_PAUSED) { if (lxcFreezeContainer(vm) < 0) { @@ -3155,11 +3140,8 @@ static int lxcDomainResume(virDomainPtr dom) if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("Domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 state =3D virDomainObjGetState(vm, NULL); if (state =3D=3D VIR_DOMAIN_RUNNING) { @@ -3214,11 +3196,8 @@ lxcDomainOpenConsole(virDomainPtr dom, if (virDomainOpenConsoleEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 if (dev_name) { for (i =3D 0; i < vm->def->nconsoles; i++) { @@ -3292,11 +3271,8 @@ lxcDomainSendProcessSignal(virDomainPtr dom, if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 /* * XXX if the kernel has /proc/$PID/ns/pid we can @@ -3391,11 +3367,8 @@ lxcDomainShutdownFlags(virDomainPtr dom, if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("Domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 if (priv->initpid =3D=3D 0) { virReportError(VIR_ERR_OPERATION_INVALID, @@ -3474,11 +3447,8 @@ lxcDomainReboot(virDomainPtr dom, if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("Domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 if (priv->initpid =3D=3D 0) { virReportError(VIR_ERR_OPERATION_INVALID, @@ -5111,11 +5081,8 @@ static int lxcDomainLxcOpenNamespace(virDomainPtr do= m, if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_QUERY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("Domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } =20 if (!priv->initpid) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", @@ -5441,11 +5408,8 @@ lxcDomainGetCPUStats(virDomainPtr dom, if (virDomainGetCPUStatsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } =20 if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUACC= T)) { virReportError(VIR_ERR_OPERATION_INVALID, --=20 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list