From nobody Thu May 2 11:33:40 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; 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 1504007354740544.0433857373749; Tue, 29 Aug 2017 04:49:14 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B76F8800A8; Tue, 29 Aug 2017 11:49: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 8D44818022; Tue, 29 Aug 2017 11:49:11 +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 C398C1800C89; Tue, 29 Aug 2017 11:49:10 +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 v7TBn75p022995 for ; Tue, 29 Aug 2017 07:49:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9588A7FB59; Tue, 29 Aug 2017 11:49:07 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id E86197FB5A for ; Tue, 29 Aug 2017 11:49:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B76F8800A8 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.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:09 +0200 Message-Id: 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 1/7] lib: Add API to dump xml configuration of managed save state domain 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 29 Aug 2017 11:49:12 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Kothapally Madhu Pavan Similar to domainSaveImageGetXMLDesc this commit adds domainManagedSaveGetX= MLDesc API which allows to get the xml of managed save state domain. Signed-off-by: Kothapally Madhu Pavan --- include/libvirt/libvirt-domain.h | 2 ++ src/driver-hypervisor.h | 5 ++++ src/libvirt-domain.c | 49 ++++++++++++++++++++++++++++++++++++= ++++ src/libvirt_public.syms | 1 + src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 17 +++++++++++++- src/remote_protocol-structs | 8 +++++++ 7 files changed, 82 insertions(+), 1 deletion(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index fae24ac93..4c5a7f7b5 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -1213,6 +1213,8 @@ int virDomainHasManagedSaveImage(v= irDomainPtr dom, unsigned int flags); int virDomainManagedSaveRemove(virDomainPtr dom, unsigned int flags); +char * virDomainManagedSaveGetXMLDesc(virDomainPtr domain, + unsigned int flags); /* * Domain core dump diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index 7b35e9e68..a3f9cbc31 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -750,6 +750,10 @@ typedef int (*virDrvDomainManagedSaveRemove)(virDomainPtr domain, unsigned int flags); +typedef char * +(*virDrvDomainManagedSaveGetXMLDesc)(virDomainPtr domain, + unsigned int flags); + typedef virDomainSnapshotPtr (*virDrvDomainSnapshotCreateXML)(virDomainPtr domain, const char *xmlDesc, @@ -1428,6 +1432,7 @@ struct _virHypervisorDriver { virDrvDomainManagedSave domainManagedSave; virDrvDomainHasManagedSaveImage domainHasManagedSaveImage; virDrvDomainManagedSaveRemove domainManagedSaveRemove; + virDrvDomainManagedSaveGetXMLDesc domainManagedSaveGetXMLDesc; virDrvDomainSnapshotCreateXML domainSnapshotCreateXML; virDrvDomainSnapshotGetXMLDesc domainSnapshotGetXMLDesc; virDrvDomainSnapshotNum domainSnapshotNum; diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 4d0ac30d5..f43ab2478 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -9339,6 +9339,55 @@ virDomainManagedSaveRemove(virDomainPtr dom, unsigne= d int flags) } +/** + * virDomainManagedSaveGetXMLDesc: + * @domain: a domain object + * @flags: bitwise-OR of subset of virDomainXMLFlags + * + * This method will extract the XML description of the managed save + * state file of a domain. + * + * No security-sensitive data will be included unless @flags contains + * VIR_DOMAIN_XML_SECURE; this flag is rejected on read-only + * connections. For this API, @flags should not contain either + * VIR_DOMAIN_XML_INACTIVE or VIR_DOMAIN_XML_UPDATE_CPU. + * + * Returns a 0 terminated UTF-8 encoded XML instance, or NULL in case of + * error. The caller must free() the returned value. + */ +char * +virDomainManagedSaveGetXMLDesc(virDomainPtr domain, unsigned int flags) +{ + virConnectPtr conn; + + VIR_DOMAIN_DEBUG(domain, "flags=3D%x", flags); + + virResetLastError(); + + virCheckDomainReturn(domain, NULL); + conn =3D domain->conn; + + if ((conn->flags & VIR_CONNECT_RO) && (flags & VIR_DOMAIN_XML_SECURE))= { + virReportError(VIR_ERR_OPERATION_DENIED, "%s", + _("virDomainManagedSaveGetXMLDesc with secure flag"= )); + goto error; + } + + if (conn->driver->domainManagedSaveGetXMLDesc) { + char *ret; + ret =3D conn->driver->domainManagedSaveGetXMLDesc(domain, flags); + if (!ret) + goto error; + return ret; + } + + virReportUnsupportedError(); + + error: + virDispatchError(domain->conn); + return NULL; +} + /** * virDomainOpenConsole: diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index b55ca4b55..58b9b4910 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -771,5 +771,6 @@ LIBVIRT_3.4.0 { LIBVIRT_3.7.0 { global: virDomainMigrateGetMaxDowntime; + virDomainManagedSaveGetXMLDesc; } 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 027b073ec..c64f5b337 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8411,6 +8411,7 @@ static virHypervisorDriver hypervisor_driver =3D { .domainManagedSave =3D remoteDomainManagedSave, /* 0.8.0 */ .domainHasManagedSaveImage =3D remoteDomainHasManagedSaveImage, /* 0.8= .0 */ .domainManagedSaveRemove =3D remoteDomainManagedSaveRemove, /* 0.8.0 */ + .domainManagedSaveGetXMLDesc =3D remoteDomainManagedSaveGetXMLDesc, /*= 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 2d49ceb3a..76033acc9 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -2556,6 +2556,15 @@ struct remote_domain_managed_save_remove_args { unsigned int flags; }; +struct remote_domain_managed_save_get_xml_desc_args { + remote_nonnull_domain dom; + unsigned int flags; +}; + +struct remote_domain_managed_save_get_xml_desc_ret { + remote_nonnull_string xml; +}; + struct remote_domain_snapshot_create_xml_args { remote_nonnull_domain dom; remote_nonnull_string xml_desc; @@ -6079,6 +6088,12 @@ enum remote_procedure { * @generate: both * @acl: domain:migrate */ - REMOTE_PROC_DOMAIN_MIGRATE_GET_MAX_DOWNTIME =3D 387 + REMOTE_PROC_DOMAIN_MIGRATE_GET_MAX_DOWNTIME =3D 387, + /** + * @generate: both + * @acl: domain:read + * @acl: domain:read_secure:VIR_DOMAIN_XML_SECURE + */ + REMOTE_PROC_DOMAIN_MANAGED_SAVE_GET_XML_DESC =3D 388 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 540553efe..4803a46f2 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -1970,6 +1970,13 @@ struct remote_domain_managed_save_remove_args { remote_nonnull_domain dom; u_int flags; }; +struct remote_domain_managed_save_get_xml_desc_args { + remote_nonnull_domain dom; + u_int flags; +}; +struct remote_domain_managed_save_get_xml_desc_ret { + remote_nonnull_string xml; +}; struct remote_domain_snapshot_create_xml_args { remote_nonnull_domain dom; remote_nonnull_string xml_desc; @@ -3241,4 +3248,5 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_EVENT_BLOCK_THRESHOLD =3D 385, 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, }; --=20 2.14.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 11:33:40 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; 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 From nobody Thu May 2 11:33:40 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; 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 1504007368073835.6811325270859; Tue, 29 Aug 2017 04:49:28 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 01B92356C9; Tue, 29 Aug 2017 11:49:26 +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 D48587FB50; 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 9B03E180610A; 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 v7TBn92w023010 for ; Tue, 29 Aug 2017 07:49:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 369EA7FB59; Tue, 29 Aug 2017 11:49:09 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id B5EE47FA5C for ; Tue, 29 Aug 2017 11:49:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 01B92356C9 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.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:11 +0200 Message-Id: <18d4cafef7f84f511797f5b9dfc908f439cac6f7.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 3/7] qemu: Implement qemuDomainManagedSaveGetXMLDesc 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); 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 This commit adds qemu driver implementation to get xml description for managed save state domain. Signed-off-by: Kothapally Madhu Pavan --- src/qemu/qemu_driver.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 672d3f8b3..b9e58e562 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6797,6 +6797,50 @@ qemuDomainSaveImageDefineXML(virConnectPtr conn, con= st char *path, return ret; } +static char * +qemuDomainManagedSaveGetXMLDesc(virDomainPtr dom, unsigned int flags) +{ + virQEMUDriverPtr driver =3D dom->conn->privateData; + virDomainObjPtr vm; + char *path =3D NULL; + char *ret =3D NULL; + virDomainDefPtr def =3D NULL; + int fd =3D -1; + virQEMUSaveDataPtr data =3D NULL; + + /* We only take subset of virDomainDefFormat flags. */ + virCheckFlags(VIR_DOMAIN_XML_SECURE, NULL); + + if (!(vm =3D qemuDomObjFromDomain(dom))) + return ret; + + if (virDomainManagedSaveGetXMLDescEnsureACL(dom->conn, vm->def, flags)= < 0) + goto cleanup; + + if (!(path =3D qemuDomainManagedSavePath(driver, vm))) + goto cleanup; + + if (!virFileExists(path)) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("domain does not have managed save image")); + goto cleanup; + } + + if ((fd =3D qemuDomainSaveImageOpen(driver, path, &def, &data, + false, NULL, false, false)) < 0) + goto cleanup; + + ret =3D qemuDomainDefFormatXML(driver, def, flags); + + cleanup: + virQEMUSaveDataFree(data); + virDomainDefFree(def); + VIR_FORCE_CLOSE(fd); + virDomainObjEndAPI(&vm); + VIR_FREE(path); + return ret; +} + /* Return 0 on success, 1 if incomplete saved image was silently unlinked, * and -1 on failure with error raised. */ static int @@ -20900,6 +20944,7 @@ static virHypervisorDriver qemuHypervisorDriver =3D= { .domainManagedSave =3D qemuDomainManagedSave, /* 0.8.0 */ .domainHasManagedSaveImage =3D qemuDomainHasManagedSaveImage, /* 0.8.0= */ .domainManagedSaveRemove =3D qemuDomainManagedSaveRemove, /* 0.8.0 */ + .domainManagedSaveGetXMLDesc =3D qemuDomainManagedSaveGetXMLDesc, /* 3= .7.0 */ .domainSnapshotCreateXML =3D qemuDomainSnapshotCreateXML, /* 0.8.0 */ .domainSnapshotGetXMLDesc =3D qemuDomainSnapshotGetXMLDesc, /* 0.8.0 */ .domainSnapshotNum =3D qemuDomainSnapshotNum, /* 0.8.0 */ --=20 2.14.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 11:33:40 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; 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 150400737147518.31342276139617; Tue, 29 Aug 2017 04:49:31 -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 3D96DC047B7D; Tue, 29 Aug 2017 11:49:29 +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 0EEC780945; Tue, 29 Aug 2017 11:49:29 +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 BE2A51806107; Tue, 29 Aug 2017 11:49:28 +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 v7TBnALT023015 for ; Tue, 29 Aug 2017 07:49:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 413C97FA5C; Tue, 29 Aug 2017 11:49:10 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id C00CC7FB51 for ; Tue, 29 Aug 2017 11:49:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3D96DC047B7D Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.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:12 +0200 Message-Id: <021f7c132bebd6e074c64eea9481ba3491c17eef.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 4/7] qemu: Implement qemuDomainManagedSaveDefineXML 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.31]); Tue, 29 Aug 2017 11:49:29 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Kothapally Madhu Pavan This commit adds qemu driver implementation to edit xml configuration of managed save state file of a domain. Signed-off-by: Kothapally Madhu Pavan --- src/qemu/qemu_driver.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b9e58e562..b7824512c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6841,6 +6841,39 @@ qemuDomainManagedSaveGetXMLDesc(virDomainPtr dom, un= signed int flags) return ret; } +static int +qemuDomainManagedSaveDefineXML(virDomainPtr dom, const char *dxml, + unsigned int flags) +{ + virQEMUDriverPtr driver =3D dom->conn->privateData; + virConnectPtr conn =3D dom->conn; + virDomainObjPtr vm; + char *path =3D NULL; + int ret =3D -1; + + if (!(vm =3D qemuDomObjFromDomain(dom))) + return -1; + + if (virDomainManagedSaveDefineXMLEnsureACL(conn, vm->def) < 0) + goto cleanup; + + if (!(path =3D qemuDomainManagedSavePath(driver, vm))) + goto cleanup; + + if (!virFileExists(path)) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("domain does not have managed save image")); + goto cleanup; + } + + ret =3D qemuDomainSaveImageDefineXML(conn, path, dxml, flags); + + cleanup: + virDomainObjEndAPI(&vm); + VIR_FREE(path); + return ret; +} + /* Return 0 on success, 1 if incomplete saved image was silently unlinked, * and -1 on failure with error raised. */ static int @@ -20945,6 +20978,7 @@ static virHypervisorDriver qemuHypervisorDriver =3D= { .domainHasManagedSaveImage =3D qemuDomainHasManagedSaveImage, /* 0.8.0= */ .domainManagedSaveRemove =3D qemuDomainManagedSaveRemove, /* 0.8.0 */ .domainManagedSaveGetXMLDesc =3D qemuDomainManagedSaveGetXMLDesc, /* 3= .7.0 */ + .domainManagedSaveDefineXML =3D qemuDomainManagedSaveDefineXML, /* 3.7= .0 */ .domainSnapshotCreateXML =3D qemuDomainSnapshotCreateXML, /* 0.8.0 */ .domainSnapshotGetXMLDesc =3D qemuDomainSnapshotGetXMLDesc, /* 0.8.0 */ .domainSnapshotNum =3D qemuDomainSnapshotNum, /* 0.8.0 */ --=20 2.14.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 11:33:40 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; 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 1504007371457346.15905493503385; Tue, 29 Aug 2017 04:49:31 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 27101883DC; Tue, 29 Aug 2017 11:49:29 +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 E88BB7FB61; Tue, 29 Aug 2017 11:49:28 +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 A1CE13FC74; Tue, 29 Aug 2017 11:49:28 +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 v7TBnBuL023025 for ; Tue, 29 Aug 2017 07:49:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 295B07FA5C; Tue, 29 Aug 2017 11:49:11 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id A73C97FB5A for ; Tue, 29 Aug 2017 11:49:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 27101883DC Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.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:13 +0200 Message-Id: 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 5/7] virsh: Implement managedsave-define 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 29 Aug 2017 11:49:29 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Kothapally Madhu Pavan Add a simple virsh command handler which makes use of the new API. Signed-off-by: Kothapally Madhu Pavan --- tools/virsh-domain.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++= ++++ tools/virsh.pod | 12 ++++++++ 2 files changed, 90 insertions(+) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index a3410e791..8f048f678 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -4704,6 +4704,78 @@ cmdManagedSaveRemove(vshControl *ctl, const vshCmd *= cmd) return ret; } +/* + * "managedsave-define" command + */ +static const vshCmdInfo info_managed_save_define[] =3D { + {.name =3D "help", + .data =3D N_("redefine the XML for a domain's managed save state file= ") + }, + {.name =3D "desc", + .data =3D N_("Replace the domain XML associated with a managed save s= tate file") + }, + {.name =3D NULL} +}; + +static const vshCmdOptDef opts_managed_save_define[] =3D { + VIRSH_COMMON_OPT_DOMAIN_FULL, + {.name =3D "xml", + .type =3D VSH_OT_DATA, + .flags =3D VSH_OFLAG_REQ, + .help =3D N_("filename containing updated XML for the target") + }, + {.name =3D "running", + .type =3D VSH_OT_BOOL, + .help =3D N_("set domain to be running on start") + }, + {.name =3D "paused", + .type =3D VSH_OT_BOOL, + .help =3D N_("set domain to be paused on start") + }, + {.name =3D NULL} +}; + +static bool +cmdManagedSaveDefine(vshControl *ctl, const vshCmd *cmd) +{ + bool ret =3D false; + virDomainPtr dom =3D NULL; + const char *xmlfile =3D NULL; + char *xml =3D NULL; + unsigned int flags =3D 0; + + if (vshCommandOptBool(cmd, "running")) + flags |=3D VIR_DOMAIN_SAVE_RUNNING; + if (vshCommandOptBool(cmd, "paused")) + flags |=3D VIR_DOMAIN_SAVE_PAUSED; + + VSH_EXCLUSIVE_OPTIONS("running", "paused"); + + if (vshCommandOptStringReq(ctl, cmd, "xml", &xmlfile) < 0) + return false; + + if (virFileReadAll(xmlfile, VSH_MAX_XML_FILE, &xml) < 0) + return false; + + if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + goto cleanup; + + if (virDomainManagedSaveDefineXML(dom, xml, flags) < 0) { + vshError(ctl, _("Failed to update %s XML configuration"), + virDomainGetName(dom)); + goto cleanup; + } + + vshPrintExtra(ctl, _("Managed save state file of domain %s updated.\n"= ), + virDomainGetName(dom)); + ret =3D true; + + cleanup: + virshDomainFree(dom); + VIR_FREE(xml); + return ret; +} + /* * "schedinfo" command */ @@ -13886,6 +13958,12 @@ const vshCmdDef domManagementCmds[] =3D { .info =3D info_managedsaveremove, .flags =3D 0 }, + {.name =3D "managedsave-define", + .handler =3D cmdManagedSaveDefine, + .opts =3D opts_managed_save_define, + .info =3D info_managed_save_define, + .flags =3D 0 + }, {.name =3D "memtune", .handler =3D cmdMemtune, .opts =3D opts_memtune, diff --git a/tools/virsh.pod b/tools/virsh.pod index 15a414399..5c87af302 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -1630,6 +1630,18 @@ has any managed save image. Remove the B state file for a domain, if it exists. This ensures the domain will do a full boot the next time it is started. +=3Ditem B I I [{I<--running> | I<--paused= >}] + +Update the domain XML that will be used when I is later +started. The I argument must be a file name containing +the alternative XML, with changes only in the host-specific portions of +the domain XML. For example, it can be used to change disk file paths. + +The managed save image records whether the domain should be started to a +running or paused state. Normally, this command does not alter the +recorded state; passing either the I<--running> or I<--paused> flag +will allow overriding which state the B should use. + =3Ditem B [I] Provide the maximum number of virtual CPUs supported for a guest VM on --=20 2.14.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 11:33:40 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; 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 1504007373791393.4877647490847; Tue, 29 Aug 2017 04:49:33 -0700 (PDT) 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 ACBF17EA85; Tue, 29 Aug 2017 11:49:31 +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 8E54266D75; Tue, 29 Aug 2017 11:49:31 +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 542673FACE; Tue, 29 Aug 2017 11:49:31 +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 v7TBnBmK023038 for ; Tue, 29 Aug 2017 07:49:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id EABEF7FB51; Tue, 29 Aug 2017 11:49:11 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7459F7FA5C for ; Tue, 29 Aug 2017 11:49:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com ACBF17EA85 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.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:14 +0200 Message-Id: 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 6/7] virsh: Implement managedsave-dumpxml 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 29 Aug 2017 11:49:32 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Kothapally Madhu Pavan Add a simple virsh command handler which makes use of the new API. Signed-off-by: Kothapally Madhu Pavan --- tools/virsh-domain.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++= ++++ tools/virsh.pod | 6 ++++++ 2 files changed, 60 insertions(+) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 8f048f678..14960c4a2 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -4704,6 +4704,54 @@ cmdManagedSaveRemove(vshControl *ctl, const vshCmd *= cmd) return ret; } +/* + * "managedsave-dumpxml" command + */ +static const vshCmdInfo info_managed_save_dumpxml[] =3D { + {.name =3D "help", + .data =3D N_("Domain information of managed save state file in XML") + }, + {.name =3D "desc", + .data =3D N_("Dump XML of domain information for a managed save state = file to stdout.") + }, + {.name =3D NULL} +}; + +static const vshCmdOptDef opts_managed_save_dumpxml[] =3D { + VIRSH_COMMON_OPT_DOMAIN_FULL, + {.name =3D "security-info", + .type =3D VSH_OT_BOOL, + .help =3D N_("include security sensitive information in XML dump") + }, + {.name =3D NULL} +}; + +static bool +cmdManagedSaveDumpxml(vshControl *ctl, const vshCmd *cmd) +{ + bool ret =3D false; + virDomainPtr dom =3D NULL; + unsigned int flags =3D 0; + char *xml =3D NULL; + + if (vshCommandOptBool(cmd, "security-info")) + flags |=3D VIR_DOMAIN_XML_SECURE; + + if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + goto cleanup; + + if (!(xml =3D virDomainManagedSaveGetXMLDesc(dom, flags))) + goto cleanup; + + vshPrint(ctl, "%s", xml); + ret =3D true; + + cleanup: + virshDomainFree(dom); + VIR_FREE(xml); + return ret; +} + /* * "managedsave-define" command */ @@ -13958,6 +14006,12 @@ const vshCmdDef domManagementCmds[] =3D { .info =3D info_managedsaveremove, .flags =3D 0 }, + {.name =3D "managedsave-dumpxml", + .handler =3D cmdManagedSaveDumpxml, + .opts =3D opts_managed_save_dumpxml, + .info =3D info_managed_save_dumpxml, + .flags =3D 0 + }, {.name =3D "managedsave-define", .handler =3D cmdManagedSaveDefine, .opts =3D opts_managed_save_define, diff --git a/tools/virsh.pod b/tools/virsh.pod index 5c87af302..f7b05f803 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -1642,6 +1642,12 @@ running or paused state. Normally, this command doe= s not alter the recorded state; passing either the I<--running> or I<--paused> flag will allow overriding which state the B should use. +=3Ditem B I [I<--security-info>] + +Extract the domain XML that was in effect at the time the saved state +file I was created with the B command. Using +I<--security-info> will also include security sensitive information. + =3Ditem B [I] Provide the maximum number of virtual CPUs supported for a guest VM on --=20 2.14.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 11:33:40 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; 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 15040073739161014.6774797087509; Tue, 29 Aug 2017 04:49:33 -0700 (PDT) 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 CF97940431B; Tue, 29 Aug 2017 11:49:31 +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 AEC8E66D66; Tue, 29 Aug 2017 11:49:31 +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 76BD93FACF; Tue, 29 Aug 2017 11:49:31 +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 v7TBnCM2023045 for ; Tue, 29 Aug 2017 07:49:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id B8F627FB51; Tue, 29 Aug 2017 11:49:12 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 41BAF7FA5C for ; Tue, 29 Aug 2017 11:49:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CF97940431B Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.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:15 +0200 Message-Id: <912bc7204fbda3f280c25ee142241d7666aaae6f.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 7/7] virsh: Implement managedsave-edit 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 29 Aug 2017 11:49:32 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Kothapally Madhu Pavan Add a simple virsh command handler which makes use of the new API. Signed-off-by: Kothapally Madhu Pavan --- tools/virsh-domain.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++= ++++ tools/virsh.pod | 21 +++++++++++++++ 2 files changed, 93 insertions(+) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 14960c4a2..f235c66b0 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -4704,6 +4704,72 @@ cmdManagedSaveRemove(vshControl *ctl, const vshCmd *= cmd) return ret; } +/* + * "managedsave-edit" command + */ +static const vshCmdInfo info_managed_save_edit[] =3D { + {.name =3D "help", + .data =3D N_("edit XML for a domain's managed save state file") + }, + {.name =3D "desc", + .data =3D N_("Edit the domain XML associated with the managed save sta= te file") + }, + {.name =3D NULL} +}; + +static const vshCmdOptDef opts_managed_save_edit[] =3D { + VIRSH_COMMON_OPT_DOMAIN_FULL, + {.name =3D "running", + .type =3D VSH_OT_BOOL, + .help =3D N_("set domain to be running on start") + }, + {.name =3D "paused", + .type =3D VSH_OT_BOOL, + .help =3D N_("set domain to be paused on start") + }, + {.name =3D NULL} +}; + +static bool +cmdManagedSaveEdit(vshControl *ctl, const vshCmd *cmd) +{ + bool ret =3D false; + virDomainPtr dom =3D NULL; + unsigned int getxml_flags =3D VIR_DOMAIN_XML_SECURE; + unsigned int define_flags =3D 0; + + if (vshCommandOptBool(cmd, "running")) + define_flags |=3D VIR_DOMAIN_SAVE_RUNNING; + if (vshCommandOptBool(cmd, "paused")) + define_flags |=3D VIR_DOMAIN_SAVE_PAUSED; + + VSH_EXCLUSIVE_OPTIONS("running", "paused"); + + dom =3D virshCommandOptDomain(ctl, cmd, NULL); + if (dom =3D=3D NULL) + goto cleanup; + +#define EDIT_GET_XML virDomainManagedSaveGetXMLDesc(dom, getxml_flags) +#define EDIT_NOT_CHANGED = \ + do { = \ + vshPrintExtra(ctl, _("Managed save image of domain %s XML configur= ation " \ + "not changed.\n"), virDomainGetName(dom)); = \ + ret =3D true; = \ + goto edit_cleanup; = \ + } while (0) +#define EDIT_DEFINE \ + (virDomainManagedSaveDefineXML(dom, doc_edited, define_flags) =3D=3D 0) +#include "virsh-edit.c" + + vshPrintExtra(ctl, _("Managed save image of Domain %s XML configuratio= n edited.\n"), + virDomainGetName(dom)); + ret =3D true; + + cleanup: + virshDomainFree(dom); + return ret; +} + /* * "managedsave-dumpxml" command */ @@ -14006,6 +14072,12 @@ const vshCmdDef domManagementCmds[] =3D { .info =3D info_managedsaveremove, .flags =3D 0 }, + {.name =3D "managedsave-edit", + .handler =3D cmdManagedSaveEdit, + .opts =3D opts_managed_save_edit, + .info =3D info_managed_save_edit, + .flags =3D 0 + }, {.name =3D "managedsave-dumpxml", .handler =3D cmdManagedSaveDumpxml, .opts =3D opts_managed_save_dumpxml, diff --git a/tools/virsh.pod b/tools/virsh.pod index f7b05f803..c13f96f22 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -1648,6 +1648,27 @@ Extract the domain XML that was in effect at the tim= e the saved state file I was created with the B command. Using I<--security-info> will also include security sensitive information. +=3Ditem B I [{I<--running> | I<--paused>}] + +Edit the XML configuration associated with a saved state file of a +I was created by the B command. + +The managed save image records whether the domain should be started to a +running or paused state. Normally, this command does not alter the +recorded state; passing either the I<--running> or I<--paused> flag +will allow overriding which state the B should use. + +This is equivalent to: + + virsh managedsave-dumpxml domain-name > state-file.xml + vi state-file.xml (or make changes with your other text editor) + virsh managedsave-define domain-name state-file-xml + +except that it does some error checking. + +The editor used can be supplied by the C<$VISUAL> or C<$EDITOR> environment +variables, and defaults to C. + =3Ditem B [I] Provide the maximum number of virtual CPUs supported for a guest VM on --=20 2.14.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list