From nobody Thu May 15 02:06:16 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 15153806202941023.394649966629; Sun, 7 Jan 2018 19:03:40 -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 12A6B369BD; Mon, 8 Jan 2018 03:03:39 +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 E0DAC5DA60; Mon, 8 Jan 2018 03:03:38 +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 A75A84ED34; Mon, 8 Jan 2018 03:03:38 +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 w0833Geo007628 for ; Sun, 7 Jan 2018 22:03:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id 272DB5EDE2; Mon, 8 Jan 2018 03:03:16 +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 210A15D755 for ; Mon, 8 Jan 2018 03:03:14 +0000 (UTC) Received: from mail-qt0-f194.google.com (mail-qt0-f194.google.com [209.85.216.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 2C3416146F for ; Mon, 8 Jan 2018 03:03:13 +0000 (UTC) Received: by mail-qt0-f194.google.com with SMTP id u10so12096969qtg.2 for ; Sun, 07 Jan 2018 19:03:13 -0800 (PST) Received: from localhost.localdomain ([187.107.180.10]) by smtp.googlemail.com with ESMTPSA id y16sm7034281qta.48.2018.01.07.19.03.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 07 Jan 2018 19:03:11 -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=vRLeAw/RoVfLNvGFnaAtepR/rin8TWFU2BoIVmH4ESs=; b=lVKVC1K7oh1EJ2HVJuPfrvMnduNyAZkcC5X3ET5xWidwm9/8Q0FX9NoOqtVgZfQm+Z 9zj/E81wYnFGwMho96IquKq7MscndD5Sbyf2kd7kUEOe0Ij997Aq00UCayA18tAZP9Cw FRJsfG5P79+FePs5RNjG4reWI1pMLb1N/y0AkKQZwDPtXxVGCpoPdIAHxBOmAyJ9rG5+ EA8l1qZOv/p++DzAtO67fL+t2bPbhmz7vMuQB39e9LrPchYrwBAF9WHrkoyoJvyOhvx+ v5yQ0PdljMftf+uULZWB9ZDFpXMSckXlpKrDHizWqIQf/4PjW+PUqzSZo4t2AIyJn6QR AMGg== 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=vRLeAw/RoVfLNvGFnaAtepR/rin8TWFU2BoIVmH4ESs=; b=Ob2mT3zuZ8uCtoQfEteqSD1KvJN1Ny8fS6aFTs6UnG0fiP071du9Nm5VxurrY/nYXv GteE+HYsMQqQOc/rYVB0fuAk/2UWMk/nfFUe+w5KLuPxaZYDvsfE/4cbz0t6ZEyojmqK E/NMM4lodXbIjlrHvgT5WoFp1Paf1gfQjWxSTOT7bMAXyOVckgzqavbvtT7VsLl3+7P/ 7zAIpmfG9teNHI7As5TM8n3UkljBkJpl0c63X6LAsrBRz9hyj3CI6fL4p1+6xlFg39tt qZBy623S4IH5ISljjWau4C/oh640ouTtOGzmfK/T0j5JmHOZ1QHQaK82rTiAKfO87Gug JTBA== X-Gm-Message-State: AKwxytcFkgGQjmRVcpnLwb436QgeSSZbHQ+9xhukX5Mdigrs/VTILfyk m0nOi9AVA3ZD7XtVvbkrofNPpw== X-Google-Smtp-Source: ACJfBotD0IP/3Y2EKm//+fOqKAuMIgteyU12yOodlhd0gXirxdxO2UNnsqiBeVjYvTU5/4gjR5oZYw== X-Received: by 10.200.11.67 with SMTP id m3mr13760939qti.186.1515380592140; Sun, 07 Jan 2018 19:03:12 -0800 (PST) From: Julio Faracco To: libvir-list@redhat.com Date: Mon, 8 Jan 2018 01:02:59 -0200 Message-Id: <1515380580-14220-2-git-send-email-jcfaracco@gmail.com> In-Reply-To: <1515380580-14220-1-git-send-email-jcfaracco@gmail.com> References: <1515380580-14220-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]); Mon, 08 Jan 2018 03:03:13 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 08 Jan 2018 03:03:13 +0000 (UTC) for IP:'209.85.216.194' DOMAIN:'mail-qt0-f194.google.com' HELO:'mail-qt0-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.216.194 mail-qt0-f194.google.com 209.85.216.194 mail-qt0-f194.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 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.30]); Mon, 08 Jan 2018 03:03:39 +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 | 72 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 72 insertions(+) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index dc743b4..26bc8a2 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -2618,6 +2618,77 @@ 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 (!privdom->persistent) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("cannot rename a transient domain")); + 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 +6893,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