From nobody Fri May 16 01:33:41 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; 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 1504007368184935.8419358094313; Tue, 29 Aug 2017 04:49:28 -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 ED9EEC0587DE; Tue, 29 Aug 2017 11:49:25 +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 C9F5063639; Tue, 29 Aug 2017 11:49:25 +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 916251806108; Tue, 29 Aug 2017 11:49:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7TBn886023003 for ; Tue, 29 Aug 2017 07:49:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5E3807FB5A; Tue, 29 Aug 2017 11:49:08 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id DCA397FB59 for ; Tue, 29 Aug 2017 11:49:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com ED9EEC0587DE Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 29 Aug 2017 13:49:10 +0200 Message-Id: <1558f2584fd9b32c7903238bff2c9f12ba406ba6.1504007230.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v5 2/7] lib: Add API to edit domain's managed save state xml configuration 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.32]); Tue, 29 Aug 2017 11:49:26 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Kothapally Madhu Pavan Similar to domainSaveImageDefineXML this commit adds domainManagedSaveDefin= eXML API which allows to edit domain's managed save state xml configuration. Signed-off-by: Kothapally Madhu Pavan --- include/libvirt/libvirt-domain.h | 4 +++ src/driver-hypervisor.h | 6 +++++ src/libvirt-domain.c | 57 ++++++++++++++++++++++++++++++++++++= ++++ src/libvirt_public.syms | 1 + src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 15 ++++++++++- src/remote_protocol-structs | 6 +++++ 7 files changed, 89 insertions(+), 1 deletion(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 4c5a7f7b5..030a62c43 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -1215,6 +1215,10 @@ int virDomainManagedSaveRemove(vi= rDomainPtr dom, unsigned int flags); char * virDomainManagedSaveGetXMLDesc(virDomainPtr domain, unsigned int flags); +int virDomainManagedSaveDefineXML(virDomainPtr domain, + const char *dxml, + unsigned int flags); + /* * Domain core dump diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index a3f9cbc31..6c3f7d795 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -754,6 +754,11 @@ typedef char * (*virDrvDomainManagedSaveGetXMLDesc)(virDomainPtr domain, unsigned int flags); +typedef int +(*virDrvDomainManagedSaveDefineXML)(virDomainPtr domain, + const char *dxml, + unsigned int flags); + typedef virDomainSnapshotPtr (*virDrvDomainSnapshotCreateXML)(virDomainPtr domain, const char *xmlDesc, @@ -1433,6 +1438,7 @@ struct _virHypervisorDriver { virDrvDomainHasManagedSaveImage domainHasManagedSaveImage; virDrvDomainManagedSaveRemove domainManagedSaveRemove; virDrvDomainManagedSaveGetXMLDesc domainManagedSaveGetXMLDesc; + virDrvDomainManagedSaveDefineXML domainManagedSaveDefineXML; virDrvDomainSnapshotCreateXML domainSnapshotCreateXML; virDrvDomainSnapshotGetXMLDesc domainSnapshotGetXMLDesc; virDrvDomainSnapshotNum domainSnapshotNum; diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index f43ab2478..ca5a1536a 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -9389,6 +9389,63 @@ virDomainManagedSaveGetXMLDesc(virDomainPtr domain, = unsigned int flags) } +/** + * virDomainManagedSaveDefineXML: + * @domain: a domain object + * @dxml: XML config for adjusting guest xml used on restore + * @flags: bitwise-OR of virDomainSaveRestoreFlags + * + * This updates the definition of a domain stored in a saved state + * file. + * + * @dxml can be used to alter host-specific portions of the domain XML + * that will be used on the next start of the domain. For example, it is + * possible to alter the backing filename that is associated with a + * disk device. + * + * Normally, the saved state file will remember whether the domain was + * running or paused, and restore defaults to the same state. + * Specifying VIR_DOMAIN_SAVE_RUNNING or VIR_DOMAIN_SAVE_PAUSED in + * @flags will override the default saved into the file; omitting both + * leaves the file's default unchanged. These two flags are mutually + * exclusive. + * + * Returns 0 in case of success and -1 in case of failure. + */ +int +virDomainManagedSaveDefineXML(virDomainPtr domain, const char *dxml, + unsigned int flags) +{ + virConnectPtr conn; + + VIR_DOMAIN_DEBUG(domain, "flags=3D%x", flags); + + virResetLastError(); + + VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_SAVE_RUNNING, + VIR_DOMAIN_SAVE_PAUSED, + error); + + virCheckDomainReturn(domain, -1); + conn =3D domain->conn; + + if (conn->driver->domainManagedSaveDefineXML) { + int ret; + ret =3D conn->driver->domainManagedSaveDefineXML(domain, dxml, fla= gs); + + if (ret < 0) + goto error; + return ret; + } + + virReportUnsupportedError(); + + error: + virDispatchError(domain->conn); + return -1; +} + + /** * virDomainOpenConsole: * @dom: a domain object diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 58b9b4910..498601943 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -772,5 +772,6 @@ LIBVIRT_3.7.0 { global: virDomainMigrateGetMaxDowntime; virDomainManagedSaveGetXMLDesc; + virDomainManagedSaveDefineXML; } LIBVIRT_3.4.0; # .... define new API here using predicted next version number .... diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index c64f5b337..7f814cd4f 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8412,6 +8412,7 @@ static virHypervisorDriver hypervisor_driver =3D { .domainHasManagedSaveImage =3D remoteDomainHasManagedSaveImage, /* 0.8= .0 */ .domainManagedSaveRemove =3D remoteDomainManagedSaveRemove, /* 0.8.0 */ .domainManagedSaveGetXMLDesc =3D remoteDomainManagedSaveGetXMLDesc, /*= 3.7.0 */ + .domainManagedSaveDefineXML =3D remoteDomainManagedSaveDefineXML, /* 3= .7.0 */ .domainSnapshotCreateXML =3D remoteDomainSnapshotCreateXML, /* 0.8.0 */ .domainSnapshotGetXMLDesc =3D remoteDomainSnapshotGetXMLDesc, /* 0.8.0= */ .domainSnapshotNum =3D remoteDomainSnapshotNum, /* 0.8.0 */ diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 76033acc9..07463b781 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -2565,6 +2565,12 @@ struct remote_domain_managed_save_get_xml_desc_ret { remote_nonnull_string xml; }; +struct remote_domain_managed_save_define_xml_args { + remote_nonnull_domain dom; + remote_string dxml; + unsigned int flags; +}; + struct remote_domain_snapshot_create_xml_args { remote_nonnull_domain dom; remote_nonnull_string xml_desc; @@ -6095,5 +6101,12 @@ enum remote_procedure { * @acl: domain:read * @acl: domain:read_secure:VIR_DOMAIN_XML_SECURE */ - REMOTE_PROC_DOMAIN_MANAGED_SAVE_GET_XML_DESC =3D 388 + REMOTE_PROC_DOMAIN_MANAGED_SAVE_GET_XML_DESC =3D 388, + + /** + * @generate: both + * @acl: domain:write + * @acl: domain:hibernate + */ + REMOTE_PROC_DOMAIN_MANAGED_SAVE_DEFINE_XML =3D 389 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 4803a46f2..6038bf138 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -1977,6 +1977,11 @@ struct remote_domain_managed_save_get_xml_desc_args { struct remote_domain_managed_save_get_xml_desc_ret { remote_nonnull_string xml; }; +struct remote_domain_managed_save_define_xml_args { + remote_nonnull_domain dom; + remote_string dxml; + u_int flags; +}; struct remote_domain_snapshot_create_xml_args { remote_nonnull_domain dom; remote_nonnull_string xml_desc; @@ -3249,4 +3254,5 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_SET_BLOCK_THRESHOLD =3D 386, REMOTE_PROC_DOMAIN_MIGRATE_GET_MAX_DOWNTIME =3D 387, REMOTE_PROC_DOMAIN_MANAGED_SAVE_GET_XML_DESC =3D 388, + REMOTE_PROC_DOMAIN_MANAGED_SAVE_DEFINE_XML =3D 389, }; --=20 2.14.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list