1 /*
2  * checkpoint_conf.h: domain checkpoint XML processing
3  *                 (based on snapshot_conf.h)
4  *
5  * Copyright (C) 2006-2019 Red Hat, Inc.
6  * Copyright (C) 2006-2008 Daniel P. Berrange
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library.  If not, see
20  * <http://www.gnu.org/licenses/>.
21  */
22 
23 #pragma once
24 
25 #include "internal.h"
26 #include "domain_conf.h"
27 #include "moment_conf.h"
28 #include "virobject.h"
29 
30 /* Items related to checkpoint state */
31 
32 typedef enum {
33     VIR_DOMAIN_CHECKPOINT_TYPE_DEFAULT = 0,
34     VIR_DOMAIN_CHECKPOINT_TYPE_NONE,
35     VIR_DOMAIN_CHECKPOINT_TYPE_BITMAP,
36 
37     VIR_DOMAIN_CHECKPOINT_TYPE_LAST
38 } virDomainCheckpointType;
39 
40 /* Stores disk-checkpoint information */
41 typedef struct _virDomainCheckpointDiskDef virDomainCheckpointDiskDef;
42 struct _virDomainCheckpointDiskDef {
43     char *name;     /* name matching the <target dev='...' of the domain */
44     int type;       /* virDomainCheckpointType */
45     char *bitmap;   /* bitmap name, if type is bitmap */
46     unsigned long long size; /* current checkpoint size in bytes */
47     bool sizeValid;
48 };
49 
50 /* Stores the complete checkpoint metadata */
51 struct _virDomainCheckpointDef {
52     virDomainMomentDef parent;
53 
54     /* Additional Public XML.  */
55     size_t ndisks; /* should not exceed dom->ndisks */
56     virDomainCheckpointDiskDef *disks;
57 };
58 
59 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainCheckpointDef, virObjectUnref);
60 
61 typedef enum {
62     VIR_DOMAIN_CHECKPOINT_PARSE_REDEFINE = 1 << 0,
63 } virDomainCheckpointParseFlags;
64 
65 typedef enum {
66     VIR_DOMAIN_CHECKPOINT_FORMAT_SECURE    = 1 << 0,
67     VIR_DOMAIN_CHECKPOINT_FORMAT_NO_DOMAIN = 1 << 1,
68     VIR_DOMAIN_CHECKPOINT_FORMAT_SIZE      = 1 << 2,
69 } virDomainCheckpointFormatFlags;
70 
71 unsigned int
72 virDomainCheckpointFormatConvertXMLFlags(unsigned int flags);
73 
74 virDomainCheckpointDef *
75 virDomainCheckpointDefParseString(const char *xmlStr,
76                                   virDomainXMLOption *xmlopt,
77                                   void *parseOpaque,
78                                   unsigned int flags);
79 
80 virDomainCheckpointDef *
81 virDomainCheckpointDefNew(void);
82 
83 char *
84 virDomainCheckpointDefFormat(virDomainCheckpointDef *def,
85                              virDomainXMLOption *xmlopt,
86                              unsigned int flags);
87 
88 int
89 virDomainCheckpointAlignDisks(virDomainCheckpointDef *checkpoint);
90 
91 int
92 virDomainCheckpointRedefinePrep(virDomainObj *vm,
93                                 virDomainCheckpointDef *def,
94                                 bool *update_current);
95 
96 virDomainMomentObj *
97 virDomainCheckpointRedefineCommit(virDomainObj *vm,
98                                   virDomainCheckpointDef **defptr);
99 
100 VIR_ENUM_DECL(virDomainCheckpoint);
101