From nobody Mon Feb 9 10:33:24 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1533651854603965.4421909722787; Tue, 7 Aug 2018 07:24:14 -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 69A3A3082A47; Tue, 7 Aug 2018 14:24:12 +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 3588353C7E; Tue, 7 Aug 2018 14:24:12 +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 E22D81800B87; Tue, 7 Aug 2018 14:24:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w77ENPFq010577 for ; Tue, 7 Aug 2018 10:23:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id BF8702166BA2; Tue, 7 Aug 2018 14:23:25 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5CA4A2166BA0 for ; Tue, 7 Aug 2018 14:23:24 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 7 Aug 2018 16:22:42 +0200 Message-Id: <538cbceb3c06e1e9f45e5c1583070548d0f8dd2b.1533651618.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 51/55] qemu: monitor: Report data also for 'qdev' entry in qemuMonitorJSONGetBlockInfo 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Tue, 07 Aug 2018 14:24:13 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" With -blockdev qemu will not report any useful "device" for the data returned by 'query-block'. We need to start using the 'qdev' field to do so. This patch adds data for the 'qdev' field into the returned data structure. Signed-off-by: Peter Krempa --- src/qemu/qemu_monitor_json.c | 69 +++++++++++++++++++++++++++++++++++-----= ---- 1 file changed, 55 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 75f40716ea..0579554016 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -2201,6 +2201,38 @@ qemuMonitorJSONGetBlockDevDevice(virJSONValuePtr dev) } +static int +qemuMonitorJSONBlockInfoAdd(virHashTablePtr table, + struct qemuDomainDiskInfo *info, + const char *entryname) +{ + struct qemuDomainDiskInfo *tmp =3D NULL; + int ret =3D -1; + + if (VIR_ALLOC(tmp) < 0) + goto cleanup; + + *tmp =3D *info; + tmp->nodename =3D NULL; + + if (info->nodename && + VIR_STRDUP(tmp->nodename, info->nodename) < 0) + goto cleanup; + + if (virHashAddEntry(table, entryname, tmp) < 0) + goto cleanup; + + tmp =3D NULL; + ret =3D 0; + + cleanup: + if (tmp) + VIR_FREE(tmp->nodename); + VIR_FREE(tmp); + return ret; +} + + int qemuMonitorJSONGetBlockInfo(qemuMonitorPtr mon, virHashTablePtr table) { @@ -2215,10 +2247,10 @@ int qemuMonitorJSONGetBlockInfo(qemuMonitorPtr mon, for (i =3D 0; i < virJSONValueArraySize(devices); i++) { virJSONValuePtr dev; virJSONValuePtr image; - struct qemuDomainDiskInfo *info; + struct qemuDomainDiskInfo info =3D { false }; const char *thisdev; const char *status; - const char *nodename; + const char *qdev; if (!(dev =3D qemuMonitorJSONGetBlockDev(devices, i))) goto cleanup; @@ -2227,16 +2259,18 @@ int qemuMonitorJSONGetBlockInfo(qemuMonitorPtr mon, goto cleanup; thisdev =3D qemuAliasDiskDriveSkipPrefix(thisdev); + qdev =3D virJSONValueObjectGetString(dev, "qdev"); - if (VIR_ALLOC(info) < 0) - goto cleanup; + if (*thisdev =3D=3D '\0') + thisdev =3D NULL; - if (virHashAddEntry(table, thisdev, info) < 0) { - VIR_FREE(info); + if (!qdev && !thisdev) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("query-block device entry was not in expected= format")); goto cleanup; } - if (virJSONValueObjectGetBoolean(dev, "removable", &info->removabl= e) < 0) { + if (virJSONValueObjectGetBoolean(dev, "removable", &info.removable= ) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot read %s value"), "removable"); @@ -2244,23 +2278,30 @@ int qemuMonitorJSONGetBlockInfo(qemuMonitorPtr mon, } /* 'tray_open' is present only if the device has a tray */ - if (virJSONValueObjectGetBoolean(dev, "tray_open", &info->tray_ope= n) =3D=3D 0) - info->tray =3D true; + if (virJSONValueObjectGetBoolean(dev, "tray_open", &info.tray_open= ) =3D=3D 0) + info.tray =3D true; /* presence of 'inserted' notifies that a medium is in the device = */ if ((image =3D virJSONValueObjectGetObject(dev, "inserted"))) { - if ((nodename =3D virJSONValueObjectGetString(image, "node-nam= e"))) - ignore_value(VIR_STRDUP(info->nodename, nodename)); + info.nodename =3D (char *) virJSONValueObjectGetString(image, = "node-name"); } else { - info->empty =3D true; + info.empty =3D true; } /* Missing io-status indicates no error */ if ((status =3D virJSONValueObjectGetString(dev, "io-status"))) { - info->io_status =3D qemuMonitorBlockIOStatusToError(status); - if (info->io_status < 0) + info.io_status =3D qemuMonitorBlockIOStatusToError(status); + if (info.io_status < 0) goto cleanup; } + + if (thisdev && + qemuMonitorJSONBlockInfoAdd(table, &info, thisdev) < 0) + goto cleanup; + + if (qdev && + qemuMonitorJSONBlockInfoAdd(table, &info, qdev) < 0) + goto cleanup; } ret =3D 0; --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list