mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
libvirt: introduce virDomainSaveParams public API
create an alternative to virDomainSaveFlags that is more extendible via parameters. Signed-off-by: Claudio Fontana <cfontana@suse.de> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
f79de95b16
commit
6392cb1f1f
@ -1562,6 +1562,10 @@ int virDomainSaveFlags (virDomainPtr domain,
|
||||
const char *to,
|
||||
const char *dxml,
|
||||
unsigned int flags);
|
||||
int virDomainSaveParams (virDomainPtr domain,
|
||||
virTypedParameterPtr params,
|
||||
int nparams,
|
||||
unsigned int flags);
|
||||
int virDomainRestore (virConnectPtr conn,
|
||||
const char *from);
|
||||
int virDomainRestoreFlags (virConnectPtr conn,
|
||||
@ -1569,6 +1573,28 @@ int virDomainRestoreFlags (virConnectPtr conn,
|
||||
const char *dxml,
|
||||
unsigned int flags);
|
||||
|
||||
/**
|
||||
* VIR_SAVE_PARAM_FILE:
|
||||
*
|
||||
* the parameter used to specify the savestate file to save to or restore from.
|
||||
*
|
||||
* Since: 8.4.0
|
||||
*/
|
||||
# define VIR_SAVE_PARAM_FILE "file"
|
||||
|
||||
/**
|
||||
* VIR_SAVE_PARAM_DXML:
|
||||
*
|
||||
* an optional parameter used to adjust guest xml on restore.
|
||||
* If the hypervisor supports it, it can be used to alter
|
||||
* host-specific portions of the domain XML that will be used when
|
||||
* restoring an image. For example, it is possible to alter the
|
||||
* device while the domain is stopped.
|
||||
*
|
||||
* Since: 8.4.0
|
||||
*/
|
||||
# define VIR_SAVE_PARAM_DXML "dxml"
|
||||
|
||||
/* See below for virDomainSaveImageXMLFlags */
|
||||
char * virDomainSaveImageGetXMLDesc (virConnectPtr conn,
|
||||
const char *file,
|
||||
|
@ -240,6 +240,12 @@ typedef int
|
||||
const char *dxml,
|
||||
unsigned int flags);
|
||||
|
||||
typedef int
|
||||
(*virDrvDomainSaveParams)(virDomainPtr domain,
|
||||
virTypedParameterPtr params,
|
||||
int nparams,
|
||||
unsigned int flags);
|
||||
|
||||
typedef int
|
||||
(*virDrvDomainRestore)(virConnectPtr conn,
|
||||
const char *from);
|
||||
@ -1489,6 +1495,7 @@ struct _virHypervisorDriver {
|
||||
virDrvDomainGetControlInfo domainGetControlInfo;
|
||||
virDrvDomainSave domainSave;
|
||||
virDrvDomainSaveFlags domainSaveFlags;
|
||||
virDrvDomainSaveParams domainSaveParams;
|
||||
virDrvDomainRestore domainRestore;
|
||||
virDrvDomainRestoreFlags domainRestoreFlags;
|
||||
virDrvDomainSaveImageGetXMLDesc domainSaveImageGetXMLDesc;
|
||||
|
@ -999,6 +999,54 @@ virDomainSaveFlags(virDomainPtr domain, const char *to,
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* virDomainSaveParams:
|
||||
* @domain: a domain object
|
||||
* @params: save parameters
|
||||
* @nparams: number of save parameters
|
||||
* @flags: bitwise-OR of virDomainSaveRestoreFlags
|
||||
*
|
||||
* This method extends virDomainSaveFlags by adding parameters.
|
||||
*
|
||||
* Returns 0 in case of success and -1 in case of failure.
|
||||
*
|
||||
* Since: 8.4.0
|
||||
*/
|
||||
int
|
||||
virDomainSaveParams(virDomainPtr domain,
|
||||
virTypedParameterPtr params, int nparams,
|
||||
unsigned int flags)
|
||||
{
|
||||
virConnectPtr conn;
|
||||
|
||||
VIR_DOMAIN_DEBUG(domain, "params=%p, nparams=%d, flags=0x%x",
|
||||
params, nparams, flags);
|
||||
VIR_TYPED_PARAMS_DEBUG(params, nparams);
|
||||
|
||||
virResetLastError();
|
||||
|
||||
virCheckDomainReturn(domain, -1);
|
||||
conn = domain->conn;
|
||||
|
||||
virCheckReadOnlyGoto(conn->flags, error);
|
||||
|
||||
VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_SAVE_RUNNING,
|
||||
VIR_DOMAIN_SAVE_PAUSED,
|
||||
error);
|
||||
|
||||
if (conn->driver->domainSaveParams) {
|
||||
if (conn->driver->domainSaveParams(domain, params, nparams, flags) < 0)
|
||||
goto error;
|
||||
return 0;
|
||||
}
|
||||
|
||||
virReportUnsupportedError();
|
||||
|
||||
error:
|
||||
virDispatchError(domain->conn);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virDomainRestore:
|
||||
|
@ -916,4 +916,9 @@ LIBVIRT_8.0.0 {
|
||||
virDomainSetLaunchSecurityState;
|
||||
} LIBVIRT_7.8.0;
|
||||
|
||||
LIBVIRT_8.4.0 {
|
||||
global:
|
||||
virDomainSaveParams;
|
||||
} LIBVIRT_8.0.0;
|
||||
|
||||
# .... define new API here using predicted next version number ....
|
||||
|
Loading…
Reference in New Issue
Block a user