From nobody Mon Dec 15 23:51:47 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; 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