From nobody Sat May 4 04:44:30 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1562250522; cv=none; d=zoho.com; s=zohoarc; b=knjVWhM0m3P5bQATAHA6tEUrC4jlfltAnkjvUVDoKAnUkJtj00iTLjGnm2q84+eed4Pn8D3ALAzVIy94MQaAk1XBDZpnwe2m3bgv6NC27K+CSX2QrmxYAKa+1PdHpFht65qmIE76cOTH3Ikbi8G69+KwLBFhAIt4LPW7uMMX0G4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562250522; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=xwdVL4acF1Lw/spNmlhSPYLS1mrXBqAjDF2QCW3hi/s=; b=XBu1gMddvI+5SuMB5e2ABPOK6wQn5VduXzu6u9IkmDNsJll/48I3WY4j+SdBpKXGuu0sw9vIuZ9Q08j41m8OlKD97R/5PTcXhfKOMpjhSxFb7JuFR1mHv6uUSUzW0F1O3ZnoR5oLNjeHS29Eea6Rx/ZDeEDObxe+goQeN+SoYJo= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562250522146422.60601280850096; Thu, 4 Jul 2019 07:28:42 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 279EA307D913; Thu, 4 Jul 2019 14:28:33 +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 7F76D3794; Thu, 4 Jul 2019 14:28:28 +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 D2A5E1833002; Thu, 4 Jul 2019 14:28:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x64EQek3029627 for ; Thu, 4 Jul 2019 10:26:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id 081DA5B2FE; Thu, 4 Jul 2019 14:26:40 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 38E205B2D2; Thu, 4 Jul 2019 14:26:39 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 4 Jul 2019 16:26:25 +0200 Message-Id: <4886792fbc10961255a8878bc64443af20bcc58a.1562249939.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Kevin Wolf Subject: [libvirt] [PATCH 01/11] qemu: block: Allow skipping non-target related data when formating disk JSON 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-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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Thu, 04 Jul 2019 14:28:40 +0000 (UTC) Content-Type: text/plain; charset="utf-8" When formatting new qcow2 images we need to provide the backing store string which should not contain any authentication or irelevant data. Add a flag for qemuBlockStorageSourceGetBackendProps which allows to skip the irrelevant data. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_block.c | 121 ++++++++++++++++++++++++---------------- src/qemu/qemu_block.h | 3 +- src/qemu/qemu_command.c | 2 +- tests/qemublocktest.c | 4 +- 4 files changed, 79 insertions(+), 51 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 0a6522577d..771797989e 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -624,7 +624,8 @@ qemuBlockStorageSourceBuildHostsJSONInetSocketAddress(v= irStorageSourcePtr src) static virJSONValuePtr qemuBlockStorageSourceGetGlusterProps(virStorageSourcePtr src, - bool legacy) + bool legacy, + bool onlytarget) { VIR_AUTOPTR(virJSONValue) servers =3D NULL; VIR_AUTOPTR(virJSONValue) props =3D NULL; @@ -645,7 +646,8 @@ qemuBlockStorageSourceGetGlusterProps(virStorageSourceP= tr src, "a:server", &servers, NULL) < 0) return NULL; - if (src->debug && + if (!onlytarget && + src->debug && virJSONValueObjectAdd(props, "u:debug", src->debugLevel, NULL) < 0) return NULL; @@ -654,10 +656,12 @@ qemuBlockStorageSourceGetGlusterProps(virStorageSourc= ePtr src, static virJSONValuePtr -qemuBlockStorageSourceGetVxHSProps(virStorageSourcePtr src) +qemuBlockStorageSourceGetVxHSProps(virStorageSourcePtr src, + bool onlytarget) { const char *protocol =3D virStorageNetProtocolTypeToString(src->protoc= ol); VIR_AUTOPTR(virJSONValue) server =3D NULL; + const char *tlsAlias =3D src->tlsAlias; virJSONValuePtr ret =3D NULL; if (src->nhosts !=3D 1) { @@ -669,6 +673,9 @@ qemuBlockStorageSourceGetVxHSProps(virStorageSourcePtr = src) if (!(server =3D qemuBlockStorageSourceBuildJSONInetSocketAddress(&src= ->hosts[0]))) return NULL; + if (onlytarget) + tlsAlias =3D NULL; + /* VxHS disk specification example: * { driver:"vxhs", * tls-creds:"objvirtio-disk0_tls0", @@ -677,7 +684,7 @@ qemuBlockStorageSourceGetVxHSProps(virStorageSourcePtr = src) */ ignore_value(virJSONValueObjectCreate(&ret, "s:driver", protocol, - "S:tls-creds", src->tlsAlias, + "S:tls-creds", tlsAlias, "s:vdisk-id", src->path, "a:server", &server, NULL)); @@ -686,7 +693,8 @@ qemuBlockStorageSourceGetVxHSProps(virStorageSourcePtr = src) static virJSONValuePtr -qemuBlockStorageSourceGetCURLProps(virStorageSourcePtr src) +qemuBlockStorageSourceGetCURLProps(virStorageSourcePtr src, + bool onlytarget) { qemuDomainStorageSourcePrivatePtr srcPriv =3D QEMU_DOMAIN_STORAGE_SOUR= CE_PRIVATE(src); const char *passwordalias =3D NULL; @@ -716,7 +724,7 @@ qemuBlockStorageSourceGetCURLProps(virStorageSourcePtr = src) if (!(uristr =3D virURIFormat(uri))) return NULL; - if (src->auth) { + if (!onlytarget && src->auth) { username =3D src->auth->username; passwordalias =3D srcPriv->secinfo->s.aes.alias; } @@ -733,7 +741,8 @@ qemuBlockStorageSourceGetCURLProps(virStorageSourcePtr = src) static virJSONValuePtr -qemuBlockStorageSourceGetISCSIProps(virStorageSourcePtr src) +qemuBlockStorageSourceGetISCSIProps(virStorageSourcePtr src, + bool onlytarget) { qemuDomainStorageSourcePrivatePtr srcPriv =3D QEMU_DOMAIN_STORAGE_SOUR= CE_PRIVATE(src); const char *protocol =3D virStorageNetProtocolTypeToString(src->protoc= ol); @@ -781,7 +790,7 @@ qemuBlockStorageSourceGetISCSIProps(virStorageSourcePtr= src) return NULL; } - if (src->auth) { + if (!onlytarget && src->auth) { username =3D src->auth->username; objalias =3D srcPriv->secinfo->s.aes.alias; } @@ -801,9 +810,11 @@ qemuBlockStorageSourceGetISCSIProps(virStorageSourcePt= r src) static virJSONValuePtr -qemuBlockStorageSourceGetNBDProps(virStorageSourcePtr src) +qemuBlockStorageSourceGetNBDProps(virStorageSourcePtr src, + bool onlytarget) { VIR_AUTOPTR(virJSONValue) serverprops =3D NULL; + const char *tlsAlias =3D src->tlsAlias; virJSONValuePtr ret =3D NULL; if (src->nhosts !=3D 1) { @@ -817,11 +828,14 @@ qemuBlockStorageSourceGetNBDProps(virStorageSourcePtr= src) if (!serverprops) return NULL; + if (onlytarget) + tlsAlias =3D NULL; + if (virJSONValueObjectCreate(&ret, "s:driver", "nbd", "a:server", &serverprops, "S:export", src->path, - "S:tls-creds", src->tlsAlias, + "S:tls-creds", tlsAlias, NULL) < 0) return NULL; @@ -830,7 +844,8 @@ qemuBlockStorageSourceGetNBDProps(virStorageSourcePtr s= rc) static virJSONValuePtr -qemuBlockStorageSourceGetRBDProps(virStorageSourcePtr src) +qemuBlockStorageSourceGetRBDProps(virStorageSourcePtr src, + bool onlytarget) { qemuDomainStorageSourcePrivatePtr srcPriv =3D QEMU_DOMAIN_STORAGE_SOUR= CE_PRIVATE(src); VIR_AUTOPTR(virJSONValue) servers =3D NULL; @@ -844,7 +859,7 @@ qemuBlockStorageSourceGetRBDProps(virStorageSourcePtr s= rc) !(servers =3D qemuBlockStorageSourceBuildHostsJSONInetSocketAddres= s(src))) return NULL; - if (src->auth) { + if (!onlytarget && src->auth) { username =3D srcPriv->secinfo->s.aes.username; keysecret =3D srcPriv->secinfo->s.aes.alias; /* the auth modes are modelled after our old command line generato= r */ @@ -943,16 +958,14 @@ qemuBlockStorageSourceGetSshProps(virStorageSourcePtr= src) static virJSONValuePtr -qemuBlockStorageSourceGetFileProps(virStorageSourcePtr src) +qemuBlockStorageSourceGetFileProps(virStorageSourcePtr src, + bool onlytarget) { const char *driver =3D "file"; const char *iomode =3D NULL; const char *prManagerAlias =3D NULL; virJSONValuePtr ret =3D NULL; - if (src->iomode !=3D VIR_DOMAIN_DISK_IO_DEFAULT) - iomode =3D virDomainDiskIoTypeToString(src->iomode); - if (virStorageSourceIsBlockLocal(src)) { if (src->hostcdrom) driver =3D "host_cdrom"; @@ -960,8 +973,13 @@ qemuBlockStorageSourceGetFileProps(virStorageSourcePtr= src) driver =3D "host_device"; } - if (src->pr) - prManagerAlias =3D src->pr->mgralias; + if (!onlytarget) { + if (src->pr) + prManagerAlias =3D src->pr->mgralias; + + if (src->iomode !=3D VIR_DOMAIN_DISK_IO_DEFAULT) + iomode =3D virDomainDiskIoTypeToString(src->iomode); + } ignore_value(virJSONValueObjectCreate(&ret, "s:driver", driver, @@ -974,21 +992,26 @@ qemuBlockStorageSourceGetFileProps(virStorageSourcePt= r src) static virJSONValuePtr -qemuBlockStorageSourceGetVvfatProps(virStorageSourcePtr src) +qemuBlockStorageSourceGetVvfatProps(virStorageSourcePtr src, + bool onlytarget) { - virJSONValuePtr ret =3D NULL; + VIR_AUTOPTR(virJSONValue) ret =3D NULL; /* libvirt currently does not handle the following attributes: * '*fat-type': 'int' * '*label': 'str' */ - ignore_value(virJSONValueObjectCreate(&ret, - "s:driver", "vvfat", - "s:dir", src->path, - "b:floppy", src->floppyimg, - "b:rw", !src->readonly, NULL)); + if (virJSONValueObjectCreate(&ret, + "s:driver", "vvfat", + "s:dir", src->path, + "b:floppy", src->floppyimg, NULL) < 0) + return NULL; - return ret; + if (!onlytarget && + virJSONValueObjectAdd(ret, "b:rw", !src->readonly, NULL) < 0) + return NULL; + + VIR_RETURN_PTR(ret); } @@ -1024,13 +1047,15 @@ qemuBlockStorageSourceGetBlockdevGetCacheProps(virS= torageSourcePtr src, * qemuBlockStorageSourceGetBackendProps: * @src: disk source * @legacy: use legacy formatting of attributes (for -drive / old qemus) + * @onlytarget: omit any data which does not identify the image itself * * Creates a JSON object describing the underlying storage or protocol of a * storage source. Returns NULL on error and reports an appropriate error = message. */ virJSONValuePtr qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src, - bool legacy) + bool legacy, + bool onlytarget) { int actualType =3D virStorageSourceGetActualType(src); VIR_AUTOPTR(virJSONValue) fileprops =3D NULL; @@ -1038,14 +1063,14 @@ qemuBlockStorageSourceGetBackendProps(virStorageSou= rcePtr src, switch ((virStorageType)actualType) { case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_FILE: - if (!(fileprops =3D qemuBlockStorageSourceGetFileProps(src))) + if (!(fileprops =3D qemuBlockStorageSourceGetFileProps(src, onlyta= rget))) return NULL; break; case VIR_STORAGE_TYPE_DIR: /* qemu handles directories by exposing them as a device with emul= ated * FAT filesystem */ - if (!(fileprops =3D qemuBlockStorageSourceGetVvfatProps(src))) + if (!(fileprops =3D qemuBlockStorageSourceGetVvfatProps(src, onlyt= arget))) return NULL; break; @@ -1057,12 +1082,12 @@ qemuBlockStorageSourceGetBackendProps(virStorageSou= rcePtr src, case VIR_STORAGE_TYPE_NETWORK: switch ((virStorageNetProtocol) src->protocol) { case VIR_STORAGE_NET_PROTOCOL_GLUSTER: - if (!(fileprops =3D qemuBlockStorageSourceGetGlusterProps(src,= legacy))) + if (!(fileprops =3D qemuBlockStorageSourceGetGlusterProps(src,= legacy, onlytarget))) return NULL; break; case VIR_STORAGE_NET_PROTOCOL_VXHS: - if (!(fileprops =3D qemuBlockStorageSourceGetVxHSProps(src))) + if (!(fileprops =3D qemuBlockStorageSourceGetVxHSProps(src, on= lytarget))) return NULL; break; @@ -1071,22 +1096,22 @@ qemuBlockStorageSourceGetBackendProps(virStorageSou= rcePtr src, case VIR_STORAGE_NET_PROTOCOL_FTP: case VIR_STORAGE_NET_PROTOCOL_FTPS: case VIR_STORAGE_NET_PROTOCOL_TFTP: - if (!(fileprops =3D qemuBlockStorageSourceGetCURLProps(src))) + if (!(fileprops =3D qemuBlockStorageSourceGetCURLProps(src, on= lytarget))) return NULL; break; case VIR_STORAGE_NET_PROTOCOL_ISCSI: - if (!(fileprops =3D qemuBlockStorageSourceGetISCSIProps(src))) + if (!(fileprops =3D qemuBlockStorageSourceGetISCSIProps(src, o= nlytarget))) return NULL; break; case VIR_STORAGE_NET_PROTOCOL_NBD: - if (!(fileprops =3D qemuBlockStorageSourceGetNBDProps(src))) + if (!(fileprops =3D qemuBlockStorageSourceGetNBDProps(src, onl= ytarget))) return NULL; break; case VIR_STORAGE_NET_PROTOCOL_RBD: - if (!(fileprops =3D qemuBlockStorageSourceGetRBDProps(src))) + if (!(fileprops =3D qemuBlockStorageSourceGetRBDProps(src, onl= ytarget))) return NULL; break; @@ -1107,19 +1132,21 @@ qemuBlockStorageSourceGetBackendProps(virStorageSou= rcePtr src, break; } - if (qemuBlockNodeNameValidate(src->nodestorage) < 0 || - virJSONValueObjectAdd(fileprops, "S:node-name", src->nodestorage, = NULL) < 0) - return NULL; - - if (!legacy) { - if (qemuBlockStorageSourceGetBlockdevGetCacheProps(src, fileprops)= < 0) + if (!onlytarget) { + if (qemuBlockNodeNameValidate(src->nodestorage) < 0 || + virJSONValueObjectAdd(fileprops, "S:node-name", src->nodestora= ge, NULL) < 0) return NULL; - if (virJSONValueObjectAdd(fileprops, - "b:read-only", src->readonly, - "s:discard", "unmap", - NULL) < 0) - return NULL; + if (!legacy) { + if (qemuBlockStorageSourceGetBlockdevGetCacheProps(src, filepr= ops) < 0) + return NULL; + + if (virJSONValueObjectAdd(fileprops, + "b:read-only", src->readonly, + "s:discard", "unmap", + NULL) < 0) + return NULL; + } } VIR_RETURN_PTR(fileprops); @@ -1440,7 +1467,7 @@ qemuBlockStorageSourceAttachPrepareBlockdev(virStorag= eSourcePtr src) return NULL; if (!(data->formatProps =3D qemuBlockStorageSourceGetBlockdevProps(src= )) || - !(data->storageProps =3D qemuBlockStorageSourceGetBackendProps(src= , false))) + !(data->storageProps =3D qemuBlockStorageSourceGetBackendProps(src= , false, false))) return NULL; data->storageNodeName =3D src->nodestorage; diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index 934a1f125d..7b94f4f0ff 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -58,7 +58,8 @@ qemuBlockStorageSourceSupportsConcurrentAccess(virStorage= SourcePtr src); virJSONValuePtr qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src, - bool legacy); + bool legacy, + bool onlytarget); virURIPtr qemuBlockStorageSourceGetURI(virStorageSourcePtr src); diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 688dc324c6..b963fc7235 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1610,7 +1610,7 @@ qemuDiskSourceGetProps(virStorageSourcePtr src) virJSONValuePtr props; virJSONValuePtr ret; - if (!(props =3D qemuBlockStorageSourceGetBackendProps(src, true))) + if (!(props =3D qemuBlockStorageSourceGetBackendProps(src, true, false= ))) return NULL; if (virJSONValueObjectCreate(&ret, "a:file", &props, NULL) < 0) { diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 21db3e4881..29ce27021f 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -67,7 +67,7 @@ testBackingXMLjsonXML(const void *args) return -1; } - if (!(backendprops =3D qemuBlockStorageSourceGetBackendProps(xmlsrc, t= rue))) { + if (!(backendprops =3D qemuBlockStorageSourceGetBackendProps(xmlsrc, t= rue, false))) { fprintf(stderr, "failed to format disk source json\n"); return -1; } @@ -213,7 +213,7 @@ testQemuDiskXMLToProps(const void *opaque) goto cleanup; if (!(formatProps =3D qemuBlockStorageSourceGetBlockdevProps(n)) || - !(storageProps =3D qemuBlockStorageSourceGetBackendProps(n, fa= lse))) { + !(storageProps =3D qemuBlockStorageSourceGetBackendProps(n, fa= lse, false))) { if (!data->fail) { VIR_TEST_VERBOSE("failed to generate qemu blockdev props\n= "); goto cleanup; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 04:44:30 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1562250571; cv=none; d=zoho.com; s=zohoarc; b=Xc/259P8U882OQcuelYt2vdu6xGWlQ4slOzu5hFvQ2QgAmCu9F2R6h4V8d+Zc9lNEqVnY0EzKMihyI0/Miyn81nJE0GkkZj92/+V08jZ/Wa22aK5ZUwjBoatJJ6OjEcmLbwtbsrFAoaQXx/ErKExmIVLNvPv3YGHsM26jox71MA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562250571; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ZNZltaPgfkDQAjadFdvN9G2h96eBRDp5J1u3Bmz+evI=; b=cd88vGMUn2tZaQ0oxn+EyYcwDmz2Xgblb/36aSD6FFInWmwxuuKLre1fC2RplIPLzAVokDgWULVVwumWBSCyjLyJs+9kKYacW3auA1CgOpZYd5gd2Vmi+mDgYix/LHSmZsnl4EHz1ClydkV/caeU1C6sER6onbapJCMxxcCWx2U= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562250571942985.1887439709353; Thu, 4 Jul 2019 07:29:31 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EA88488304; Thu, 4 Jul 2019 14:29:29 +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 C72B21001B3E; Thu, 4 Jul 2019 14:29:29 +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 790991833002; Thu, 4 Jul 2019 14:29:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x64EQfBa029676 for ; Thu, 4 Jul 2019 10:26:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 223075B2FE; Thu, 4 Jul 2019 14:26:41 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 55FBD5B77E; Thu, 4 Jul 2019 14:26:40 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 4 Jul 2019 16:26:26 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Kevin Wolf Subject: [libvirt] [PATCH 02/11] tests: qemublock: Add testing of pure disk source specification JSON generator 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-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 04 Jul 2019 14:29:30 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add testing of the host specification part so that we can be sure that no image/host specific data will be present. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemublocktest.c | 69 ++++++++++++++++++- .../xml2json/block-raw-noopts-srconly.json | 4 ++ .../block-raw-reservations-srconly.json | 4 ++ .../xml2json/dir-fat-cache-srconly.json | 5 ++ .../xml2json/dir-fat-floppy-srconly.json | 5 ++ .../xml2json/dir-fat-readonly-srconly.json | 5 ++ ...ile-backing_basic-aio_threads-srconly.json | 24 +++++++ ...acking_basic-cache-directsync-srconly.json | 24 +++++++ ...file-backing_basic-cache-none-srconly.json | 24 +++++++ ...le-backing_basic-cache-unsafe-srconly.json | 24 +++++++ ...backing_basic-cache-writeback-srconly.json | 24 +++++++ ...king_basic-cache-writethrough-srconly.json | 24 +++++++ .../file-backing_basic-detect-srconly.json | 24 +++++++ .../file-backing_basic-noopts-srconly.json | 16 +++++ ...le-backing_basic-unmap-detect-srconly.json | 24 +++++++ ...le-backing_basic-unmap-ignore-srconly.json | 24 +++++++ .../file-backing_basic-unmap-srconly.json | 24 +++++++ .../xml2json/file-bochs-noopts-srconly.json | 4 ++ .../xml2json/file-cloop-noopts-srconly.json | 4 ++ .../xml2json/file-dmg-noopts-srconly.json | 4 ++ .../xml2json/file-ploop-noopts-srconly.json | 4 ++ ...cow2-backing-chain-encryption-srconly.json | 8 +++ ...le-qcow2-backing-chain-noopts-srconly.json | 40 +++++++++++ ...w2-backing-chain-unterminated-srconly.json | 8 +++ .../xml2json/file-raw-aio_native-srconly.json | 4 ++ .../xml2json/file-raw-luks-srconly.json | 4 ++ .../xml2json/file-raw-noopts-srconly.json | 4 ++ .../xml2json/file-vdi-noopts-srconly.json | 4 ++ .../xml2json/file-vhd-noopts-srconly.json | 4 ++ .../xml2json/file-vpc-noopts-srconly.json | 4 ++ .../xml2json/network-nbd-tls-srconly.json | 8 +++ ...w2-backing-chain-cache-unsafe-srconly.json | 22 ++++++ ...backing-chain-encryption_auth-srconly.json | 22 ++++++ 33 files changed, 495 insertions(+), 1 deletion(-) create mode 100644 tests/qemublocktestdata/xml2json/block-raw-noopts-srcon= ly.json create mode 100644 tests/qemublocktestdata/xml2json/block-raw-reservations= -srconly.json create mode 100644 tests/qemublocktestdata/xml2json/dir-fat-cache-srconly.= json create mode 100644 tests/qemublocktestdata/xml2json/dir-fat-floppy-srconly= .json create mode 100644 tests/qemublocktestdata/xml2json/dir-fat-readonly-srcon= ly.json create mode 100644 tests/qemublocktestdata/xml2json/file-backing_basic-aio= _threads-srconly.json create mode 100644 tests/qemublocktestdata/xml2json/file-backing_basic-cac= he-directsync-srconly.json create mode 100644 tests/qemublocktestdata/xml2json/file-backing_basic-cac= he-none-srconly.json create mode 100644 tests/qemublocktestdata/xml2json/file-backing_basic-cac= he-unsafe-srconly.json create mode 100644 tests/qemublocktestdata/xml2json/file-backing_basic-cac= he-writeback-srconly.json create mode 100644 tests/qemublocktestdata/xml2json/file-backing_basic-cac= he-writethrough-srconly.json create mode 100644 tests/qemublocktestdata/xml2json/file-backing_basic-det= ect-srconly.json create mode 100644 tests/qemublocktestdata/xml2json/file-backing_basic-noo= pts-srconly.json create mode 100644 tests/qemublocktestdata/xml2json/file-backing_basic-unm= ap-detect-srconly.json create mode 100644 tests/qemublocktestdata/xml2json/file-backing_basic-unm= ap-ignore-srconly.json create mode 100644 tests/qemublocktestdata/xml2json/file-backing_basic-unm= ap-srconly.json create mode 100644 tests/qemublocktestdata/xml2json/file-bochs-noopts-srco= nly.json create mode 100644 tests/qemublocktestdata/xml2json/file-cloop-noopts-srco= nly.json create mode 100644 tests/qemublocktestdata/xml2json/file-dmg-noopts-srconl= y.json create mode 100644 tests/qemublocktestdata/xml2json/file-ploop-noopts-srco= nly.json create mode 100644 tests/qemublocktestdata/xml2json/file-qcow2-backing-cha= in-encryption-srconly.json create mode 100644 tests/qemublocktestdata/xml2json/file-qcow2-backing-cha= in-noopts-srconly.json create mode 100644 tests/qemublocktestdata/xml2json/file-qcow2-backing-cha= in-unterminated-srconly.json create mode 100644 tests/qemublocktestdata/xml2json/file-raw-aio_native-sr= conly.json create mode 100644 tests/qemublocktestdata/xml2json/file-raw-luks-srconly.= json create mode 100644 tests/qemublocktestdata/xml2json/file-raw-noopts-srconl= y.json create mode 100644 tests/qemublocktestdata/xml2json/file-vdi-noopts-srconl= y.json create mode 100644 tests/qemublocktestdata/xml2json/file-vhd-noopts-srconl= y.json create mode 100644 tests/qemublocktestdata/xml2json/file-vpc-noopts-srconl= y.json create mode 100644 tests/qemublocktestdata/xml2json/network-nbd-tls-srconl= y.json create mode 100644 tests/qemublocktestdata/xml2json/network-qcow2-backing-= chain-cache-unsafe-srconly.json create mode 100644 tests/qemublocktestdata/xml2json/network-qcow2-backing-= chain-encryption_auth-srconly.json diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 29ce27021f..161615f7f0 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -115,6 +115,9 @@ struct testQemuDiskXMLToJSONData { virJSONValuePtr *props; size_t nprops; + virJSONValuePtr *propssrc; + size_t npropssrc; + virQEMUCapsPtr qemuCaps; }; @@ -127,8 +130,13 @@ testQemuDiskXMLToPropsClear(struct testQemuDiskXMLToJS= ONData *data) for (i =3D 0; i < data->nprops; i++) virJSONValueFree(data->props[i]); + for (i =3D 0; i < data->npropssrc; i++) + virJSONValueFree(data->propssrc[i]); + data->nprops =3D 0; VIR_FREE(data->props); + data->npropssrc =3D 0; + VIR_FREE(data->propssrc); } @@ -180,6 +188,7 @@ testQemuDiskXMLToProps(const void *opaque) virStorageSourcePtr n; virJSONValuePtr formatProps =3D NULL; virJSONValuePtr storageProps =3D NULL; + VIR_AUTOPTR(virJSONValue) storageSrcOnlyProps =3D NULL; char *xmlpath =3D NULL; char *xmlstr =3D NULL; int ret =3D -1; @@ -213,6 +222,7 @@ testQemuDiskXMLToProps(const void *opaque) goto cleanup; if (!(formatProps =3D qemuBlockStorageSourceGetBlockdevProps(n)) || + !(storageSrcOnlyProps =3D qemuBlockStorageSourceGetBackendProp= s(n, false, true)) || !(storageProps =3D qemuBlockStorageSourceGetBackendProps(n, fa= lse, false))) { if (!data->fail) { VIR_TEST_VERBOSE("failed to generate qemu blockdev props\n= "); @@ -224,7 +234,8 @@ testQemuDiskXMLToProps(const void *opaque) } if (VIR_APPEND_ELEMENT(data->props, data->nprops, formatProps) < 0= || - VIR_APPEND_ELEMENT(data->props, data->nprops, storageProps) < = 0) + VIR_APPEND_ELEMENT(data->props, data->nprops, storageProps) < = 0 || + VIR_APPEND_ELEMENT(data->propssrc, data->npropssrc, storageSrc= OnlyProps) < 0) goto cleanup; } @@ -268,6 +279,23 @@ testQemuDiskXMLToPropsValidateSchema(const void *opaqu= e) virBufferFreeAndReset(&debug); } + + for (i =3D 0; i < data->npropssrc; i++) { + if (testQEMUSchemaValidate(data->propssrc[i], data->schemaroot, + data->schema, &debug) < 0) { + debugmsg =3D virBufferContentAndReset(&debug); + propsstr =3D virJSONValueToString(data->propssrc[i], true); + VIR_TEST_VERBOSE("json does not conform to QAPI schema"); + VIR_TEST_DEBUG("json:\n%s\ndoes not match schema. Debug output= :\n %s", + propsstr, NULLSTR(debugmsg)); + VIR_FREE(debugmsg); + VIR_FREE(propsstr); + ret =3D -1; + } + + virBufferFreeAndReset(&debug); + } + return ret; } @@ -313,6 +341,40 @@ testQemuDiskXMLToPropsValidateFile(const void *opaque) } +static int +testQemuDiskXMLToPropsValidateFileSrcOnly(const void *opaque) +{ + struct testQemuDiskXMLToJSONData *data =3D (void *) opaque; + virBuffer buf =3D VIR_BUFFER_INITIALIZER; + VIR_AUTOFREE(char *) jsonpath =3D NULL; + VIR_AUTOFREE(char *) actual =3D NULL; + size_t i; + + if (data->fail) + return EXIT_AM_SKIP; + + if (virAsprintf(&jsonpath, "%s%s-srconly.json", + testQemuDiskXMLToJSONPath, data->name) < 0) + return -1; + + for (i =3D 0; i < data->npropssrc; i++) { + VIR_AUTOFREE(char *) jsonstr =3D NULL; + + if (!(jsonstr =3D virJSONValueToString(data->propssrc[i], true))) + return -1; + + virBufferAdd(&buf, jsonstr, -1); + } + + if (virBufferCheckError(&buf) < 0) + return -1; + + actual =3D virBufferContentAndReset(&buf); + + return virTestCompareToFile(actual, jsonpath); +} + + static int mymain(void) { @@ -411,6 +473,8 @@ mymain(void) diskxmljsondata.name =3D nme; \ diskxmljsondata.props =3D NULL; \ diskxmljsondata.nprops =3D 0; \ + diskxmljsondata.propssrc =3D NULL; \ + diskxmljsondata.npropssrc =3D 0; \ diskxmljsondata.fail =3D fl; \ if (virTestRun("disk xml to props " nme, testQemuDiskXMLToProps, \ &diskxmljsondata) < 0) \ @@ -421,6 +485,9 @@ mymain(void) if (virTestRun("disk xml to props validate file " nme, \ testQemuDiskXMLToPropsValidateFile, &diskxmljsonda= ta) < 0) \ ret =3D -1; \ + if (virTestRun("disk xml to props source only validate file " nme,= \ + testQemuDiskXMLToPropsValidateFileSrcOnly, &diskxm= ljsondata) < 0) \ + ret =3D -1; \ testQemuDiskXMLToPropsClear(&diskxmljsondata); \ } while (0) diff --git a/tests/qemublocktestdata/xml2json/block-raw-noopts-srconly.json= b/tests/qemublocktestdata/xml2json/block-raw-noopts-srconly.json new file mode 100644 index 0000000000..72f9067353 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/block-raw-noopts-srconly.json @@ -0,0 +1,4 @@ +{ + "driver": "host_device", + "filename": "/dev/blah" +} diff --git a/tests/qemublocktestdata/xml2json/block-raw-reservations-srconl= y.json b/tests/qemublocktestdata/xml2json/block-raw-reservations-srconly.js= on new file mode 100644 index 0000000000..72f9067353 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/block-raw-reservations-srconly.json @@ -0,0 +1,4 @@ +{ + "driver": "host_device", + "filename": "/dev/blah" +} diff --git a/tests/qemublocktestdata/xml2json/dir-fat-cache-srconly.json b/= tests/qemublocktestdata/xml2json/dir-fat-cache-srconly.json new file mode 100644 index 0000000000..6ec4f78d7b --- /dev/null +++ b/tests/qemublocktestdata/xml2json/dir-fat-cache-srconly.json @@ -0,0 +1,5 @@ +{ + "driver": "vvfat", + "dir": "/var/somefiles", + "floppy": false +} diff --git a/tests/qemublocktestdata/xml2json/dir-fat-floppy-srconly.json b= /tests/qemublocktestdata/xml2json/dir-fat-floppy-srconly.json new file mode 100644 index 0000000000..6b0388bc18 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/dir-fat-floppy-srconly.json @@ -0,0 +1,5 @@ +{ + "driver": "vvfat", + "dir": "/var/somefiles", + "floppy": true +} diff --git a/tests/qemublocktestdata/xml2json/dir-fat-readonly-srconly.json= b/tests/qemublocktestdata/xml2json/dir-fat-readonly-srconly.json new file mode 100644 index 0000000000..6ec4f78d7b --- /dev/null +++ b/tests/qemublocktestdata/xml2json/dir-fat-readonly-srconly.json @@ -0,0 +1,5 @@ +{ + "driver": "vvfat", + "dir": "/var/somefiles", + "floppy": false +} diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-aio_thread= s-srconly.json b/tests/qemublocktestdata/xml2json/file-backing_basic-aio_th= reads-srconly.json new file mode 100644 index 0000000000..ea490b0034 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-aio_threads-srcon= ly.json @@ -0,0 +1,24 @@ +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/a" +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/b" +} +{ + "driver": "gluster", + "volume": "images", + "path": "c", + "server": [ + { + "type": "inet", + "host": "test.org", + "port": "24007" + } + ] +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/d" +} diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-dire= ctsync-srconly.json b/tests/qemublocktestdata/xml2json/file-backing_basic-c= ache-directsync-srconly.json new file mode 100644 index 0000000000..ea490b0034 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-directsync-= srconly.json @@ -0,0 +1,24 @@ +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/a" +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/b" +} +{ + "driver": "gluster", + "volume": "images", + "path": "c", + "server": [ + { + "type": "inet", + "host": "test.org", + "port": "24007" + } + ] +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/d" +} diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-none= -srconly.json b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-n= one-srconly.json new file mode 100644 index 0000000000..ea490b0034 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-none-srconl= y.json @@ -0,0 +1,24 @@ +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/a" +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/b" +} +{ + "driver": "gluster", + "volume": "images", + "path": "c", + "server": [ + { + "type": "inet", + "host": "test.org", + "port": "24007" + } + ] +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/d" +} diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-unsa= fe-srconly.json b/tests/qemublocktestdata/xml2json/file-backing_basic-cache= -unsafe-srconly.json new file mode 100644 index 0000000000..ea490b0034 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-unsafe-srco= nly.json @@ -0,0 +1,24 @@ +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/a" +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/b" +} +{ + "driver": "gluster", + "volume": "images", + "path": "c", + "server": [ + { + "type": "inet", + "host": "test.org", + "port": "24007" + } + ] +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/d" +} diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-writ= eback-srconly.json b/tests/qemublocktestdata/xml2json/file-backing_basic-ca= che-writeback-srconly.json new file mode 100644 index 0000000000..ea490b0034 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-writeback-s= rconly.json @@ -0,0 +1,24 @@ +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/a" +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/b" +} +{ + "driver": "gluster", + "volume": "images", + "path": "c", + "server": [ + { + "type": "inet", + "host": "test.org", + "port": "24007" + } + ] +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/d" +} diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-writ= ethrough-srconly.json b/tests/qemublocktestdata/xml2json/file-backing_basic= -cache-writethrough-srconly.json new file mode 100644 index 0000000000..ea490b0034 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-writethroug= h-srconly.json @@ -0,0 +1,24 @@ +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/a" +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/b" +} +{ + "driver": "gluster", + "volume": "images", + "path": "c", + "server": [ + { + "type": "inet", + "host": "test.org", + "port": "24007" + } + ] +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/d" +} diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-detect-src= only.json b/tests/qemublocktestdata/xml2json/file-backing_basic-detect-srco= nly.json new file mode 100644 index 0000000000..ea490b0034 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-detect-srconly.js= on @@ -0,0 +1,24 @@ +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/a" +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/b" +} +{ + "driver": "gluster", + "volume": "images", + "path": "c", + "server": [ + { + "type": "inet", + "host": "test.org", + "port": "24007" + } + ] +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/d" +} diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-noopts-src= only.json b/tests/qemublocktestdata/xml2json/file-backing_basic-noopts-srco= nly.json new file mode 100644 index 0000000000..dbdf6e563b --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-noopts-srconly.js= on @@ -0,0 +1,16 @@ +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/a" +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/b" +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/c" +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/d" +} diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-dete= ct-srconly.json b/tests/qemublocktestdata/xml2json/file-backing_basic-unmap= -detect-srconly.json new file mode 100644 index 0000000000..ea490b0034 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-detect-srco= nly.json @@ -0,0 +1,24 @@ +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/a" +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/b" +} +{ + "driver": "gluster", + "volume": "images", + "path": "c", + "server": [ + { + "type": "inet", + "host": "test.org", + "port": "24007" + } + ] +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/d" +} diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-igno= re-srconly.json b/tests/qemublocktestdata/xml2json/file-backing_basic-unmap= -ignore-srconly.json new file mode 100644 index 0000000000..ea490b0034 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-ignore-srco= nly.json @@ -0,0 +1,24 @@ +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/a" +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/b" +} +{ + "driver": "gluster", + "volume": "images", + "path": "c", + "server": [ + { + "type": "inet", + "host": "test.org", + "port": "24007" + } + ] +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/d" +} diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-srco= nly.json b/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-srconl= y.json new file mode 100644 index 0000000000..ea490b0034 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-srconly.json @@ -0,0 +1,24 @@ +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/a" +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/b" +} +{ + "driver": "gluster", + "volume": "images", + "path": "c", + "server": [ + { + "type": "inet", + "host": "test.org", + "port": "24007" + } + ] +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/d" +} diff --git a/tests/qemublocktestdata/xml2json/file-bochs-noopts-srconly.jso= n b/tests/qemublocktestdata/xml2json/file-bochs-noopts-srconly.json new file mode 100644 index 0000000000..c50fa903f5 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-bochs-noopts-srconly.json @@ -0,0 +1,4 @@ +{ + "driver": "file", + "filename": "/path/to/i.img" +} diff --git a/tests/qemublocktestdata/xml2json/file-cloop-noopts-srconly.jso= n b/tests/qemublocktestdata/xml2json/file-cloop-noopts-srconly.json new file mode 100644 index 0000000000..c50fa903f5 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-cloop-noopts-srconly.json @@ -0,0 +1,4 @@ +{ + "driver": "file", + "filename": "/path/to/i.img" +} diff --git a/tests/qemublocktestdata/xml2json/file-dmg-noopts-srconly.json = b/tests/qemublocktestdata/xml2json/file-dmg-noopts-srconly.json new file mode 100644 index 0000000000..c50fa903f5 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-dmg-noopts-srconly.json @@ -0,0 +1,4 @@ +{ + "driver": "file", + "filename": "/path/to/i.img" +} diff --git a/tests/qemublocktestdata/xml2json/file-ploop-noopts-srconly.jso= n b/tests/qemublocktestdata/xml2json/file-ploop-noopts-srconly.json new file mode 100644 index 0000000000..c50fa903f5 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-ploop-noopts-srconly.json @@ -0,0 +1,4 @@ +{ + "driver": "file", + "filename": "/path/to/i.img" +} diff --git a/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-encr= yption-srconly.json b/tests/qemublocktestdata/xml2json/file-qcow2-backing-c= hain-encryption-srconly.json new file mode 100644 index 0000000000..316dbc9df2 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-encryption-= srconly.json @@ -0,0 +1,8 @@ +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/a" +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/b" +} diff --git a/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-noop= ts-srconly.json b/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain= -noopts-srconly.json new file mode 100644 index 0000000000..d998acc194 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-noopts-srco= nly.json @@ -0,0 +1,40 @@ +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/rhel7.3.1507297895" +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/rhel7.3.1484071872" +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/rhel7.3.1483615252" +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/rhel7.3.1483605924" +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/rhel7.3.1483605920" +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/rhel7.3.1483546244" +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/rhel7.3.1483545901" +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/rhel7.3.1483545313" +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/rhel7.3.1483536402" +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/rhel7.3.qcow2" +} diff --git a/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-unte= rminated-srconly.json b/tests/qemublocktestdata/xml2json/file-qcow2-backing= -chain-unterminated-srconly.json new file mode 100644 index 0000000000..e0bce3bcd2 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-unterminate= d-srconly.json @@ -0,0 +1,8 @@ +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/rhel7.3.1507297895" +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/rhel7.3.1484071872" +} diff --git a/tests/qemublocktestdata/xml2json/file-raw-aio_native-srconly.j= son b/tests/qemublocktestdata/xml2json/file-raw-aio_native-srconly.json new file mode 100644 index 0000000000..c50fa903f5 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-raw-aio_native-srconly.json @@ -0,0 +1,4 @@ +{ + "driver": "file", + "filename": "/path/to/i.img" +} diff --git a/tests/qemublocktestdata/xml2json/file-raw-luks-srconly.json b/= tests/qemublocktestdata/xml2json/file-raw-luks-srconly.json new file mode 100644 index 0000000000..6d7088211f --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-raw-luks-srconly.json @@ -0,0 +1,4 @@ +{ + "driver": "file", + "filename": "/path/luks.img" +} diff --git a/tests/qemublocktestdata/xml2json/file-raw-noopts-srconly.json = b/tests/qemublocktestdata/xml2json/file-raw-noopts-srconly.json new file mode 100644 index 0000000000..bb3e8af9eb --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-raw-noopts-srconly.json @@ -0,0 +1,4 @@ +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/i.img" +} diff --git a/tests/qemublocktestdata/xml2json/file-vdi-noopts-srconly.json = b/tests/qemublocktestdata/xml2json/file-vdi-noopts-srconly.json new file mode 100644 index 0000000000..c50fa903f5 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-vdi-noopts-srconly.json @@ -0,0 +1,4 @@ +{ + "driver": "file", + "filename": "/path/to/i.img" +} diff --git a/tests/qemublocktestdata/xml2json/file-vhd-noopts-srconly.json = b/tests/qemublocktestdata/xml2json/file-vhd-noopts-srconly.json new file mode 100644 index 0000000000..c50fa903f5 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-vhd-noopts-srconly.json @@ -0,0 +1,4 @@ +{ + "driver": "file", + "filename": "/path/to/i.img" +} diff --git a/tests/qemublocktestdata/xml2json/file-vpc-noopts-srconly.json = b/tests/qemublocktestdata/xml2json/file-vpc-noopts-srconly.json new file mode 100644 index 0000000000..c50fa903f5 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-vpc-noopts-srconly.json @@ -0,0 +1,4 @@ +{ + "driver": "file", + "filename": "/path/to/i.img" +} diff --git a/tests/qemublocktestdata/xml2json/network-nbd-tls-srconly.json = b/tests/qemublocktestdata/xml2json/network-nbd-tls-srconly.json new file mode 100644 index 0000000000..455f4e5140 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/network-nbd-tls-srconly.json @@ -0,0 +1,8 @@ +{ + "driver": "nbd", + "server": { + "type": "inet", + "host": "host1.example.com", + "port": "10809" + } +} diff --git a/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-c= ache-unsafe-srconly.json b/tests/qemublocktestdata/xml2json/network-qcow2-b= acking-chain-cache-unsafe-srconly.json new file mode 100644 index 0000000000..69ca9caf88 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-cache-un= safe-srconly.json @@ -0,0 +1,22 @@ +{ + "driver": "rbd", + "pool": "rbdpool", + "image": "rbdimg", + "server": [ + { + "host": "host1.example.com", + "port": "0" + }, + { + "host": "host2.example.com", + "port": "0" + } + ] +} +{ + "driver": "iscsi", + "portal": "example.org:3260", + "target": "iscsitarget", + "lun": 1, + "transport": "tcp" +} diff --git a/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-e= ncryption_auth-srconly.json b/tests/qemublocktestdata/xml2json/network-qcow= 2-backing-chain-encryption_auth-srconly.json new file mode 100644 index 0000000000..6298329812 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-encrypti= on_auth-srconly.json @@ -0,0 +1,22 @@ +{ + "driver": "rbd", + "pool": "rbdpool", + "image": "rbdimg", + "server": [ + { + "host": "host1.example.com", + "port": "0" + }, + { + "host": "host2.example.com", + "port": "0" + } + ] +} +{ + "driver": "iscsi", + "portal": "example.org:3260", + "target": "iqn.2016-09.com.example:iscsitarget", + "lun": 1, + "transport": "tcp" +} --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 04:44:30 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1562250598; cv=none; d=zoho.com; s=zohoarc; b=XDWgB8LCnRiefgczPe41K9d5LsXcJ3XvpnG+303E3JzWwLSQf353+puiGRNKILKXDv3zXHdlAu9no6tIs40blFkXNbigew2swNVnH+0lK2ak/V7glTfQwMMub3CUgCBAvmyr6jEqO9c/Vh0zP7woZTgEmk2hSg8+xRbDro8BAT8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562250598; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=j5PWkXgeQqVsMJA7XmiqCaMgMxsD8NNGHlVll9IcMec=; b=B0uXBuFVpfaTL6gWv/f+KpIkiAVXdU4NgegidWBjOe8Dm7Z+KUC+XlXxnc7Z91ve7FgrSh2qlNi1O3C/WizJK5sQND1msfE1FZH60dffR5WT2QJ1SIqvIblvSaCT7RbIZZeHBCUQ2q2/gD2+VbVhxQBmO0XqPHFjbTeUK7LlQUU= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562250598570878.7583470101895; Thu, 4 Jul 2019 07:29:58 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 005B7821C1; Thu, 4 Jul 2019 14:29:52 +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 C762D5D71B; Thu, 4 Jul 2019 14:29:49 +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 69EDF1972A; Thu, 4 Jul 2019 14:29:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x64EQgB5029712 for ; Thu, 4 Jul 2019 10:26:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 173A35B77C; Thu, 4 Jul 2019 14:26:42 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6FC4D5B2D2; Thu, 4 Jul 2019 14:26:41 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 4 Jul 2019 16:26:27 +0200 Message-Id: <93d1552af1a3e340987d6f4a3b6f1d6172d5eb6c.1562249939.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Kevin Wolf Subject: [libvirt] [PATCH 03/11] util: json: Introduce helper to prepend string into a virJSONValueObject 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-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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 04 Jul 2019 14:29:57 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Libvirt treats the JSON objects as lists thus the values appear in the order they were added. To avoid too much changes introduce a helper which allows to prepend a string which will allow to keep certain outputs in order. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/libvirt_private.syms | 1 + src/util/virjson.c | 50 +++++++++++++++++++++++++++++++++------- src/util/virjson.h | 1 + 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b8772d2895..d21f415f97 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2244,6 +2244,7 @@ virJSONValueObjectGetValue; virJSONValueObjectHasKey; virJSONValueObjectIsNull; virJSONValueObjectKeysNumber; +virJSONValueObjectPrependString; virJSONValueObjectRemoveKey; virJSONValueObjectStealArray; virJSONValueObjectStealObject; diff --git a/src/util/virjson.c b/src/util/virjson.c index d2664b9d57..1cf2fb1e5c 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -606,10 +606,11 @@ virJSONValueNewObject(void) } -int -virJSONValueObjectAppend(virJSONValuePtr object, +static int +virJSONValueObjectInsert(virJSONValuePtr object, const char *key, - virJSONValuePtr value) + virJSONValuePtr value, + bool prepend) { virJSONObjectPair pair =3D { NULL, value }; int ret =3D -1; @@ -628,8 +629,13 @@ virJSONValueObjectAppend(virJSONValuePtr object, if (VIR_STRDUP(pair.key, key) < 0) return -1; - ret =3D VIR_APPEND_ELEMENT(object->data.object.pairs, - object->data.object.npairs, pair); + if (prepend) { + ret =3D VIR_INSERT_ELEMENT(object->data.object.pairs, 0, + object->data.object.npairs, pair); + } else { + ret =3D VIR_APPEND_ELEMENT(object->data.object.pairs, + object->data.object.npairs, pair); + } VIR_FREE(pair.key); return ret; @@ -637,14 +643,24 @@ virJSONValueObjectAppend(virJSONValuePtr object, int -virJSONValueObjectAppendString(virJSONValuePtr object, +virJSONValueObjectAppend(virJSONValuePtr object, + const char *key, + virJSONValuePtr value) +{ + return virJSONValueObjectInsert(object, key, value, false); +} + + +static int +virJSONValueObjectInsertString(virJSONValuePtr object, const char *key, - const char *value) + const char *value, + bool prepend) { virJSONValuePtr jvalue =3D virJSONValueNewString(value); if (!jvalue) return -1; - if (virJSONValueObjectAppend(object, key, jvalue) < 0) { + if (virJSONValueObjectInsert(object, key, jvalue, prepend) < 0) { virJSONValueFree(jvalue); return -1; } @@ -652,6 +668,24 @@ virJSONValueObjectAppendString(virJSONValuePtr object, } +int +virJSONValueObjectAppendString(virJSONValuePtr object, + const char *key, + const char *value) +{ + return virJSONValueObjectInsertString(object, key, value, false); +} + + +int +virJSONValueObjectPrependString(virJSONValuePtr object, + const char *key, + const char *value) +{ + return virJSONValueObjectInsertString(object, key, value, true); +} + + int virJSONValueObjectAppendNumberInt(virJSONValuePtr object, const char *key, diff --git a/src/util/virjson.h b/src/util/virjson.h index 41404a9a3e..a5f959595f 100644 --- a/src/util/virjson.h +++ b/src/util/virjson.h @@ -126,6 +126,7 @@ int virJSONValueObjectGetBoolean(virJSONValuePtr object= , const char *key, bool * int virJSONValueObjectIsNull(virJSONValuePtr object, const char *key); int virJSONValueObjectAppendString(virJSONValuePtr object, const char *key= , const char *value); +int virJSONValueObjectPrependString(virJSONValuePtr object, const char *ke= y, const char *value); int virJSONValueObjectAppendNumberInt(virJSONValuePtr object, const char *= key, int number); int virJSONValueObjectAppendNumberUint(virJSONValuePtr object, const char = *key, unsigned int number); int virJSONValueObjectAppendNumberLong(virJSONValuePtr object, const char = *key, long long number); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 04:44:30 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1562250522; cv=none; d=zoho.com; s=zohoarc; b=gNY7FZ4esvknTxlx5k2xVqmPHf/3vziCpePN4401IqI3SOeiS5UBpQibmAhZHEXKzUuE3hkPceC9/R8viS5K25KzI1EkagfRTsfkBykJcI4rv65VBMuf8f9tvP3n9A3MnDyeGafiQ15hL0Y8gQGX4ckDw/rwF0+2+//HxMisTwg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562250522; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=uRQEIeA+PoieftR31I96srbNRBS/O8iVtQGDPl5+7Ak=; b=JlDrfdrRYjjQH01ZpqV7o6eavw2MeY3O3HYgL95eCwx/OISqKUUA/Yqz7U2El0KRTuvMMAgFhgKcpyE5JINN7Fh80pLMHcoWWJOOUy8/JfsxVvDZ599iQqQdvUvdPWZl13lcPtTajt32lLN6Kwg0prAbARJOQjf955PBDgii4yk= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562250522156658.2300541977244; Thu, 4 Jul 2019 07:28:42 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 91FB93091799; Thu, 4 Jul 2019 14:28:33 +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 0C5961001B23; Thu, 4 Jul 2019 14:28:26 +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 5544719720; Thu, 4 Jul 2019 14:28:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x64EQhvh029747 for ; Thu, 4 Jul 2019 10:26:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0A5DB5B7FD; Thu, 4 Jul 2019 14:26:43 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6399B5B77E; Thu, 4 Jul 2019 14:26:42 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 4 Jul 2019 16:26:28 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Kevin Wolf Subject: [libvirt] [PATCH 04/11] qemu: block: Extract formating of 'driver' attribute from child formatters 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-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 04 Jul 2019 14:28:40 +0000 (UTC) Content-Type: text/plain; charset="utf-8" To allow reusing the formatters in the code for creating JSON properties for 'blockdev-create' we need to create everyhing except the 'driver' attribute. Use the new helper virJSONValueObjectPrependString to put the driver at the same place so that we don't change any output. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_block.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 771797989e..c9e6af49c9 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -640,7 +640,6 @@ qemuBlockStorageSourceGetGlusterProps(virStorageSourceP= tr src, * {type:"unix", socket:"/tmp/glusterd.socket"}, ...]} */ if (virJSONValueObjectCreate(&props, - "s:driver", "gluster", "s:volume", src->volume, "s:path", src->path, "a:server", &servers, NULL) < 0) @@ -659,7 +658,6 @@ static virJSONValuePtr qemuBlockStorageSourceGetVxHSProps(virStorageSourcePtr src, bool onlytarget) { - const char *protocol =3D virStorageNetProtocolTypeToString(src->protoc= ol); VIR_AUTOPTR(virJSONValue) server =3D NULL; const char *tlsAlias =3D src->tlsAlias; virJSONValuePtr ret =3D NULL; @@ -683,7 +681,6 @@ qemuBlockStorageSourceGetVxHSProps(virStorageSourcePtr = src, * server:{type:"tcp", host:"1.2.3.4", port:9999}} */ ignore_value(virJSONValueObjectCreate(&ret, - "s:driver", protocol, "S:tls-creds", tlsAlias, "s:vdisk-id", src->path, "a:server", &server, NULL)); @@ -702,7 +699,6 @@ qemuBlockStorageSourceGetCURLProps(virStorageSourcePtr = src, virJSONValuePtr ret =3D NULL; VIR_AUTOPTR(virURI) uri =3D NULL; VIR_AUTOFREE(char *) uristr =3D NULL; - const char *driver; /** * Common options: @@ -716,7 +712,6 @@ qemuBlockStorageSourceGetCURLProps(virStorageSourcePtr = src, * sslverify */ - driver =3D virStorageNetProtocolTypeToString(src->protocol); if (!(uri =3D qemuBlockStorageSourceGetURI(src))) return NULL; @@ -730,7 +725,6 @@ qemuBlockStorageSourceGetCURLProps(virStorageSourcePtr = src, } ignore_value(virJSONValueObjectCreate(&ret, - "s:driver", driver, "s:url", uristr, "S:username", username, "S:password-secret", passwordali= as, @@ -745,7 +739,6 @@ qemuBlockStorageSourceGetISCSIProps(virStorageSourcePtr= src, bool onlytarget) { qemuDomainStorageSourcePrivatePtr srcPriv =3D QEMU_DOMAIN_STORAGE_SOUR= CE_PRIVATE(src); - const char *protocol =3D virStorageNetProtocolTypeToString(src->protoc= ol); VIR_AUTOFREE(char *) target =3D NULL; char *lunStr =3D NULL; char *username =3D NULL; @@ -796,7 +789,6 @@ qemuBlockStorageSourceGetISCSIProps(virStorageSourcePtr= src, } ignore_value(virJSONValueObjectCreate(&ret, - "s:driver", protocol, "s:portal", portal, "s:target", target, "u:lun", lun, @@ -832,7 +824,6 @@ qemuBlockStorageSourceGetNBDProps(virStorageSourcePtr s= rc, tlsAlias =3D NULL; if (virJSONValueObjectCreate(&ret, - "s:driver", "nbd", "a:server", &serverprops, "S:export", src->path, "S:tls-creds", tlsAlias, @@ -880,7 +871,6 @@ qemuBlockStorageSourceGetRBDProps(virStorageSourcePtr s= rc, } if (virJSONValueObjectCreate(&ret, - "s:driver", "rbd", "s:pool", src->volume, "s:image", src->path, "S:snapshot", src->snapshot, @@ -915,7 +905,6 @@ qemuBlockStorageSourceGetSheepdogProps(virStorageSource= Ptr src) /* libvirt does not support the 'snap-id' and 'tag' properties */ if (virJSONValueObjectCreate(&ret, - "s:driver", "sheepdog", "a:server", &serverprops, "s:vdi", src->path, NULL) < 0) @@ -946,7 +935,6 @@ qemuBlockStorageSourceGetSshProps(virStorageSourcePtr s= rc) username =3D src->auth->username; if (virJSONValueObjectCreate(&ret, - "s:driver", "ssh", "s:path", src->path, "a:server", &serverprops, "S:user", username, @@ -961,18 +949,10 @@ static virJSONValuePtr qemuBlockStorageSourceGetFileProps(virStorageSourcePtr src, bool onlytarget) { - const char *driver =3D "file"; const char *iomode =3D NULL; const char *prManagerAlias =3D NULL; virJSONValuePtr ret =3D NULL; - if (virStorageSourceIsBlockLocal(src)) { - if (src->hostcdrom) - driver =3D "host_cdrom"; - else - driver =3D "host_device"; - } - if (!onlytarget) { if (src->pr) prManagerAlias =3D src->pr->mgralias; @@ -982,7 +962,6 @@ qemuBlockStorageSourceGetFileProps(virStorageSourcePtr = src, } ignore_value(virJSONValueObjectCreate(&ret, - "s:driver", driver, "s:filename", src->path, "S:aio", iomode, "S:pr-manager", prManagerAlias, @@ -1059,10 +1038,20 @@ qemuBlockStorageSourceGetBackendProps(virStorageSou= rcePtr src, { int actualType =3D virStorageSourceGetActualType(src); VIR_AUTOPTR(virJSONValue) fileprops =3D NULL; + const char *driver =3D NULL; switch ((virStorageType)actualType) { case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_FILE: + if (virStorageSourceIsBlockLocal(src)) { + if (src->hostcdrom) + driver =3D "host_cdrom"; + else + driver =3D "host_device"; + } else { + driver =3D "file"; + } + if (!(fileprops =3D qemuBlockStorageSourceGetFileProps(src, onlyta= rget))) return NULL; break; @@ -1082,11 +1071,13 @@ qemuBlockStorageSourceGetBackendProps(virStorageSou= rcePtr src, case VIR_STORAGE_TYPE_NETWORK: switch ((virStorageNetProtocol) src->protocol) { case VIR_STORAGE_NET_PROTOCOL_GLUSTER: + driver =3D "gluster"; if (!(fileprops =3D qemuBlockStorageSourceGetGlusterProps(src,= legacy, onlytarget))) return NULL; break; case VIR_STORAGE_NET_PROTOCOL_VXHS: + driver =3D "vxhs"; if (!(fileprops =3D qemuBlockStorageSourceGetVxHSProps(src, on= lytarget))) return NULL; break; @@ -1096,31 +1087,37 @@ qemuBlockStorageSourceGetBackendProps(virStorageSou= rcePtr src, case VIR_STORAGE_NET_PROTOCOL_FTP: case VIR_STORAGE_NET_PROTOCOL_FTPS: case VIR_STORAGE_NET_PROTOCOL_TFTP: + driver =3D virStorageNetProtocolTypeToString(src->protocol); if (!(fileprops =3D qemuBlockStorageSourceGetCURLProps(src, on= lytarget))) return NULL; break; case VIR_STORAGE_NET_PROTOCOL_ISCSI: + driver =3D "iscsi"; if (!(fileprops =3D qemuBlockStorageSourceGetISCSIProps(src, o= nlytarget))) return NULL; break; case VIR_STORAGE_NET_PROTOCOL_NBD: + driver =3D "nbd"; if (!(fileprops =3D qemuBlockStorageSourceGetNBDProps(src, onl= ytarget))) return NULL; break; case VIR_STORAGE_NET_PROTOCOL_RBD: + driver =3D "rbd"; if (!(fileprops =3D qemuBlockStorageSourceGetRBDProps(src, onl= ytarget))) return NULL; break; case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG: + driver =3D "sheepdog"; if (!(fileprops =3D qemuBlockStorageSourceGetSheepdogProps(src= ))) return NULL; break; case VIR_STORAGE_NET_PROTOCOL_SSH: + driver =3D "ssh"; if (!(fileprops =3D qemuBlockStorageSourceGetSshProps(src))) return NULL; break; @@ -1132,6 +1129,9 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourc= ePtr src, break; } + if (driver && virJSONValueObjectPrependString(fileprops, "driver", dri= ver) < 0) + return NULL; + if (!onlytarget) { if (qemuBlockNodeNameValidate(src->nodestorage) < 0 || virJSONValueObjectAdd(fileprops, "S:node-name", src->nodestora= ge, NULL) < 0) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 04:44:30 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1562250613; cv=none; d=zoho.com; s=zohoarc; b=BCjew2nclTROdCGxu8ShjqKlOiM9u8duAiZlgnNseug1+mDUidatYzHpNlR+pha+a46x/ZK3fpkz4wZHb5qP/GYf4Wjnf7hQ+yR0l7wt8FUambIRaWncB9qrX1MWM22KrwXIjlLpZa/55HlFldJBWFLTgWrrVI4s+Svi+gIWw+0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562250613; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=WQG53t9onW1IdX7urMmrY7WXADWOiWDUN2Ch8ZWGYYg=; b=Wbstfwp5CuE5INYc9CRmbGSh53yJAqGGsR9LW1fkyeegw6XZpp+DrzAaBtDmKE/nOmWivDUlwlI+ukv7PBY5fYCOkmxR0FzMo3XrM+soFIIg1J93Hb5XpsoPG35wSNdmKVeFV6zcvD/cii08F3nzypuKUoggoI+FE7mQxgTUFuE= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562250613048864.2292054053152; Thu, 4 Jul 2019 07:30:13 -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 42AD330C585A; Thu, 4 Jul 2019 14:29:54 +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 2151179808; Thu, 4 Jul 2019 14:29:53 +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 D37F019725; Thu, 4 Jul 2019 14:29:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x64EQi1N029901 for ; Thu, 4 Jul 2019 10:26:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2417A5B2FE; Thu, 4 Jul 2019 14:26:44 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 582225B2D2; Thu, 4 Jul 2019 14:26:43 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 4 Jul 2019 16:26:29 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Kevin Wolf Subject: [libvirt] [PATCH 05/11] qemu: block: Use 'auto-read-only' instead of 'read-only' for backing chain 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-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.46]); Thu, 04 Jul 2019 14:30:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" To allow using -blockdev with blockjobs need to reopen files in read-write mode when modifying the backing chain. To achieve this we need to use 'auto-read-only' for the backing files rather than the normal 'read-only' property. That way qemu knows that the files need to be reopened. Note that the format drivers (e.g. qcow2) are still opened with the read-only property enabled when being a member of the backing chain since they are supposed to be immutable unless a block job is started. QEMU v4.0 allows also dynamic behaviour for auto-read-only which allows us to use sVirt as we only grant write permissions to files when doing a blockjob. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_block.c | 26 ++++++++++++++++--- src/qemu/qemu_block.h | 6 +++-- src/qemu/qemu_command.c | 4 +-- src/qemu/qemu_migration.c | 4 ++- tests/qemublocktest.c | 7 ++--- .../xml2json/block-raw-noopts.json | 2 +- .../xml2json/block-raw-reservations.json | 2 +- .../xml2json/dir-fat-cache.json | 2 +- .../xml2json/dir-fat-floppy.json | 2 +- .../xml2json/dir-fat-readonly.json | 2 +- .../file-backing_basic-aio_threads.json | 8 +++--- .../file-backing_basic-cache-directsync.json | 8 +++--- .../file-backing_basic-cache-none.json | 8 +++--- .../file-backing_basic-cache-unsafe.json | 8 +++--- .../file-backing_basic-cache-writeback.json | 8 +++--- ...file-backing_basic-cache-writethrough.json | 8 +++--- .../xml2json/file-backing_basic-detect.json | 8 +++--- .../xml2json/file-backing_basic-noopts.json | 8 +++--- .../file-backing_basic-unmap-detect.json | 8 +++--- .../file-backing_basic-unmap-ignore.json | 8 +++--- .../xml2json/file-backing_basic-unmap.json | 8 +++--- .../xml2json/file-bochs-noopts.json | 2 +- .../xml2json/file-cloop-noopts.json | 2 +- .../xml2json/file-dmg-noopts.json | 2 +- .../xml2json/file-ploop-noopts.json | 2 +- .../file-qcow2-backing-chain-encryption.json | 4 +-- .../file-qcow2-backing-chain-noopts.json | 20 +++++++------- ...file-qcow2-backing-chain-unterminated.json | 4 +-- .../xml2json/file-raw-aio_native.json | 2 +- .../xml2json/file-raw-luks.json | 2 +- .../xml2json/file-raw-noopts.json | 2 +- .../xml2json/file-vdi-noopts.json | 2 +- .../xml2json/file-vhd-noopts.json | 2 +- .../xml2json/file-vpc-noopts.json | 2 +- .../xml2json/network-nbd-tls.json | 2 +- ...work-qcow2-backing-chain-cache-unsafe.json | 4 +-- ...k-qcow2-backing-chain-encryption_auth.json | 4 +-- .../qemu-ns.x86_64-4.0.0.args | 2 +- .../qemu-ns.x86_64-latest.args | 2 +- 39 files changed, 115 insertions(+), 92 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index c9e6af49c9..9abdac5ca3 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1027,6 +1027,7 @@ qemuBlockStorageSourceGetBlockdevGetCacheProps(virSto= rageSourcePtr src, * @src: disk source * @legacy: use legacy formatting of attributes (for -drive / old qemus) * @onlytarget: omit any data which does not identify the image itself + * @autoreadonly: Use the new auto-readonly feature in qemu * * Creates a JSON object describing the underlying storage or protocol of a * storage source. Returns NULL on error and reports an appropriate error = message. @@ -1034,11 +1035,23 @@ qemuBlockStorageSourceGetBlockdevGetCacheProps(virS= torageSourcePtr src, virJSONValuePtr qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src, bool legacy, - bool onlytarget) + bool onlytarget, + bool autoreadonly) { int actualType =3D virStorageSourceGetActualType(src); VIR_AUTOPTR(virJSONValue) fileprops =3D NULL; const char *driver =3D NULL; + virTristateBool aro =3D VIR_TRISTATE_BOOL_ABSENT; + virTristateBool ro =3D VIR_TRISTATE_BOOL_ABSENT; + + if (autoreadonly) { + aro =3D VIR_TRISTATE_BOOL_YES; + } else { + if (src->readonly) + ro =3D VIR_TRISTATE_BOOL_YES; + else + ro =3D VIR_TRISTATE_BOOL_NO; + } switch ((virStorageType)actualType) { case VIR_STORAGE_TYPE_BLOCK: @@ -1142,7 +1155,8 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourc= ePtr src, return NULL; if (virJSONValueObjectAdd(fileprops, - "b:read-only", src->readonly, + "T:read-only", ro, + "T:auto-read-only", aro, "s:discard", "unmap", NULL) < 0) return NULL; @@ -1447,6 +1461,7 @@ qemuBlockStorageSourceAttachDataFree(qemuBlockStorage= SourceAttachDataPtr data) /** * qemuBlockStorageSourceAttachPrepareBlockdev: * @src: storage source to prepare data from + * @autoreadonly: use 'auto-read-only' feature of qemu * * Creates a qemuBlockStorageSourceAttachData structure containing data to= attach * @src to a VM using the blockdev-add approach. Note that this function o= nly @@ -1459,7 +1474,8 @@ qemuBlockStorageSourceAttachDataFree(qemuBlockStorage= SourceAttachDataPtr data) * error is reported */ qemuBlockStorageSourceAttachDataPtr -qemuBlockStorageSourceAttachPrepareBlockdev(virStorageSourcePtr src) +qemuBlockStorageSourceAttachPrepareBlockdev(virStorageSourcePtr src, + bool autoreadonly) { VIR_AUTOPTR(qemuBlockStorageSourceAttachData) data =3D NULL; @@ -1467,7 +1483,9 @@ qemuBlockStorageSourceAttachPrepareBlockdev(virStorag= eSourcePtr src) return NULL; if (!(data->formatProps =3D qemuBlockStorageSourceGetBlockdevProps(src= )) || - !(data->storageProps =3D qemuBlockStorageSourceGetBackendProps(src= , false, false))) + !(data->storageProps =3D qemuBlockStorageSourceGetBackendProps(src= , false, + false, + autor= eadonly))) return NULL; data->storageNodeName =3D src->nodestorage; diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index 7b94f4f0ff..12ddfad2ac 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -59,7 +59,8 @@ qemuBlockStorageSourceSupportsConcurrentAccess(virStorage= SourcePtr src); virJSONValuePtr qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src, bool legacy, - bool onlytarget); + bool onlytarget, + bool autoreadonly); virURIPtr qemuBlockStorageSourceGetURI(virStorageSourcePtr src); @@ -106,7 +107,8 @@ VIR_DEFINE_AUTOPTR_FUNC(qemuBlockStorageSourceAttachDat= a, qemuBlockStorageSourceAttachDataFree); qemuBlockStorageSourceAttachDataPtr -qemuBlockStorageSourceAttachPrepareBlockdev(virStorageSourcePtr src); +qemuBlockStorageSourceAttachPrepareBlockdev(virStorageSourcePtr src, + bool autoreadonly); qemuBlockStorageSourceAttachDataPtr qemuBlockStorageSourceDetachPrepare(virStorageSourcePtr src, diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index b963fc7235..27f71ce0fa 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1610,7 +1610,7 @@ qemuDiskSourceGetProps(virStorageSourcePtr src) virJSONValuePtr props; virJSONValuePtr ret; - if (!(props =3D qemuBlockStorageSourceGetBackendProps(src, true, false= ))) + if (!(props =3D qemuBlockStorageSourceGetBackendProps(src, true, false= , false))) return NULL; if (virJSONValueObjectCreate(&ret, "a:file", &props, NULL) < 0) { @@ -11206,7 +11206,7 @@ qemuBuildStorageSourceChainAttachPrepareBlockdev(vi= rStorageSourcePtr top, return NULL; for (n =3D top; virStorageSourceIsBacking(n); n =3D n->backingStore) { - if (!(elem =3D qemuBlockStorageSourceAttachPrepareBlockdev(n))) + if (!(elem =3D qemuBlockStorageSourceAttachPrepareBlockdev(n, true= ))) return NULL; if (qemuBuildStorageSourceAttachPrepareCommon(n, elem, qemuCaps) <= 0) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 2436f5051b..e71933446a 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -830,7 +830,9 @@ qemuMigrationSrcNBDStorageCopyBlockdev(virQEMUDriverPtr= driver, virAsprintf(©src->nodeformat, "migration-%s-format", disk->dst= ) < 0) goto cleanup; - if (!(data =3D qemuBlockStorageSourceAttachPrepareBlockdev(copysrc))) + /* Migration via blockdev-mirror was supported sooner than the auto-re= ad-only + * feature was added to qemu */ + if (!(data =3D qemuBlockStorageSourceAttachPrepareBlockdev(copysrc, fa= lse))) goto cleanup; if (qemuDomainObjEnterMonitorAsync(driver, vm, diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 161615f7f0..5c381d1e3b 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -67,7 +67,8 @@ testBackingXMLjsonXML(const void *args) return -1; } - if (!(backendprops =3D qemuBlockStorageSourceGetBackendProps(xmlsrc, t= rue, false))) { + if (!(backendprops =3D qemuBlockStorageSourceGetBackendProps(xmlsrc, t= rue, false, + false))) { fprintf(stderr, "failed to format disk source json\n"); return -1; } @@ -222,8 +223,8 @@ testQemuDiskXMLToProps(const void *opaque) goto cleanup; if (!(formatProps =3D qemuBlockStorageSourceGetBlockdevProps(n)) || - !(storageSrcOnlyProps =3D qemuBlockStorageSourceGetBackendProp= s(n, false, true)) || - !(storageProps =3D qemuBlockStorageSourceGetBackendProps(n, fa= lse, false))) { + !(storageSrcOnlyProps =3D qemuBlockStorageSourceGetBackendProp= s(n, false, true, true)) || + !(storageProps =3D qemuBlockStorageSourceGetBackendProps(n, fa= lse, false, true))) { if (!data->fail) { VIR_TEST_VERBOSE("failed to generate qemu blockdev props\n= "); goto cleanup; diff --git a/tests/qemublocktestdata/xml2json/block-raw-noopts.json b/tests= /qemublocktestdata/xml2json/block-raw-noopts.json index f223659c76..fa8b29a1f9 100644 --- a/tests/qemublocktestdata/xml2json/block-raw-noopts.json +++ b/tests/qemublocktestdata/xml2json/block-raw-noopts.json @@ -8,6 +8,6 @@ "driver": "host_device", "filename": "/dev/blah", "node-name": "0123456789ABCDEF0123456789ABCDE", - "read-only": false, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/block-raw-reservations.json b= /tests/qemublocktestdata/xml2json/block-raw-reservations.json index 2fb106d673..970723279d 100644 --- a/tests/qemublocktestdata/xml2json/block-raw-reservations.json +++ b/tests/qemublocktestdata/xml2json/block-raw-reservations.json @@ -9,6 +9,6 @@ "filename": "/dev/blah", "pr-manager": "node-a-st-pr-alias", "node-name": "node-a-st", - "read-only": false, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/dir-fat-cache.json b/tests/qe= mublocktestdata/xml2json/dir-fat-cache.json index ef33add681..2a24175ef4 100644 --- a/tests/qemublocktestdata/xml2json/dir-fat-cache.json +++ b/tests/qemublocktestdata/xml2json/dir-fat-cache.json @@ -18,6 +18,6 @@ "direct": true, "no-flush": false }, - "read-only": true, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/dir-fat-floppy.json b/tests/q= emublocktestdata/xml2json/dir-fat-floppy.json index db7954a6bc..3b4accb8ef 100644 --- a/tests/qemublocktestdata/xml2json/dir-fat-floppy.json +++ b/tests/qemublocktestdata/xml2json/dir-fat-floppy.json @@ -10,6 +10,6 @@ "floppy": true, "rw": false, "node-name": "node-s", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/dir-fat-readonly.json b/tests= /qemublocktestdata/xml2json/dir-fat-readonly.json index a306fb4d47..986e3a3ffd 100644 --- a/tests/qemublocktestdata/xml2json/dir-fat-readonly.json +++ b/tests/qemublocktestdata/xml2json/dir-fat-readonly.json @@ -10,6 +10,6 @@ "floppy": false, "rw": false, "node-name": "node-s", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-aio_thread= s.json b/tests/qemublocktestdata/xml2json/file-backing_basic-aio_threads.js= on index a9bdd1bcc2..e77421d372 100644 --- a/tests/qemublocktestdata/xml2json/file-backing_basic-aio_threads.json +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-aio_threads.json @@ -10,7 +10,7 @@ "filename": "/var/lib/libvirt/images/a", "aio": "threads", "node-name": "node-a-s", - "read-only": false, + "auto-read-only": true, "discard": "unmap" } { @@ -25,7 +25,7 @@ "filename": "/var/lib/libvirt/images/b", "aio": "threads", "node-name": "node-b-s", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } { @@ -47,7 +47,7 @@ } ], "node-name": "node-c-s", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } { @@ -61,6 +61,6 @@ "filename": "/var/lib/libvirt/images/d", "aio": "threads", "node-name": "node-d-s", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-dire= ctsync.json b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-dir= ectsync.json index 18cd183cd8..1d5ae09813 100644 --- a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-directsync.= json +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-directsync.= json @@ -17,7 +17,7 @@ "direct": true, "no-flush": false }, - "read-only": false, + "auto-read-only": true, "discard": "unmap" } { @@ -39,7 +39,7 @@ "direct": true, "no-flush": false }, - "read-only": true, + "auto-read-only": true, "discard": "unmap" } { @@ -69,7 +69,7 @@ "direct": true, "no-flush": false }, - "read-only": true, + "auto-read-only": true, "discard": "unmap" } { @@ -90,6 +90,6 @@ "direct": true, "no-flush": false }, - "read-only": true, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-none= .json b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-none.json index 18cd183cd8..1d5ae09813 100644 --- a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-none.json +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-none.json @@ -17,7 +17,7 @@ "direct": true, "no-flush": false }, - "read-only": false, + "auto-read-only": true, "discard": "unmap" } { @@ -39,7 +39,7 @@ "direct": true, "no-flush": false }, - "read-only": true, + "auto-read-only": true, "discard": "unmap" } { @@ -69,7 +69,7 @@ "direct": true, "no-flush": false }, - "read-only": true, + "auto-read-only": true, "discard": "unmap" } { @@ -90,6 +90,6 @@ "direct": true, "no-flush": false }, - "read-only": true, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-unsa= fe.json b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-unsafe.= json index 4e92061c65..4afd7366cf 100644 --- a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-unsafe.json +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-unsafe.json @@ -17,7 +17,7 @@ "direct": false, "no-flush": true }, - "read-only": false, + "auto-read-only": true, "discard": "unmap" } { @@ -39,7 +39,7 @@ "direct": false, "no-flush": true }, - "read-only": true, + "auto-read-only": true, "discard": "unmap" } { @@ -69,7 +69,7 @@ "direct": false, "no-flush": true }, - "read-only": true, + "auto-read-only": true, "discard": "unmap" } { @@ -90,6 +90,6 @@ "direct": false, "no-flush": true }, - "read-only": true, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-writ= eback.json b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-writ= eback.json index a105b47483..9ed806eb04 100644 --- a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-writeback.j= son +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-writeback.j= son @@ -17,7 +17,7 @@ "direct": false, "no-flush": false }, - "read-only": false, + "auto-read-only": true, "discard": "unmap" } { @@ -39,7 +39,7 @@ "direct": false, "no-flush": false }, - "read-only": true, + "auto-read-only": true, "discard": "unmap" } { @@ -69,7 +69,7 @@ "direct": false, "no-flush": false }, - "read-only": true, + "auto-read-only": true, "discard": "unmap" } { @@ -90,6 +90,6 @@ "direct": false, "no-flush": false }, - "read-only": true, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-writ= ethrough.json b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-w= ritethrough.json index a105b47483..9ed806eb04 100644 --- a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-writethroug= h.json +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-writethroug= h.json @@ -17,7 +17,7 @@ "direct": false, "no-flush": false }, - "read-only": false, + "auto-read-only": true, "discard": "unmap" } { @@ -39,7 +39,7 @@ "direct": false, "no-flush": false }, - "read-only": true, + "auto-read-only": true, "discard": "unmap" } { @@ -69,7 +69,7 @@ "direct": false, "no-flush": false }, - "read-only": true, + "auto-read-only": true, "discard": "unmap" } { @@ -90,6 +90,6 @@ "direct": false, "no-flush": false }, - "read-only": true, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-detect.jso= n b/tests/qemublocktestdata/xml2json/file-backing_basic-detect.json index 44a6e90fcd..6be2df9d1d 100644 --- a/tests/qemublocktestdata/xml2json/file-backing_basic-detect.json +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-detect.json @@ -10,7 +10,7 @@ "driver": "file", "filename": "/var/lib/libvirt/images/a", "node-name": "node-a-s", - "read-only": false, + "auto-read-only": true, "discard": "unmap" } { @@ -24,7 +24,7 @@ "driver": "file", "filename": "/var/lib/libvirt/images/b", "node-name": "node-b-s", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } { @@ -46,7 +46,7 @@ } ], "node-name": "node-c-s", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } { @@ -59,6 +59,6 @@ "driver": "file", "filename": "/var/lib/libvirt/images/d", "node-name": "node-d-s", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-noopts.jso= n b/tests/qemublocktestdata/xml2json/file-backing_basic-noopts.json index b0fd9b6988..5916347b93 100644 --- a/tests/qemublocktestdata/xml2json/file-backing_basic-noopts.json +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-noopts.json @@ -9,7 +9,7 @@ "driver": "file", "filename": "/var/lib/libvirt/images/a", "node-name": "node-a-s", - "read-only": false, + "auto-read-only": true, "discard": "unmap" } { @@ -23,7 +23,7 @@ "driver": "file", "filename": "/var/lib/libvirt/images/b", "node-name": "node-b-s", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } { @@ -37,7 +37,7 @@ "driver": "file", "filename": "/var/lib/libvirt/images/c", "node-name": "node-c-s", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } { @@ -50,6 +50,6 @@ "driver": "file", "filename": "/var/lib/libvirt/images/d", "node-name": "node-d-s", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-dete= ct.json b/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-detect.= json index 6cf4e77090..27e6e5ab60 100644 --- a/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-detect.json +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-detect.json @@ -11,7 +11,7 @@ "driver": "file", "filename": "/var/lib/libvirt/images/a", "node-name": "node-a-s", - "read-only": false, + "auto-read-only": true, "discard": "unmap" } { @@ -26,7 +26,7 @@ "driver": "file", "filename": "/var/lib/libvirt/images/b", "node-name": "node-b-s", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } { @@ -49,7 +49,7 @@ } ], "node-name": "node-c-s", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } { @@ -63,6 +63,6 @@ "driver": "file", "filename": "/var/lib/libvirt/images/d", "node-name": "node-d-s", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-igno= re.json b/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-ignore.= json index b6e454297f..63c5cd2799 100644 --- a/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-ignore.json +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-ignore.json @@ -11,7 +11,7 @@ "driver": "file", "filename": "/var/lib/libvirt/images/a", "node-name": "node-a-s", - "read-only": false, + "auto-read-only": true, "discard": "unmap" } { @@ -26,7 +26,7 @@ "driver": "file", "filename": "/var/lib/libvirt/images/b", "node-name": "node-b-s", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } { @@ -49,7 +49,7 @@ } ], "node-name": "node-c-s", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } { @@ -63,6 +63,6 @@ "driver": "file", "filename": "/var/lib/libvirt/images/d", "node-name": "node-d-s", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-unmap.json= b/tests/qemublocktestdata/xml2json/file-backing_basic-unmap.json index 21a10c8543..ac952c8acd 100644 --- a/tests/qemublocktestdata/xml2json/file-backing_basic-unmap.json +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-unmap.json @@ -10,7 +10,7 @@ "driver": "file", "filename": "/var/lib/libvirt/images/a", "node-name": "node-a-s", - "read-only": false, + "auto-read-only": true, "discard": "unmap" } { @@ -25,7 +25,7 @@ "driver": "file", "filename": "/var/lib/libvirt/images/b", "node-name": "node-b-s", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } { @@ -48,7 +48,7 @@ } ], "node-name": "node-c-s", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } { @@ -62,6 +62,6 @@ "driver": "file", "filename": "/var/lib/libvirt/images/d", "node-name": "node-d-s", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/file-bochs-noopts.json b/test= s/qemublocktestdata/xml2json/file-bochs-noopts.json index 6ab43b2a1c..3692820436 100644 --- a/tests/qemublocktestdata/xml2json/file-bochs-noopts.json +++ b/tests/qemublocktestdata/xml2json/file-bochs-noopts.json @@ -8,6 +8,6 @@ "driver": "file", "filename": "/path/to/i.img", "node-name": "test2", - "read-only": false, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/file-cloop-noopts.json b/test= s/qemublocktestdata/xml2json/file-cloop-noopts.json index f709c3d3bd..7ae8b5ca5f 100644 --- a/tests/qemublocktestdata/xml2json/file-cloop-noopts.json +++ b/tests/qemublocktestdata/xml2json/file-cloop-noopts.json @@ -8,6 +8,6 @@ "driver": "file", "filename": "/path/to/i.img", "node-name": "test2", - "read-only": false, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/file-dmg-noopts.json b/tests/= qemublocktestdata/xml2json/file-dmg-noopts.json index 55261de4b2..db722a55cc 100644 --- a/tests/qemublocktestdata/xml2json/file-dmg-noopts.json +++ b/tests/qemublocktestdata/xml2json/file-dmg-noopts.json @@ -8,6 +8,6 @@ "driver": "file", "filename": "/path/to/i.img", "node-name": "test2", - "read-only": false, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/file-ploop-noopts.json b/test= s/qemublocktestdata/xml2json/file-ploop-noopts.json index 81fa263098..7817b0980e 100644 --- a/tests/qemublocktestdata/xml2json/file-ploop-noopts.json +++ b/tests/qemublocktestdata/xml2json/file-ploop-noopts.json @@ -8,6 +8,6 @@ "driver": "file", "filename": "/path/to/i.img", "node-name": "test2", - "read-only": false, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-encr= yption.json b/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-enc= ryption.json index 376fce9f9e..57f1f61c05 100644 --- a/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-encryption.= json +++ b/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-encryption.= json @@ -13,7 +13,7 @@ "driver": "file", "filename": "/var/lib/libvirt/images/a", "node-name": "node-a-s", - "read-only": false, + "auto-read-only": true, "discard": "unmap" } { @@ -31,6 +31,6 @@ "driver": "file", "filename": "/var/lib/libvirt/images/b", "node-name": "node-b-s", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-noop= ts.json b/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-noopts.= json index 6bc6e2fe30..197ee2a4b6 100644 --- a/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-noopts.json +++ b/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-noopts.json @@ -9,7 +9,7 @@ "driver": "file", "filename": "/var/lib/libvirt/images/rhel7.3.1507297895", "node-name": "#block004", - "read-only": false, + "auto-read-only": true, "discard": "unmap" } { @@ -23,7 +23,7 @@ "driver": "file", "filename": "/var/lib/libvirt/images/rhel7.3.1484071872", "node-name": "#block256", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } { @@ -37,7 +37,7 @@ "driver": "file", "filename": "/var/lib/libvirt/images/rhel7.3.1483615252", "node-name": "#block418", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } { @@ -51,7 +51,7 @@ "driver": "file", "filename": "/var/lib/libvirt/images/rhel7.3.1483605924", "node-name": "#block624", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } { @@ -65,7 +65,7 @@ "driver": "file", "filename": "/var/lib/libvirt/images/rhel7.3.1483605920", "node-name": "#block869", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } { @@ -79,7 +79,7 @@ "driver": "file", "filename": "/var/lib/libvirt/images/rhel7.3.1483546244", "node-name": "#block1047", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } { @@ -93,7 +93,7 @@ "driver": "file", "filename": "/var/lib/libvirt/images/rhel7.3.1483545901", "node-name": "#block1279", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } { @@ -107,7 +107,7 @@ "driver": "file", "filename": "/var/lib/libvirt/images/rhel7.3.1483545313", "node-name": "#block1444", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } { @@ -121,7 +121,7 @@ "driver": "file", "filename": "/var/lib/libvirt/images/rhel7.3.1483536402", "node-name": "#block1602", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } { @@ -135,6 +135,6 @@ "driver": "file", "filename": "/var/lib/libvirt/images/rhel7.3.qcow2", "node-name": "#block1864", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-unte= rminated.json b/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-u= nterminated.json index 454c07faec..3ffefa831c 100644 --- a/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-unterminate= d.json +++ b/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-unterminate= d.json @@ -9,7 +9,7 @@ "driver": "file", "filename": "/var/lib/libvirt/images/rhel7.3.1507297895", "node-name": "#block004", - "read-only": false, + "auto-read-only": true, "discard": "unmap" } { @@ -22,6 +22,6 @@ "driver": "file", "filename": "/var/lib/libvirt/images/rhel7.3.1484071872", "node-name": "#block256", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/file-raw-aio_native.json b/te= sts/qemublocktestdata/xml2json/file-raw-aio_native.json index 4e63561311..1ae76895cd 100644 --- a/tests/qemublocktestdata/xml2json/file-raw-aio_native.json +++ b/tests/qemublocktestdata/xml2json/file-raw-aio_native.json @@ -17,6 +17,6 @@ "direct": true, "no-flush": false }, - "read-only": false, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/file-raw-luks.json b/tests/qe= mublocktestdata/xml2json/file-raw-luks.json index c26dd3bba5..e4ed61db07 100644 --- a/tests/qemublocktestdata/xml2json/file-raw-luks.json +++ b/tests/qemublocktestdata/xml2json/file-raw-luks.json @@ -9,6 +9,6 @@ "driver": "file", "filename": "/path/luks.img", "node-name": "test2", - "read-only": false, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/file-raw-noopts.json b/tests/= qemublocktestdata/xml2json/file-raw-noopts.json index cace1f6448..01160c8253 100644 --- a/tests/qemublocktestdata/xml2json/file-raw-noopts.json +++ b/tests/qemublocktestdata/xml2json/file-raw-noopts.json @@ -8,6 +8,6 @@ "driver": "file", "filename": "/var/lib/libvirt/images/i.img", "node-name": "0123456789ABCDEF0123456789ABCDE", - "read-only": false, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/file-vdi-noopts.json b/tests/= qemublocktestdata/xml2json/file-vdi-noopts.json index 15f9da2091..5d4d6dfe5a 100644 --- a/tests/qemublocktestdata/xml2json/file-vdi-noopts.json +++ b/tests/qemublocktestdata/xml2json/file-vdi-noopts.json @@ -8,6 +8,6 @@ "driver": "file", "filename": "/path/to/i.img", "node-name": "test2", - "read-only": false, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/file-vhd-noopts.json b/tests/= qemublocktestdata/xml2json/file-vhd-noopts.json index ce96c4be8a..6c810d2036 100644 --- a/tests/qemublocktestdata/xml2json/file-vhd-noopts.json +++ b/tests/qemublocktestdata/xml2json/file-vhd-noopts.json @@ -8,6 +8,6 @@ "driver": "file", "filename": "/path/to/i.img", "node-name": "test2", - "read-only": false, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/file-vpc-noopts.json b/tests/= qemublocktestdata/xml2json/file-vpc-noopts.json index 9cba99e567..69b8102cf4 100644 --- a/tests/qemublocktestdata/xml2json/file-vpc-noopts.json +++ b/tests/qemublocktestdata/xml2json/file-vpc-noopts.json @@ -8,6 +8,6 @@ "driver": "file", "filename": "/path/to/i.img", "node-name": "test2", - "read-only": false, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/network-nbd-tls.json b/tests/= qemublocktestdata/xml2json/network-nbd-tls.json index a1529a6c44..0dc453fb7e 100644 --- a/tests/qemublocktestdata/xml2json/network-nbd-tls.json +++ b/tests/qemublocktestdata/xml2json/network-nbd-tls.json @@ -14,6 +14,6 @@ }, "tls-creds": "node-a-s-tls0", "node-name": "node-a-s", - "read-only": false, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-c= ache-unsafe.json b/tests/qemublocktestdata/xml2json/network-qcow2-backing-c= hain-cache-unsafe.json index e66f62d24b..9ee18dba51 100644 --- a/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-cache-un= safe.json +++ b/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-cache-un= safe.json @@ -34,7 +34,7 @@ "direct": false, "no-flush": true }, - "read-only": false, + "auto-read-only": true, "discard": "unmap" } { @@ -59,6 +59,6 @@ "direct": false, "no-flush": true }, - "read-only": true, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-e= ncryption_auth.json b/tests/qemublocktestdata/xml2json/network-qcow2-backin= g-chain-encryption_auth.json index 921cb3ea69..fb19641982 100644 --- a/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-encrypti= on_auth.json +++ b/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-encrypti= on_auth.json @@ -30,7 +30,7 @@ ], "key-secret": "node-a-s-secalias", "node-name": "node-a-s", - "read-only": false, + "auto-read-only": true, "discard": "unmap" } { @@ -53,6 +53,6 @@ "user": "testuser-iscsi", "password-secret": "node-b-s-secalias", "node-name": "node-b-s", - "read-only": true, + "auto-read-only": true, "discard": "unmap" } diff --git a/tests/qemuxml2argvdata/qemu-ns.x86_64-4.0.0.args b/tests/qemux= ml2argvdata/qemu-ns.x86_64-4.0.0.args index 6e059d336a..2f49af885b 100644 --- a/tests/qemuxml2argvdata/qemu-ns.x86_64-4.0.0.args +++ b/tests/qemuxml2argvdata/qemu-ns.x86_64-4.0.0.args @@ -30,7 +30,7 @@ file=3D/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ -boot strict=3Don \ -device piix3-usb-uhci,id=3Dusb,bus=3Dpci.0,addr=3D0x1.0x2 \ -blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1",\ -"node-name":"libvirt-1-storage","read-only":false,"discard":"unmap"}' \ +"node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw= ",\ "file":"libvirt-1-storage"}' \ -device ide-hd,bus=3Dide.0,unit=3D0,drive=3Dlibvirt-1-format,id=3Dide0-0-0= ,bootindex=3D1 \ diff --git a/tests/qemuxml2argvdata/qemu-ns.x86_64-latest.args b/tests/qemu= xml2argvdata/qemu-ns.x86_64-latest.args index ebb7b0da37..f898ab2e07 100644 --- a/tests/qemuxml2argvdata/qemu-ns.x86_64-latest.args +++ b/tests/qemuxml2argvdata/qemu-ns.x86_64-latest.args @@ -30,7 +30,7 @@ file=3D/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ -boot strict=3Don \ -device piix3-usb-uhci,id=3Dusb,bus=3Dpci.0,addr=3D0x1.0x2 \ -blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1",\ -"node-name":"libvirt-1-storage","read-only":false,"discard":"unmap"}' \ +"node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw= ",\ "file":"libvirt-1-storage"}' \ -device ide-hd,bus=3Dide.0,unit=3D0,drive=3Dlibvirt-1-format,id=3Dide0-0-0= ,bootindex=3D1 \ --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 04:44:30 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1562250599; cv=none; d=zoho.com; s=zohoarc; b=hE33uwkobE/YPGjechTe/6xsB1gi23NURuwFdaBe97bdBHL9ShK/ywab66cZti21VFzEjyOK6bas3v15/n1bGxlVieVBJyBzoSVC3do3wHRJ+DrxZXOeBKYtPA67REyXkfvgtOAiKy4sYCXWArwpCw982DMcRVnAdWtS27srWdE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562250599; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=/KkRrX9WQmPAPhzVu4jB0pxZRXWOT5iTYxHtCOj+sgY=; b=JECvPxulWfoG2qkOfI6LLyD7KaIisKJc66nZLi02JcqRB4QnY9Biu3KEdyXHSFSdIKAMF4JYeG9xaIEnGLP2t/ndbqWeLiPQheXiL23zrECWWAvZHkZVhJRy8L4FjIK2wCHxDvGYRjs+JCgxA0NXNPNWDrvH9QWqCkBazxk7Zuc= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562250599337805.1896490730102; Thu, 4 Jul 2019 07:29:59 -0700 (PDT) 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 11ED36749D; Thu, 4 Jul 2019 14:29:52 +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 DA07F7DE4E; Thu, 4 Jul 2019 14:29:50 +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 379CE1833003; Thu, 4 Jul 2019 14:29:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x64EQjRE029969 for ; Thu, 4 Jul 2019 10:26:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id 17A2F5B2FE; Thu, 4 Jul 2019 14:26:45 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 710CB5B77E; Thu, 4 Jul 2019 14:26:44 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 4 Jul 2019 16:26:30 +0200 Message-Id: <02a55a2192f112a146d4f25c03d01e7fa7b08712.1562249939.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Kevin Wolf Subject: [libvirt] [PATCH 06/11] qemu: block: Add generator for image format creation properties 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-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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 04 Jul 2019 14:29:57 +0000 (UTC) Content-Type: text/plain; charset="utf-8" 'blockdev-add' allows us to use qemu to format images to our desired format. This patch implements helpers which convert a virStorageSourcePtr into JSON objects describing the required configuration. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_block.c | 321 ++++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_block.h | 6 + 2 files changed, 327 insertions(+) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 9abdac5ca3..54dd2b5328 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1866,3 +1866,324 @@ qemuBlockStorageGetCopyOnReadProps(virDomainDiskDef= Ptr disk) return ret; } + + +static int +qemuBlockStorageSourceCreateAddBacking(virStorageSourcePtr backing, + virJSONValuePtr props, + bool format) +{ + VIR_AUTOPTR(virJSONValue) backingProps =3D NULL; + VIR_AUTOFREE(char *) backingJSON =3D NULL; + VIR_AUTOFREE(char *) backingPseudoprotocol =3D NULL; + const char *backingFileStr =3D NULL; + const char *backingFormatStr =3D NULL; + + if (!virStorageSourceIsBacking(backing)) + return 0; + + if (format) { + if (backing->encryption && + backing->encryption->format =3D=3D VIR_STORAGE_ENCRYPTION_FORM= AT_LUKS) + backingFormatStr =3D "luks"; + else + backingFormatStr =3D virStorageFileFormatTypeToString(backing-= >format); + } + + if (virStorageSourceIsLocalStorage(backing)) { + backingFileStr =3D backing->path; + } else { + if (!(backingProps =3D qemuBlockStorageSourceGetBackendProps(backi= ng, false, + true, f= alse))) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("failed to generate backing file JSON propert= ies")); + return -1; + } + + if (!(backingJSON =3D virJSONValueToString(backingProps, false))) + return -1; + + if (virAsprintf(&backingPseudoprotocol, "json:%s", backingJSON) < = 0) + return -1; + + backingFileStr =3D backingPseudoprotocol; + } + + if (virJSONValueObjectAdd(props, + "S:backing-file", backingFileStr, + "S:backing-fmt", backingFormatStr, + NULL) < 0) + return -1; + + return 0; +} + + +static int +qemuBlockStorageSourceCreateGetFormatPropsGeneric(virStorageSourcePtr src, + const char *driver, + virJSONValuePtr *retprop= s, + virStorageSourcePtr back= ing) +{ + VIR_AUTOPTR(virJSONValue) props =3D NULL; + + if (virJSONValueObjectCreate(&props, + "s:driver", driver, + "s:file", src->nodestorage, + "u:size", src->capacity, + NULL) < 0) + return -1; + + if (backing && + qemuBlockStorageSourceCreateAddBacking(backing, props, false) < 0) + return -1; + + VIR_STEAL_PTR(*retprops, props); + return 0; +} + + +static int +qemuBlockStorageSourceCreateGetEncryptionLUKS(virStorageSourcePtr src, + virJSONValuePtr *luksProps) +{ + qemuDomainStorageSourcePrivatePtr srcpriv =3D QEMU_DOMAIN_STORAGE_SOUR= CE_PRIVATE(src); + VIR_AUTOPTR(virJSONValue) props =3D NULL; + VIR_AUTOFREE(char *) cipheralg =3D NULL; + const char *keysecret =3D NULL; + + if (srcpriv && + srcpriv->encinfo && + srcpriv->encinfo->type =3D=3D VIR_DOMAIN_SECRET_INFO_TYPE_AES) + keysecret =3D srcpriv->encinfo->s.aes.alias; + + if (virJSONValueObjectCreate(&props, + "s:key-secret", keysecret, + NULL) < 0) + return -1; + + if (src->encryption) { + if (src->encryption->encinfo.cipher_name && + virAsprintf(&cipheralg, "%s-%u", + src->encryption->encinfo.cipher_name, + src->encryption->encinfo.cipher_size) < 0) + return -1; + + if (virJSONValueObjectAdd(props, + "S:cipher-alg", cipheralg, + "S:cipher-mode", src->encryption->encinf= o.cipher_mode, + "S:hash-alg", src->encryption->encinfo.c= ipher_hash, + "S:ivgen-alg", src->encryption->encinfo.= ivgen_name, + "S:ivgen-hash-alg", src->encryption->enc= info.ivgen_hash, + NULL) < 0) + return -1; + } + + VIR_STEAL_PTR(*luksProps, props); + return 0; +} + + +static int +qemuBlockStorageSourceCreateGetFormatPropsLUKS(virStorageSourcePtr src, + virJSONValuePtr *props) +{ + VIR_AUTOPTR(virJSONValue) luksprops =3D NULL; + + if (qemuBlockStorageSourceCreateGetEncryptionLUKS(src, &luksprops) < 0) + return -1; + + if (virJSONValueObjectAdd(luksprops, + "s:driver", "luks", + "s:file", src->nodestorage, + "u:size", src->capacity, + NULL) < 0) + return -1; + + VIR_STEAL_PTR(*props, luksprops); + return 0; +} + + +static int +qemuBlockStorageSourceCreateAddEncryptionQcow(virStorageSourcePtr src, + virJSONValuePtr props) +{ + VIR_AUTOPTR(virJSONValue) encryptProps =3D NULL; + + if (!src->encryption) + return 0; + + if (src->encryption->format !=3D VIR_STORAGE_ENCRYPTION_FORMAT_LUKS) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("creation of qcow/qcow2 files supports only 'luks= ' encryption")); + return -1; + } + + if (qemuBlockStorageSourceCreateGetEncryptionLUKS(src, &encryptProps) = < 0) + return -1; + + if (virJSONValueObjectAdd(encryptProps, "s:format", "luks", NULL) < 0) + return -1; + + if (virJSONValueObjectAdd(props, "a:encrypt", &encryptProps, NULL) < 0) + return -1; + + return 0; +} + + +static int +qemuBlockStorageSourceCreateGetFormatPropsQcow2(virStorageSourcePtr src, + virStorageSourcePtr backin= g, + virJSONValuePtr *props) +{ + VIR_AUTOPTR(virJSONValue) qcow2props =3D NULL; + const char *qcow2version =3D NULL; + + if (STREQ_NULLABLE(src->compat, "0.10")) + qcow2version =3D "v2"; + else if (STREQ_NULLABLE(src->compat, "1.1")) + qcow2version =3D "v3"; + + if (virJSONValueObjectCreate(&qcow2props, + "s:driver", "qcow2", + "s:file", src->nodestorage, + "u:size", src->capacity, + "S:version", qcow2version, + NULL) < 0) + return -1; + + if (qemuBlockStorageSourceCreateAddBacking(backing, qcow2props, true) = < 0 || + qemuBlockStorageSourceCreateAddEncryptionQcow(src, qcow2props) < 0) + return -1; + + VIR_STEAL_PTR(*props, qcow2props); + return 0; +} + + +static int +qemuBlockStorageSourceCreateGetFormatPropsQcow(virStorageSourcePtr src, + virStorageSourcePtr backing, + virJSONValuePtr *props) +{ + VIR_AUTOPTR(virJSONValue) qcowprops =3D NULL; + + if (virJSONValueObjectCreate(&qcowprops, + "s:driver", "qcow", + "s:file", src->nodestorage, + "u:size", src->capacity, + NULL) < 0) + return -1; + + if (qemuBlockStorageSourceCreateAddBacking(backing, qcowprops, false) = < 0 || + qemuBlockStorageSourceCreateAddEncryptionQcow(src, qcowprops) < 0) + return -1; + + VIR_STEAL_PTR(*props, qcowprops); + return 0; +} + + +static int +qemuBlockStorageSourceCreateGetFormatPropsQed(virStorageSourcePtr src, + virStorageSourcePtr backing, + virJSONValuePtr *props) +{ + VIR_AUTOPTR(virJSONValue) qedprops =3D NULL; + + if (virJSONValueObjectCreate(&qedprops, + "s:driver", "qed", + "s:file", src->nodestorage, + "u:size", src->capacity, + NULL) < 0) + return -1; + + if (qemuBlockStorageSourceCreateAddBacking(backing, qedprops, true) < = 0) + return -1; + + VIR_STEAL_PTR(*props, qedprops); + return 0; +} + + +/** + * qemuBlockStorageSourceCreateGetFormatProps: + * @src: storage source to format + * @backing: storage source describing backing image of @src (if necessary) + * @props: filled with props to be used with 'blockdev-create' to format @= src + * + * @src must be properly initialized to contain node-names of the protocol= layer + * which should be formatted. @props may be NULL with success returned in = which + * case creation of given storage format is not supported. Note that creat= ion + * of 'raw' storage is also returns NULL as there is nothing to do. + */ +int +qemuBlockStorageSourceCreateGetFormatProps(virStorageSourcePtr src, + virStorageSourcePtr backing, + virJSONValuePtr *props) +{ + switch ((virStorageFileFormat) src->format) { + case VIR_STORAGE_FILE_RAW: + if (!src->encryption || + src->encryption->format !=3D VIR_STORAGE_ENCRYPTION_FORMAT_LUK= S) + return 0; + + return qemuBlockStorageSourceCreateGetFormatPropsLUKS(src, props); + + case VIR_STORAGE_FILE_QCOW2: + return qemuBlockStorageSourceCreateGetFormatPropsQcow2(src, backin= g, props); + + case VIR_STORAGE_FILE_QCOW: + return qemuBlockStorageSourceCreateGetFormatPropsQcow(src, backing= , props); + + case VIR_STORAGE_FILE_QED: + return qemuBlockStorageSourceCreateGetFormatPropsQed(src, backing,= props); + + case VIR_STORAGE_FILE_VPC: + return qemuBlockStorageSourceCreateGetFormatPropsGeneric(src, "vpc= ", + props, NU= LL); + + case VIR_STORAGE_FILE_PLOOP: + return qemuBlockStorageSourceCreateGetFormatPropsGeneric(src, "par= allels", + props, NU= LL); + + case VIR_STORAGE_FILE_VDI: + return qemuBlockStorageSourceCreateGetFormatPropsGeneric(src, "vdi= ", + props, NU= LL); + + case VIR_STORAGE_FILE_VHD: + return qemuBlockStorageSourceCreateGetFormatPropsGeneric(src, "vhd= x", + props, NU= LL); + + case VIR_STORAGE_FILE_VMDK: + return qemuBlockStorageSourceCreateGetFormatPropsGeneric(src, "vmd= k", + props, ba= cking); + + /* unsupported by qemu / impossible */ + case VIR_STORAGE_FILE_FAT: + case VIR_STORAGE_FILE_BOCHS: + case VIR_STORAGE_FILE_CLOOP: + case VIR_STORAGE_FILE_DMG: + case VIR_STORAGE_FILE_COW: + case VIR_STORAGE_FILE_ISO: + case VIR_STORAGE_FILE_DIR: + return 0; + + case VIR_STORAGE_FILE_AUTO_SAFE: + case VIR_STORAGE_FILE_AUTO: + case VIR_STORAGE_FILE_NONE: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("mishandled storage format '%s'"), + virStorageFileFormatTypeToString(src->format)); + return -1; + + case VIR_STORAGE_FILE_LAST: + default: + break; + } + + virReportEnumRangeError(virStorageFileFormat, src->format); + return -1; +} diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index 12ddfad2ac..738ef9e8b0 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -162,3 +162,9 @@ qemuBlockSnapshotAddLegacy(virJSONValuePtr actions, virDomainDiskDefPtr disk, virStorageSourcePtr newsrc, bool reuse); + +int +qemuBlockStorageSourceCreateGetFormatProps(virStorageSourcePtr src, + virStorageSourcePtr backing, + virJSONValuePtr *props) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 04:44:30 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1562250626; cv=none; d=zoho.com; s=zohoarc; b=C7ZIgFeHThQ3v1q/k0tkh3XKgmbDvu3homG/dbjNh9arAGBWm7CWFB+TRVtFecL882TgZE1t2nlaUTRuW9RhOGCuMfBVutEim5LVhdh/OyDZVt9rejB3UXkOt4zLmyXtPx7tYXegGcXoIYuayW5cVK0dXltfA9sxHEE1CTC1ZFQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562250626; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=yRHLvfOWkadjybfbM5sPkT2BABd/Cd+zrn8iI69XaWc=; b=PZbf+58gXZocpLaEKItBmvRLVp/uO1UIYAvqGxhe5gmBzQqqrdic9/84zay/Y0ruqUVswRDUqhKEckNoXZfuB5HNUSkZk4xvokMUEiMIUdRp1U2G9syKBvQ4CY6HZ3u7sKmK7HY6G0ptX/B4BfmOrSe8f0XPwwXOGltmCqft6+A= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562250626759283.6230297473386; Thu, 4 Jul 2019 07:30:26 -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 26BE5307D871; Thu, 4 Jul 2019 14:30:25 +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 E6B6B79808; Thu, 4 Jul 2019 14:30:24 +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 98F641833001; Thu, 4 Jul 2019 14:30:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x64EQkeG029998 for ; Thu, 4 Jul 2019 10:26:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0AC7D5B2FE; Thu, 4 Jul 2019 14:26:46 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 647535B2D2; Thu, 4 Jul 2019 14:26:45 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 4 Jul 2019 16:26:31 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Kevin Wolf Subject: [libvirt] [PATCH 07/11] qemu: block: Add generator for creating storage with blockdev-create 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-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.48]); Thu, 04 Jul 2019 14:30:25 +0000 (UTC) Content-Type: text/plain; charset="utf-8" QEMU allows us to create storage on certain network protocols which allow image creation through their API. Wire up the generator for using it with libvirt as well as for local files. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_block.c | 88 +++++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_block.h | 5 +++ 2 files changed, 93 insertions(+) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 54dd2b5328..709ed29375 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -2187,3 +2187,91 @@ qemuBlockStorageSourceCreateGetFormatProps(virStorag= eSourcePtr src, virReportEnumRangeError(virStorageFileFormat, src->format); return -1; } + + +/** + * qemuBlockStorageSourceCreateGetStorageProps: + * @src: storage source to create + * @props: filled with props to be used with 'blockdev-create' to create @= src + * + * This function should be used only if @src->type is VIR_STORAGE_TYPE_NET= WORK. + * Note that @props may be NULL if qemu does not support creation storage + * on given protocol. @src->physical is used as size for the storage. + */ +int +qemuBlockStorageSourceCreateGetStorageProps(virStorageSourcePtr src, + virJSONValuePtr *props) +{ + int actualType =3D virStorageSourceGetActualType(src); + VIR_AUTOPTR(virJSONValue) location =3D NULL; + const char *driver =3D NULL; + const char *filename =3D NULL; + + switch ((virStorageType) actualType) { + case VIR_STORAGE_TYPE_FILE: + driver =3D "file"; + filename =3D src->path; + break; + + case VIR_STORAGE_TYPE_NETWORK: + switch ((virStorageNetProtocol) src->protocol) { + case VIR_STORAGE_NET_PROTOCOL_GLUSTER: + driver =3D "gluster"; + if (!(location =3D qemuBlockStorageSourceGetGlusterProps(src, = false, false))) + return -1; + break; + + case VIR_STORAGE_NET_PROTOCOL_RBD: + driver =3D "rbd"; + if (!(location =3D qemuBlockStorageSourceGetRBDProps(src, fals= e))) + return -1; + break; + + case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG: + driver =3D "sheepdog"; + if (!(location =3D qemuBlockStorageSourceGetSheepdogProps(src)= )) + return -1; + break; + + case VIR_STORAGE_NET_PROTOCOL_SSH: + driver =3D "ssh"; + if (!(location =3D qemuBlockStorageSourceGetSshProps(src))) + return -1; + break; + + /* unsupported/impossible */ + case VIR_STORAGE_NET_PROTOCOL_NBD: + case VIR_STORAGE_NET_PROTOCOL_ISCSI: + case VIR_STORAGE_NET_PROTOCOL_VXHS: + case VIR_STORAGE_NET_PROTOCOL_HTTP: + case VIR_STORAGE_NET_PROTOCOL_HTTPS: + case VIR_STORAGE_NET_PROTOCOL_FTP: + case VIR_STORAGE_NET_PROTOCOL_FTPS: + case VIR_STORAGE_NET_PROTOCOL_TFTP: + case VIR_STORAGE_NET_PROTOCOL_NONE: + case VIR_STORAGE_NET_PROTOCOL_LAST: + return 0; + } + break; + + case VIR_STORAGE_TYPE_BLOCK: + case VIR_STORAGE_TYPE_DIR: + case VIR_STORAGE_TYPE_VOLUME: + return 0; + + case VIR_STORAGE_TYPE_NONE: + case VIR_STORAGE_TYPE_LAST: + virReportEnumRangeError(virStorageType, actualType); + return -1; + } + + if (virJSONValueObjectCreate(props, + "s:driver", driver, + "S:filename", filename, + "A:location", &location, + "u:size", src->physical, + NULL) < 0) + return -1; + + return 0; +} diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index 738ef9e8b0..a5f6a3c75b 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -168,3 +168,8 @@ qemuBlockStorageSourceCreateGetFormatProps(virStorageSo= urcePtr src, virStorageSourcePtr backing, virJSONValuePtr *props) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK; + +int +qemuBlockStorageSourceCreateGetStorageProps(virStorageSourcePtr src, + virJSONValuePtr *props) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 04:44:30 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1562250638; cv=none; d=zoho.com; s=zohoarc; b=Ibu4XZ1rKKHy1D6DG4Md3knFa+MxbAY1JoGewEW5FZk0jCHkbNjEMoVK32VawV1tWw5vuKfXXnWZyHb0g91qMutY/RlDjWqpjVsset/bp2xlGxMVCw8jEAMtF2pcuM0hjTwm8CLt2mYNuH4c4kv7gBr7AwDU6Rh9OzBaBHk0l9Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562250638; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=bc8viQ0AAJWOJ9cW4BV6W+JcUTkIKi4+NjxJ/zP6z7I=; b=gL2w20V8GXGlcCjCZN0oGSK7DNCbZI6hfelG+Yc3YZKhG3Lz7l7M2OyRaUTmFvXhkTRChFtzWRB6veL9r8Zf/HxKG10is+FveeBetVF0r3kq61KIysX/f0xpdVf+MTCu2kwWP6vYKWjekiUQ3NpTMFlIyDt4jsXM7wOyJGzrfJU= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562250638026838.6266529737184; Thu, 4 Jul 2019 07:30:38 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 487A43082131; Thu, 4 Jul 2019 14:30:36 +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 1D7CA18EEE; Thu, 4 Jul 2019 14:30:36 +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 D0BA519725; Thu, 4 Jul 2019 14:30:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x64EQlcV030038 for ; Thu, 4 Jul 2019 10:26:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id F2EA45B2FE; Thu, 4 Jul 2019 14:26:46 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5788B5B2D2; Thu, 4 Jul 2019 14:26:46 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 4 Jul 2019 16:26:32 +0200 Message-Id: <159faf48dd8d9838626ddb1249cd1823920c8bf7.1562249939.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Kevin Wolf Subject: [libvirt] [PATCH 08/11] qemu: domain: Export qemuDomainPrepareStorageSourceBlockdev 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-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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 04 Jul 2019 14:30:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 9 +-------- src/qemu/qemu_domain.h | 5 +++++ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6225ac23e2..79f18a6a7c 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -135,13 +135,6 @@ static void qemuDomainLogContextDispose(void *obj); static void qemuDomainSaveCookieDispose(void *obj); -static int -qemuDomainPrepareStorageSourceBlockdev(virDomainDiskDefPtr disk, - virStorageSourcePtr src, - qemuDomainObjPrivatePtr priv, - virQEMUDriverConfigPtr cfg); - - static int qemuDomainOnceInit(void) { @@ -14146,7 +14139,7 @@ qemuDomainPrepareDiskSourceLegacy(virDomainDiskDefP= tr disk, } -static int +int qemuDomainPrepareStorageSourceBlockdev(virDomainDiskDefPtr disk, virStorageSourcePtr src, qemuDomainObjPrivatePtr priv, diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 3eea8b0f96..c684b4cad9 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -810,6 +810,11 @@ int qemuDomainStorageSourceAccessAllow(virQEMUDriverPt= r driver, bool readonly, bool newSource); +int qemuDomainPrepareStorageSourceBlockdev(virDomainDiskDefPtr disk, + virStorageSourcePtr src, + qemuDomainObjPrivatePtr priv, + virQEMUDriverConfigPtr cfg); + int qemuDomainCleanupAdd(virDomainObjPtr vm, qemuDomainCleanupCallback cb); void qemuDomainCleanupRemove(virDomainObjPtr vm, --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 04:44:30 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1562250615; cv=none; d=zoho.com; s=zohoarc; b=FPmzCKGZG1RE9An7C3A3y4apKqoEWDcfnjslbCq9IRTprR2Puts7x7ATIK6Jvcr+ZcO/GCc7x9zj5cqUjngV8R1Y6iSU5llb4MKZnTZZ1E31dFFDUz+TIldFjeERh6aa1KvnvEEuALEBQLgx12OWV0d8s+IHzPdrKnUzhj4bdvs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562250615; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=rbRs0H/hP4SYPwxJRcvAFo4ppRcCLiJ38fMp8DwmVU8=; b=GV8HGokYYtFGCbEShKeJg+5ZRV4bpt+C6hMUGfxRkmP5ahKmSiv5j/J+X2OAmf+7UOGSS18eTqn/PEigmutGjbJYj/4jHKMjg2hdMuaZ0GS3W0HHW8qpQNMbpslDrQVx7mfF82i9JEv/IiNfVpRRwBx6ojPYP72UMdF5VVmJZOw= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562250615971689.4582041945303; Thu, 4 Jul 2019 07:30:15 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CC0FD59454; Thu, 4 Jul 2019 14:30:13 +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 8AECD3794; Thu, 4 Jul 2019 14:30:11 +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 280961972B; Thu, 4 Jul 2019 14:30:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x64EQlGw030066 for ; Thu, 4 Jul 2019 10:26:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id E61BC5B2D2; Thu, 4 Jul 2019 14:26:47 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4ACFA5B77E; Thu, 4 Jul 2019 14:26:47 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 4 Jul 2019 16:26:33 +0200 Message-Id: <0be5448438b1aa5d879636d113c79255547bbf55.1562249939.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Kevin Wolf Subject: [libvirt] [PATCH 09/11] conf: snapshot: Export virDomainSnapshotDiskDefParseXML 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-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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 04 Jul 2019 14:30:14 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Allow using it from the tests. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/snapshot_conf.c | 2 +- src/conf/snapshot_conf.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index c7f29360e7..247d3f71b0 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -121,7 +121,7 @@ virDomainSnapshotDefDispose(void *obj) virObjectUnref(def->cookie); } -static int +int virDomainSnapshotDiskDefParseXML(xmlNodePtr node, xmlXPathContextPtr ctxt, virDomainSnapshotDiskDefPtr def, diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index 08b2a3b955..f4be434afc 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -123,6 +123,11 @@ int virDomainSnapshotAlignDisks(virDomainSnapshotDefPt= r snapshot, int default_snapshot, bool require_match); +int virDomainSnapshotDiskDefParseXML(xmlNodePtr node, + xmlXPathContextPtr ctxt, + virDomainSnapshotDiskDefPtr def, + unsigned int flags, + virDomainXMLOptionPtr xmlopt); bool virDomainSnapshotDefIsExternal(virDomainSnapshotDefPtr def); bool virDomainSnapshotIsExternal(virDomainMomentObjPtr snap); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 04:44:30 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1562250625; cv=none; d=zoho.com; s=zohoarc; b=VndX0jhYOAGoNl+ydhaIAY94XWCe68mG9HjEcMtXDnAQ6ydQlC+qgI7w9GUBfP+3Y5u0XA2T+qNXwzAq00QyXZySZt2nz+yQKhwB2F813a33c+mvBt2vpAjsejdYSfHsxRHa9FtBhmzH0VO37HVK1SUkPbslRLcTuTYCV9bM41g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562250625; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=q5wkg4bEywdI1dLjp9FhpvNRJYSQU7eXXUli0x308q0=; b=XiOf8oCVWYhSkZAgqZyb8oGmmOWq1TrtmAbxvQDEPA1SeQuJ877qzQZ5mJM3IZm+sPXYmD8QW0/uWq8lw4LQ75XoJs0dt1mEqSskSsfctZHppJyAM3cSIYcbA8CX8OedYhDL3NYpHD2+kJX0VvLqcW5hN74Qbaf1SaXj4g8u3hc= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562250625757650.2850719878397; Thu, 4 Jul 2019 07:30:25 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 83B74301E3D3; Thu, 4 Jul 2019 14:30:16 +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 4E14C6B8CC; Thu, 4 Jul 2019 14:30:16 +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 E69AC1972B; Thu, 4 Jul 2019 14:30:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x64EQnec030093 for ; Thu, 4 Jul 2019 10:26:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id D8F165B2FE; Thu, 4 Jul 2019 14:26:48 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E4285B2D2; Thu, 4 Jul 2019 14:26:48 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 4 Jul 2019 16:26:34 +0200 Message-Id: <65de99f7ab6f5ff491cca1d946b77d5a6868d315.1562249939.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Kevin Wolf Subject: [libvirt] [PATCH 10/11] conf: snapshot: Provide a function to free virDomainSnapshotDiskDefPtr 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-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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 04 Jul 2019 14:30:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Tests will need to parse such a definition so it also needs to be freed. Provide a function for it. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/snapshot_conf.c | 11 +++++++++++ src/conf/snapshot_conf.h | 1 + 2 files changed, 12 insertions(+) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 247d3f71b0..f3385d930b 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -95,6 +95,17 @@ virDomainSnapshotDiskDefClear(virDomainSnapshotDiskDefPt= r disk) disk->src =3D NULL; } +void +virDomainSnapshotDiskDefFree(virDomainSnapshotDiskDefPtr disk) +{ + if (!disk) + return; + + virDomainSnapshotDiskDefClear(disk); + VIR_FREE(disk); +} + + /* Allocate a new virDomainSnapshotDef; free with virObjectUnref() */ virDomainSnapshotDefPtr virDomainSnapshotDefNew(void) diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index f4be434afc..445899dd07 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -114,6 +114,7 @@ virDomainSnapshotDefPtr virDomainSnapshotDefParseNode(x= mlDocPtr xml, bool *current, unsigned int flags); virDomainSnapshotDefPtr virDomainSnapshotDefNew(void); +void virDomainSnapshotDiskDefFree(virDomainSnapshotDiskDefPtr disk); char *virDomainSnapshotDefFormat(const char *uuidstr, virDomainSnapshotDefPtr def, virCapsPtr caps, --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 04:44:30 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1562250642; cv=none; d=zoho.com; s=zohoarc; b=GPRZrmunm6ZAga8sU8UkRnvktnmfxHU7QMdYEMbdXF4ZBOsGKu5gqW5J9Lgsgp/hbU6/a4i3eaUJHoAVnfr+0K8PdN+t2+7lnSZ4NdeBQuo1NVhu4evOajwLPYeTFTwT2u5HHP5aaatdogBUj3/qhiXbSRvO2sBAPOk2+jdeOUw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562250642; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=f/SZZuVQyLRo8CSCzqU6NSt80rAuZyV0zkcBqUforXs=; b=LPDVUX7h40MfXf/26Hp+R5frotBlr+Wny8N1nKlPpY1Xs3POz86y+7NVkckQ6UrRLnb5NPFds5/cc5tMBGzFmd+cqhOA/q7YHjoERWUnVAbeCz65xAdHYl6It644P3JW3iZAXHGW6Uah50XrcVnqHl1l1xaRLQesUKSNkqeNWyE= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 156225064269042.65303231937685; Thu, 4 Jul 2019 07:30:42 -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 6A6C6300145F; Thu, 4 Jul 2019 14:30:32 +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 3A161795AF; Thu, 4 Jul 2019 14:30:32 +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 DCFB41833006; Thu, 4 Jul 2019 14:30:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x64EQnhk030126 for ; Thu, 4 Jul 2019 10:26:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id CD8675B801; Thu, 4 Jul 2019 14:26:49 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 328BB5B2D2; Thu, 4 Jul 2019 14:26:49 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 4 Jul 2019 16:26:35 +0200 Message-Id: <448824214a41c1fe0144cd7ab3625e1c7dc1d62f.1562249939.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Kevin Wolf Subject: [libvirt] [PATCH 11/11] tests: qemublock: Add testing of 'blockdev-create' generators 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-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.43]); Thu, 04 Jul 2019 14:30:33 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Test the output against the schema and also against what we expect. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemublocktest.c | 170 ++++++++++++++++++ .../imagecreate/luks-encopts.json | 19 ++ .../imagecreate/luks-encopts.xml | 16 ++ .../imagecreate/luks-noopts.json | 14 ++ .../imagecreate/luks-noopts.xml | 14 ++ .../imagecreate/network-gluster-qcow2.json | 28 +++ .../imagecreate/network-gluster-qcow2.xml | 13 ++ .../imagecreate/network-rbd-qcow2.json | 26 +++ .../imagecreate/network-rbd-qcow2.xml | 13 ++ .../imagecreate/network-sheepdog-qcow2.json | 20 +++ .../imagecreate/network-sheepdog-qcow2.xml | 12 ++ .../imagecreate/network-ssh-qcow2.json | 19 ++ .../imagecreate/network-ssh-qcow2.xml | 12 ++ .../imagecreate/qcow2-backing-luks.json | 15 ++ .../imagecreate/qcow2-backing-luks.xml | 1 + .../imagecreate/qcow2-backing-raw-nbd.json | 15 ++ .../imagecreate/qcow2-backing-raw-nbd.xml | 1 + .../imagecreate/qcow2-backing-raw.json | 15 ++ .../imagecreate/qcow2-backing-raw.xml | 1 + .../qcow2-luks-encopts-backing.json | 24 +++ .../qcow2-luks-encopts-backing.xml | 1 + .../imagecreate/qcow2-luks-encopts.json | 22 +++ .../imagecreate/qcow2-luks-encopts.xml | 16 ++ .../imagecreate/qcow2-luks-noopts.json | 17 ++ .../imagecreate/qcow2-luks-noopts.xml | 14 ++ .../qemublocktestdata/imagecreate/qcow2.json | 13 ++ tests/qemublocktestdata/imagecreate/qcow2.xml | 11 ++ .../imagecreate/raw-nbd.json | 4 + .../qemublocktestdata/imagecreate/raw-nbd.xml | 12 ++ tests/qemublocktestdata/imagecreate/raw.json | 9 + tests/qemublocktestdata/imagecreate/raw.xml | 11 ++ 31 files changed, 578 insertions(+) create mode 100644 tests/qemublocktestdata/imagecreate/luks-encopts.json create mode 100644 tests/qemublocktestdata/imagecreate/luks-encopts.xml create mode 100644 tests/qemublocktestdata/imagecreate/luks-noopts.json create mode 100644 tests/qemublocktestdata/imagecreate/luks-noopts.xml create mode 100644 tests/qemublocktestdata/imagecreate/network-gluster-qco= w2.json create mode 100644 tests/qemublocktestdata/imagecreate/network-gluster-qco= w2.xml create mode 100644 tests/qemublocktestdata/imagecreate/network-rbd-qcow2.j= son create mode 100644 tests/qemublocktestdata/imagecreate/network-rbd-qcow2.x= ml create mode 100644 tests/qemublocktestdata/imagecreate/network-sheepdog-qc= ow2.json create mode 100644 tests/qemublocktestdata/imagecreate/network-sheepdog-qc= ow2.xml create mode 100644 tests/qemublocktestdata/imagecreate/network-ssh-qcow2.j= son create mode 100644 tests/qemublocktestdata/imagecreate/network-ssh-qcow2.x= ml create mode 100644 tests/qemublocktestdata/imagecreate/qcow2-backing-luks.= json create mode 120000 tests/qemublocktestdata/imagecreate/qcow2-backing-luks.= xml create mode 100644 tests/qemublocktestdata/imagecreate/qcow2-backing-raw-n= bd.json create mode 120000 tests/qemublocktestdata/imagecreate/qcow2-backing-raw-n= bd.xml create mode 100644 tests/qemublocktestdata/imagecreate/qcow2-backing-raw.j= son create mode 120000 tests/qemublocktestdata/imagecreate/qcow2-backing-raw.x= ml create mode 100644 tests/qemublocktestdata/imagecreate/qcow2-luks-encopts-= backing.json create mode 120000 tests/qemublocktestdata/imagecreate/qcow2-luks-encopts-= backing.xml create mode 100644 tests/qemublocktestdata/imagecreate/qcow2-luks-encopts.= json create mode 100644 tests/qemublocktestdata/imagecreate/qcow2-luks-encopts.= xml create mode 100644 tests/qemublocktestdata/imagecreate/qcow2-luks-noopts.j= son create mode 100644 tests/qemublocktestdata/imagecreate/qcow2-luks-noopts.x= ml create mode 100644 tests/qemublocktestdata/imagecreate/qcow2.json create mode 100644 tests/qemublocktestdata/imagecreate/qcow2.xml create mode 100644 tests/qemublocktestdata/imagecreate/raw-nbd.json create mode 100644 tests/qemublocktestdata/imagecreate/raw-nbd.xml create mode 100644 tests/qemublocktestdata/imagecreate/raw.json create mode 100644 tests/qemublocktestdata/imagecreate/raw.xml diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 5c381d1e3b..cd5047a545 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -342,6 +342,138 @@ testQemuDiskXMLToPropsValidateFile(const void *opaque) } +struct testQemuImageCreateData { + const char *name; + const char *backingname; + virHashTablePtr schema; + virJSONValuePtr schemaroot; + virQEMUDriverPtr driver; + virQEMUCapsPtr qemuCaps; +}; + +static const char *testQemuImageCreatePath =3D abs_srcdir "/qemublocktestd= ata/imagecreate/"; + +static virStorageSourcePtr +testQemuImageCreateLoadDiskXML(const char *name, + virDomainXMLOptionPtr xmlopt) + +{ + virDomainSnapshotDiskDefPtr diskdef =3D NULL; + VIR_AUTOPTR(xmlDoc) doc =3D NULL; + VIR_AUTOPTR(xmlXPathContext) ctxt =3D NULL; + xmlNodePtr node; + VIR_AUTOFREE(char *) xmlpath =3D NULL; + virStorageSourcePtr ret =3D NULL; + + if (virAsprintf(&xmlpath, "%s%s.xml", + testQemuImageCreatePath, name) < 0) + return NULL; + + if (!(doc =3D virXMLParseFileCtxt(xmlpath, &ctxt))) + return NULL; + + if (!(node =3D virXPathNode("//disk", ctxt))) { + VIR_TEST_VERBOSE("failed to find element\n"); + return NULL; + } + + if (VIR_ALLOC(diskdef) < 0) + return NULL; + + if (virDomainSnapshotDiskDefParseXML(node, ctxt, diskdef, + VIR_DOMAIN_DEF_PARSE_STATUS, + xmlopt) =3D=3D 0) + VIR_STEAL_PTR(ret, diskdef->src); + + virDomainSnapshotDiskDefFree(diskdef); + return ret; +} + + +static int +testQemuImageCreate(const void *opaque) +{ + struct testQemuImageCreateData *data =3D (void *) opaque; + VIR_AUTOPTR(virJSONValue) protocolprops =3D NULL; + VIR_AUTOPTR(virJSONValue) formatprops =3D NULL; + VIR_AUTOUNREF(virStorageSourcePtr) src =3D NULL; + VIR_AUTOCLEAN(virBuffer) debug =3D VIR_BUFFER_INITIALIZER; + VIR_AUTOCLEAN(virBuffer) actualbuf =3D VIR_BUFFER_INITIALIZER; + VIR_AUTOFREE(char *) jsonprotocol =3D NULL; + VIR_AUTOFREE(char *) jsonformat =3D NULL; + VIR_AUTOFREE(char *) actual =3D NULL; + VIR_AUTOFREE(char *) jsonpath =3D NULL; + + if (!(src =3D testQemuImageCreateLoadDiskXML(data->name, data->driver-= >xmlopt))) + return -1; + + if (data->backingname && + !(src->backingStore =3D testQemuImageCreateLoadDiskXML(data->backi= ngname, + data->driver-= >xmlopt))) + return -1; + + if (testQemuDiskXMLToJSONFakeSecrets(src) < 0) + return -1; + + /* fake some sizes */ + src->capacity =3D 1337; + src->physical =3D 42; + + if (qemuDomainValidateStorageSource(src, data->qemuCaps) < 0) + return -1; + + if (qemuBlockStorageSourceCreateGetStorageProps(src, &protocolprops) <= 0) + return -1; + + if (qemuBlockStorageSourceCreateGetFormatProps(src, src->backingStore,= &formatprops) < 0) + return -1; + + if (formatprops) { + if (!(jsonformat =3D virJSONValueToString(formatprops, true))) + return -1; + + if (testQEMUSchemaValidate(formatprops, data->schemaroot, data->sc= hema, + &debug) < 0) { + VIR_AUTOFREE(char *) debugmsg =3D virBufferContentAndReset(&de= bug); + VIR_TEST_VERBOSE("blockdev-create format json does not conform= to QAPI schema"); + VIR_TEST_DEBUG("json:\n%s\ndoes not match schema. Debug output= :\n %s", + jsonformat, NULLSTR(debugmsg)); + return -1; + } + virBufferFreeAndReset(&debug); + } + + if (protocolprops) { + if (!(jsonprotocol =3D virJSONValueToString(protocolprops, true))) + return -1; + + if (testQEMUSchemaValidate(protocolprops, data->schemaroot, data->= schema, + &debug) < 0) { + VIR_AUTOFREE(char *) debugmsg =3D virBufferContentAndReset(&de= bug); + VIR_TEST_VERBOSE("blockdev-create protocol json does not confo= rm to QAPI schema"); + VIR_TEST_DEBUG("json:\n%s\ndoes not match schema. Debug output= :\n %s", + jsonprotocol, NULLSTR(debugmsg)); + return -1; + } + virBufferFreeAndReset(&debug); + } + + virBufferStrcat(&actualbuf, "protocol:\n", NULLSTR(jsonprotocol), + "\nformat:\n", NULLSTR(jsonformat), NULL); + virBufferTrim(&actualbuf, "\n", -1); + virBufferAddLit(&actualbuf, "\n"); + + if (virAsprintf(&jsonpath, "%s%s.json", + testQemuImageCreatePath, data->name) < 0) + return -1; + + if (!(actual =3D virBufferContentAndReset(&actualbuf))) + return -1; + + return virTestCompareToFile(actual, jsonpath); +} + + static int testQemuDiskXMLToPropsValidateFileSrcOnly(const void *opaque) { @@ -383,6 +515,7 @@ mymain(void) virQEMUDriver driver; struct testBackingXMLjsonXMLdata xmljsonxmldata; struct testQemuDiskXMLToJSONData diskxmljsondata; + struct testQemuImageCreateData imagecreatedata; char *capslatest_x86_64 =3D NULL; virQEMUCapsPtr caps_x86_64 =3D NULL; @@ -390,6 +523,7 @@ mymain(void) return EXIT_FAILURE; diskxmljsondata.driver =3D &driver; + imagecreatedata.driver =3D &driver; if (!(capslatest_x86_64 =3D testQemuGetLatestCapsForArch("x86_64", "xm= l"))) return EXIT_FAILURE; @@ -401,6 +535,7 @@ mymain(void) return EXIT_FAILURE; diskxmljsondata.qemuCaps =3D caps_x86_64; + imagecreatedata.qemuCaps =3D caps_x86_64; virTestCounterReset("qemu storage source xml->json->xml "); @@ -548,6 +683,41 @@ mymain(void) TEST_DISK_TO_JSON("block-raw-noopts"); TEST_DISK_TO_JSON("block-raw-reservations"); +# define TEST_IMAGE_CREATE(testname, testbacking) \ + do { \ + imagecreatedata.name =3D testname; \ + imagecreatedata.backingname =3D testbacking; \ + if (virTestRun("image create xml to props " testname, testQemuImag= eCreate, \ + &imagecreatedata) < 0) \ + ret =3D -1; \ + } while (0) + imagecreatedata.schema =3D diskxmljsondata.schema; + if (virQEMUQAPISchemaPathGet("blockdev-create/arg-type/options", + imagecreatedata.schema, + &imagecreatedata.schemaroot) < 0 || + !imagecreatedata.schemaroot) { + VIR_TEST_VERBOSE("failed to find schema entry for blockdev-create\= n"); + ret =3D -1; + goto cleanup; + } + + TEST_IMAGE_CREATE("raw", NULL); + TEST_IMAGE_CREATE("raw-nbd", NULL); + TEST_IMAGE_CREATE("luks-noopts", NULL); + TEST_IMAGE_CREATE("luks-encopts", NULL); + TEST_IMAGE_CREATE("qcow2", NULL); + TEST_IMAGE_CREATE("qcow2-luks-noopts", NULL); + TEST_IMAGE_CREATE("qcow2-luks-encopts", NULL); + TEST_IMAGE_CREATE("qcow2-backing-raw", "raw"); + TEST_IMAGE_CREATE("qcow2-backing-raw-nbd", "raw-nbd"); + TEST_IMAGE_CREATE("qcow2-backing-luks", "luks-noopts"); + TEST_IMAGE_CREATE("qcow2-luks-encopts-backing", "qcow2"); + + TEST_IMAGE_CREATE("network-gluster-qcow2", NULL); + TEST_IMAGE_CREATE("network-rbd-qcow2", NULL); + TEST_IMAGE_CREATE("network-ssh-qcow2", NULL); + TEST_IMAGE_CREATE("network-sheepdog-qcow2", NULL); + cleanup: virHashFree(diskxmljsondata.schema); qemuTestDriverFree(&driver); diff --git a/tests/qemublocktestdata/imagecreate/luks-encopts.json b/tests/= qemublocktestdata/imagecreate/luks-encopts.json new file mode 100644 index 0000000000..f065ad89a7 --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/luks-encopts.json @@ -0,0 +1,19 @@ +protocol: +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/i.img", + "size": 42 +} + +format: +{ + "key-secret": "0123456789ABCDEF0123456789ABCDE-encalias", + "cipher-alg": "serpent-256", + "cipher-mode": "cbc", + "hash-alg": "sha256", + "ivgen-alg": "plain64", + "ivgen-hash-alg": "sha256", + "driver": "luks", + "file": "0123456789ABCDEF0123456789ABCDE", + "size": 1337 +} diff --git a/tests/qemublocktestdata/imagecreate/luks-encopts.xml b/tests/q= emublocktestdata/imagecreate/luks-encopts.xml new file mode 100644 index 0000000000..bb0ee54adc --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/luks-encopts.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/tests/qemublocktestdata/imagecreate/luks-noopts.json b/tests/q= emublocktestdata/imagecreate/luks-noopts.json new file mode 100644 index 0000000000..1ea1948119 --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/luks-noopts.json @@ -0,0 +1,14 @@ +protocol: +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/i.img", + "size": 42 +} + +format: +{ + "key-secret": "0123456789ABCDEF0123456789ABCDE-encalias", + "driver": "luks", + "file": "0123456789ABCDEF0123456789ABCDE", + "size": 1337 +} diff --git a/tests/qemublocktestdata/imagecreate/luks-noopts.xml b/tests/qe= mublocktestdata/imagecreate/luks-noopts.xml new file mode 100644 index 0000000000..ac224b02de --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/luks-noopts.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/tests/qemublocktestdata/imagecreate/network-gluster-qcow2.json= b/tests/qemublocktestdata/imagecreate/network-gluster-qcow2.json new file mode 100644 index 0000000000..aee7bfd401 --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/network-gluster-qcow2.json @@ -0,0 +1,28 @@ +protocol: +{ + "driver": "gluster", + "location": { + "volume": "asdf", + "path": "i.qcow2", + "server": [ + { + "type": "inet", + "host": "example.com", + "port": "1234" + }, + { + "type": "inet", + "host": "alternate.example.com", + "port": "3214" + } + ] + }, + "size": 42 +} + +format: +{ + "driver": "qcow2", + "file": "0123456789ABCDEF0123456789ABCDE", + "size": 1337 +} diff --git a/tests/qemublocktestdata/imagecreate/network-gluster-qcow2.xml = b/tests/qemublocktestdata/imagecreate/network-gluster-qcow2.xml new file mode 100644 index 0000000000..f3dbf24180 --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/network-gluster-qcow2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/tests/qemublocktestdata/imagecreate/network-rbd-qcow2.json b/t= ests/qemublocktestdata/imagecreate/network-rbd-qcow2.json new file mode 100644 index 0000000000..56d9c0f1ed --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/network-rbd-qcow2.json @@ -0,0 +1,26 @@ +protocol: +{ + "driver": "rbd", + "location": { + "pool": "asdf", + "image": "i.qcow2", + "server": [ + { + "host": "example.com", + "port": "1234" + }, + { + "host": "alternate.example.com", + "port": "4321" + } + ] + }, + "size": 42 +} + +format: +{ + "driver": "qcow2", + "file": "0123456789ABCDEF0123456789ABCDE", + "size": 1337 +} diff --git a/tests/qemublocktestdata/imagecreate/network-rbd-qcow2.xml b/te= sts/qemublocktestdata/imagecreate/network-rbd-qcow2.xml new file mode 100644 index 0000000000..0f6c1ddb98 --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/network-rbd-qcow2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/tests/qemublocktestdata/imagecreate/network-sheepdog-qcow2.jso= n b/tests/qemublocktestdata/imagecreate/network-sheepdog-qcow2.json new file mode 100644 index 0000000000..b7272625a2 --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/network-sheepdog-qcow2.json @@ -0,0 +1,20 @@ +protocol: +{ + "driver": "sheepdog", + "location": { + "server": { + "type": "inet", + "host": "example.com", + "port": "1234" + }, + "vdi": "asdf/i.qcow2" + }, + "size": 42 +} + +format: +{ + "driver": "qcow2", + "file": "0123456789ABCDEF0123456789ABCDE", + "size": 1337 +} diff --git a/tests/qemublocktestdata/imagecreate/network-sheepdog-qcow2.xml= b/tests/qemublocktestdata/imagecreate/network-sheepdog-qcow2.xml new file mode 100644 index 0000000000..1145daafdd --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/network-sheepdog-qcow2.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/tests/qemublocktestdata/imagecreate/network-ssh-qcow2.json b/t= ests/qemublocktestdata/imagecreate/network-ssh-qcow2.json new file mode 100644 index 0000000000..31416ed4fc --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/network-ssh-qcow2.json @@ -0,0 +1,19 @@ +protocol: +{ + "driver": "ssh", + "location": { + "path": "asdf/i.qcow2", + "server": { + "host": "example.com", + "port": "1234" + } + }, + "size": 42 +} + +format: +{ + "driver": "qcow2", + "file": "0123456789ABCDEF0123456789ABCDE", + "size": 1337 +} diff --git a/tests/qemublocktestdata/imagecreate/network-ssh-qcow2.xml b/te= sts/qemublocktestdata/imagecreate/network-ssh-qcow2.xml new file mode 100644 index 0000000000..4c44f81c81 --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/network-ssh-qcow2.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/tests/qemublocktestdata/imagecreate/qcow2-backing-luks.json b/= tests/qemublocktestdata/imagecreate/qcow2-backing-luks.json new file mode 100644 index 0000000000..63ba35dc79 --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/qcow2-backing-luks.json @@ -0,0 +1,15 @@ +protocol: +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/i.qcow2", + "size": 42 +} + +format: +{ + "driver": "qcow2", + "file": "0123456789ABCDEF0123456789ABCDE", + "size": 1337, + "backing-file": "/var/lib/libvirt/images/i.img", + "backing-fmt": "luks" +} diff --git a/tests/qemublocktestdata/imagecreate/qcow2-backing-luks.xml b/t= ests/qemublocktestdata/imagecreate/qcow2-backing-luks.xml new file mode 120000 index 0000000000..5769c2c866 --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/qcow2-backing-luks.xml @@ -0,0 +1 @@ +qcow2.xml \ No newline at end of file diff --git a/tests/qemublocktestdata/imagecreate/qcow2-backing-raw-nbd.json= b/tests/qemublocktestdata/imagecreate/qcow2-backing-raw-nbd.json new file mode 100644 index 0000000000..34ce74a548 --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/qcow2-backing-raw-nbd.json @@ -0,0 +1,15 @@ +protocol: +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/i.qcow2", + "size": 42 +} + +format: +{ + "driver": "qcow2", + "file": "0123456789ABCDEF0123456789ABCDE", + "size": 1337, + "backing-file": "json:{\"driver\":\"nbd\",\"server\":{\"type\":\"inet\",= \"host\":\"example.com\",\"port\":\"1234\"}}", + "backing-fmt": "raw" +} diff --git a/tests/qemublocktestdata/imagecreate/qcow2-backing-raw-nbd.xml = b/tests/qemublocktestdata/imagecreate/qcow2-backing-raw-nbd.xml new file mode 120000 index 0000000000..5769c2c866 --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/qcow2-backing-raw-nbd.xml @@ -0,0 +1 @@ +qcow2.xml \ No newline at end of file diff --git a/tests/qemublocktestdata/imagecreate/qcow2-backing-raw.json b/t= ests/qemublocktestdata/imagecreate/qcow2-backing-raw.json new file mode 100644 index 0000000000..8176c8dadd --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/qcow2-backing-raw.json @@ -0,0 +1,15 @@ +protocol: +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/i.qcow2", + "size": 42 +} + +format: +{ + "driver": "qcow2", + "file": "0123456789ABCDEF0123456789ABCDE", + "size": 1337, + "backing-file": "/var/lib/libvirt/images/i.img", + "backing-fmt": "raw" +} diff --git a/tests/qemublocktestdata/imagecreate/qcow2-backing-raw.xml b/te= sts/qemublocktestdata/imagecreate/qcow2-backing-raw.xml new file mode 120000 index 0000000000..5769c2c866 --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/qcow2-backing-raw.xml @@ -0,0 +1 @@ +qcow2.xml \ No newline at end of file diff --git a/tests/qemublocktestdata/imagecreate/qcow2-luks-encopts-backing= .json b/tests/qemublocktestdata/imagecreate/qcow2-luks-encopts-backing.json new file mode 100644 index 0000000000..a57617dfac --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/qcow2-luks-encopts-backing.json @@ -0,0 +1,24 @@ +protocol: +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/i.qcow2", + "size": 42 +} + +format: +{ + "driver": "qcow2", + "file": "0123456789ABCDEF0123456789ABCDE", + "size": 1337, + "backing-file": "/var/lib/libvirt/images/i.qcow2", + "backing-fmt": "qcow2", + "encrypt": { + "key-secret": "0123456789ABCDEF0123456789ABCDE-encalias", + "cipher-alg": "serpent-256", + "cipher-mode": "cbc", + "hash-alg": "sha256", + "ivgen-alg": "plain64", + "ivgen-hash-alg": "sha256", + "format": "luks" + } +} diff --git a/tests/qemublocktestdata/imagecreate/qcow2-luks-encopts-backing= .xml b/tests/qemublocktestdata/imagecreate/qcow2-luks-encopts-backing.xml new file mode 120000 index 0000000000..6ea018cec2 --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/qcow2-luks-encopts-backing.xml @@ -0,0 +1 @@ +qcow2-luks-encopts.xml \ No newline at end of file diff --git a/tests/qemublocktestdata/imagecreate/qcow2-luks-encopts.json b/= tests/qemublocktestdata/imagecreate/qcow2-luks-encopts.json new file mode 100644 index 0000000000..8796726fcb --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/qcow2-luks-encopts.json @@ -0,0 +1,22 @@ +protocol: +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/i.qcow2", + "size": 42 +} + +format: +{ + "driver": "qcow2", + "file": "0123456789ABCDEF0123456789ABCDE", + "size": 1337, + "encrypt": { + "key-secret": "0123456789ABCDEF0123456789ABCDE-encalias", + "cipher-alg": "serpent-256", + "cipher-mode": "cbc", + "hash-alg": "sha256", + "ivgen-alg": "plain64", + "ivgen-hash-alg": "sha256", + "format": "luks" + } +} diff --git a/tests/qemublocktestdata/imagecreate/qcow2-luks-encopts.xml b/t= ests/qemublocktestdata/imagecreate/qcow2-luks-encopts.xml new file mode 100644 index 0000000000..d6616bd164 --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/qcow2-luks-encopts.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/tests/qemublocktestdata/imagecreate/qcow2-luks-noopts.json b/t= ests/qemublocktestdata/imagecreate/qcow2-luks-noopts.json new file mode 100644 index 0000000000..f9caaee6bb --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/qcow2-luks-noopts.json @@ -0,0 +1,17 @@ +protocol: +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/i.qcow2", + "size": 42 +} + +format: +{ + "driver": "qcow2", + "file": "0123456789ABCDEF0123456789ABCDE", + "size": 1337, + "encrypt": { + "key-secret": "0123456789ABCDEF0123456789ABCDE-encalias", + "format": "luks" + } +} diff --git a/tests/qemublocktestdata/imagecreate/qcow2-luks-noopts.xml b/te= sts/qemublocktestdata/imagecreate/qcow2-luks-noopts.xml new file mode 100644 index 0000000000..e2d1c42424 --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/qcow2-luks-noopts.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/tests/qemublocktestdata/imagecreate/qcow2.json b/tests/qemublo= cktestdata/imagecreate/qcow2.json new file mode 100644 index 0000000000..7142cf67b6 --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/qcow2.json @@ -0,0 +1,13 @@ +protocol: +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/i.qcow2", + "size": 42 +} + +format: +{ + "driver": "qcow2", + "file": "0123456789ABCDEF0123456789ABCDE", + "size": 1337 +} diff --git a/tests/qemublocktestdata/imagecreate/qcow2.xml b/tests/qemubloc= ktestdata/imagecreate/qcow2.xml new file mode 100644 index 0000000000..f3c235f82f --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/qcow2.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/tests/qemublocktestdata/imagecreate/raw-nbd.json b/tests/qemub= locktestdata/imagecreate/raw-nbd.json new file mode 100644 index 0000000000..d1e089e3e3 --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/raw-nbd.json @@ -0,0 +1,4 @@ +protocol: + +format: + diff --git a/tests/qemublocktestdata/imagecreate/raw-nbd.xml b/tests/qemubl= ocktestdata/imagecreate/raw-nbd.xml new file mode 100644 index 0000000000..256bf23797 --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/raw-nbd.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/tests/qemublocktestdata/imagecreate/raw.json b/tests/qemublock= testdata/imagecreate/raw.json new file mode 100644 index 0000000000..06abb25ab9 --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/raw.json @@ -0,0 +1,9 @@ +protocol: +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/i.img", + "size": 42 +} + +format: + diff --git a/tests/qemublocktestdata/imagecreate/raw.xml b/tests/qemublockt= estdata/imagecreate/raw.xml new file mode 100644 index 0000000000..3a91600bd8 --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/raw.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list