From nobody Wed Apr 24 11:24:55 2024 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; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1565699320; cv=none; d=zoho.com; s=zohoarc; b=Jgj6gpg0Se9jwd4ggMzv1JWzq+HA48c/pQf85pXWioeccC/tcmGdILeIj+EURk5qe+rcPhMgBDdt7axvhy4tnEeiLVCLdf5pPg6BCzidcWpgDI+StKyCpBslkJobY6q8qjO5NMNd8T6V4H/ysaL7nOQgxG0B5upai6cmwcluxZw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565699320; 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:ARC-Authentication-Results; bh=XKckvHy60vg2VtVog0AuRJIJPbe2igZX9DT88gBDEA0=; b=ZeUR/ipZF5VSvM9m5C428xNtY7QceQ6ggbPGtFBmybXJ18Rf6qHNRPJgREHkvdxhXqKCNHX7F8IehnZoQU7fJIOHQAWrhPFiic4kIyQ+DbaeWhWzSAEW9QdL/jrcJ1tTJX2jbregwthZqcOPGTwO+Utf9O0kfcLpvEsI3ujlC7M= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1565699320825385.1658523245819; Tue, 13 Aug 2019 05:28:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3A80730A7B81; Tue, 13 Aug 2019 12:28:37 +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 14FB4891AC; Tue, 13 Aug 2019 12:28:37 +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 BB5B5E205; Tue, 13 Aug 2019 12:28: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 x7DCSabe002462 for ; Tue, 13 Aug 2019 08:28:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 286BF82483; Tue, 13 Aug 2019 12:28:36 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 21F2D5D717 for ; Tue, 13 Aug 2019 12:28:32 +0000 (UTC) Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) (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 A452BA3EB6 for ; Tue, 13 Aug 2019 12:28:31 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id q12so17307813wrj.12 for ; Tue, 13 Aug 2019 05:28:31 -0700 (PDT) Received: from archlap.localdomain ([185.32.231.210]) by smtp.gmail.com with ESMTPSA id q19sm965623wmc.41.2019.08.13.05.28.28 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 13 Aug 2019 05:28:29 -0700 (PDT) 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:mime-version :content-transfer-encoding; bh=DZtUh9ePFGaQjIuQylNEJfQa6GaGdpGs2ZKosfqePzU=; b=XWVjckNovng/eUfhZiSS5j9Tmg8QAoxtRdHw5hNX1S352ZLZkgpUwdFtc0cjjyoc2q NQYERze0sHLVaJrx/j1OF0sW1D4rEqAqp4pFaQlkn1Yh4/knBcPZSe8FAqmQ7BV1jfX1 hFljB9aEyjeo57caCCfn2ohFh9eFhqp1QvYPC8I5PC1ke85PH5ay7PgeQMd3MxpFKgda 6YcUol5kPcmZBudyRwPKm1mdoRZIuZ2ePwiQQvu87S21VlB2ir79LemPR3yet02stxPJ IIH4cwqJg6d6yvGECPkJYLnnYDEQyvgxgj2QQuqOVXtuuqKXkJJ1QEwMgM+yf5qNonN6 YaDg== 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:mime-version:content-transfer-encoding; bh=DZtUh9ePFGaQjIuQylNEJfQa6GaGdpGs2ZKosfqePzU=; b=e0s7A+MV0SzTQabyDSabaY7/3Z6eM6UxEIwZXYmmT8H5nsNOQn7Wu61mUpjvpGH6C1 VtQvpb3BhKS0wSQr/O7W3YJLxpAkkqQKz4ZBO/5+b0ZcJGQr/kffvhtQITfukEoLe8hl re2hAweSDoM//NzbIpgfFvMggshHbhOIp4netUWwGyciUZNp/i04Q6t3+Wb6sDnatejD lDKrfQ73Cva1NA9dypnoueqQN1QaDdfVogYprdXz8x1TsXF1JC/p8DesgXJ5DDgsU4SP R2MzhDNTqA9c0y20MM7p3WtWd9gzvTehf3x80D8Tk/jS8BcckeiQ4jFquqUrb7R/WGtX eykw== X-Gm-Message-State: APjAAAVp00sxJGXdU7uZk223OczAuYPW6KNC4oY+J8VLOstTBqGAEAby alTNrI1y+NEfmQAQ5cT/VKNZ/thSK4k= X-Google-Smtp-Source: APXvYqwpmT6QiHOk/7Nvh0V+DCBPrD63o97MkFxpe9j3oLgFyFZNT1NsVJYxtRoQwikI0qri+WYO5Q== X-Received: by 2002:adf:fc81:: with SMTP id g1mr41849664wrr.78.1565699310039; Tue, 13 Aug 2019 05:28:30 -0700 (PDT) From: Ilias Stamatis To: libvir-list@redhat.com Date: Tue, 13 Aug 2019 15:28:09 +0300 Message-Id: <20190813122810.26351-2-stamatis.iliass@gmail.com> In-Reply-To: <20190813122810.26351-1-stamatis.iliass@gmail.com> References: <20190813122810.26351-1-stamatis.iliass@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 13 Aug 2019 12:28:32 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 13 Aug 2019 12:28:32 +0000 (UTC) for IP:'209.85.221.68' DOMAIN:'mail-wr1-f68.google.com' HELO:'mail-wr1-f68.google.com' FROM:'stamatis.iliass@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.505 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS) 209.85.221.68 mail-wr1-f68.google.com 209.85.221.68 mail-wr1-f68.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 1/2] test_driver: handle different lifecycle actions in testDomainShutdownFlags 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: , 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Tue, 13 Aug 2019 12:28:39 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Ilias Stamatis Reviewed-by: Erik Skultety --- src/test/test_driver.c | 77 ++++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 32 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 5f5c512571..5a3ed45008 100755 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1902,6 +1902,40 @@ static int testDomainSuspend(virDomainPtr domain) return ret; } + +static void +testDomainActionSetState(virDomainObjPtr dom, + int lifecycle_type) +{ + switch (lifecycle_type) { + case VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY: + virDomainObjSetState(dom, VIR_DOMAIN_SHUTOFF, + VIR_DOMAIN_SHUTOFF_SHUTDOWN); + break; + + case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART: + virDomainObjSetState(dom, VIR_DOMAIN_RUNNING, + VIR_DOMAIN_RUNNING_BOOTED); + break; + + case VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE: + virDomainObjSetState(dom, VIR_DOMAIN_SHUTOFF, + VIR_DOMAIN_SHUTOFF_SHUTDOWN); + break; + + case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME: + virDomainObjSetState(dom, VIR_DOMAIN_RUNNING, + VIR_DOMAIN_RUNNING_BOOTED); + break; + + default: + virDomainObjSetState(dom, VIR_DOMAIN_SHUTOFF, + VIR_DOMAIN_SHUTOFF_SHUTDOWN); + break; + } +} + + static int testDomainShutdownFlags(virDomainPtr domain, unsigned int flags) { @@ -1922,13 +1956,17 @@ static int testDomainShutdownFlags(virDomainPtr dom= ain, goto cleanup; } - testDomainShutdownState(domain, privdom, VIR_DOMAIN_SHUTOFF_SHUTDOWN); - event =3D virDomainEventLifecycleNewFromObj(privdom, - VIR_DOMAIN_EVENT_STOPPED, - VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN); + testDomainActionSetState(privdom, privdom->def->onPoweroff); - if (!privdom->persistent) - virDomainObjListRemove(privconn->domains, privdom); + if (virDomainObjGetState(privdom, NULL) =3D=3D VIR_DOMAIN_SHUTOFF) { + testDomainShutdownState(domain, privdom, VIR_DOMAIN_SHUTOFF_SHUTDO= WN); + event =3D virDomainEventLifecycleNewFromObj(privdom, + VIR_DOMAIN_EVENT_STOPPED, + VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN= ); + + if (!privdom->persistent) + virDomainObjListRemove(privconn->domains, privdom); + } ret =3D 0; cleanup: @@ -1967,32 +2005,7 @@ static int testDomainReboot(virDomainPtr domain, virDomainObjSetState(privdom, VIR_DOMAIN_SHUTDOWN, VIR_DOMAIN_SHUTDOWN_USER); - switch (privdom->def->onReboot) { - case VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY: - virDomainObjSetState(privdom, VIR_DOMAIN_SHUTOFF, - VIR_DOMAIN_SHUTOFF_SHUTDOWN); - break; - - case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART: - virDomainObjSetState(privdom, VIR_DOMAIN_RUNNING, - VIR_DOMAIN_RUNNING_BOOTED); - break; - - case VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE: - virDomainObjSetState(privdom, VIR_DOMAIN_SHUTOFF, - VIR_DOMAIN_SHUTOFF_SHUTDOWN); - break; - - case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME: - virDomainObjSetState(privdom, VIR_DOMAIN_RUNNING, - VIR_DOMAIN_RUNNING_BOOTED); - break; - - default: - virDomainObjSetState(privdom, VIR_DOMAIN_SHUTOFF, - VIR_DOMAIN_SHUTOFF_SHUTDOWN); - break; - } + testDomainActionSetState(privdom, privdom->def->onReboot); if (virDomainObjGetState(privdom, NULL) =3D=3D VIR_DOMAIN_SHUTOFF) { testDomainShutdownState(domain, privdom, VIR_DOMAIN_SHUTOFF_SHUTDO= WN); -- 2.22.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Apr 24 11:24:55 2024 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; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1565699329; cv=none; d=zoho.com; s=zohoarc; b=YHGJTmV2n+uNZgFJ1rJNW/XtrhcZopCWG5INYraJlrlxTwRSh6geqEzcpshk2AyhuJg6fkGsBPAKrKtiDkBPHmDuaq4vrGVLpPn07FoGl5ptszsdGmpWs1wAVD3Y/CRqkIspwVT1AIYMB7W7c5FWF+2PNLhCWu8zFvV3BISZof0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565699329; 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:ARC-Authentication-Results; bh=eFjv27mXdIlXzRJjwPQ8AveWkNoNbVQQrrS2w3uOeOg=; b=YURv9y9T+P9H2IXS1CuQ99Cy40ei0Jdhx4sS511ZccvEDxJzzZDoXyphPXpLDQscqDeIT2YoDlsiDi9KVK+h5b/11LuMN87pVtATCej9TV6YFbztEjdKXIzNND65RGFVzQMcVrdeQ0AJFsscG5xPd02LPB2n4FNVe9WOKwPhSSM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1565699329488768.936522598576; Tue, 13 Aug 2019 05:28:49 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id EF9FF30D47F3; Tue, 13 Aug 2019 12:28:47 +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 CE18B8249C; Tue, 13 Aug 2019 12:28:47 +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 94493180BA99; Tue, 13 Aug 2019 12:28:47 +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 x7DCSjGC002479 for ; Tue, 13 Aug 2019 08:28:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id 739D282496; Tue, 13 Aug 2019 12:28:45 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6A77F5D717 for ; Tue, 13 Aug 2019 12:28:45 +0000 (UTC) Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) (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 2A8B8C04D946 for ; Tue, 13 Aug 2019 12:28:43 +0000 (UTC) Received: by mail-wm1-f68.google.com with SMTP id 207so1336588wma.1 for ; Tue, 13 Aug 2019 05:28:43 -0700 (PDT) Received: from archlap.localdomain ([185.32.231.210]) by smtp.gmail.com with ESMTPSA id q19sm965623wmc.41.2019.08.13.05.28.40 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 13 Aug 2019 05:28:40 -0700 (PDT) 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:mime-version :content-transfer-encoding; bh=bno8N8qqmTF/rVGAHEN7SRIf3ex0G4QwPPQ5+0I/Q1M=; b=Pjbrta5JmgjRRNpcjBJf6g0+gq7Bb47mbk1EwmMi9/ivMiYcBpGedgYu/3Q1b9u+Ap Rv7Gv+ksuu3HhxtJFziDed7c3riFcjk2HpiCQzn8Q+29840tcUvrbC8RS9zsF5htTPcE hFB2rfqg8wi2/FNz0g1S0NT/dqbWAMG8dYqi2cmGRJomzXy60LPGZgjLSicBthVSUiY4 3mZv9CdVgFBEl8Ey9153stYLPJ0l4SC/UfVpwPcZxTuIcsWh+bDY43nhdh5z50fg8rTY 6xgVfS/N+bjA3YzHbxE3bmRLeUto+IgZE+x1pkU2ypHZT0sWlIafPvcgtEDNc6a0D4ZQ mZ0g== 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:mime-version:content-transfer-encoding; bh=bno8N8qqmTF/rVGAHEN7SRIf3ex0G4QwPPQ5+0I/Q1M=; b=rJTiId07BlxQOJiOgLLMOg+QQ/eE57S4ull8aEFGBvqCwUc1UC6TOpQzv31C3cFnny H7cF+uQfsusSSWqSI1b81Cf/D0P+Gc2QpW40psRUFSuA1g1S+8FJ+wH03WBnLjC68eet xQfaXfoBzgDCbWr+xB+F4Z2UjPHP7sQ0iIbZ5oJxfyCTHkqgdrgqKAEGLFiPqZJazChk XK6kR2dcwD0ojXQ5gQAse5EOgNJf/t3hUVQUhCGqObXA0AGsZMbVXOZmD53DUYlSbC48 eUvYuJilbS6Cth2FBCt71CrbEU41oOvfUVJep3KXJUe9+J76oYiqwkNXptTF3nEUDPuy T1lA== X-Gm-Message-State: APjAAAUd6huT8rJh+ltkTbjGlphfudfm0cr1+9QVLaJRpWhNKJB8s6G8 ic6G+pMBLjpteBLhKbmNVMW/EVNrGbA= X-Google-Smtp-Source: APXvYqziH8fy3ExUCvYT/GhGgQVGJwg0GmoTdiXXDTxhyAqCRL524RfO4T/iI50mK97PqgJVhYmFTA== X-Received: by 2002:a7b:c091:: with SMTP id r17mr2720829wmh.74.1565699321490; Tue, 13 Aug 2019 05:28:41 -0700 (PDT) From: Ilias Stamatis To: libvir-list@redhat.com Date: Tue, 13 Aug 2019 15:28:10 +0300 Message-Id: <20190813122810.26351-3-stamatis.iliass@gmail.com> In-Reply-To: <20190813122810.26351-1-stamatis.iliass@gmail.com> References: <20190813122810.26351-1-stamatis.iliass@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 13 Aug 2019 12:28:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 13 Aug 2019 12:28:43 +0000 (UTC) for IP:'209.85.128.68' DOMAIN:'mail-wm1-f68.google.com' HELO:'mail-wm1-f68.google.com' FROM:'stamatis.iliass@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.541 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS) 209.85.128.68 mail-wm1-f68.google.com 209.85.128.68 mail-wm1-f68.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 2/2] test_driver: implement virDomainSetLifecycleAction 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: , 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 13 Aug 2019 12:28:48 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Ilias Stamatis Reviewed-by: Erik Skultety --- src/test/test_driver.c | 58 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 5a3ed45008..2008e7e43a 100755 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -8132,6 +8132,63 @@ testDomainGetBlockInfo(virDomainPtr dom, } +static void +testDomainModifyLifecycleAction(virDomainDefPtr def, + virDomainLifecycle type, + virDomainLifecycleAction action) +{ + switch (type) { + case VIR_DOMAIN_LIFECYCLE_POWEROFF: + def->onPoweroff =3D action; + break; + case VIR_DOMAIN_LIFECYCLE_REBOOT: + def->onReboot =3D action; + break; + case VIR_DOMAIN_LIFECYCLE_CRASH: + def->onCrash =3D action; + break; + case VIR_DOMAIN_LIFECYCLE_LAST: + break; + } +} + + +static int +testDomainSetLifecycleAction(virDomainPtr dom, + unsigned int type, + unsigned int action, + unsigned int flags) +{ + virDomainObjPtr vm =3D NULL; + virDomainDefPtr def =3D NULL; + virDomainDefPtr persistentDef =3D NULL; + int ret =3D -1; + + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | + VIR_DOMAIN_AFFECT_CONFIG, -1); + + if (!virDomainDefLifecycleActionAllowed(type, action)) + return -1; + + if (!(vm =3D testDomObjFromDomain(dom))) + return -1; + + if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) + goto cleanup; + + if (def) + testDomainModifyLifecycleAction(def, type, action); + + if (persistentDef) + testDomainModifyLifecycleAction(persistentDef, type, action); + + ret =3D 0; + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + + /* * Snapshot APIs */ @@ -9437,6 +9494,7 @@ static virHypervisorDriver testHypervisorDriver =3D { .domainMemoryStats =3D testDomainMemoryStats, /* 5.7.0 */ .domainMemoryPeek =3D testDomainMemoryPeek, /* 5.4.0 */ .domainGetBlockInfo =3D testDomainGetBlockInfo, /* 5.7.0 */ + .domainSetLifecycleAction =3D testDomainSetLifecycleAction, /* 5.7.0 */ .domainSnapshotNum =3D testDomainSnapshotNum, /* 1.1.4 */ .domainSnapshotListNames =3D testDomainSnapshotListNames, /* 1.1.4 */ -- 2.22.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list