From 84783d9d1cf8abbf0fc28c751bf1ff76e171efa1 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Thu, 23 Oct 2014 11:28:16 +0100 Subject: [PATCH] Move virDomainSnapshot related APIs out of libvirt.h.in Create a new libvirt-domain-snapshot.h file to hold the public API definitions for the virDomainSnapshot type. This header file is not self-contained, so applications will not directly include it. They will continue to #include --- docs/apibuild.py | 1 + include/libvirt/Makefile.am | 1 + include/libvirt/libvirt-domain-snapshot.h | 212 ++++++++++++++++++++++ include/libvirt/libvirt.h.in | 184 +------------------ libvirt.spec.in | 1 + mingw-libvirt.spec.in | 2 + 6 files changed, 221 insertions(+), 180 deletions(-) create mode 100644 include/libvirt/libvirt-domain-snapshot.h diff --git a/docs/apibuild.py b/docs/apibuild.py index 9b5f6d6b59..55d09f03d9 100755 --- a/docs/apibuild.py +++ b/docs/apibuild.py @@ -22,6 +22,7 @@ debugsym=None # included_files = { "libvirt.h": "header with general libvirt API definitions", + "libvirt-domain-snapshot.h": "header with general libvirt API definitions", "virterror.h": "header with error specific API definitions", "libvirt.c": "Main interfaces for the libvirt library", "libvirt-domain.c": "Domain interfaces for the libvirt library", diff --git a/include/libvirt/Makefile.am b/include/libvirt/Makefile.am index 5638890c48..ea935b0a6b 100644 --- a/include/libvirt/Makefile.am +++ b/include/libvirt/Makefile.am @@ -19,6 +19,7 @@ virincdir = $(includedir)/libvirt virinc_HEADERS = libvirt.h \ + libvirt-domain-snapshot.h \ libvirt-lxc.h \ libvirt-qemu.h \ virterror.h diff --git a/include/libvirt/libvirt-domain-snapshot.h b/include/libvirt/libvirt-domain-snapshot.h new file mode 100644 index 0000000000..0f73f24b2b --- /dev/null +++ b/include/libvirt/libvirt-domain-snapshot.h @@ -0,0 +1,212 @@ +/* + * libvirt-domain-snapshot.h + * Summary: APIs for management of domain snapshots + * Description: Provides APIs for the management of domain snapshots + * Author: Daniel Veillard + * + * Copyright (C) 2006-2014 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#ifndef __VIR_LIBVIRT_DOMAIN_SNAPSHOT_H__ +# define __VIR_LIBVIRT_DOMAIN_SNAPSHOT_H__ + +# ifndef __VIR_LIBVIRT_H_INCLUDES__ +# error "Don't include this file directly, only use libvirt/libvirt.h" +# endif + +/** + * virDomainSnapshot: + * + * a virDomainSnapshot is a private structure representing a snapshot of + * a domain. + */ +typedef struct _virDomainSnapshot virDomainSnapshot; + +/** + * virDomainSnapshotPtr: + * + * a virDomainSnapshotPtr is pointer to a virDomainSnapshot private structure, + * and is the type used to reference a domain snapshot in the API. + */ +typedef virDomainSnapshot *virDomainSnapshotPtr; + +const char *virDomainSnapshotGetName(virDomainSnapshotPtr snapshot); +virDomainPtr virDomainSnapshotGetDomain(virDomainSnapshotPtr snapshot); +virConnectPtr virDomainSnapshotGetConnect(virDomainSnapshotPtr snapshot); + +typedef enum { + VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE = (1 << 0), /* Restore or alter + metadata */ + VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT = (1 << 1), /* With redefine, make + snapshot current */ + VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA = (1 << 2), /* Make snapshot without + remembering it */ + VIR_DOMAIN_SNAPSHOT_CREATE_HALT = (1 << 3), /* Stop running guest + after snapshot */ + VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY = (1 << 4), /* disk snapshot, not + system checkpoint */ + VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT = (1 << 5), /* reuse any existing + external files */ + VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE = (1 << 6), /* use guest agent to + quiesce all mounted + file systems within + the domain */ + VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC = (1 << 7), /* atomically avoid + partial changes */ + VIR_DOMAIN_SNAPSHOT_CREATE_LIVE = (1 << 8), /* create the snapshot + while the guest is + running */ +} virDomainSnapshotCreateFlags; + +/* Take a snapshot of the current VM state */ +virDomainSnapshotPtr virDomainSnapshotCreateXML(virDomainPtr domain, + const char *xmlDesc, + unsigned int flags); + +/* Dump the XML of a snapshot */ +char *virDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, + unsigned int flags); + +/** + * virDomainSnapshotListFlags: + * + * Flags valid for virDomainSnapshotNum(), + * virDomainSnapshotListNames(), virDomainSnapshotNumChildren(), and + * virDomainSnapshotListChildrenNames(), virDomainListAllSnapshots(), + * and virDomainSnapshotListAllChildren(). Note that the interpretation + * of flag (1<<0) depends on which function it is passed to; but serves + * to toggle the per-call default of whether the listing is shallow or + * recursive. Remaining bits come in groups; if all bits from a group are + * 0, then that group is not used to filter results. */ +typedef enum { + VIR_DOMAIN_SNAPSHOT_LIST_ROOTS = (1 << 0), /* Filter by snapshots + with no parents, when + listing a domain */ + VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS = (1 << 0), /* List all descendants, + not just children, when + listing a snapshot */ + + /* For historical reasons, groups do not use contiguous bits. */ + + VIR_DOMAIN_SNAPSHOT_LIST_LEAVES = (1 << 2), /* Filter by snapshots + with no children */ + VIR_DOMAIN_SNAPSHOT_LIST_NO_LEAVES = (1 << 3), /* Filter by snapshots + that have children */ + + VIR_DOMAIN_SNAPSHOT_LIST_METADATA = (1 << 1), /* Filter by snapshots + which have metadata */ + VIR_DOMAIN_SNAPSHOT_LIST_NO_METADATA = (1 << 4), /* Filter by snapshots + with no metadata */ + + VIR_DOMAIN_SNAPSHOT_LIST_INACTIVE = (1 << 5), /* Filter by snapshots + taken while guest was + shut off */ + VIR_DOMAIN_SNAPSHOT_LIST_ACTIVE = (1 << 6), /* Filter by snapshots + taken while guest was + active, and with + memory state */ + VIR_DOMAIN_SNAPSHOT_LIST_DISK_ONLY = (1 << 7), /* Filter by snapshots + taken while guest was + active, but without + memory state */ + + VIR_DOMAIN_SNAPSHOT_LIST_INTERNAL = (1 << 8), /* Filter by snapshots + stored internal to + disk images */ + VIR_DOMAIN_SNAPSHOT_LIST_EXTERNAL = (1 << 9), /* Filter by snapshots + that use files external + to disk images */ +} virDomainSnapshotListFlags; + +/* Return the number of snapshots for this domain */ +int virDomainSnapshotNum(virDomainPtr domain, unsigned int flags); + +/* Get the names of all snapshots for this domain */ +int virDomainSnapshotListNames(virDomainPtr domain, char **names, int nameslen, + unsigned int flags); + +/* Get all snapshot objects for this domain */ +int virDomainListAllSnapshots(virDomainPtr domain, + virDomainSnapshotPtr **snaps, + unsigned int flags); + +/* Return the number of child snapshots for this snapshot */ +int virDomainSnapshotNumChildren(virDomainSnapshotPtr snapshot, + unsigned int flags); + +/* Get the names of all child snapshots for this snapshot */ +int virDomainSnapshotListChildrenNames(virDomainSnapshotPtr snapshot, + char **names, int nameslen, + unsigned int flags); + +/* Get all snapshot object children for this snapshot */ +int virDomainSnapshotListAllChildren(virDomainSnapshotPtr snapshot, + virDomainSnapshotPtr **snaps, + unsigned int flags); + +/* Get a handle to a named snapshot */ +virDomainSnapshotPtr virDomainSnapshotLookupByName(virDomainPtr domain, + const char *name, + unsigned int flags); + +/* Check whether a domain has a snapshot which is currently used */ +int virDomainHasCurrentSnapshot(virDomainPtr domain, unsigned int flags); + +/* Get a handle to the current snapshot */ +virDomainSnapshotPtr virDomainSnapshotCurrent(virDomainPtr domain, + unsigned int flags); + +/* Get a handle to the parent snapshot, if one exists */ +virDomainSnapshotPtr virDomainSnapshotGetParent(virDomainSnapshotPtr snapshot, + unsigned int flags); + +/* Determine if a snapshot is the current snapshot of its domain. */ +int virDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot, + unsigned int flags); + +/* Determine if a snapshot has associated libvirt metadata that would + * prevent the deletion of its domain. */ +int virDomainSnapshotHasMetadata(virDomainSnapshotPtr snapshot, + unsigned int flags); + +typedef enum { + VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING = 1 << 0, /* Run after revert */ + VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED = 1 << 1, /* Pause after revert */ + VIR_DOMAIN_SNAPSHOT_REVERT_FORCE = 1 << 2, /* Allow risky reverts */ +} virDomainSnapshotRevertFlags; + +/* Revert the domain to a point-in-time snapshot. The + * state of the guest after this call will be the state + * of the guest when the snapshot in question was taken + */ +int virDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, + unsigned int flags); + +/* Delete a snapshot */ +typedef enum { + VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN = (1 << 0), /* Also delete children */ + VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY = (1 << 1), /* Delete just metadata */ + VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY = (1 << 2), /* Delete just children */ +} virDomainSnapshotDeleteFlags; + +int virDomainSnapshotDelete(virDomainSnapshotPtr snapshot, + unsigned int flags); + +int virDomainSnapshotRef(virDomainSnapshotPtr snapshot); +int virDomainSnapshotFree(virDomainSnapshotPtr snapshot); + +#endif /* __VIR_LIBVIRT_DOMAIN_SNAPSHOT_H__ */ diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index c910b31f91..77c7b1b142 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -4590,186 +4590,6 @@ int virDomainAbortJob(virDomainPtr dom); #define VIR_DOMAIN_JOB_COMPRESSION_OVERFLOW "compression_overflow" -/** - * virDomainSnapshot: - * - * a virDomainSnapshot is a private structure representing a snapshot of - * a domain. - */ -typedef struct _virDomainSnapshot virDomainSnapshot; - -/** - * virDomainSnapshotPtr: - * - * a virDomainSnapshotPtr is pointer to a virDomainSnapshot private structure, - * and is the type used to reference a domain snapshot in the API. - */ -typedef virDomainSnapshot *virDomainSnapshotPtr; - -const char *virDomainSnapshotGetName(virDomainSnapshotPtr snapshot); -virDomainPtr virDomainSnapshotGetDomain(virDomainSnapshotPtr snapshot); -virConnectPtr virDomainSnapshotGetConnect(virDomainSnapshotPtr snapshot); - -typedef enum { - VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE = (1 << 0), /* Restore or alter - metadata */ - VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT = (1 << 1), /* With redefine, make - snapshot current */ - VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA = (1 << 2), /* Make snapshot without - remembering it */ - VIR_DOMAIN_SNAPSHOT_CREATE_HALT = (1 << 3), /* Stop running guest - after snapshot */ - VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY = (1 << 4), /* disk snapshot, not - system checkpoint */ - VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT = (1 << 5), /* reuse any existing - external files */ - VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE = (1 << 6), /* use guest agent to - quiesce all mounted - file systems within - the domain */ - VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC = (1 << 7), /* atomically avoid - partial changes */ - VIR_DOMAIN_SNAPSHOT_CREATE_LIVE = (1 << 8), /* create the snapshot - while the guest is - running */ -} virDomainSnapshotCreateFlags; - -/* Take a snapshot of the current VM state */ -virDomainSnapshotPtr virDomainSnapshotCreateXML(virDomainPtr domain, - const char *xmlDesc, - unsigned int flags); - -/* Dump the XML of a snapshot */ -char *virDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, - unsigned int flags); - -/** - * virDomainSnapshotListFlags: - * - * Flags valid for virDomainSnapshotNum(), - * virDomainSnapshotListNames(), virDomainSnapshotNumChildren(), and - * virDomainSnapshotListChildrenNames(), virDomainListAllSnapshots(), - * and virDomainSnapshotListAllChildren(). Note that the interpretation - * of flag (1<<0) depends on which function it is passed to; but serves - * to toggle the per-call default of whether the listing is shallow or - * recursive. Remaining bits come in groups; if all bits from a group are - * 0, then that group is not used to filter results. */ -typedef enum { - VIR_DOMAIN_SNAPSHOT_LIST_ROOTS = (1 << 0), /* Filter by snapshots - with no parents, when - listing a domain */ - VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS = (1 << 0), /* List all descendants, - not just children, when - listing a snapshot */ - - /* For historical reasons, groups do not use contiguous bits. */ - - VIR_DOMAIN_SNAPSHOT_LIST_LEAVES = (1 << 2), /* Filter by snapshots - with no children */ - VIR_DOMAIN_SNAPSHOT_LIST_NO_LEAVES = (1 << 3), /* Filter by snapshots - that have children */ - - VIR_DOMAIN_SNAPSHOT_LIST_METADATA = (1 << 1), /* Filter by snapshots - which have metadata */ - VIR_DOMAIN_SNAPSHOT_LIST_NO_METADATA = (1 << 4), /* Filter by snapshots - with no metadata */ - - VIR_DOMAIN_SNAPSHOT_LIST_INACTIVE = (1 << 5), /* Filter by snapshots - taken while guest was - shut off */ - VIR_DOMAIN_SNAPSHOT_LIST_ACTIVE = (1 << 6), /* Filter by snapshots - taken while guest was - active, and with - memory state */ - VIR_DOMAIN_SNAPSHOT_LIST_DISK_ONLY = (1 << 7), /* Filter by snapshots - taken while guest was - active, but without - memory state */ - - VIR_DOMAIN_SNAPSHOT_LIST_INTERNAL = (1 << 8), /* Filter by snapshots - stored internal to - disk images */ - VIR_DOMAIN_SNAPSHOT_LIST_EXTERNAL = (1 << 9), /* Filter by snapshots - that use files external - to disk images */ -} virDomainSnapshotListFlags; - -/* Return the number of snapshots for this domain */ -int virDomainSnapshotNum(virDomainPtr domain, unsigned int flags); - -/* Get the names of all snapshots for this domain */ -int virDomainSnapshotListNames(virDomainPtr domain, char **names, int nameslen, - unsigned int flags); - -/* Get all snapshot objects for this domain */ -int virDomainListAllSnapshots(virDomainPtr domain, - virDomainSnapshotPtr **snaps, - unsigned int flags); - -/* Return the number of child snapshots for this snapshot */ -int virDomainSnapshotNumChildren(virDomainSnapshotPtr snapshot, - unsigned int flags); - -/* Get the names of all child snapshots for this snapshot */ -int virDomainSnapshotListChildrenNames(virDomainSnapshotPtr snapshot, - char **names, int nameslen, - unsigned int flags); - -/* Get all snapshot object children for this snapshot */ -int virDomainSnapshotListAllChildren(virDomainSnapshotPtr snapshot, - virDomainSnapshotPtr **snaps, - unsigned int flags); - -/* Get a handle to a named snapshot */ -virDomainSnapshotPtr virDomainSnapshotLookupByName(virDomainPtr domain, - const char *name, - unsigned int flags); - -/* Check whether a domain has a snapshot which is currently used */ -int virDomainHasCurrentSnapshot(virDomainPtr domain, unsigned int flags); - -/* Get a handle to the current snapshot */ -virDomainSnapshotPtr virDomainSnapshotCurrent(virDomainPtr domain, - unsigned int flags); - -/* Get a handle to the parent snapshot, if one exists */ -virDomainSnapshotPtr virDomainSnapshotGetParent(virDomainSnapshotPtr snapshot, - unsigned int flags); - -/* Determine if a snapshot is the current snapshot of its domain. */ -int virDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot, - unsigned int flags); - -/* Determine if a snapshot has associated libvirt metadata that would - * prevent the deletion of its domain. */ -int virDomainSnapshotHasMetadata(virDomainSnapshotPtr snapshot, - unsigned int flags); - -typedef enum { - VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING = 1 << 0, /* Run after revert */ - VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED = 1 << 1, /* Pause after revert */ - VIR_DOMAIN_SNAPSHOT_REVERT_FORCE = 1 << 2, /* Allow risky reverts */ -} virDomainSnapshotRevertFlags; - -/* Revert the domain to a point-in-time snapshot. The - * state of the guest after this call will be the state - * of the guest when the snapshot in question was taken - */ -int virDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, - unsigned int flags); - -/* Delete a snapshot */ -typedef enum { - VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN = (1 << 0), /* Also delete children */ - VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY = (1 << 1), /* Delete just metadata */ - VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY = (1 << 2), /* Delete just children */ -} virDomainSnapshotDeleteFlags; - -int virDomainSnapshotDelete(virDomainSnapshotPtr snapshot, - unsigned int flags); - -int virDomainSnapshotRef(virDomainSnapshotPtr snapshot); -int virDomainSnapshotFree(virDomainSnapshotPtr snapshot); /** * virConnectDomainEventGenericCallback: @@ -5829,6 +5649,10 @@ typedef virMemoryParameter *virMemoryParameterPtr; /* Add new interfaces to the appropriate sections earlier in this * file; the end of the file is reserved for deprecated names. */ +#define __VIR_LIBVIRT_H_INCLUDES__ +#include +#undef __VIR_LIBVIRT_H_INCLUDES__ + #ifdef __cplusplus } #endif diff --git a/libvirt.spec.in b/libvirt.spec.in index aa06b845c4..686cced5e7 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -2251,6 +2251,7 @@ exit 0 %dir %{_includedir}/libvirt %{_includedir}/libvirt/virterror.h %{_includedir}/libvirt/libvirt.h +%{_includedir}/libvirt/libvirt-domain-snapshot.h %{_includedir}/libvirt/libvirt-qemu.h %{_includedir}/libvirt/libvirt-lxc.h %{_libdir}/pkgconfig/libvirt.pc diff --git a/mingw-libvirt.spec.in b/mingw-libvirt.spec.in index a1e58cb4df..6579386bbf 100644 --- a/mingw-libvirt.spec.in +++ b/mingw-libvirt.spec.in @@ -229,6 +229,7 @@ rm -rf $RPM_BUILD_ROOT%{mingw64_libexecdir}/libvirt-guests.sh %dir %{mingw32_includedir}/libvirt %{mingw32_includedir}/libvirt/libvirt.h +%{mingw32_includedir}/libvirt/libvirt-domain-snapshot.h %{mingw32_includedir}/libvirt/virterror.h %{mingw32_includedir}/libvirt/libvirt-lxc.h %{mingw32_includedir}/libvirt/libvirt-qemu.h @@ -292,6 +293,7 @@ rm -rf $RPM_BUILD_ROOT%{mingw64_libexecdir}/libvirt-guests.sh %dir %{mingw64_includedir}/libvirt %{mingw64_includedir}/libvirt/libvirt.h +%{mingw64_includedir}/libvirt/libvirt-domain-snapshot.h %{mingw64_includedir}/libvirt/virterror.h %{mingw64_includedir}/libvirt/libvirt-lxc.h %{mingw64_includedir}/libvirt/libvirt-qemu.h