[Sheepdog] Is sheepdog supported in libvirt/virt-install ?

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Fri Jul 23 19:25:57 CEST 2010


At Fri, 23 Jul 2010 11:05:42 +0100,
Haven wrote:
> 
>   Hi,
> 
> I have just discovered sheepdog a few days ago and started having a 
> play with it yesterday. I've had a look through the getting started 
> guide and have a couple of questions.
> 
> Is it possible to use sheepdog in libvirt via virt-install or only 
> via the qemu utilities ?
> 

Only via the qemu utilities.  But it's nice to add a sheepdog support
to libvirt.  I've added it to the TODO list.

http://www.osrg.net/sheepdog/todo.html

I'm working on a scalability problem of Sheepdog now.  Any other
contributions would be greatly appreciated.

> Secondly, how do you cleanly remove added images. When running:
> >  collie vdi delete <image>
> 
> I am left with error entries:
> 
> >   name        id    size    used  shared    creation time   vdi id
> > ------------------------------------------------------------------
> > error 8137509, 0
> > error 16593660, 0
> 

Thanks for your report!  Can you try the following patch?

=
From c046e740ea7c84d8670c348b53305a0f931e74d0 Mon Sep 17 00:00:00 2001
From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
Date: Fri, 23 Jul 2010 23:42:15 +0900
Subject: [PATCH] sheep: fix vdi deletion

We need to clear a bit from a vdi bitmap after deleting VDIs.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 sheep/group.c      |    7 ++++++-
 sheep/sheep_priv.h |    2 +-
 sheep/vdi.c        |   11 +++++------
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/sheep/group.c b/sheep/group.c
index 7d36d15..ca37772 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -673,7 +673,7 @@ static void vdi_op(struct vdi_op_message *msg)
 			ret = SD_RES_VDI_LOCKED;
 			break;
 		}
-		ret = del_vdi(hdr->epoch, data, hdr->data_length, hdr->snapid);
+		ret = del_vdi(hdr->epoch, data, hdr->data_length, &vid, hdr->snapid);
 		break;
 	case SD_OP_LOCK_VDI:
 	case SD_OP_GET_VDI_INFO:
@@ -726,7 +726,12 @@ static void vdi_op_done(struct vdi_op_message *msg)
 		break;
 	}
 	case SD_OP_DEL_VDI:
+	{
+		unsigned long nr = rsp->vdi_id;
+		vprintf(SDOG_INFO "done %d %ld\n", ret, nr);
+		clear_bit(nr, sys->vdi_inuse);
 		break;
+	}
 	case SD_OP_LOCK_VDI:
 		if (lookup_vm(&sys->vm_list, (char *)data)) {
 			ret = SD_RES_VDI_LOCKED;
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 542da27..ce2e0e6 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -133,7 +133,7 @@ int add_vdi(uint32_t epoch, char *data, int data_len, uint64_t size,
 	    uint32_t *new_vid, uint32_t base_vid, uint32_t copies,
 	    int is_snapshot);
 
-int del_vdi(uint32_t epoch, char *data, int data_len, uint32_t snapid);
+int del_vdi(uint32_t epoch, char *data, int data_len, uint32_t *vid, uint32_t snapid);
 
 int lookup_vdi(uint32_t epoch, char *data, int data_len, uint32_t *vid, uint32_t snapid);
 
diff --git a/sheep/vdi.c b/sheep/vdi.c
index 102d956..a88b4e7 100644
--- a/sheep/vdi.c
+++ b/sheep/vdi.c
@@ -285,10 +285,9 @@ int add_vdi(uint32_t epoch, char *data, int data_len, uint64_t size,
 
 int start_deletion(uint32_t vid, uint32_t epoch);
 
-int del_vdi(uint32_t epoch, char *data, int data_len, uint32_t snapid)
+int del_vdi(uint32_t epoch, char *data, int data_len, uint32_t *vid, uint32_t snapid)
 {
 	char *name = data;
-	uint32_t vid;
 	uint32_t dummy0;
 	unsigned long dummy1, dummy2;
 	int ret;
@@ -299,7 +298,7 @@ int del_vdi(uint32_t epoch, char *data, int data_len, uint32_t snapid)
 	if (data_len != SD_MAX_VDI_LEN)
 		return SD_RES_INVALID_PARMS;
 
-	ret = do_lookup_vdi(epoch, name, strlen(name), &vid, NULL, snapid,
+	ret = do_lookup_vdi(epoch, name, strlen(name), vid, NULL, snapid,
 			     &dummy0, &dummy1, &dummy2);
 	if (ret != SD_RES_SUCCESS)
 		return ret;
@@ -310,7 +309,7 @@ int del_vdi(uint32_t epoch, char *data, int data_len, uint32_t snapid)
 		nr_reqs = nr_nodes;
 
 	ret = read_object(entries, nr_nodes, epoch,
-			  vid_to_vdi_oid(vid), (char *)&inode, sizeof(inode), 0,
+			  vid_to_vdi_oid(*vid), (char *)&inode, sizeof(inode), 0,
 			  nr_reqs);
 	if (ret < 0)
 		return SD_RES_EIO;
@@ -318,12 +317,12 @@ int del_vdi(uint32_t epoch, char *data, int data_len, uint32_t snapid)
 	memset(inode.name, 0, sizeof(inode.name));
 
 	ret = write_object(entries, nr_nodes, epoch,
-			   vid_to_vdi_oid(vid), (char *)&inode, sizeof(inode), 0,
+			   vid_to_vdi_oid(*vid), (char *)&inode, sizeof(inode), 0,
 			   nr_reqs, 0);
 	if (ret < 0)
 		return SD_RES_EIO;
 
-	ret = start_deletion(vid, epoch);
+	ret = start_deletion(*vid, epoch);
 	if (ret < 0)
 		return SD_RES_NO_MEM;
 
-- 
1.5.6.5




More information about the sheepdog mailing list