From patchwork Mon Oct 7 21:49:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175432 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4849281ill; Mon, 7 Oct 2019 14:53:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqxCyydQfiHdg8VMTwler9+ORAYJ1udSCaYXfdhJg7TK7lk4GXe4bDxhkKiWNsxC5I5ItApf X-Received: by 2002:aca:1b14:: with SMTP id b20mr1157776oib.48.1570485224304; Mon, 07 Oct 2019 14:53:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570485224; cv=none; d=google.com; s=arc-20160816; b=cCSr1JSwwzY4Ype4gHIjvBqdCmGzYfmFJV/KXpUzVOo1h6M6l5wXJhPE0ElfNBblpG f5udJClOK4t30dDmdJ1kSQofYKAB0UvWa+6ZZhzOUhQVVVFsHKihy5xnn2vuz4yq6am8 dXMGSSrm2QV2nvOP6OayxMlsjnycycs+SZuQVAJy3xB+MbFfzJUQoz/iywD4o5b/6CTb 9XpqMWLfx8dqEUTGPRyQnJ1oc0WclL48NDDSMhs21acFfm9fN3rXDtVdWzmVF659sx+r Ac88085RUUflohZp58GMGPSno68+4yB3S5++QijRm5eKx+fMauYsbQOCZtFKMJ6g/TDx 09+w== 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=iJlpkK6IRSaU2ztojwhT0w5FVG4m/kZXidOfDpIiETM=; b=IAPS9LdHusC1UbHsOgeK5bz6JB/dojZINq38CUSpxPc8FelG6eGvWwt/yd9DOU0UQg koiCc3WjuvXqK41xKb4eeL098qsRjyZMhFf7F39YPIHG1E1H9keNBEj1nH5if9NrhU/l xCyoQihEwSDYGm7AdRqhVwQgcNBx7g1qSiuIJvGrZJbRE4wx2fBQvlflym67ybPsWuZ7 +9LGoCjv1Wv1CYaNxqWPqDrML1oZ1CJOqbr7QpGRYHSVpAtatFLEV6rvfV6hXmNl7L0p w9l33CM8+UVu8YzOncwk/e1TOqPS7Lx0T7DRvkXgUjxsZnwAGzN/4Tw27KhoVwJcMqrY w+Ww== 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 z2si8854290oti.64.2019.10.07.14.53.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:53:44 -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 1767B30832E9; Mon, 7 Oct 2019 21:53:43 +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 E68A5600CE; Mon, 7 Oct 2019 21:53:42 +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 AAA7C180B536; Mon, 7 Oct 2019 21:53:42 +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 x97Lnium014663 for ; Mon, 7 Oct 2019 17:49:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0FEF35C224; Mon, 7 Oct 2019 21:49:44 +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 574725C223; Mon, 7 Oct 2019 21:49:37 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:28 -0400 Message-Id: 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 14/30] storagefile: Parse qcow2 external data file 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.5.16 (mx1.redhat.com [10.5.110.44]); Mon, 07 Oct 2019 21:53:43 +0000 (UTC) This is tracked as a qcow2 extension, like backing store format Signed-off-by: Cole Robinson --- src/util/virstoragefile.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) -- 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 621cc56e87..7e32d7619e 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -202,6 +202,7 @@ qedGetBackingStore(char **, int *, const char *, size_t); #define QCOW2_HDR_EXTENSION_END 0 #define QCOW2_HDR_EXTENSION_BACKING_FORMAT 0xE2792ACA +#define QCOW2_HDR_EXTENSION_DATA_FILE 0x44415441 #define QCOW2v3_HDR_FEATURES_INCOMPATIBLE (QCOW2_HDR_TOTAL_SIZE) #define QCOW2v3_HDR_FEATURES_COMPATIBLE (QCOW2v3_HDR_FEATURES_INCOMPATIBLE+8) @@ -429,7 +430,8 @@ cowGetBackingStore(char **res, static int qcow2GetExtensions(const char *buf, size_t buf_size, - int *backingFormat) + int *backingFormat, + char **externalDataStoreRaw) { size_t offset; size_t extension_start; @@ -508,6 +510,9 @@ qcow2GetExtensions(const char *buf, case QCOW2_HDR_EXTENSION_BACKING_FORMAT: { VIR_AUTOFREE(char *) tmp = NULL; + if (!backingFormat) + break; + if (VIR_ALLOC_N(tmp, len + 1) < 0) return -1; memcpy(tmp, buf + offset, len); @@ -516,6 +521,19 @@ qcow2GetExtensions(const char *buf, *backingFormat = virStorageFileFormatTypeFromString(tmp); if (*backingFormat <= VIR_STORAGE_FILE_NONE) return -1; + break; + } + + case QCOW2_HDR_EXTENSION_DATA_FILE: { + if (!externalDataStoreRaw) + break; + + if (VIR_ALLOC_N(*externalDataStoreRaw, len + 1) < 0) + return -1; + memcpy(*externalDataStoreRaw, buf + offset, len); + (*externalDataStoreRaw)[len] = '\0'; + VIR_DEBUG("parsed externalDataStoreRaw='%s'", *externalDataStoreRaw); + break; } } @@ -566,7 +584,7 @@ qcowXGetBackingStore(char **res, memcpy(*res, buf + offset, size); (*res)[size] = '\0'; - if (qcow2GetExtensions(buf, buf_size, format) < 0) + if (qcow2GetExtensions(buf, buf_size, format, NULL) < 0) return BACKING_STORE_INVALID; return BACKING_STORE_OK;