From nobody Fri May 16 05:34:26 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1501063442387801.2458232166929; Wed, 26 Jul 2017 03:04:02 -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 77F596572F; Wed, 26 Jul 2017 10:03:57 +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 13DC66FE79; Wed, 26 Jul 2017 10:03:57 +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 C43351805981; Wed, 26 Jul 2017 10:03:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6QA1D3Z008916 for ; Wed, 26 Jul 2017 06:01:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id EBA1E6FE76; Wed, 26 Jul 2017 10:01:13 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 494F86FE6A; Wed, 26 Jul 2017 10:01:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 77F596572F Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 26 Jul 2017 12:00:47 +0200 Message-Id: <6086e81888b18103e1f3c0db4042a2803d02d029.1501062802.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 17/24] qemu: block: store and test driver names for detected storage nodes 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: , MIME-Version: 1.0 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.38]); Wed, 26 Jul 2017 10:03:58 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Store the 'drv' field both for the storage node and for the format node and format them in the test case. --- src/qemu/qemu_block.c | 14 ++++++++++= +--- src/qemu/qemu_block.h | 4 ++++ .../qemumonitorjson-nodename-basic.result | 6 ++++++ tests/qemumonitorjsontest.c | 2 ++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index bca6965fa..348961199 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -56,6 +56,9 @@ qemuBlockNodeNameBackingChainDataFree(qemuBlockNodeNameBa= ckingChainDataPtr data) VIR_FREE(data->qemufilename); + VIR_FREE(data->drvformat); + VIR_FREE(data->drvstorage); + qemuBlockNodeNameBackingChainDataFree(data->backing); VIR_FREE(data); @@ -108,7 +111,8 @@ qemuBlockNodeNameGetBackingChainBacking(virJSONValuePtr= next, virJSONValuePtr parentnodedata; virJSONValuePtr nodedata; const char *nodename =3D virJSONValueObjectGetString(next, "node-name"= ); - const char *drvname; + const char *drvname =3D NULL; + const char *drvparent =3D NULL; const char *parentnodename =3D NULL; const char *filename =3D NULL; int ret =3D -1; @@ -134,8 +138,10 @@ qemuBlockNodeNameGetBackingChainBacking(virJSONValuePt= r next, if (parent && (parentnodename =3D virJSONValueObjectGetString(parent, "node-name= "))) { - if ((parentnodedata =3D virHashLookup(nodenamestable, parentnodena= me))) + if ((parentnodedata =3D virHashLookup(nodenamestable, parentnodena= me))) { filename =3D virJSONValueObjectGetString(parentnodedata, "file= "); + drvparent =3D virJSONValueObjectGetString(parentnodedata, "drv= "); + } } if (VIR_ALLOC(data) < 0) @@ -143,7 +149,9 @@ qemuBlockNodeNameGetBackingChainBacking(virJSONValuePtr= next, if (VIR_STRDUP(data->nodeformat, nodename) < 0 || VIR_STRDUP(data->nodestorage, parentnodename) < 0 || - VIR_STRDUP(data->qemufilename, filename) < 0) + VIR_STRDUP(data->qemufilename, filename) < 0 || + VIR_STRDUP(data->drvformat, drvname) < 0 || + VIR_STRDUP(data->drvstorage, drvparent) < 0) goto cleanup; if (backing && diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index 5d21057a7..c0ed43ec0 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -34,6 +34,10 @@ struct qemuBlockNodeNameBackingChainData { char *nodeformat; /* node name of the format layer */ char *nodestorage; /* node name of the storage backing the format nod= e */ + /* for testing purposes */ + char *drvformat; + char *drvstorage; + qemuBlockNodeNameBackingChainDataPtr backing; }; diff --git a/tests/qemumonitorjsondata/qemumonitorjson-nodename-basic.resul= t b/tests/qemumonitorjsondata/qemumonitorjson-nodename-basic.result index bc183f8b9..ad8b9b46e 100644 --- a/tests/qemumonitorjsondata/qemumonitorjson-nodename-basic.result +++ b/tests/qemumonitorjsondata/qemumonitorjson-nodename-basic.result @@ -1,10 +1,16 @@ drive-virtio-disk0 filename : '/var/lib/libvirt/images/rhel7.3.1483545313' format node : '#block187' +format drv : 'qcow2' storage node: '#block033' +storage drv : 'file' filename : '/var/lib/libvirt/images/rhel7.3.1483536402' format node : '#block306' + format drv : 'qcow2' storage node: '#block220' + storage drv : 'file' filename : '/var/lib/libvirt/images/rhel7.3.qcow2' format node : '#block558' + format drv : 'qcow2' storage node: '#block481' + storage drv : 'file' diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 88169832e..346d5c401 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -2714,8 +2714,10 @@ testBlockNodeNameDetectFormat(void *payload, virBufferAsprintf(buf, "filename : '%s'\n", entry->qemufilename= ); virBufferAsprintf(buf, "format node : '%s'\n", NULLSTR(entry->nodeformat)); + virBufferAsprintf(buf, "format drv : '%s'\n", NULLSTR(entry->drvf= ormat)); virBufferAsprintf(buf, "storage node: '%s'\n", NULLSTR(entry->nodestorage)); + virBufferAsprintf(buf, "storage drv : '%s'\n", NULLSTR(entry->drvs= torage)); virBufferAdjustIndent(buf, 2); --=20 2.13.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list