[sheepdog] [PATCH] collie/farm: save vmstate objects during cluster-wide snapshot
Kai Zhang
kyle at zelin.io
Mon Jun 24 08:04:57 CEST 2013
Without this patch, qemu's 'loadvm' command will fail after
loading cluster-wide snapshot to a new cluster.
Signed-off-by: Kai Zhang <kyle at zelin.io>
---
collie/cluster.c | 12 +++++++++++-
include/sheepdog_proto.h | 5 +++++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/collie/cluster.c b/collie/cluster.c
index c0c4ab2..4e94ad2 100644
--- a/collie/cluster.c
+++ b/collie/cluster.c
@@ -253,14 +253,17 @@ static void fill_object_tree(uint32_t vid, const char *name, const char *tag,
uint32_t snapid, uint32_t flags,
const struct sd_inode *i, void *data)
{
- uint64_t vdi_oid = vid_to_vdi_oid(vid);
+ uint64_t vdi_oid = vid_to_vdi_oid(vid), vmstate_oid;
+ int nr_vmstate_object;
/* ignore active vdi */
if (!vdi_is_snapshot(i))
return;
+ /* fill vdi object id */
object_tree_insert(vdi_oid, i->nr_copies);
+ /* fill data object id */
for (uint64_t idx = 0; idx < MAX_DATA_OBJS; idx++) {
if (i->data_vdi_id[idx]) {
uint64_t oid = vid_to_data_oid(i->data_vdi_id[idx],
@@ -268,6 +271,13 @@ static void fill_object_tree(uint32_t vid, const char *name, const char *tag,
object_tree_insert(oid, i->nr_copies);
}
}
+
+ /* fill vmstate object id */
+ nr_vmstate_object = (i->vm_state_size / SD_DATA_OBJ_SIZE) + 1;
+ for (int idx = 0; idx < nr_vmstate_object; idx++) {
+ vmstate_oid = vid_to_vmstate_oid(vid, idx);
+ object_tree_insert(vmstate_oid, i->nr_copies);
+ }
}
static int save_snapshot(int argc, char **argv)
diff --git a/include/sheepdog_proto.h b/include/sheepdog_proto.h
index beef0a6..156457a 100644
--- a/include/sheepdog_proto.h
+++ b/include/sheepdog_proto.h
@@ -307,6 +307,11 @@ static inline uint64_t vid_to_attr_oid(uint32_t vid, uint32_t attrid)
return ((uint64_t)vid << VDI_SPACE_SHIFT) | VDI_ATTR_BIT | attrid;
}
+static inline uint64_t vid_to_vmstate_oid(uint32_t vid, uint32_t idx)
+{
+ return VMSTATE_BIT | ((uint64_t)vid << VDI_SPACE_SHIFT) | idx;
+}
+
static inline bool vdi_is_snapshot(const struct sd_inode *inode)
{
return !!inode->snap_ctime;
--
1.7.9.5
More information about the sheepdog
mailing list