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 <cfont...@suse.de> Reviewed-by: Daniel P. Berrangé <berra...@redhat.com> --- include/libvirt/libvirt-domain.h | 4 +++ src/driver-hypervisor.h | 7 +++++ src/libvirt-domain.c | 45 ++++++++++++++++++++++++++++++++ src/libvirt_public.syms | 1 + 4 files changed, 57 insertions(+) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h index 52c86f3813..d8375583fd 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -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: diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index 434a7d7cc4..69516e8fea 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -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; diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index ca2fe5e99d..0d6afcc1c6 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -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 diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 32ffbbaf84..9f58b52924 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -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 .... -- 2.35.3