From patchwork Mon Oct 7 21:49:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175429 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4848632ill; Mon, 7 Oct 2019 14:53:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqzPSLyzAIeQ/9hVBjDOjE8DoF/DmCddJdSOgR/FhugqWXKyg6wyNeSaX6zHWz8Raw/wLjD8 X-Received: by 2002:aca:1c06:: with SMTP id c6mr1187367oic.27.1570485181554; Mon, 07 Oct 2019 14:53:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570485181; cv=none; d=google.com; s=arc-20160816; b=hpRmYugw+dBbZiZof+fsy/UZKftRx2XBtL8nT/+Dac4k0BNQWe+njB2Rx+gVq9iv3i 2vsClmCmCg3tEdUCkzbedn5QkXQdS21VDzAfUMrFeUUJCcgGTN3XuQx1gyu1FBjAD1v+ sDmDaDcVQRHgNPmt6GVgtRtmN98u8Yva2eo5UKE/vEhOPoCZcLjJTTOB+PQZ4vKncTKw Gd+7XbaBqyRSp/bny43mlTjaw9tViXoFrVgUypdrxAKRtBpEDFmfTHgvn0HASYMudcOa KaDXf12rAcFDR8rg+pYqAqrRphNVe7ZXxtjCL5yWLJU29+l/j87V92gnYXZbVe3nKT3F upoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=ooQ8NQVpqcq589byhOREixiTAd44wmHd0EUdUSCviC0=; b=Rea82fqoMpl8xGRk266n5Hw1gQG2hx4OMwSFfuu/gcgLhawxVpxQwdwk1weeGfCMMm txtGAhrzW4noWbNcHK0O2qPr5ntWqADTJlS/MikpQkQ19sWmWrXzoAZyc0FfSNqQtX2Q DmMiWkRDie/OUIbnrNn+WWcikFT4oa3bfBFohMMHuiuSN0e0TacawiquDKucWTAwgSxw zpHi0/Mrdu+dfFccNUIhX4WNaKz95AU0mXdRjCtUgtW0mzCQNKzsf6RRTPG/34/84tzA hGMD94jwhQpCjWg8X5LXUEWzq8UkqcIioGZ0+buz6zHSnjtTyPVuoZcP8E9xK17wKrTQ AjKw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id 2si10310338oih.277.2019.10.07.14.53.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:53:01 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 57F8818C4277; Mon, 7 Oct 2019 21:52:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2CC656012C; Mon, 7 Oct 2019 21:52:59 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C6E9118037C9; Mon, 7 Oct 2019 21:52:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97LoX9S015072 for ; Mon, 7 Oct 2019 17:50:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 04CC15C290; Mon, 7 Oct 2019 21:50:33 +0000 (UTC) Delivered-To: libvir-list@redhat.com Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A31B5C224; Mon, 7 Oct 2019 21:50:24 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:33 -0400 Message-Id: <429e602ae44341aef3aaed8186ef032d80a1e6a9.1570482718.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 19/30] storagefile: Fill in meta->externalDataStore X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.62]); Mon, 07 Oct 2019 21:53:00 +0000 (UTC) Add virStorageSourceNewFromExternalData, similar to virStorageSourceNewFromBacking and use it to fill in a virStorageSource for externalDataStore Signed-off-by: Cole Robinson --- src/util/virstoragefile.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index ce669b6e0b..4aa70d71b1 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3799,6 +3799,24 @@ virStorageSourceNewFromBacking(virStorageSourcePtr parent, } +static int +virStorageSourceNewFromExternalData(virStorageSourcePtr parent, + virStorageSourcePtr *externalDataStore) +{ + int rc; + + if ((rc = virStorageSourceNewFromChild(parent, + parent->externalDataStoreRaw, + externalDataStore)) < 0) + return rc; + + /* qcow2 data_file can only be raw */ + (*externalDataStore)->format = VIR_STORAGE_FILE_RAW; + (*externalDataStore)->readonly = parent->readonly; + return rc; +} + + /** * @src: disk source definition structure * @fd: file descriptor @@ -5007,6 +5025,23 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src, } VIR_STEAL_PTR(src->backingStore, backingStore); + + if (src->externalDataStoreRaw) { + VIR_AUTOUNREF(virStorageSourcePtr) externalDataStore = NULL; + + if ((rv = virStorageSourceNewFromExternalData(src, + &externalDataStore)) < 0) + goto cleanup; + + if (rv == 1) { + /* the file would not be usable for VM usage */ + ret = 0; + goto cleanup; + } + + VIR_STEAL_PTR(src->externalDataStore, externalDataStore); + } + ret = 0; cleanup: