From nobody Wed May 14 13:21:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1524001565582744.306357945888; Tue, 17 Apr 2018 14:46:05 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 18FFC3182F42; Tue, 17 Apr 2018 21:46:04 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E1E3B5F71A; Tue, 17 Apr 2018 21:46:03 +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 7788D4CA9E; Tue, 17 Apr 2018 21:46:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3HLhgDC005316 for ; Tue, 17 Apr 2018 17:43:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2C3991102E2C; Tue, 17 Apr 2018 21:43:42 +0000 (UTC) Received: from localhost.localdomain (ovpn-204-41.brq.redhat.com [10.40.204.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id B5E1F1102E28 for ; Tue, 17 Apr 2018 21:43:41 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 17 Apr 2018 23:43:35 +0200 Message-Id: <34ba19e669713bf360fb304bf60c0e27e1432484.1524001354.git.jtomko@redhat.com> In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/3] storage: remove qemu-img help scraping 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 17 Apr 2018 21:46:04 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 We have been checking whether qemu-img supports the -o compat option by scraping the -help output. Since we require QEMU 1.5.0 now and this option was introduced in 1.1, assume we support it and ditch the help parsing code along with the extra qemu-img invocation. Signed-off-by: J=C3=A1n Tomko Reviewed-by: John Ferlan --- src/storage/storage_util.c | 73 +++-----------------------------------= ---- src/storage/storage_util.h | 1 - tests/storagevolxml2argvtest.c | 5 ++- 3 files changed, 6 insertions(+), 73 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 897dfdaae..f7a4231e2 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -787,61 +787,6 @@ storagePloopResize(virStorageVolDefPtr vol, return ret; } =20 -/* Flag values shared w/ storagevolxml2argvtest.c. - * - * QEMU_IMG_BACKING_FORMAT_OPTIONS (added in qemu 0.11) - * QEMU_IMG_BACKING_FORMAT_OPTIONS_COMPAT - * was made necessary due to 2.0 change to change the default - * qcow2 file format from 0.10 to 1.1. - */ -enum { - QEMU_IMG_BACKING_FORMAT_OPTIONS =3D 0, - QEMU_IMG_BACKING_FORMAT_OPTIONS_COMPAT, -}; - -static bool -virStorageBackendQemuImgSupportsCompat(const char *qemuimg) -{ - bool ret =3D false; - char *output; - virCommandPtr cmd =3D NULL; - - cmd =3D virCommandNewArgList(qemuimg, "create", "-o", "?", "-f", "qcow= 2", - "/dev/null", NULL); - - virCommandAddEnvString(cmd, "LC_ALL=3DC"); - virCommandSetOutputBuffer(cmd, &output); - - if (virCommandRun(cmd, NULL) < 0) - goto cleanup; - - if (strstr(output, "\ncompat ")) - ret =3D true; - - cleanup: - virCommandFree(cmd); - VIR_FREE(output); - return ret; -} - - -static int -virStorageBackendQEMUImgBackingFormat(const char *qemuimg) -{ - /* As of QEMU 0.11 the [-o options] support was added via qemu - * commit id '9ea2ea71', so we start with that base and figure - * out what else we have */ - int ret =3D QEMU_IMG_BACKING_FORMAT_OPTIONS; - - /* QEMU 2.0 changed to using a format that only QEMU 1.1 and newer - * understands. Since we still support QEMU 0.12 and newer, we need - * to be able to handle the previous format as can be set via a - * compat=3D0.10 option. */ - if (virStorageBackendQemuImgSupportsCompat(qemuimg)) - ret =3D QEMU_IMG_BACKING_FORMAT_OPTIONS_COMPAT; - - return ret; -} =20 /* The _virStorageBackendQemuImgInfo separates the command line building f= rom * the volume definition so that qemuDomainSnapshotCreateInactiveExternal = can @@ -1089,14 +1034,12 @@ storageBackendCreateQemuImgSetBacking(virStoragePoo= lObjPtr pool, =20 static int storageBackendCreateQemuImgSetOptions(virCommandPtr cmd, - int imgformat, virStorageEncryptionInfoDefPtr enc, struct _virStorageBackendQemuImgInfo= info) { char *opts =3D NULL; =20 - if (info.format =3D=3D VIR_STORAGE_FILE_QCOW2 && !info.compat && - imgformat >=3D QEMU_IMG_BACKING_FORMAT_OPTIONS_COMPAT) + if (info.format =3D=3D VIR_STORAGE_FILE_QCOW2 && !info.compat) info.compat =3D "0.10"; =20 if (storageBackendCreateQemuImgOpts(enc, &opts, info) < 0) @@ -1170,16 +1113,13 @@ storageBackendResizeQemuImgImageOpts(virCommandPtr = cmd, } =20 =20 -/* Create a qemu-img virCommand from the supplied binary path, - * volume definitions and imgformat - */ +/* Create a qemu-img virCommand from the supplied arguments */ virCommandPtr virStorageBackendCreateQemuImgCmdFromVol(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, virStorageVolDefPtr inputvol, unsigned int flags, const char *create_tool, - int imgformat, const char *secretPath) { virCommandPtr cmd =3D NULL; @@ -1293,7 +1233,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePo= olObjPtr pool, enc =3D &vol->target.encryption->encinfo; } =20 - if (storageBackendCreateQemuImgSetOptions(cmd, imgformat, enc, info) <= 0) + if (storageBackendCreateQemuImgSetOptions(cmd, enc, info) < 0) goto error; VIR_FREE(info.secretAlias); =20 @@ -1386,7 +1326,6 @@ storageBackendCreateQemuImg(virStoragePoolObjPtr pool, { int ret =3D -1; char *create_tool; - int imgformat; virCommandPtr cmd; char *secretPath =3D NULL; =20 @@ -1400,10 +1339,6 @@ storageBackendCreateQemuImg(virStoragePoolObjPtr poo= l, return -1; } =20 - imgformat =3D virStorageBackendQEMUImgBackingFormat(create_tool); - if (imgformat < 0) - goto cleanup; - if (vol->target.format =3D=3D VIR_STORAGE_FILE_RAW && vol->target.encryption && vol->target.encryption->format =3D=3D VIR_STORAGE_ENCRYPTION_FORMA= T_LUKS) { @@ -1414,7 +1349,7 @@ storageBackendCreateQemuImg(virStoragePoolObjPtr pool, =20 cmd =3D virStorageBackendCreateQemuImgCmdFromVol(pool, vol, inputvol, flags, create_tool, - imgformat, secretPath); + secretPath); if (!cmd) goto cleanup; =20 diff --git a/src/storage/storage_util.h b/src/storage/storage_util.h index e9cb98211..930770275 100644 --- a/src/storage/storage_util.h +++ b/src/storage/storage_util.h @@ -159,7 +159,6 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePool= ObjPtr pool, virStorageVolDefPtr inputvol, unsigned int flags, const char *create_tool, - int imgformat, const char *secretPath); =20 int virStorageBackendSCSIFindLUs(virStoragePoolObjPtr pool, diff --git a/tests/storagevolxml2argvtest.c b/tests/storagevolxml2argvtest.c index 68ee9c3d8..ca44ccd48 100644 --- a/tests/storagevolxml2argvtest.c +++ b/tests/storagevolxml2argvtest.c @@ -40,7 +40,6 @@ testCompareXMLToArgvFiles(bool shouldFail, const char *inputvolxml, const char *cmdline, unsigned int flags, - int imgformat, unsigned long parse_flags) { char *actualCmdline =3D NULL; @@ -82,7 +81,7 @@ testCompareXMLToArgvFiles(bool shouldFail, =20 cmd =3D virStorageBackendCreateQemuImgCmdFromVol(obj, vol, inputvol, flags, - create_tool, imgformat, + create_tool, NULL); if (!cmd) { if (shouldFail) { @@ -154,7 +153,7 @@ testCompareXMLToArgvHelper(const void *data) result =3D testCompareXMLToArgvFiles(info->shouldFail, poolxml, volxml, inputpoolxml, inputvolxml, cmdline, info->flags, - info->imgformat, info->parseflags); + info->parseflags); =20 cleanup: VIR_FREE(poolxml); --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list