From nobody Mon Feb 9 00:06:44 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 1534176161075741.4022172182767; Mon, 13 Aug 2018 09:02:41 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EE11C30A5696; Mon, 13 Aug 2018 16:02:38 +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 ADC012709D; Mon, 13 Aug 2018 16:02:38 +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 4B2173F7D2; Mon, 13 Aug 2018 16:02:38 +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 w7DG1M90002082 for ; Mon, 13 Aug 2018 12:01:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2D03B2166BA5; Mon, 13 Aug 2018 16:01:22 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD5812166BA0 for ; Mon, 13 Aug 2018 16:01:21 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 13 Aug 2018 18:00:32 +0200 Message-Id: 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] [PATCHv2 58/62] 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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 13 Aug 2018 16:02:39 +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 in cases when "device" is empty or it does not match the entry name. 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 f98269b34a..6f49de101f 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -2209,6 +2209,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) { @@ -2223,10 +2255,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; @@ -2235,16 +2267,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"); @@ -2252,23 +2286,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 && STRNEQ_NULLABLE(thisdev, 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