From: Kothapally Madhu Pavan <kmp@xxxxxxxxxxxxxxxxxx> Similar to domainSaveImageGetXMLDesc this commit adds domainManagedSaveGetXMLDesc API which allows to get the xml of managed save state domain. Signed-off-by: Kothapally Madhu Pavan <kmp@xxxxxxxxxxxxxxxxxx> --- 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-domain.h index fae24ac93..4c5a7f7b5 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -1213,6 +1213,8 @@ int virDomainHasManagedSaveImage(virDomainPtr 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, unsigned 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=%x", flags); + + virResetLastError(); + + virCheckDomainReturn(domain, NULL); + conn = 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 = 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 = { .domainManagedSave = remoteDomainManagedSave, /* 0.8.0 */ .domainHasManagedSaveImage = remoteDomainHasManagedSaveImage, /* 0.8.0 */ .domainManagedSaveRemove = remoteDomainManagedSaveRemove, /* 0.8.0 */ + .domainManagedSaveGetXMLDesc = remoteDomainManagedSaveGetXMLDesc, /* 3.7.0 */ .domainSnapshotCreateXML = remoteDomainSnapshotCreateXML, /* 0.8.0 */ .domainSnapshotGetXMLDesc = remoteDomainSnapshotGetXMLDesc, /* 0.8.0 */ .domainSnapshotNum = 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 = 387 + REMOTE_PROC_DOMAIN_MIGRATE_GET_MAX_DOWNTIME = 387, + /** + * @generate: both + * @acl: domain:read + * @acl: domain:read_secure:VIR_DOMAIN_XML_SECURE + */ + REMOTE_PROC_DOMAIN_MANAGED_SAVE_GET_XML_DESC = 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 = 385, REMOTE_PROC_DOMAIN_SET_BLOCK_THRESHOLD = 386, REMOTE_PROC_DOMAIN_MIGRATE_GET_MAX_DOWNTIME = 387, + REMOTE_PROC_DOMAIN_MANAGED_SAVE_GET_XML_DESC = 388, }; -- 2.14.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list