From nobody Mon Feb 9 08:30:48 2026 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