From nobody Tue Apr 30 01:51:22 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15138848326348.936270254011902; Thu, 21 Dec 2017 11:33:52 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 02C2DC058EBC; Thu, 21 Dec 2017 19:33:51 +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 A783B5DA67; Thu, 21 Dec 2017 19:33:50 +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 7754F4BB79; Thu, 21 Dec 2017 19:33:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vBLJXlLE025344 for ; Thu, 21 Dec 2017 14:33:47 -0500 Received: by smtp.corp.redhat.com (Postfix) id E83F09231F; Thu, 21 Dec 2017 19:33:47 +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 E0A821800B for ; Thu, 21 Dec 2017 19:33:45 +0000 (UTC) Received: from mail-qk0-f194.google.com (mail-qk0-f194.google.com [209.85.220.194]) (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 AC4E5624BE for ; Thu, 21 Dec 2017 19:33:44 +0000 (UTC) Received: by mail-qk0-f194.google.com with SMTP id o126so19777301qke.12 for ; Thu, 21 Dec 2017 11:33:44 -0800 (PST) Received: from localhost.localdomain ([189.0.171.32]) by smtp.googlemail.com with ESMTPSA id b65sm4440515qkc.0.2017.12.21.11.33.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Dec 2017 11:33:42 -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=KHxGmyVW3/2z6t/K/LQsBYsYw3fVt6Acf63DwfJn+yg=; b=hMyHXriAKASmQEbXp5S/mzfvPON0T82UAwtgvZoEjTEyh3zoJtY6xqn1x7/nOzdmku JtcdJe33h9YhVPG6IKtPrGuqGgm/MUoFDwFus0zHygyy4BLqBhtVZZFBGVbsMq+o8+ss o2LB+8BFiLOsaMZkYPF5p3ZlffDKAnIstHzJA1vXmPkhQnCE5tUomDyXHoqbk6cZDOOJ 7iDIyOY45bKxg+MAhPfepig+HaycAQSZklORRlJdXp5PPxB8h/Wxpcrezxzgt7tlnxk5 mjT5rd5nOEjuiRPRcwlMbq4eo8mKDIDWUXyB7vBX1oxc9yNTW8VevuTjjKNsvQKSvD26 4Bbw== 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=KHxGmyVW3/2z6t/K/LQsBYsYw3fVt6Acf63DwfJn+yg=; b=Sm2Wecf336IO0DA/uc8ERjR8LGqoW0dgvWt2z4KCr2LfzHca+kXW+85XI4kiyzWYYt xc0gBgPHI/JIbm1vbjYdq99r7noirF59dIVOhKPBjHKszA5k6C8cjknWJUF9Jg6TTIZ8 vC5d281YlpfKizIvVl4Vqy3cGrUwitcyoMpLfGrxsnX0E5DSUb07cLNU5+0tgzuITfyh E+Zu0W2vSVJhhvnPwjvz2RoqcfHMqyPPPV1QWJA15jVWcAl+3EiFCgwJJE27Djuj8Cy2 An5PLVfXiVwAmsQj47dxzMB2yaqdeBq69WmFfX25Ybe11ugCUsWg3ZelLuO38igk0Dab Jprw== X-Gm-Message-State: AKGB3mK/bRXIbt9DKiKILF4m/wk9zCD16Tp1dZUqZnzqx935H05VtVsT lzxsAsKN/a0MJH2M2otNEHs9pw== X-Google-Smtp-Source: ACJfBoulHMeBULBH99qUpXMwMarwm9ddhAYRkDoBNF3vQfcThbTrNtWlMp96NrtrO28hEoAc/Lswig== X-Received: by 10.55.99.140 with SMTP id x134mr4001594qkb.35.1513884823574; Thu, 21 Dec 2017 11:33:43 -0800 (PST) From: Julio Faracco To: libvir-list@redhat.com Date: Thu, 21 Dec 2017 17:33:27 -0200 Message-Id: <1513884808-22472-2-git-send-email-jcfaracco@gmail.com> In-Reply-To: <1513884808-22472-1-git-send-email-jcfaracco@gmail.com> References: <1513884808-22472-1-git-send-email-jcfaracco@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 21 Dec 2017 19:33:44 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 21 Dec 2017 19:33:44 +0000 (UTC) for IP:'209.85.220.194' DOMAIN:'mail-qk0-f194.google.com' HELO:'mail-qk0-f194.google.com' FROM:'jcfaracco@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.13 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.220.194 mail-qk0-f194.google.com 209.85.220.194 mail-qk0-f194.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/2] test: Implementing testDomainRename(). 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 21 Dec 2017 19:33:51 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" There is no method to rename inactive domains for test driver. After this patch, we can rename the domains using 'domrename'. virsh# domrename test anothertest Domain successfully renamed Signed-off-by: Julio Faracco --- src/test/test_driver.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 96 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 8adc216..710fd5d 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -2618,6 +2618,101 @@ testDomainGetVcpuPinInfo(virDomainPtr dom, return ret; } =20 +static int +testDomainRenameCallback(virDomainObjPtr privdom, + const char *new_name, + unsigned int flags, + void *opaque) +{ + testDriverPtr driver =3D opaque; + virObjectEventPtr event_new =3D NULL; + virObjectEventPtr event_old =3D NULL; + int ret =3D -1; + char *new_dom_name =3D NULL; + char *old_dom_name =3D NULL; + + virCheckFlags(0, ret); + + if (VIR_STRDUP(new_dom_name, new_name) < 0) + goto cleanup; + + event_old =3D virDomainEventLifecycleNewFromObj(privdom, + VIR_DOMAIN_EVENT_UNDEFINED, + VIR_DOMAIN_EVENT_UNDEFINED_REN= AMED); + + /* Switch name in domain definition. */ + old_dom_name =3D privdom->def->name; + privdom->def->name =3D new_dom_name; + new_dom_name =3D NULL; + + event_new =3D virDomainEventLifecycleNewFromObj(privdom, + VIR_DOMAIN_EVENT_DEFINED, + VIR_DOMAIN_EVENT_DEFINED_REN= AMED); + ret =3D 0; + + cleanup: + VIR_FREE(old_dom_name); + VIR_FREE(new_dom_name); + testObjectEventQueue(driver, event_old); + testObjectEventQueue(driver, event_new); + return ret; +} + +static int testDomainRename(virDomainPtr dom, + const char *new_name, + unsigned int flags) +{ + testDriverPtr driver =3D dom->conn->privateData; + virDomainObjPtr privdom =3D NULL; + int ret =3D -1; + + virCheckFlags(0, -1); + + if (!(privdom =3D testDomObjFromDomain(dom))) + goto cleanup; + + if (virDomainObjIsActive(privdom)) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("cannot rename active domain")); + goto cleanup; + } + + if (!privdom->persistent) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("cannot rename a transient domain")); + goto cleanup; + } + + if (privdom->hasManagedSave) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("domain with a managed saved state can't be renam= ed")); + goto cleanup; + } + + if (virDomainObjGetState(privdom, NULL) !=3D VIR_DOMAIN_SHUTOFF) { + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain has to be shutoff before renaming")= ); + goto cleanup; + } + + if (virDomainSnapshotObjListNum(privdom->snapshots, NULL, 0) > 0) { + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("cannot rename domain with snapshots")); + goto cleanup; + } + + if (virDomainObjListRename(driver->domains, privdom, new_name, flags, + testDomainRenameCallback, driver) < 0) + goto cleanup; + + /* Success, domain has been renamed. */ + ret =3D 0; + + cleanup: + virDomainObjEndAPI(&privdom); + return ret; +} + static char *testDomainGetXMLDesc(virDomainPtr domain, unsigned int flags) { testDriverPtr privconn =3D domain->conn->privateData; @@ -6825,6 +6920,7 @@ static virHypervisorDriver testHypervisorDriver =3D { .connectDomainEventDeregisterAny =3D testConnectDomainEventDeregisterA= ny, /* 0.8.0 */ .connectIsAlive =3D testConnectIsAlive, /* 0.9.8 */ .nodeGetCPUMap =3D testNodeGetCPUMap, /* 1.0.0 */ + .domainRename =3D testDomainRename, /* 4.0.0 */ .domainScreenshot =3D testDomainScreenshot, /* 1.0.5 */ .domainGetMetadata =3D testDomainGetMetadata, /* 1.1.3 */ .domainSetMetadata =3D testDomainSetMetadata, /* 1.1.3 */ --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 01:51:22 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1513884833153653.9086111242759; Thu, 21 Dec 2017 11:33:53 -0800 (PST) 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 4691E7F7A9; Thu, 21 Dec 2017 19:33:51 +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 7ECAC2C309; Thu, 21 Dec 2017 19:33:50 +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 EEFB84A467; Thu, 21 Dec 2017 19:33:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vBLJXmoB025350 for ; Thu, 21 Dec 2017 14:33:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4E2881710F; Thu, 21 Dec 2017 19:33:48 +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 45E381800C for ; Thu, 21 Dec 2017 19:33:48 +0000 (UTC) Received: from mail-qk0-f194.google.com (mail-qk0-f194.google.com [209.85.220.194]) (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 ECC3C3683C for ; Thu, 21 Dec 2017 19:33:46 +0000 (UTC) Received: by mail-qk0-f194.google.com with SMTP id i190so11868608qka.5 for ; Thu, 21 Dec 2017 11:33:46 -0800 (PST) Received: from localhost.localdomain ([189.0.171.32]) by smtp.googlemail.com with ESMTPSA id b65sm4440515qkc.0.2017.12.21.11.33.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Dec 2017 11:33:45 -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=rTHj4GQmuheauMKRKZduuCaV/od/1UX1sC6DBbFqHxA=; b=hGX7yLV1kVDMURP6B+m5gB4w1oybY7ldnRuqf+3uHV+9tSEE0I2aRY/sY9AKywebWR KDZsoOfrD3p55LpSBs0aDl5lyA9gZ949rpIwt4RLWiMUXCLK635A2a1BsANgYvG+uySl 4jqVFOd6AqM2O6IOlae3+c+sl71WHju69zswrCPaAo5hzwkXv4furJmqMG1KicQkw/LS 53pwpXNPRNinaKR/jZo+LYkj/Pn60t37595naY4pq5bcec94BE5Mr6g9TK3ZVQkB3qC2 796C1wJQr53+PbU0NyIAkIWpnBTuIPYokycRQmga57Xn++smAYF4fPkQPz7NaHW3nxKm nBlw== 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=rTHj4GQmuheauMKRKZduuCaV/od/1UX1sC6DBbFqHxA=; b=bQC8iqvlZdlool3PIecJvgPRC2Z9Gd3OZmOIikXky+EqQcgB32F2vRDCZWS+zNtU5n LkGhND62j1aft9bcYHOhdBQbD/V/J/I+uRttgyS4X9qz3irXHiJ8d0WQlbskb5BSb4PB RYKMC3RpyC3XESZTB7jTcIFON+KFF4omh7EsNXSX99Ax6cOmyGbmnMQRDTPTHHcv3szS 6j1jsn+OA0hL+nTZ/EYhNTF+oJBLfQKoQXfEDFGQcZCfiIpgub1knaYxUNzXWYRBR8ft E5e6KZ3zwHOh2aAEIAW84u8nmo42k77NBKHtZFSVHL1VzoQbRknPuY+EEkthVl/V4Sxm Izeg== X-Gm-Message-State: AKGB3mKgRCsZNJQmG7gM3vHU45U8rdqgmK/fDUucpAXkC7R2FMwcdTZ8 1HX3Ug/6mmc3tMkY8G+WIr+USg== X-Google-Smtp-Source: ACJfBou8sr97T8DEN/w54bfxu/hUC7rEOq9H6pHmXeSBLxp67ab0lTcjey1ZDPaoum7m5/jSQmPqGg== X-Received: by 10.55.159.145 with SMTP id i139mr16013807qke.339.1513884825943; Thu, 21 Dec 2017 11:33:45 -0800 (PST) From: Julio Faracco To: libvir-list@redhat.com Date: Thu, 21 Dec 2017 17:33:28 -0200 Message-Id: <1513884808-22472-3-git-send-email-jcfaracco@gmail.com> In-Reply-To: <1513884808-22472-1-git-send-email-jcfaracco@gmail.com> References: <1513884808-22472-1-git-send-email-jcfaracco@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 21 Dec 2017 19:33:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 21 Dec 2017 19:33:47 +0000 (UTC) for IP:'209.85.220.194' DOMAIN:'mail-qk0-f194.google.com' HELO:'mail-qk0-f194.google.com' FROM:'jcfaracco@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.13 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.220.194 mail-qk0-f194.google.com 209.85.220.194 mail-qk0-f194.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] tests: Adding test case for virsh 'domrename' command. 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 21 Dec 2017 19:33:51 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This commit introduce the virsh-rename test script to test the 'domrename' command. The test contains one succedeed script to rename and another failed test. Signed-off-by: Julio Faracco --- tests/Makefile.am | 1 + tests/virsh-rename | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100755 tests/virsh-rename diff --git a/tests/Makefile.am b/tests/Makefile.am index 3441dab..0ff90fb 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -410,6 +410,7 @@ libvirtd_test_scripts =3D \ virt-admin-self-test \ virsh-start \ virsh-undefine \ + virsh-rename \ virsh-uriprecedence \ virsh-vcpupin \ $(NULL) diff --git a/tests/virsh-rename b/tests/virsh-rename new file mode 100755 index 0000000..4d976bb --- /dev/null +++ b/tests/virsh-rename @@ -0,0 +1,43 @@ +#!/bin/sh +# exercise virsh's "domrename" command + +# Copyright (C) 2008-2009, 2017 Red Hat, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHEXP ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see +# . + +. "$(dirname $0)/test-lib.sh" + +if test "$VERBOSE" =3D yes; then + set -x + $abs_top_builddir/tools/virsh --version +fi + +fail=3D0 + +# Succeed, now: first shut down, then rename the domain. +$abs_top_builddir/tools/virsh -q -c test:///default \ + 'shutdown test; domrename test anothertest' > out 2>&1 +test $? =3D 1 && fail=3D1 + +# Failed, now: rename the domain without shutting down. +$abs_top_builddir/tools/virsh -q -c test:///default \ + 'domrename test anothertest' > out 2>&1 +test $? =3D 1 || fail=3D1 +cat <<\EOF > expout || fail=3D1 +error: Requested operation is not valid: cannot rename active domain +EOF +compare expout out || fail=3D1 + +(exit $fail); exit $fail --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list