mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-31 18:33:11 +00:00
7e5b993d3b
The semantics of the backup operation don't strictly require that all disks being backed up are part of the same incremental part (when a disk was checkpointed/backed up separately or in a different VM), or even they may not have a previous checkpoint at all (e.g. when the disk was freshly hotplugged to the vm). In such cases we can still create a common checkpoint for all of them and backup differences according to configuration. This patch adds a per-disk configuration of the checkpoint to do the incremental backup from via the 'incremental' attribute and allows perform full backups via the 'backupmode' attribute. Note that no changes to the qemu driver are necessary to take advantage of this as we already obey the per-disk 'incremental' field. https://bugzilla.redhat.com/show_bug.cgi?id=1829829 Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
131 lines
4.2 KiB
C
131 lines
4.2 KiB
C
/*
|
|
* backup_conf.h: domain backup XML processing
|
|
* (based on domain_conf.h)
|
|
*
|
|
* Copyright (C) 2006-2019 Red Hat, Inc.
|
|
* Copyright (C) 2006-2008 Daniel P. Berrange
|
|
*
|
|
* 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
|
|
* <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "internal.h"
|
|
#include "virconftypes.h"
|
|
|
|
/* Items related to incremental backup state */
|
|
|
|
typedef enum {
|
|
VIR_DOMAIN_BACKUP_TYPE_DEFAULT = 0,
|
|
VIR_DOMAIN_BACKUP_TYPE_PUSH,
|
|
VIR_DOMAIN_BACKUP_TYPE_PULL,
|
|
|
|
VIR_DOMAIN_BACKUP_TYPE_LAST
|
|
} virDomainBackupType;
|
|
|
|
typedef enum {
|
|
VIR_DOMAIN_BACKUP_DISK_STATE_NONE = 0,
|
|
VIR_DOMAIN_BACKUP_DISK_STATE_RUNNING,
|
|
VIR_DOMAIN_BACKUP_DISK_STATE_COMPLETE,
|
|
VIR_DOMAIN_BACKUP_DISK_STATE_FAILED,
|
|
VIR_DOMAIN_BACKUP_DISK_STATE_CANCELLING,
|
|
VIR_DOMAIN_BACKUP_DISK_STATE_CANCELLED,
|
|
VIR_DOMAIN_BACKUP_DISK_STATE_LAST
|
|
} virDomainBackupDiskState;
|
|
|
|
|
|
typedef enum {
|
|
VIR_DOMAIN_BACKUP_DISK_BACKUP_MODE_DEFAULT = 0,
|
|
VIR_DOMAIN_BACKUP_DISK_BACKUP_MODE_FULL,
|
|
VIR_DOMAIN_BACKUP_DISK_BACKUP_MODE_INCREMENTAL,
|
|
|
|
VIR_DOMAIN_BACKUP_DISK_BACKUP_MODE_LAST
|
|
} virDomainBackupDiskBackupMode;
|
|
|
|
|
|
/* Stores disk-backup information */
|
|
typedef struct _virDomainBackupDiskDef virDomainBackupDiskDef;
|
|
typedef virDomainBackupDiskDef *virDomainBackupDiskDefPtr;
|
|
struct _virDomainBackupDiskDef {
|
|
char *name; /* name matching the <target dev='...' of the domain */
|
|
virTristateBool backup; /* whether backup is requested */
|
|
virDomainBackupDiskBackupMode backupmode;
|
|
char *incremental; /* name of the starting point checkpoint of an incremental backup */
|
|
char *exportname; /* name of the NBD export for pull mode backup */
|
|
char *exportbitmap; /* name of the bitmap exposed in NBD for pull mode backup */
|
|
|
|
/* details of target for push-mode, or of the scratch file for pull-mode */
|
|
virStorageSourcePtr store;
|
|
|
|
/* internal data */
|
|
virDomainBackupDiskState state;
|
|
};
|
|
|
|
/* Stores the complete backup metadata */
|
|
typedef struct _virDomainBackupDef virDomainBackupDef;
|
|
typedef virDomainBackupDef *virDomainBackupDefPtr;
|
|
struct _virDomainBackupDef {
|
|
/* Public XML. */
|
|
int type; /* virDomainBackupType */
|
|
char *incremental;
|
|
virStorageNetHostDefPtr server; /* only when type == PULL */
|
|
virTristateBool tls; /* use TLS for NBD */
|
|
|
|
size_t ndisks; /* should not exceed dom->ndisks */
|
|
virDomainBackupDiskDef *disks;
|
|
|
|
/* internal data */
|
|
|
|
/* NBD TLS internals */
|
|
char *tlsAlias;
|
|
char *tlsSecretAlias;
|
|
|
|
/* statistic totals for completed disks */
|
|
unsigned long long push_transferred;
|
|
unsigned long long push_total;
|
|
unsigned long long pull_tmp_used;
|
|
unsigned long long pull_tmp_total;
|
|
|
|
char *errmsg; /* error message of failed sub-blockjob */
|
|
};
|
|
|
|
typedef enum {
|
|
VIR_DOMAIN_BACKUP_PARSE_INTERNAL = 1 << 0,
|
|
} virDomainBackupParseFlags;
|
|
|
|
virDomainBackupDefPtr
|
|
virDomainBackupDefParseString(const char *xmlStr,
|
|
virDomainXMLOptionPtr xmlopt,
|
|
unsigned int flags);
|
|
|
|
virDomainBackupDefPtr
|
|
virDomainBackupDefParseNode(xmlDocPtr xml,
|
|
xmlNodePtr root,
|
|
virDomainXMLOptionPtr xmlopt,
|
|
unsigned int flags);
|
|
void
|
|
virDomainBackupDefFree(virDomainBackupDefPtr def);
|
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainBackupDef, virDomainBackupDefFree);
|
|
|
|
int
|
|
virDomainBackupDefFormat(virBufferPtr buf,
|
|
virDomainBackupDefPtr def,
|
|
bool internal);
|
|
int
|
|
virDomainBackupAlignDisks(virDomainBackupDefPtr backup,
|
|
virDomainDefPtr dom,
|
|
const char *suffix);
|