mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
snapshot: Define explicit flags for snapshot xml
Commitf609cb85
(0.9.5) introduced virDomainSnapshotGetXMLDesc()'s use of @flags as a subset of virDomainXMLFlags, documenting that 2 of the 3 flags defined at the time would never be valid. Later, commit28f8dfdc
(1.0.0) introduced a new flag, VIR_DOMAIN_XML_MIGRATABLE, but did not adjust the snapshot documentation to declare it as invalid. However, since the flag is not accepted as valid by any of the drivers (remote is just passthrough; esx and vbox don't support flags; qemu, test, and vz only support VIR_DOMAIN_XML_SECURE), and it is unlikely that the domain state saved off during a snapshot creation needs to be migration-friendly (as the snapshot is not the source of a migration), it is easier to just define an explicit set of supported flags directly related to the snapshot API rather than trying to borrow from domain API, and risking confusion if even more domain flags are added later (in fact, I have an upcoming patch that plans to add a new flag to virDomainGetXMLDesc that makes no sense for snapshots). There is no API or ABI impact (since we purposefully used unsigned int rather than an enum type in public API, and since the new flag name carries the same value as the reused name). Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
12a51f372a
commit
a27031c408
@ -78,6 +78,10 @@ virDomainSnapshotPtr virDomainSnapshotCreateXML(virDomainPtr domain,
|
|||||||
const char *xmlDesc,
|
const char *xmlDesc,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
VIR_DOMAIN_SNAPSHOT_XML_SECURE = VIR_DOMAIN_XML_SECURE, /* dump security sensitive information too */
|
||||||
|
} virDomainSnapshotXMLFlags;
|
||||||
|
|
||||||
/* Dump the XML of a snapshot */
|
/* Dump the XML of a snapshot */
|
||||||
char *virDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
|
char *virDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
|
@ -244,14 +244,13 @@ virDomainSnapshotCreateXML(virDomainPtr domain,
|
|||||||
/**
|
/**
|
||||||
* virDomainSnapshotGetXMLDesc:
|
* virDomainSnapshotGetXMLDesc:
|
||||||
* @snapshot: a domain snapshot object
|
* @snapshot: a domain snapshot object
|
||||||
* @flags: bitwise-OR of subset of virDomainXMLFlags
|
* @flags: bitwise-OR of supported virDomainSnapshotXMLFlags
|
||||||
*
|
*
|
||||||
* Provide an XML description of the domain snapshot.
|
* Provide an XML description of the domain snapshot.
|
||||||
*
|
*
|
||||||
* No security-sensitive data will be included unless @flags contains
|
* No security-sensitive data will be included unless @flags contains
|
||||||
* VIR_DOMAIN_XML_SECURE; this flag is rejected on read-only
|
* VIR_DOMAIN_SNAPSHOT_XML_SECURE; this flag is rejected on read-only
|
||||||
* connections. For this API, @flags should not contain either
|
* connections.
|
||||||
* 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.
|
* Returns a 0 terminated UTF-8 encoded XML instance, or NULL in case of error.
|
||||||
* the caller must free() the returned value.
|
* the caller must free() the returned value.
|
||||||
@ -268,7 +267,8 @@ virDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
|
|||||||
virCheckDomainSnapshotReturn(snapshot, NULL);
|
virCheckDomainSnapshotReturn(snapshot, NULL);
|
||||||
conn = snapshot->domain->conn;
|
conn = snapshot->domain->conn;
|
||||||
|
|
||||||
if ((conn->flags & VIR_CONNECT_RO) && (flags & VIR_DOMAIN_XML_SECURE)) {
|
if ((conn->flags & VIR_CONNECT_RO) &&
|
||||||
|
(flags & VIR_DOMAIN_SNAPSHOT_XML_SECURE)) {
|
||||||
virReportError(VIR_ERR_OPERATION_DENIED, "%s",
|
virReportError(VIR_ERR_OPERATION_DENIED, "%s",
|
||||||
_("virDomainSnapshotGetXMLDesc with secure flag"));
|
_("virDomainSnapshotGetXMLDesc with secure flag"));
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -16247,7 +16247,7 @@ qemuDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
|
|||||||
virDomainSnapshotObjPtr snap = NULL;
|
virDomainSnapshotObjPtr snap = NULL;
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_XML_SECURE, NULL);
|
virCheckFlags(VIR_DOMAIN_SNAPSHOT_XML_SECURE, NULL);
|
||||||
|
|
||||||
if (!(vm = qemuDomObjFromSnapshot(snapshot)))
|
if (!(vm = qemuDomObjFromSnapshot(snapshot)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -4902,7 +4902,7 @@ enum remote_procedure {
|
|||||||
* @generate: both
|
* @generate: both
|
||||||
* @priority: high
|
* @priority: high
|
||||||
* @acl: domain:read
|
* @acl: domain:read
|
||||||
* @acl: domain:read_secure:VIR_DOMAIN_XML_SECURE
|
* @acl: domain:read_secure:VIR_DOMAIN_SNAPSHOT_XML_SECURE
|
||||||
*/
|
*/
|
||||||
REMOTE_PROC_DOMAIN_SNAPSHOT_GET_XML_DESC = 186,
|
REMOTE_PROC_DOMAIN_SNAPSHOT_GET_XML_DESC = 186,
|
||||||
|
|
||||||
|
@ -6197,7 +6197,7 @@ testDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
|
|||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
testDriverPtr privconn = snapshot->domain->conn->privateData;
|
testDriverPtr privconn = snapshot->domain->conn->privateData;
|
||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_XML_SECURE, NULL);
|
virCheckFlags(VIR_DOMAIN_SNAPSHOT_XML_SECURE, NULL);
|
||||||
|
|
||||||
if (!(vm = testDomObjFromSnapshot(snapshot)))
|
if (!(vm = testDomObjFromSnapshot(snapshot)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -2273,7 +2273,7 @@ vzDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, unsigned int flags)
|
|||||||
virDomainSnapshotObjListPtr snapshots = NULL;
|
virDomainSnapshotObjListPtr snapshots = NULL;
|
||||||
vzConnPtr privconn = snapshot->domain->conn->privateData;
|
vzConnPtr privconn = snapshot->domain->conn->privateData;
|
||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_XML_SECURE, NULL);
|
virCheckFlags(VIR_DOMAIN_SNAPSHOT_XML_SECURE, NULL);
|
||||||
|
|
||||||
if (!(dom = vzDomObjFromDomain(snapshot->domain)))
|
if (!(dom = vzDomObjFromDomain(snapshot->domain)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user