From nobody Thu May 2 17:14:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; envelope-from=libvir-list-bounces@redhat.com; helo=mx3-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mx.zohomail.com with SMTPS id 1487923605690940.1774638016881; Fri, 24 Feb 2017 00:06:45 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1O83WbT012172; Fri, 24 Feb 2017 03:03:32 -0500 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1O83UsR028206 for ; Fri, 24 Feb 2017 03:03:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id 092502D654; Fri, 24 Feb 2017 08:03:30 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 020712D653 for ; Fri, 24 Feb 2017 08:03:29 +0000 (UTC) Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 54AEF4E4D0 for ; Fri, 24 Feb 2017 08:03:29 +0000 (UTC) Received: by mail-pf0-f193.google.com with SMTP id o64so726808pfb.1 for ; Fri, 24 Feb 2017 00:03:28 -0800 (PST) Received: from localhost.net ([2601:647:4501:a0d1::9f97]) by smtp.googlemail.com with ESMTPSA id s5sm13610285pgc.57.2017.02.24.00.03.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Feb 2017 00:03:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=IT2BnC3K83a1pPKSCKRV02I0Gr16KYUA18ktL1FwgKE=; b=I6FhWDozVN/zAx7I7iwwe33NLAIN65Ht7Eb2FLY7mtTkHTvVDVE3I1GkDHr6kFtrc0 pY+TWQdwFwamC8bQ6RepihF+QCe0ve2eTw7sbdkM+DoH98G/FFef2KDWni7q4W5KVLQo Qbda/rqD6hwaJ+x3tSNFE69qvEf5ho/2kRhVSHlzZ4SNLaI0LGKClhvYFiGcK/hnOApB qA/jAYKo6HJOgFmrpZvvUzJry8nONZW3RT9Gw/u714lGbEjh1OwFMzLLovGy4IlKtD4T zkanxWQehnajYqVVfjtuA7tx2fUaXE1l+r5N73/Y8ZJ/juVjwarP6HkWdjC3la9q7IMV c1bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=IT2BnC3K83a1pPKSCKRV02I0Gr16KYUA18ktL1FwgKE=; b=BBk+GO7Qgq9WIGVLgiQIC2lVL2uKFTFbNsposcWrIIwbH/gurqpYraZ6ar0w+vf2tn QE61gVeG1vmF9KxN5kYkob0AL5gHu+NJxh7wOPEujmH7FUi8rYV/wAfiBuaxFOmnIw+h IL0tQzq1BSAfAt7YVE9KHW3JEsZ0gX+KmK4MhK5Y2ZchLZJvOgKCaSyvSeKhxfphe/kQ fqMtUM00QKmUjuU+E0sCnyXEuQFjq4lWM3brkN/e1UjaiqAuqRSdkjR3kgE5SMP9f8Z4 mGGEyWCMk0X7jQwojHHttGqAHkI/xcMXYB5y3ujc1ztENQczjUPzOz1XIm9DFC/B3LYR AbWw== X-Gm-Message-State: AMke39myrZ6BXTd+dcNGDMXmM0YnzrO2QmxWK5iRv6ELjJBP//acPN3YePhqV2KShA7GRg== X-Received: by 10.98.31.17 with SMTP id f17mr1894100pff.78.1487923407558; Fri, 24 Feb 2017 00:03:27 -0800 (PST) From: Sagar Ghuge To: libvir-list@redhat.com Date: Fri, 24 Feb 2017 00:03:12 -0800 Message-Id: <20170224080314.23074-2-ghugesss@gmail.com> In-Reply-To: <20170224080314.23074-1-ghugesss@gmail.com> References: <20170224080314.23074-1-ghugesss@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 24 Feb 2017 08:03:29 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 24 Feb 2017 08:03:29 +0000 (UTC) for IP:'209.85.192.193' DOMAIN:'mail-pf0-f193.google.com' HELO:'mail-pf0-f193.google.com' FROM:'ghugesss@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.482 (BAYES_50, DCC_REPUT_13_19, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_SORBS_SPAM, SPF_PASS) 209.85.192.193 mail-pf0-f193.google.com 209.85.192.193 mail-pf0-f193.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.74 on 10.5.11.28 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/3] libxl: Implement virDomainObjCheckIsActive 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add function which raises error if domain is not active Signed-off-by: Sagar Ghuge --- src/conf/domain_conf.c | 15 +++++++++++++++ src/conf/domain_conf.h | 1 + 2 files changed, 16 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 97d42fe..a44454c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2997,6 +2997,21 @@ virDomainObjWait(virDomainObjPtr vm) } =20 =20 +int +virDomainObjCheckIsActive(virDomainObjPtr vm) +{ + if (!virDomainObjIsActive(vm)) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("domain is not running")); + return -1; + } + + return 0; +} + + + + /** * Waits for domain condition to be triggered for a specific period of tim= e. * diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 1e53cc3..cfeb1ba 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2559,6 +2559,7 @@ bool virDomainObjTaint(virDomainObjPtr obj, =20 void virDomainObjBroadcast(virDomainObjPtr vm); int virDomainObjWait(virDomainObjPtr vm); +int virDomainObjCheckIsActive(virDomainObjPtr vm); int virDomainObjWaitUntil(virDomainObjPtr vm, unsigned long long whenms); =20 --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 17:14:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; envelope-from=libvir-list-bounces@redhat.com; helo=mx3-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mx.zohomail.com with SMTPS id 1487923631620963.3234973911527; Fri, 24 Feb 2017 00:07:11 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1O84B4Z012208; Fri, 24 Feb 2017 03:04:12 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1O83XmX028221 for ; Fri, 24 Feb 2017 03:03:33 -0500 Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1O83Xtb020084 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Fri, 24 Feb 2017 03:03:33 -0500 Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C0B218123E for ; Fri, 24 Feb 2017 08:03:32 +0000 (UTC) Received: by mail-pf0-f193.google.com with SMTP id o64so726879pfb.1 for ; Fri, 24 Feb 2017 00:03:31 -0800 (PST) Received: from localhost.net ([2601:647:4501:a0d1::9f97]) by smtp.googlemail.com with ESMTPSA id s5sm13610285pgc.57.2017.02.24.00.03.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Feb 2017 00:03:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=Ei+MK+57iUZmECawm8SB42dDKEJUewkXvbzKpi4f02c=; b=dBTWHdtLQ528Dq2l0NiYcv1AQz4CuS95N98k39NQrxviqObh2smhxCsHDAQajvY8RK BXnu4bn9ssXmRJqEm3IdytmUOj8URZ7Htj5d2Y78BF80eV9vzP4bdY3+5zAPj25CDzuQ ncL621uEy7T5mHzZCDzUN9BSrok9tsPAfgBo2oo3V8lqyEal8PdBk3OXO+xlJUROgW1d rNSO3I2iBQnnAgntRSz18tytORGVMGQ+rIsuvD1vCy01hiwJqVO0xKVYtr1MCZY8qrvv UgYNY4qDQbVUaWS8ErwX/YYbf8dmffKZen0ceRp1zuiJd6I1FmnmGi8US7huEMe+G3jJ dPFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=Ei+MK+57iUZmECawm8SB42dDKEJUewkXvbzKpi4f02c=; b=RTZKnKHAYNbI3Fnp7KVfC7DDOwuS6w3HrV5jE4XOJ6JpOCaQqfix/WzxcbEfBffYGp FkvML3lZ0tA/ITFMGgn1aWPncaRVMrpadPol+J9vGy91ISib1LQfBEKbNsFTNZtFBobQ Rdid2avMYDsVgWC/ZcqoPGG695NGr6q57aOgdykzAVaoUvHaLLAnV+96H8tn0+wkG9eW 0J7ql/9NMC+IAhKPLoq0A8frIomK9CgV1xz6vDlijiNU8C9C9AbXC/nuIx7D2EdDoFkt kRS0KSUu7xd3bXGTpjRcXXUF4n+9DViJ9ML+4VOyDpOnRByuNDom0HVfMbnqtMKjVno8 XrbQ== X-Gm-Message-State: AMke39lsoaSe9QYH2n1a1nOhRespwQRIBaksfP7V3fP4O8g/WVZ0Xtlos4wZFLLyVquqjA== X-Received: by 10.99.228.69 with SMTP id i5mr1896857pgk.63.1487923411075; Fri, 24 Feb 2017 00:03:31 -0800 (PST) From: Sagar Ghuge To: libvir-list@redhat.com Date: Fri, 24 Feb 2017 00:03:13 -0800 Message-Id: <20170224080314.23074-3-ghugesss@gmail.com> In-Reply-To: <20170224080314.23074-1-ghugesss@gmail.com> References: <20170224080314.23074-1-ghugesss@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 24 Feb 2017 08:03:32 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 24 Feb 2017 08:03:32 +0000 (UTC) for IP:'209.85.192.193' DOMAIN:'mail-pf0-f193.google.com' HELO:'mail-pf0-f193.google.com' FROM:'ghugesss@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.482 (BAYES_50, DCC_REPUT_13_19, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_SORBS_SPAM, SPF_PASS) 209.85.192.193 mail-pf0-f193.google.com 209.85.192.193 mail-pf0-f193.google.com X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Scanned-By: MIMEDefang 2.78 on 10.5.110.25 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/3] change virDomainObjIsActive with virDomainObjCheckIsActive 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Sagar Ghuge --- src/test/test_driver.c | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 5fef3f1..bbcaa44 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1769,11 +1769,8 @@ static int testDomainDestroy(virDomainPtr domain) if (!(privdom =3D testDomObjFromDomain(domain))) goto cleanup; =20 - if (!virDomainObjIsActive(privdom)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckIsActive(privdom) < 0) goto cleanup; - } =20 testDomainShutdownState(domain, privdom, VIR_DOMAIN_SHUTOFF_DESTROYED); event =3D virDomainEventLifecycleNewFromObj(privdom, @@ -1902,11 +1899,8 @@ static int testDomainReboot(virDomainPtr domain, if (!(privdom =3D testDomObjFromDomain(domain))) goto cleanup; =20 - if (!virDomainObjIsActive(privdom)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckIsActive(privdom) < 0) goto cleanup; - } =20 virDomainObjSetState(privdom, VIR_DOMAIN_SHUTDOWN, VIR_DOMAIN_SHUTDOWN_USER); @@ -2028,11 +2022,8 @@ testDomainSaveFlags(virDomainPtr domain, const char = *path, if (!(privdom =3D testDomObjFromDomain(domain))) goto cleanup; =20 - if (!virDomainObjIsActive(privdom)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckIsActive(privdom) < 0) goto cleanup; - } =20 xml =3D virDomainDefFormat(privdom->def, privconn->caps, VIR_DOMAIN_DEF_FORMAT_SECURE); @@ -2232,11 +2223,8 @@ static int testDomainCoreDumpWithFormat(virDomainPtr= domain, if (!(privdom =3D testDomObjFromDomain(domain))) goto cleanup; =20 - if (!virDomainObjIsActive(privdom)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckIsActive(privdom) < 0) goto cleanup; - } =20 if ((fd =3D open(to, O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR)) < 0) { virReportSystemError(errno, @@ -3126,11 +3114,8 @@ static int testDomainBlockStats(virDomainPtr domain, if (!(privdom =3D testDomObjFromDomain(domain))) return ret; =20 - if (!virDomainObjIsActive(privdom)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckIsActive(privdom) < 0) goto error; - } =20 if (virDomainDiskIndexByName(privdom->def, path, false) < 0) { virReportError(VIR_ERR_INVALID_ARG, @@ -3171,11 +3156,8 @@ static int testDomainInterfaceStats(virDomainPtr dom= ain, if (!(privdom =3D testDomObjFromDomain(domain))) return -1; =20 - if (!virDomainObjIsActive(privdom)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckIsActive(privdom) < 0) goto error; - } =20 for (i =3D 0; i < privdom->def->nnets; i++) { if (privdom->def->nets[i]->ifname && @@ -6065,11 +6047,8 @@ testDomainManagedSave(virDomainPtr dom, unsigned int= flags) if (!(vm =3D testDomObjFromDomain(dom))) return -1; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckIsActive(vm) < 0) goto cleanup; - } =20 if (!vm->persistent) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 17:14:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; envelope-from=libvir-list-bounces@redhat.com; helo=mx4-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mx.zohomail.com with SMTPS id 1487923686760474.02710740728173; Fri, 24 Feb 2017 00:08:06 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1O84BZh018397; Fri, 24 Feb 2017 03:04:12 -0500 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1O83bmJ028233 for ; Fri, 24 Feb 2017 03:03:37 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3338A2D5C0; Fri, 24 Feb 2017 08:03:37 +0000 (UTC) Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2AFBE2D654 for ; Fri, 24 Feb 2017 08:03:37 +0000 (UTC) Received: from mail-pg0-f66.google.com (mail-pg0-f66.google.com [74.125.83.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 534A64D686 for ; Fri, 24 Feb 2017 08:03:35 +0000 (UTC) Received: by mail-pg0-f66.google.com with SMTP id z128so2228235pgb.3 for ; Fri, 24 Feb 2017 00:03:34 -0800 (PST) Received: from localhost.net ([2601:647:4501:a0d1::9f97]) by smtp.googlemail.com with ESMTPSA id s5sm13610285pgc.57.2017.02.24.00.03.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Feb 2017 00:03:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=N5diO2QZGb7xzYOsCkjUqiiC1r8TMzOU3eidFBS8feg=; b=mldPENHVZ0XascgsxLSbNXv8tRENAT+FPY5NEl76YL6f0t5spxlzUPx7hmfEyedvqw ifNtQqy5D5ybDfJYPTNfbA9pjXY4t9Pr6dS8h1Vz6fI9bjuYXy44oRhu26IoLsIUJ8hc 2a4uZzNds5nxYpEobKEow8aokbtVHttVmmWL/Y3E5qEnpcVm1uFujrBZwUx+JoYXrrDN VB/aaJa/2Dkr2ZQKPMh9I02Mlx2QWiYmLQLwoZh0WXTFW7XxFjzpjUOMzOYpSnuRFNUt ge7XfUbptQ+YaYfc7/LRsRk3EVLU8HsyeqYtZPOppMYa/Wqo5awE5oTNcoYi8z5eUROE vLjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=N5diO2QZGb7xzYOsCkjUqiiC1r8TMzOU3eidFBS8feg=; b=Ue4YKs80vPTPzUgK/gcVjzW+6kt85syxRKMqAPIhNkR4HldvXjlLjROfBxBiWPtkv9 oZLjH/R6HNdueNCIYpvwhOMl/9khjynAj2QJ8SjTWd3hXLD4S+6ZciLcPywSVgriL9Vi 3++h7O2AV5T7ak9z2YAFamphmYdlvXlPZ/dWhD/2CPA9CMwYiffzGpObQ7Vw5yj0+O/T OWhd9AfLJHC8u/QRYaUiJXq1u4VKsiiBmzKKNhE9jrEcF45iAWXrtpfi+Q0605IWlofy 8Bep9AfjalYQ5gB88EcA2mFMQ+aFhfUwbmj5JgrQkD2zwu+oOFvQpFv2QcP52AZYkDgf Y0SA== X-Gm-Message-State: AMke39l5zga9GvKfOq+9ukmPtsCY3fkrWgcRDx/MU0vzRfaXINaxQ1k39FpwGCemfVB44A== X-Received: by 10.99.39.195 with SMTP id n186mr1893770pgn.178.1487923413198; Fri, 24 Feb 2017 00:03:33 -0800 (PST) From: Sagar Ghuge To: libvir-list@redhat.com Date: Fri, 24 Feb 2017 00:03:14 -0800 Message-Id: <20170224080314.23074-4-ghugesss@gmail.com> In-Reply-To: <20170224080314.23074-1-ghugesss@gmail.com> References: <20170224080314.23074-1-ghugesss@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 24 Feb 2017 08:03:35 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 24 Feb 2017 08:03:35 +0000 (UTC) for IP:'74.125.83.66' DOMAIN:'mail-pg0-f66.google.com' HELO:'mail-pg0-f66.google.com' FROM:'ghugesss@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.57 (BAYES_50, DCC_REPUT_13_19, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 74.125.83.66 mail-pg0-f66.google.com 74.125.83.66 mail-pg0-f66.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.74 on 10.5.11.28 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/3] libxl: Change virDomainObjIsActive to virDomainObjCheckIsActive 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Replace virDomainObjIsActive with virDomainObjCheckIsActive which raises error if domain is not active Signed-off-by: Sagar Ghuge --- ...libxl-Implement-virDomainObjCheckIsActive.patch | 55 ++++ ...omainObjIsActive-with-virDomainObjCheckIs.patch | 109 ++++++++ ...e-virDomainObjIsActive-to-virDomainObjChe.patch | 298 +++++++++++++++++= ++++ patch1 | 52 ++++ src/libxl/libxl_driver.c | 102 ++----- 5 files changed, 537 insertions(+), 79 deletions(-) create mode 100644 0001-libxl-Implement-virDomainObjCheckIsActive.patch create mode 100644 0002-change-virDomainObjIsActive-with-virDomainObjCheck= Is.patch create mode 100644 0003-libxl-Change-virDomainObjIsActive-to-virDomainObjC= he.patch create mode 100644 patch1 diff --git a/0001-libxl-Implement-virDomainObjCheckIsActive.patch b/0001-li= bxl-Implement-virDomainObjCheckIsActive.patch new file mode 100644 index 0000000..161a59d --- /dev/null +++ b/0001-libxl-Implement-virDomainObjCheckIsActive.patch @@ -0,0 +1,55 @@ +From 364fe0cec782a312a7c0fc3a6ebf7580053f4f9a Mon Sep 17 00:00:00 2001 +From: Sagar Ghuge +Date: Thu, 23 Feb 2017 19:47:26 -0800 +Subject: [PATCH 1/3] libxl: Implement virDomainObjCheckIsActive + +Add function which raises error if domain is +not active + +Signed-off-by: Sagar Ghuge +--- + src/conf/domain_conf.c | 15 +++++++++++++++ + src/conf/domain_conf.h | 1 + + 2 files changed, 16 insertions(+) + +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index 97d42fe..a44454c 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -2997,6 +2997,21 @@ virDomainObjWait(virDomainObjPtr vm) + } +=20 +=20 ++int ++virDomainObjCheckIsActive(virDomainObjPtr vm) ++{ ++ if (!virDomainObjIsActive(vm)) { ++ virReportError(VIR_ERR_OPERATION_FAILED, "%s", ++ _("domain is not running")); ++ return -1; ++ } ++ ++ return 0; ++} ++ ++ ++ ++ + /** + * Waits for domain condition to be triggered for a specific period of ti= me. + * +diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h +index 1e53cc3..cfeb1ba 100644 +--- a/src/conf/domain_conf.h ++++ b/src/conf/domain_conf.h +@@ -2559,6 +2559,7 @@ bool virDomainObjTaint(virDomainObjPtr obj, +=20 + void virDomainObjBroadcast(virDomainObjPtr vm); + int virDomainObjWait(virDomainObjPtr vm); ++int virDomainObjCheckIsActive(virDomainObjPtr vm); + int virDomainObjWaitUntil(virDomainObjPtr vm, + unsigned long long whenms); +=20 +--=20 +2.9.3 + diff --git a/0002-change-virDomainObjIsActive-with-virDomainObjCheckIs.patc= h b/0002-change-virDomainObjIsActive-with-virDomainObjCheckIs.patch new file mode 100644 index 0000000..fa82dce --- /dev/null +++ b/0002-change-virDomainObjIsActive-with-virDomainObjCheckIs.patch @@ -0,0 +1,109 @@ +From 2656b5e6e8047e5f23563d6dff4347bba4483e2a Mon Sep 17 00:00:00 2001 +From: Sagar Ghuge +Date: Thu, 23 Feb 2017 20:40:08 -0800 +Subject: [PATCH 2/3] change virDomainObjIsActive with + virDomainObjCheckIsActive + +Signed-off-by: Sagar Ghuge +--- + src/test/test_driver.c | 35 +++++++---------------------------- + 1 file changed, 7 insertions(+), 28 deletions(-) + +diff --git a/src/test/test_driver.c b/src/test/test_driver.c +index 5fef3f1..bbcaa44 100644 +--- a/src/test/test_driver.c ++++ b/src/test/test_driver.c +@@ -1769,11 +1769,8 @@ static int testDomainDestroy(virDomainPtr domain) + if (!(privdom =3D testDomObjFromDomain(domain))) + goto cleanup; +=20 +- if (!virDomainObjIsActive(privdom)) { +- virReportError(VIR_ERR_OPERATION_INVALID, +- "%s", _("domain is not running")); ++ if (virDomainObjCheckIsActive(privdom) < 0) + goto cleanup; +- } +=20 + testDomainShutdownState(domain, privdom, VIR_DOMAIN_SHUTOFF_DESTROYED= ); + event =3D virDomainEventLifecycleNewFromObj(privdom, +@@ -1902,11 +1899,8 @@ static int testDomainReboot(virDomainPtr domain, + if (!(privdom =3D testDomObjFromDomain(domain))) + goto cleanup; +=20 +- if (!virDomainObjIsActive(privdom)) { +- virReportError(VIR_ERR_OPERATION_INVALID, +- "%s", _("domain is not running")); ++ if (virDomainObjCheckIsActive(privdom) < 0) + goto cleanup; +- } +=20 + virDomainObjSetState(privdom, VIR_DOMAIN_SHUTDOWN, + VIR_DOMAIN_SHUTDOWN_USER); +@@ -2028,11 +2022,8 @@ testDomainSaveFlags(virDomainPtr domain, const char= *path, + if (!(privdom =3D testDomObjFromDomain(domain))) + goto cleanup; +=20 +- if (!virDomainObjIsActive(privdom)) { +- virReportError(VIR_ERR_OPERATION_INVALID, +- "%s", _("domain is not running")); ++ if (virDomainObjCheckIsActive(privdom) < 0) + goto cleanup; +- } +=20 + xml =3D virDomainDefFormat(privdom->def, privconn->caps, + VIR_DOMAIN_DEF_FORMAT_SECURE); +@@ -2232,11 +2223,8 @@ static int testDomainCoreDumpWithFormat(virDomainPt= r domain, + if (!(privdom =3D testDomObjFromDomain(domain))) + goto cleanup; +=20 +- if (!virDomainObjIsActive(privdom)) { +- virReportError(VIR_ERR_OPERATION_INVALID, +- "%s", _("domain is not running")); ++ if (virDomainObjCheckIsActive(privdom) < 0) + goto cleanup; +- } +=20 + if ((fd =3D open(to, O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR)) < 0)= { + virReportSystemError(errno, +@@ -3126,11 +3114,8 @@ static int testDomainBlockStats(virDomainPtr domain, + if (!(privdom =3D testDomObjFromDomain(domain))) + return ret; +=20 +- if (!virDomainObjIsActive(privdom)) { +- virReportError(VIR_ERR_OPERATION_INVALID, +- "%s", _("domain is not running")); ++ if (virDomainObjCheckIsActive(privdom) < 0) + goto error; +- } +=20 + if (virDomainDiskIndexByName(privdom->def, path, false) < 0) { + virReportError(VIR_ERR_INVALID_ARG, +@@ -3171,11 +3156,8 @@ static int testDomainInterfaceStats(virDomainPtr do= main, + if (!(privdom =3D testDomObjFromDomain(domain))) + return -1; +=20 +- if (!virDomainObjIsActive(privdom)) { +- virReportError(VIR_ERR_OPERATION_INVALID, +- "%s", _("domain is not running")); ++ if (virDomainObjCheckIsActive(privdom) < 0) + goto error; +- } +=20 + for (i =3D 0; i < privdom->def->nnets; i++) { + if (privdom->def->nets[i]->ifname && +@@ -6065,11 +6047,8 @@ testDomainManagedSave(virDomainPtr dom, unsigned in= t flags) + if (!(vm =3D testDomObjFromDomain(dom))) + return -1; +=20 +- if (!virDomainObjIsActive(vm)) { +- virReportError(VIR_ERR_OPERATION_INVALID, +- "%s", _("domain is not running")); ++ if (virDomainObjCheckIsActive(vm) < 0) + goto cleanup; +- } +=20 + if (!vm->persistent) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", +--=20 +2.9.3 + diff --git a/0003-libxl-Change-virDomainObjIsActive-to-virDomainObjChe.patc= h b/0003-libxl-Change-virDomainObjIsActive-to-virDomainObjChe.patch new file mode 100644 index 0000000..5ea8ca7 --- /dev/null +++ b/0003-libxl-Change-virDomainObjIsActive-to-virDomainObjChe.patch @@ -0,0 +1,298 @@ +From ff65287895d08018e30e76923011cc1c8668e214 Mon Sep 17 00:00:00 2001 +From: Sagar Ghuge +Date: Thu, 23 Feb 2017 20:55:35 -0800 +Subject: [PATCH 3/3] libxl: Change virDomainObjIsActive to + virDomainObjCheckIsActive + +Replace virDomainObjIsActive with virDomainObjCheckIsActive +which raises error if domain is not active + +Signed-off-by: Sagar Ghuge +--- + src/libxl/libxl_driver.c | 102 +++++++++++-------------------------------= ----- + 1 file changed, 23 insertions(+), 79 deletions(-) + +diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c +index e5b8f48..7a69215 100644 +--- a/src/libxl/libxl_driver.c ++++ b/src/libxl/libxl_driver.c +@@ -1183,10 +1183,8 @@ libxlDomainSuspend(virDomainPtr dom) + if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) + goto cleanup; +=20 +- if (!virDomainObjIsActive(vm)) { +- virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not = running")); ++ if (virDomainObjCheckIsActive(vm) < 0) + goto endjob; +- } +=20 + if (virDomainObjGetState(vm, NULL) !=3D VIR_DOMAIN_PAUSED) { + if (libxl_domain_pause(cfg->ctx, vm->def->id) !=3D 0) { +@@ -1239,10 +1237,8 @@ libxlDomainResume(virDomainPtr dom) + if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) + goto cleanup; +=20 +- if (!virDomainObjIsActive(vm)) { +- virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not = running")); ++ if (virDomainObjCheckIsActive(vm) < 0) + goto endjob; +- } +=20 + if (virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_PAUSED) { + if (libxl_domain_unpause(cfg->ctx, vm->def->id) !=3D 0) { +@@ -1297,11 +1293,8 @@ libxlDomainShutdownFlags(virDomainPtr dom, unsigned= int flags) + if (virDomainShutdownFlagsEnsureACL(dom->conn, vm->def, flags) < 0) + goto cleanup; +=20 +- if (!virDomainObjIsActive(vm)) { +- virReportError(VIR_ERR_OPERATION_INVALID, +- "%s", _("Domain is not running")); ++ if (virDomainObjCheckIsActive(vm) < 0) + goto cleanup; +- } +=20 + if (flags & VIR_DOMAIN_SHUTDOWN_PARAVIRT) { + ret =3D libxl_domain_shutdown(cfg->ctx, vm->def->id); +@@ -1364,11 +1357,8 @@ libxlDomainReboot(virDomainPtr dom, unsigned int fl= ags) + if (virDomainRebootEnsureACL(dom->conn, vm->def, flags) < 0) + goto cleanup; +=20 +- if (!virDomainObjIsActive(vm)) { +- virReportError(VIR_ERR_OPERATION_INVALID, +- "%s", _("Domain is not running")); ++ if (virDomainObjCheckIsActive(vm) < 0) + goto cleanup; +- } +=20 + if (flags & VIR_DOMAIN_REBOOT_PARAVIRT) { + ret =3D libxl_domain_reboot(cfg->ctx, vm->def->id); +@@ -1411,11 +1401,8 @@ libxlDomainDestroyFlags(virDomainPtr dom, + if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) + goto cleanup; +=20 +- if (!virDomainObjIsActive(vm)) { +- virReportError(VIR_ERR_OPERATION_INVALID, +- "%s", _("Domain is not running")); ++ if (virDomainObjCheckIsActive(vm) < 0) + goto endjob; +- } +=20 + if (libxlDomainDestroyInternal(driver, vm) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, +@@ -1820,10 +1807,8 @@ libxlDomainSaveFlags(virDomainPtr dom, const char *= to, const char *dxml, + if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) + goto cleanup; +=20 +- if (!virDomainObjIsActive(vm)) { +- virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not = running")); ++ if (virDomainObjCheckIsActive(vm) < 0) + goto endjob; +- } +=20 + if (libxlDoDomainSave(driver, vm, to) < 0) + goto endjob; +@@ -1946,10 +1931,8 @@ libxlDomainCoreDump(virDomainPtr dom, const char *t= o, unsigned int flags) + if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) + goto cleanup; +=20 +- if (!virDomainObjIsActive(vm)) { +- virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not = running")); ++ if (virDomainObjCheckIsActive(vm) < 0) + goto endjob; +- } +=20 + if (!(flags & VIR_DUMP_LIVE) && + virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_RUNNING) { +@@ -2043,10 +2026,9 @@ libxlDomainManagedSave(virDomainPtr dom, unsigned i= nt flags) + if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) + goto cleanup; +=20 +- if (!virDomainObjIsActive(vm)) { +- virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not = running")); ++ if (virDomainObjCheckIsActive(vm) < 0) + goto endjob; +- } ++ + if (!vm->persistent) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("cannot do managed save for transient domain")); +@@ -2518,10 +2500,8 @@ libxlDomainGetVcpus(virDomainPtr dom, virVcpuInfoPt= r info, int maxinfo, + if (virDomainGetVcpusEnsureACL(dom->conn, vm->def) < 0) + goto cleanup; +=20 +- if (!virDomainObjIsActive(vm)) { +- virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not = running")); ++ if (virDomainObjCheckIsActive(vm) < 0) + goto cleanup; +- } +=20 + if ((vcpuinfo =3D libxl_list_vcpu(cfg->ctx, vm->def->id, &maxcpu, + &hostcpus)) =3D=3D NULL) { +@@ -2755,11 +2735,8 @@ libxlDomainCreateWithFlags(virDomainPtr dom, + if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) + goto cleanup; +=20 +- if (virDomainObjIsActive(vm)) { +- virReportError(VIR_ERR_OPERATION_INVALID, +- "%s", _("Domain is already running")); ++ if (virDomainObjCheckIsActive(vm) < 0) + goto endjob; +- } +=20 + ret =3D libxlDomainStartNew(driver, vm, + (flags & VIR_DOMAIN_START_PAUSED) !=3D 0); +@@ -4498,10 +4475,8 @@ libxlDomainGetSchedulerType(virDomainPtr dom, int *= nparams) + if (virDomainGetSchedulerTypeEnsureACL(dom->conn, vm->def) < 0) + goto cleanup; +=20 +- if (!virDomainObjIsActive(vm)) { +- virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not = running")); ++ if (virDomainObjCheckIsActive(vm) < 0) + goto cleanup; +- } +=20 + sched_id =3D libxl_get_scheduler(cfg->ctx); +=20 +@@ -4562,11 +4537,8 @@ libxlDomainGetSchedulerParametersFlags(virDomainPtr= dom, + if (virDomainGetSchedulerParametersFlagsEnsureACL(dom->conn, vm->def)= < 0) + goto cleanup; +=20 +- if (!virDomainObjIsActive(vm)) { +- virReportError(VIR_ERR_OPERATION_INVALID, "%s", +- _("Domain is not running")); ++ if (virDomainObjCheckIsActive(vm) < 0) + goto cleanup; +- } +=20 + sched_id =3D libxl_get_scheduler(cfg->ctx); +=20 +@@ -4643,10 +4615,8 @@ libxlDomainSetSchedulerParametersFlags(virDomainPtr= dom, + if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) + goto cleanup; +=20 +- if (!virDomainObjIsActive(vm)) { +- virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not = running")); ++ if (virDomainObjCheckIsActive(vm) < 0) + goto endjob; +- } +=20 + sched_id =3D libxl_get_scheduler(cfg->ctx); +=20 +@@ -4712,11 +4682,8 @@ libxlDomainOpenConsole(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 (virDomainObjCheckIsActive(vm) < 0) + goto cleanup; +- } +=20 + priv =3D vm->privateData; + if (dev_name) { +@@ -4812,11 +4779,8 @@ libxlDomainGetNumaParameters(virDomainPtr dom, + if (virDomainGetNumaParametersEnsureACL(dom->conn, vm->def) < 0) + goto cleanup; +=20 +- if (!virDomainObjIsActive(vm)) { +- virReportError(VIR_ERR_OPERATION_INVALID, "%s", +- _("Domain is not running")); ++ if (virDomainObjCheckIsActive(vm) < 0) + goto cleanup; +- } +=20 + if ((*nparams) =3D=3D 0) { + *nparams =3D LIBXL_NUMA_NPARAM; +@@ -4983,11 +4947,8 @@ libxlDomainInterfaceStats(virDomainPtr dom, + if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0) + goto cleanup; +=20 +- if (!virDomainObjIsActive(vm)) { +- virReportError(VIR_ERR_OPERATION_INVALID, +- "%s", _("domain is not running")); ++ if (virDomainObjCheckIsActive(vm) < 0) + goto endjob; +- } +=20 + /* Check the path is one of the domain's network interfaces. */ + for (i =3D 0; i < vm->def->nnets; i++) { +@@ -5111,11 +5072,8 @@ libxlDomainGetCPUStats(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 (virDomainObjCheckIsActive(vm) < 0) + goto cleanup; +- } +=20 + if (start_cpu =3D=3D -1) + ret =3D libxlDomainGetTotalCPUStats(driver, vm, params, nparams); +@@ -5164,11 +5122,8 @@ libxlDomainMemoryStats(virDomainPtr dom, + if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0) + goto cleanup; +=20 +- if (!virDomainObjIsActive(vm)) { +- virReportError(VIR_ERR_OPERATION_INVALID, +- "%s", _("domain is not running")); ++ if (virDomainObjCheckIsActive(vm) < 0) + goto endjob; +- } +=20 + if (libxl_domain_info(cfg->ctx, &d_info, vm->def->id) !=3D 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, +@@ -5528,11 +5483,8 @@ libxlDomainBlockStats(virDomainPtr dom, + if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0) + goto cleanup; +=20 +- if (!virDomainObjIsActive(vm)) { +- virReportError(VIR_ERR_OPERATION_INVALID, +- "%s", _("domain is not running")); ++ if (virDomainObjCheckIsActive(vm) < 0) + goto endjob; +- } +=20 + memset(&blkstats, 0, sizeof(libxlBlockStats)); + if ((ret =3D libxlDomainBlockStatsGather(vm, path, &blkstats)) < 0) +@@ -5581,11 +5533,8 @@ libxlDomainBlockStatsFlags(virDomainPtr dom, + if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0) + goto cleanup; +=20 +- if (!virDomainObjIsActive(vm)) { +- virReportError(VIR_ERR_OPERATION_INVALID, +- "%s", _("domain is not running")); ++ if (virDomainObjCheckIsActive(vm) < 0) + goto endjob; +- } +=20 + /* return count of supported stats */ + if (*nparams =3D=3D 0) { +@@ -5922,9 +5871,7 @@ libxlDomainMigrateBegin3Params(virDomainPtr domain, + return NULL; + } +=20 +- if (!virDomainObjIsActive(vm)) { +- virReportError(VIR_ERR_OPERATION_INVALID, +- "%s", _("domain is not running")); ++ if (virDomainObjCheckIsActive(vm) < 0) { + virObjectUnlock(vm); + return NULL; + } +@@ -6330,11 +6277,8 @@ libxlDomainInterfaceAddresses(virDomainPtr dom, + if (virDomainInterfaceAddressesEnsureACL(dom->conn, vm->def) < 0) + goto cleanup; +=20 +- if (!virDomainObjIsActive(vm)) { +- virReportError(VIR_ERR_OPERATION_INVALID, "%s", +- _("domain is not running")); ++ if (virDomainObjCheckIsActive(vm) < 0) + goto cleanup; +- } +=20 + switch (source) { + case VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE: +--=20 +2.9.3 + diff --git a/patch1 b/patch1 new file mode 100644 index 0000000..e39c5cd --- /dev/null +++ b/patch1 @@ -0,0 +1,52 @@ +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index 1bc72a4..10a69af 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -2995,6 +2995,19 @@ virDomainObjWait(virDomainObjPtr vm) + } +=20 +=20 ++int ++virDomainObjCheckIsActive(virDomainObjPtr vm) ++{ ++ if (!virDomainObjIsActive(vm)) { ++ virReportError(VIR_ERR_OPERATION_FAILED, "%s", ++ _("domain is not running")); ++ return -1; ++ } ++ ++ return 0; ++} ++ ++ + /** + * Waits for domain condition to be triggered for a specific period of ti= me. + * +diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h +index dd79206..b6c7826 100644 +--- a/src/conf/domain_conf.h ++++ b/src/conf/domain_conf.h +@@ -2559,6 +2559,7 @@ bool virDomainObjTaint(virDomainObjPtr obj, +=20 + void virDomainObjBroadcast(virDomainObjPtr vm); + int virDomainObjWait(virDomainObjPtr vm); ++int virDomainObjCheckIsActive(virDomainObjPtr vm); + int virDomainObjWaitUntil(virDomainObjPtr vm, + unsigned long long whenms); +=20 +diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c +index 74cb05a..3a487ac 100644 +--- a/src/libxl/libxl_driver.c ++++ b/src/libxl/libxl_driver.c +@@ -1183,10 +1183,8 @@ libxlDomainSuspend(virDomainPtr dom) + if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) + goto cleanup; +=20 +- if (!virDomainObjIsActive(vm)) { +- virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not = running")); ++ if (virDomainObjCheckIsActive(vm) < 0) + goto endjob; +- } +=20 + if (virDomainObjGetState(vm, NULL) !=3D VIR_DOMAIN_PAUSED) { + if (libxl_domain_pause(cfg->ctx, vm->def->id) !=3D 0) { diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index e5b8f48..7a69215 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -1183,10 +1183,8 @@ libxlDomainSuspend(virDomainPtr dom) if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not r= unning")); + if (virDomainObjCheckIsActive(vm) < 0) goto endjob; - } =20 if (virDomainObjGetState(vm, NULL) !=3D VIR_DOMAIN_PAUSED) { if (libxl_domain_pause(cfg->ctx, vm->def->id) !=3D 0) { @@ -1239,10 +1237,8 @@ libxlDomainResume(virDomainPtr dom) if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not r= unning")); + if (virDomainObjCheckIsActive(vm) < 0) goto endjob; - } =20 if (virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_PAUSED) { if (libxl_domain_unpause(cfg->ctx, vm->def->id) !=3D 0) { @@ -1297,11 +1293,8 @@ libxlDomainShutdownFlags(virDomainPtr dom, unsigned = int flags) if (virDomainShutdownFlagsEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("Domain is not running")); + if (virDomainObjCheckIsActive(vm) < 0) goto cleanup; - } =20 if (flags & VIR_DOMAIN_SHUTDOWN_PARAVIRT) { ret =3D libxl_domain_shutdown(cfg->ctx, vm->def->id); @@ -1364,11 +1357,8 @@ libxlDomainReboot(virDomainPtr dom, unsigned int fla= gs) if (virDomainRebootEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("Domain is not running")); + if (virDomainObjCheckIsActive(vm) < 0) goto cleanup; - } =20 if (flags & VIR_DOMAIN_REBOOT_PARAVIRT) { ret =3D libxl_domain_reboot(cfg->ctx, vm->def->id); @@ -1411,11 +1401,8 @@ libxlDomainDestroyFlags(virDomainPtr dom, if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("Domain is not running")); + if (virDomainObjCheckIsActive(vm) < 0) goto endjob; - } =20 if (libxlDomainDestroyInternal(driver, vm) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1820,10 +1807,8 @@ libxlDomainSaveFlags(virDomainPtr dom, const char *t= o, const char *dxml, if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not r= unning")); + if (virDomainObjCheckIsActive(vm) < 0) goto endjob; - } =20 if (libxlDoDomainSave(driver, vm, to) < 0) goto endjob; @@ -1946,10 +1931,8 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to= , unsigned int flags) if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not r= unning")); + if (virDomainObjCheckIsActive(vm) < 0) goto endjob; - } =20 if (!(flags & VIR_DUMP_LIVE) && virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_RUNNING) { @@ -2043,10 +2026,9 @@ libxlDomainManagedSave(virDomainPtr dom, unsigned in= t flags) if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not r= unning")); + if (virDomainObjCheckIsActive(vm) < 0) goto endjob; - } + if (!vm->persistent) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("cannot do managed save for transient domain")); @@ -2518,10 +2500,8 @@ libxlDomainGetVcpus(virDomainPtr dom, virVcpuInfoPtr= info, int maxinfo, if (virDomainGetVcpusEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not r= unning")); + if (virDomainObjCheckIsActive(vm) < 0) goto cleanup; - } =20 if ((vcpuinfo =3D libxl_list_vcpu(cfg->ctx, vm->def->id, &maxcpu, &hostcpus)) =3D=3D NULL) { @@ -2755,11 +2735,8 @@ libxlDomainCreateWithFlags(virDomainPtr dom, if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) goto cleanup; =20 - if (virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("Domain is already running")); + if (virDomainObjCheckIsActive(vm) < 0) goto endjob; - } =20 ret =3D libxlDomainStartNew(driver, vm, (flags & VIR_DOMAIN_START_PAUSED) !=3D 0); @@ -4498,10 +4475,8 @@ libxlDomainGetSchedulerType(virDomainPtr dom, int *n= params) if (virDomainGetSchedulerTypeEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not r= unning")); + if (virDomainObjCheckIsActive(vm) < 0) goto cleanup; - } =20 sched_id =3D libxl_get_scheduler(cfg->ctx); =20 @@ -4562,11 +4537,8 @@ libxlDomainGetSchedulerParametersFlags(virDomainPtr = dom, if (virDomainGetSchedulerParametersFlagsEnsureACL(dom->conn, vm->def) = < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("Domain is not running")); + if (virDomainObjCheckIsActive(vm) < 0) goto cleanup; - } =20 sched_id =3D libxl_get_scheduler(cfg->ctx); =20 @@ -4643,10 +4615,8 @@ libxlDomainSetSchedulerParametersFlags(virDomainPtr = dom, if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not r= unning")); + if (virDomainObjCheckIsActive(vm) < 0) goto endjob; - } =20 sched_id =3D libxl_get_scheduler(cfg->ctx); =20 @@ -4712,11 +4682,8 @@ libxlDomainOpenConsole(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 (virDomainObjCheckIsActive(vm) < 0) goto cleanup; - } =20 priv =3D vm->privateData; if (dev_name) { @@ -4812,11 +4779,8 @@ libxlDomainGetNumaParameters(virDomainPtr dom, if (virDomainGetNumaParametersEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("Domain is not running")); + if (virDomainObjCheckIsActive(vm) < 0) goto cleanup; - } =20 if ((*nparams) =3D=3D 0) { *nparams =3D LIBXL_NUMA_NPARAM; @@ -4983,11 +4947,8 @@ libxlDomainInterfaceStats(virDomainPtr dom, if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckIsActive(vm) < 0) goto endjob; - } =20 /* Check the path is one of the domain's network interfaces. */ for (i =3D 0; i < vm->def->nnets; i++) { @@ -5111,11 +5072,8 @@ libxlDomainGetCPUStats(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 (virDomainObjCheckIsActive(vm) < 0) goto cleanup; - } =20 if (start_cpu =3D=3D -1) ret =3D libxlDomainGetTotalCPUStats(driver, vm, params, nparams); @@ -5164,11 +5122,8 @@ libxlDomainMemoryStats(virDomainPtr dom, if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckIsActive(vm) < 0) goto endjob; - } =20 if (libxl_domain_info(cfg->ctx, &d_info, vm->def->id) !=3D 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -5528,11 +5483,8 @@ libxlDomainBlockStats(virDomainPtr dom, if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckIsActive(vm) < 0) goto endjob; - } =20 memset(&blkstats, 0, sizeof(libxlBlockStats)); if ((ret =3D libxlDomainBlockStatsGather(vm, path, &blkstats)) < 0) @@ -5581,11 +5533,8 @@ libxlDomainBlockStatsFlags(virDomainPtr dom, if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckIsActive(vm) < 0) goto endjob; - } =20 /* return count of supported stats */ if (*nparams =3D=3D 0) { @@ -5922,9 +5871,7 @@ libxlDomainMigrateBegin3Params(virDomainPtr domain, return NULL; } =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckIsActive(vm) < 0) { virObjectUnlock(vm); return NULL; } @@ -6330,11 +6277,8 @@ libxlDomainInterfaceAddresses(virDomainPtr dom, if (virDomainInterfaceAddressesEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("domain is not running")); + if (virDomainObjCheckIsActive(vm) < 0) goto cleanup; - } =20 switch (source) { case VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE: --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list