From patchwork Fri Apr 3 17:58:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 11473255 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 65473912 for ; Fri, 3 Apr 2020 18:01:22 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3B7B9206F5 for ; Fri, 3 Apr 2020 18:01:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MlDTUvzQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3B7B9206F5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:59240 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jKQd6-0001cw-Gu for patchwork-qemu-devel@patchwork.kernel.org; Fri, 03 Apr 2020 14:01:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39233) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jKQbS-00082Y-If for qemu-devel@nongnu.org; Fri, 03 Apr 2020 13:59:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jKQbR-0007Wl-Fg for qemu-devel@nongnu.org; Fri, 03 Apr 2020 13:59:38 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:56799 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jKQbR-0007Vp-Br for qemu-devel@nongnu.org; Fri, 03 Apr 2020 13:59:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585936777; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ow8fHVhdF5XdDD9HXHcAMKy9dd3Xe7mid7JBL1s9T2Y=; b=MlDTUvzQZqB7jtpxWnSc+urHZaGqUOFaDcDst0UlhUPCvCQ6uItXpRmIJLOW9vwsTduSSm FBZeA4GCEyg7aCtuiuMC4ynpLhjFbq21WTp10Aa58p5fBZqy5XBA2y/iygKW/Wh3KItxwK P0rkv/IGlroZpdi1JooPua4kmQEuadE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-25-u0b58hJkPs2nQclaNpvbgw-1; Fri, 03 Apr 2020 13:59:33 -0400 X-MC-Unique: u0b58hJkPs2nQclaNpvbgw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 63CD2107ACC4; Fri, 3 Apr 2020 17:59:30 +0000 (UTC) Received: from blue.redhat.com (ovpn-113-246.phx2.redhat.com [10.3.113.246]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9463B5C1BE; Fri, 3 Apr 2020 17:59:14 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Subject: [PATCH v5 1/7] sheepdog: Add trivial backing_fmt support Date: Fri, 3 Apr 2020 12:58:53 -0500 Message-Id: <20200403175859.863248-2-eblake@redhat.com> In-Reply-To: <20200403175859.863248-1-eblake@redhat.com> References: <20200403175859.863248-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, pkrempa@redhat.com, "open list:Sheepdog" , qemu-block@nongnu.org, kchamart@redhat.com, libvir-list@redhat.com, Michael Tokarev , Laurent Vivier , mreitz@redhat.com, "open list:Trivial patches" , Liu Yuan Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Sheepdog already requires that if backing_file is present, that it be another sheepdog image (see sd_co_create). Meanwhile, we want to move towards always being explicit about the backing format for other drivers where it matters. So for convenience, make qemu-img create -F sheepdog work, while rejecting all other explicit formats (note that this is only for QemuOpts usage; there is no change to the QAPI to allow a format through -blockdev). Signed-off-by: Eric Blake --- block/sheepdog.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/block/sheepdog.c b/block/sheepdog.c index 59f7ebb1710f..8f558367d2d5 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -2163,13 +2163,21 @@ static int coroutine_fn sd_co_create_opts(BlockDriver *drv, Error **errp) { BlockdevCreateOptions *create_options = NULL; - QDict *qdict, *location_qdict; + QDict *qdict = NULL, *location_qdict; Visitor *v; - char *redundancy; + char *redundancy = NULL; Error *local_err = NULL; int ret; + char *backing_fmt = NULL; redundancy = qemu_opt_get_del(opts, BLOCK_OPT_REDUNDANCY); + backing_fmt = qemu_opt_get_del(opts, BLOCK_OPT_BACKING_FMT); + + if (backing_fmt && strcmp(backing_fmt, "sheepdog") != 0) { + error_setg(errp, "backing_file must be a sheepdog image"); + ret = -EINVAL; + goto fail; + } qdict = qemu_opts_to_qdict(opts, NULL); qdict_put_str(qdict, "driver", "sheepdog"); @@ -2234,6 +2242,7 @@ fail: qapi_free_BlockdevCreateOptions(create_options); qobject_unref(qdict); g_free(redundancy); + g_free(backing_fmt); return ret; } @@ -3191,6 +3200,11 @@ static QemuOptsList sd_create_opts = { .type = QEMU_OPT_STRING, .help = "File name of a base image" }, + { + .name = BLOCK_OPT_BACKING_FMT, + .type = QEMU_OPT_STRING, + .help = "Must be 'sheepdog' if present", + }, { .name = BLOCK_OPT_PREALLOC, .type = QEMU_OPT_STRING,