From nobody Sun May 5 10:21:01 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 1516043928477602.1610033826473; Mon, 15 Jan 2018 11:18:48 -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 6636580C1E; Mon, 15 Jan 2018 19:18:40 +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 7822E5D70A; Mon, 15 Jan 2018 19:18:36 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 11F6E410B3; Mon, 15 Jan 2018 19:18:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w0FJITWT017924 for ; Mon, 15 Jan 2018 14:18:29 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4D5EF5EDE4; Mon, 15 Jan 2018 19:18:29 +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 469B65D753 for ; Mon, 15 Jan 2018 19:18:26 +0000 (UTC) Received: from mail-qk0-f193.google.com (mail-qk0-f193.google.com [209.85.220.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 A7CB740226 for ; Mon, 15 Jan 2018 19:18:25 +0000 (UTC) Received: by mail-qk0-f193.google.com with SMTP id u76so18037904qku.11 for ; Mon, 15 Jan 2018 11:18:25 -0800 (PST) Received: from localhost.localdomain ([177.45.186.140]) by smtp.googlemail.com with ESMTPSA id y23sm240675qtj.20.2018.01.15.11.18.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Jan 2018 11:18:23 -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=gitP3d+Acxu5mPLwIVI61eCBMgPVC8RJg9/IToUKHcs=; b=a6lszRq8E0McKsRy+aKZb+QZmRwdgqnt3fMpZVlDhAjRDo9/O+8T4sWzcxf+g2ZS1h BrAfx9JDHiY3CMcmtPMCcBbvrwvcqSIJ+F6pVr0jjpz734qq3TWFw64yKeHV7t1B+BRa rkrxRG/P6Y/crYakpopBZpcKaD6tHQDoaAswRO/5OwUAJyZaTynvhBVRHKcwVdbOt2f3 V8gYWgT7EXIpfxRgD1gU46b0E/adi9JhZFWbgZ/3laOUiSVhJRSa15l0YHRSEKa4po2O 8AXn0Ud5Du2aARwy4+TfM4Wepd01YCLYznY6M7GSTYZVSFuaN7oVl3uptz1j0qm/d2/q eKSA== 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=gitP3d+Acxu5mPLwIVI61eCBMgPVC8RJg9/IToUKHcs=; b=Wz2KZdn7iwXuq7mYyC+//u72BRXUyTklI2QAMkwbjKXyFgddtTgQgiqR0AFXpFAIUd LBR+w8qBSOW5nxf7qFCFMAXs840QNdiBZ6MLM9rSrIZt9INuLav70IcbntvpIVjpNTVI N/ndjbGB+4iRgBQ/qcjkWpYQPF8XjvTV7xgdDLYGS4ul7UAcWVXsS6Dn/T1r1yVkhtek +mQziBloZOSiEQZOBPHXYcw8sUesOkqrI1Co8ZDMD24lRoZ5vT6saeJOxars1skVQd5C pvEYxUMHRogrb2S4LUf0FPI39UbrhzAnJm0OEoOmx4QHWrJ+53FFajk/4H6Az/X8Sr1X H2LA== X-Gm-Message-State: AKwxytejoWudz1SV50w4x0O+yaU09CkSMB+FbCqQoLPXWxg+kD0DS1hh iHy1iOxensukvFubRI/yekXlCQ== X-Google-Smtp-Source: ACJfBotY5Nb7oisxyXae8L6KhmsYcBXfWpBlOLrQjUf4enKiOiOSpNJovK+8uVngaYFpVPwj9J3esw== X-Received: by 10.55.22.88 with SMTP id g85mr44622309qkh.117.1516043904464; Mon, 15 Jan 2018 11:18:24 -0800 (PST) From: Julio Faracco To: libvir-list@redhat.com Date: Mon, 15 Jan 2018 17:18:08 -0200 Message-Id: <1516043889-32720-2-git-send-email-jcfaracco@gmail.com> In-Reply-To: <1516043889-32720-1-git-send-email-jcfaracco@gmail.com> References: <1516043889-32720-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]); Mon, 15 Jan 2018 19:18:25 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 15 Jan 2018 19:18:25 +0000 (UTC) for IP:'209.85.220.193' DOMAIN:'mail-qk0-f193.google.com' HELO:'mail-qk0-f193.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.193 mail-qk0-f193.google.com 209.85.220.193 mail-qk0-f193.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 v3 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 15 Jan 2018 19:18:46 +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 | 84 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 84 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index dc743b4..1461efb 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -2618,6 +2618,89 @@ 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, -1); + + 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 (virDomainObjGetState(privdom, NULL) !=3D VIR_DOMAIN_SHUTOFF) { + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain has to be shutoff before renaming")= ); + 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; @@ -6822,6 +6905,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 Sun May 5 10:21:01 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 1516043953621921.3182670271491; Mon, 15 Jan 2018 11:19:13 -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 AF36D7E420; Mon, 15 Jan 2018 19:19:11 +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 D1CA55D6A5; Mon, 15 Jan 2018 19:19:10 +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 D72B418033DB; Mon, 15 Jan 2018 19:19:07 +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 w0FJIdFe017954 for ; Mon, 15 Jan 2018 14:18:39 -0500 Received: by smtp.corp.redhat.com (Postfix) id DCCB45C257; Mon, 15 Jan 2018 19:18:39 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D6C9B5C20A for ; Mon, 15 Jan 2018 19:18:36 +0000 (UTC) Received: from mail-qt0-f193.google.com (mail-qt0-f193.google.com [209.85.216.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 01B2C7AE8B for ; Mon, 15 Jan 2018 19:18:28 +0000 (UTC) Received: by mail-qt0-f193.google.com with SMTP id i40so15451325qti.8 for ; Mon, 15 Jan 2018 11:18:27 -0800 (PST) Received: from localhost.localdomain ([177.45.186.140]) by smtp.googlemail.com with ESMTPSA id y23sm240675qtj.20.2018.01.15.11.18.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Jan 2018 11:18:26 -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=N4xid9b2U+DHeEXxsbtNDVBBij4JJiE4oh9tkAvRy+0=; b=eUw4cY0Rg4t8aESBTXEgWLeIzC2BuLGOrxyFLYJt5vbXxtsFJfMJLlotZsn7wMK4mn 0oS1L/3B3IKDK3vpqoHvA5B4B/pcXYwOBoBBqgRjxZ4pXLevcJ5CKZrWXPuzvYhrsxoo jHFn/JV4G80WGhl3ntGtd8Ihbtziidv9ZFOzE1/C9eSoYnKdkAQQgOvhDx2RGaiht26z sQWctm50SttWdhUa6rxb39DgnRURWcFNsoVviDy3S2LBiYhban1HsfUjgbRrlej6q50U dZpYHnqhG53z3bCri+28cZg+1+yMuSuaul3tXmeXJvL9zMBicvDZX3sLlKHi9fQeho8Q yNfA== 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=N4xid9b2U+DHeEXxsbtNDVBBij4JJiE4oh9tkAvRy+0=; b=lXeSFyioAaSf8u7xKMTE1NxJtjHEE1QcbuzQ3UMeoJx8yTCuyzPamuhPwT5wfhlICS jaMyToi8kNbE6NeDTqoxO6yzWbFr+GDI1UVI+s5yoU7u9piJZtEVlwsddqLkIg/o/pJL CYnvHe7/3KY+K88Uj5d9+G3lDyudt272Ff/QISeGJNlpvZR08cDnkVz74dJiZtQ5xhZk zDkrZLBdSdc+Q3W2tOfj8X4sdHUVXKWYrDrUIiXWI4AB3oIWNRlrJ42ad9P0P/iZCfSj YUBtxTlozqpeImE4mMCvgYlVeryfeJLnr8KN0ujz78oZNjFQITIahvS+tdBlBVsLKpo+ sfWQ== X-Gm-Message-State: AKwxytf0gkljKS4ps2F6BCCJ+9tolBV2m5FqaJdmT2D3BXoYoGAr8UJ2 zk8QbLHJ/dMypdsKVDQoCqkqbA== X-Google-Smtp-Source: ACJfBosK9LKBDmQMzLN9Mrcbc31iGYi+HE8la9sYNBkrr+c8ogbn0lYf9s6JcwnYyp8/ZkvP+go4Nw== X-Received: by 10.237.55.166 with SMTP id j35mr50811382qtb.31.1516043906901; Mon, 15 Jan 2018 11:18:26 -0800 (PST) From: Julio Faracco To: libvir-list@redhat.com Date: Mon, 15 Jan 2018 17:18:09 -0200 Message-Id: <1516043889-32720-3-git-send-email-jcfaracco@gmail.com> In-Reply-To: <1516043889-32720-1-git-send-email-jcfaracco@gmail.com> References: <1516043889-32720-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.25]); Mon, 15 Jan 2018 19:18:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 15 Jan 2018 19:18:28 +0000 (UTC) for IP:'209.85.216.193' DOMAIN:'mail-qt0-f193.google.com' HELO:'mail-qt0-f193.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.216.193 mail-qt0-f193.google.com 209.85.216.193 mail-qt0-f193.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 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.27]); Mon, 15 Jan 2018 19:19:12 +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