From patchwork Thu Jan 27 16:33:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: MORITA Kazutaka X-Patchwork-Id: 512901 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p0RGZpaY007363 for ; Thu, 27 Jan 2011 16:35:53 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751731Ab1A0Qft (ORCPT ); Thu, 27 Jan 2011 11:35:49 -0500 Received: from sh.osrg.net ([192.16.179.4]:48855 "EHLO sh.osrg.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751223Ab1A0Qfs (ORCPT ); Thu, 27 Jan 2011 11:35:48 -0500 Received: from fs.osrg.net (postfix@fs.osrg.net [10.0.0.12]) by sh.osrg.net (8.14.3/8.14.3/OSRG-NET) with ESMTP id p0RGZL3l010930; Fri, 28 Jan 2011 01:35:21 +0900 Received: from localhost (dfs1401.osrg.net [10.68.14.1]) by fs.osrg.net (Postfix) with ESMTP id E583C3E03FE; Fri, 28 Jan 2011 01:35:20 +0900 (JST) From: MORITA Kazutaka To: kwolf@redhat.com Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, sheepdog@lists.wpkg.org Subject: [PATCH] sheepdog: support creating images on remote hosts Date: Fri, 28 Jan 2011 01:33:10 +0900 Message-Id: <1296145990-1055-1-git-send-email-morita.kazutaka@lab.ntt.co.jp> X-Mailer: git-send-email 1.5.6.5 X-Dispatcher: imput version 20070423(IM149) Lines: 54 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 27 Jan 2011 16:35:56 +0000 (UTC) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0 (sh.osrg.net [192.16.179.4]); Fri, 28 Jan 2011 01:35:22 +0900 (JST) X-Virus-Scanned: clamav-milter 0.96.5 at sh X-Virus-Status: Clean Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/block/sheepdog.c b/block/sheepdog.c index e62820a..a54e0de 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -1294,12 +1294,23 @@ static int do_sd_create(char *filename, int64_t vdi_size, static int sd_create(const char *filename, QEMUOptionParameter *options) { int ret; - uint32_t vid = 0; + uint32_t vid = 0, base_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; @@ -1338,11 +1349,11 @@ static int sd_create(const char *filename, QEMUOptionParameter *options) return -EINVAL; } - vid = s->inode.vdi_id; + base_vid = s->inode.vdi_id; bdrv_delete(bs); } - return do_sd_create((char *)filename, vdi_size, vid, NULL, 0, NULL, NULL); + return do_sd_create((char *)vdi, vdi_size, base_vid, &vid, 0, s.addr, s.port); } static void sd_close(BlockDriverState *bs)