At Sun, 3 Oct 2010 23:12:46 +0200, Floris Bos wrote: > > However I think that CREATING new VDIs on an external sheepdog server is not > implemented/broken. > > do_sd_create() does not use s->addr, but a function parameter. > > http://git.savannah.gnu.org/cgit/qemu.git/tree/block/sheepdog.c#n1244 > > == > static int do_sd_create(char *filename, int64_t vdi_size, > uint32_t base_vid, uint32_t *vdi_id, int snapshot, > const char *addr, const char *port) > { > SheepdogVdiReq hdr; > SheepdogVdiRsp *rsp = (SheepdogVdiRsp *)&hdr; > int fd, ret; > unsigned int wlen, rlen = 0; > char buf[SD_MAX_VDI_LEN]; > > fd = connect_to_sdog(addr, port); > == > > And do_sd_create() is called with the "addr" parameter hardcoded to null in > sd_create(), making it always use the default of localhost:7000 when creating > new VDIs: > > http://git.savannah.gnu.org/cgit/qemu.git/tree/block/sheepdog.c#n937 > > == > return do_sd_create((char *)filename, vdi_size, vid, NULL, 0, NULL, NULL); > == > Yes. We should parse the input vdiname to get a target host. This is a fix patch. == This patch parses the input filename in sd_create(), and enables us specifying a target server to create sheepdog images. Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp> --- block/sheepdog.c | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/block/sheepdog.c b/block/sheepdog.c index e62820a..0f4b9d3 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -1297,9 +1297,20 @@ static int sd_create(const char *filename, QEMUOptionParameter *options) uint32_t vid = 0; int64_t vdi_size = 0; char *backing_file = NULL; + BDRVSheepdogState s; + char vdi[SD_MAX_VDI_LEN], tag[SD_MAX_VDI_TAG_LEN]; + uint32_t snapid; strstart(filename, "sheepdog:", (const char **)&filename); + memset(&s, 0, sizeof(s)); + memset(vdi, 0, sizeof(vdi)); + memset(tag, 0, sizeof(tag)); + if (parse_vdiname(&s, filename, vdi, &snapid, tag) < 0) { + error_report("invalid filename\n"); + return -EINVAL; + } + while (options && options->name) { if (!strcmp(options->name, BLOCK_OPT_SIZE)) { vdi_size = options->value.n; @@ -1342,7 +1353,7 @@ static int sd_create(const char *filename, QEMUOptionParameter *options) bdrv_delete(bs); } - return do_sd_create((char *)filename, vdi_size, vid, NULL, 0, NULL, NULL); + return do_sd_create((char *)vdi, vdi_size, vid, NULL, 0, s.addr, s.port); } static void sd_close(BlockDriverState *bs) -- 1.5.6.5 |