1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

libvirt: introduce virDomainRestoreParams public API

add new API in order to be able to extend parameters to the domain
restore operation. We will use it to fit the existing arguments of
VirDomainRestoreFlags for now.

Signed-off-by: Claudio Fontana <cfontana@suse.de>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Claudio Fontana 2022-05-06 15:10:52 +02:00 committed by Daniel P. Berrangé
parent 6392cb1f1f
commit f9a8e25b15
4 changed files with 57 additions and 0 deletions

View File

@ -1572,6 +1572,10 @@ int virDomainRestoreFlags (virConnectPtr conn,
const char *from,
const char *dxml,
unsigned int flags);
int virDomainRestoreParams (virConnectPtr conn,
virTypedParameterPtr params,
int nparams,
unsigned int flags);
/**
* VIR_SAVE_PARAM_FILE:

View File

@ -256,6 +256,12 @@ typedef int
const char *dxml,
unsigned int flags);
typedef int
(*virDrvDomainRestoreParams)(virConnectPtr conn,
virTypedParameterPtr params,
int nparams,
unsigned int flags);
typedef char *
(*virDrvDomainSaveImageGetXMLDesc)(virConnectPtr conn,
const char *file,
@ -1498,6 +1504,7 @@ struct _virHypervisorDriver {
virDrvDomainSaveParams domainSaveParams;
virDrvDomainRestore domainRestore;
virDrvDomainRestoreFlags domainRestoreFlags;
virDrvDomainRestoreParams domainRestoreParams;
virDrvDomainSaveImageGetXMLDesc domainSaveImageGetXMLDesc;
virDrvDomainSaveImageDefineXML domainSaveImageDefineXML;
virDrvDomainCoreDump domainCoreDump;

View File

@ -1181,6 +1181,51 @@ virDomainRestoreFlags(virConnectPtr conn, const char *from, const char *dxml,
}
/**
* virDomainRestoreParams:
* @conn: pointer to the hypervisor connection
* @params: restore parameters
* @nparams: number of restore parameters
* @flags: bitwise-OR of virDomainSaveRestoreFlags
*
* This method extends virDomainRestoreFlags by adding parameters.
*
* Returns 0 in case of success and -1 in case of failure.
*
* Since: 8.4.0
*/
int
virDomainRestoreParams(virConnectPtr conn,
virTypedParameterPtr params, int nparams,
unsigned int flags)
{
VIR_DEBUG("conn=%p, params=%p, nparams=%d, flags=0x%x",
conn, params, nparams, flags);
VIR_TYPED_PARAMS_DEBUG(params, nparams);
virResetLastError();
virCheckConnectReturn(conn, -1);
virCheckReadOnlyGoto(conn->flags, error);
VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_SAVE_RUNNING,
VIR_DOMAIN_SAVE_PAUSED,
error);
if (conn->driver->domainRestoreParams) {
if (conn->driver->domainRestoreParams(conn, params, nparams, flags) < 0)
goto error;
return 0;
}
virReportUnsupportedError();
error:
virDispatchError(conn);
return -1;
}
/**
* virDomainSaveImageGetXMLDesc:
* @conn: pointer to the hypervisor connection

View File

@ -919,6 +919,7 @@ LIBVIRT_8.0.0 {
LIBVIRT_8.4.0 {
global:
virDomainSaveParams;
virDomainRestoreParams;
} LIBVIRT_8.0.0;
# .... define new API here using predicted next version number ....