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: 80713 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E0485B7125 for ; Fri, 28 Jan 2011 03:40:36 +1100 (EST) Received: from localhost ([127.0.0.1]:39049 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PiUtd-0000nu-VS for incoming@patchwork.ozlabs.org; Thu, 27 Jan 2011 11:40:33 -0500 Received: from [140.186.70.92] (port=42993 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PiUor-0005oD-Fx for qemu-devel@nongnu.org; Thu, 27 Jan 2011 11:35:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PiUop-0002Vo-Rp for qemu-devel@nongnu.org; Thu, 27 Jan 2011 11:35:37 -0500 Received: from sh.osrg.net ([192.16.179.4]:58321) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PiUop-0002Uz-Ap for qemu-devel@nongnu.org; Thu, 27 Jan 2011 11:35:35 -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 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: 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 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: sheepdog@lists.wpkg.org, qemu-devel@nongnu.org, kvm@vger.kernel.org Subject: [Qemu-devel] [PATCH] sheepdog: support creating images on remote hosts X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- block/sheepdog.c | 17 ++++++++++++++--- 1 files changed, 14 insertions(+), 3 deletions(-) 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)