From nobody Mon Feb 9 18:19:06 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1606757503; cv=none; d=zohomail.com; s=zohoarc; b=RV9cAa0+RPhhw0ayCSHX7Bt62hCqc9+bCXab28yvqlAdVquszbJrB8jn8wMZ6tQ4ANXzgkA/1IsIfkfjMFjTdkGKs/sfWgbeJcjEMwRzYKErX1aNfK0aTx22JUjZk9z6kkTFVO1cd/xX/xmQvgLpgMQKHp73xMXpLdAmfn+stGM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606757503; h=Content-Type:Content-Transfer-Encoding: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; bh=q2eiXr7Z2tfcUrNUUHmeBorvIYpAKaiMEfYuMDy6WOs=; b=ECY7S4+hug9rr9Ag+HLS8wI05W/NsWaJk/vWlqP+cny0TAYlhYcFC8NbkCQzPL2ISu4HxbsupDHGs+vpvz/z70YmJlAwpq/R/AQm+Asf48BQtEK0T7B1gdRPuIlOQXpl+6Sk0aXyYf+tFTjB22VkXiZxxpx+VECMhpJldorvFQI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1606757503063474.0003911256274; Mon, 30 Nov 2020 09:31:43 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-381-aPqKyPeaNgS5zUZkK17q0A-1; Mon, 30 Nov 2020 12:26:41 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 81C03104FB6A; Mon, 30 Nov 2020 17:26:11 +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 7E27A5D6A8; Mon, 30 Nov 2020 17:26:10 +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 CB196180954D; Mon, 30 Nov 2020 17:26:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0AUHQ9sa003721 for ; Mon, 30 Nov 2020 12:26:09 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0A079189BB; Mon, 30 Nov 2020 17:26:09 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 26A2C9CA0 for ; Mon, 30 Nov 2020 17:26:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606757204; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=q2eiXr7Z2tfcUrNUUHmeBorvIYpAKaiMEfYuMDy6WOs=; b=hJl98LWTQVDGX0E/L014giAe+wa76dGIGxaBLXOqdbzk4+u+XMKvBcfL/xHik8xt1TrV/N MA8gCtdzdR4JVwaKFtC31Bknb0u3xAgREXjEFpY28j7bMk09fRn5GM+ndSVWeQYyUnbulb GLlZsIunj8eN/XskvshkE/ZesFsbzls= X-MC-Unique: aPqKyPeaNgS5zUZkK17q0A-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/3] qemuMonitorGetCommandLineOptionParameters: remove the unused function and helpers Date: Mon, 30 Nov 2020 18:25:59 +0100 Message-Id: <63f869e6f74b4467ce649067dd2dae2e722c0c8b.1606757081.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Remove the function along with helpers for caching the reply and tests. Signed-off-by: Peter Krempa --- src/qemu/qemu_monitor.c | 35 ---------- src/qemu/qemu_monitor.h | 8 --- src/qemu/qemu_monitor_json.c | 120 ----------------------------------- src/qemu/qemu_monitor_json.h | 5 -- tests/qemumonitorjsontest.c | 117 ---------------------------------- 5 files changed, 285 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index a60d04f78a..c333fc1364 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -101,9 +101,6 @@ struct _qemuMonitor { bool waitGreeting; - /* cache of query-command-line-options results */ - virJSONValuePtr options; - /* If found, path to the virtio memballoon driver */ char *balloonpath; bool ballooninit; @@ -240,7 +237,6 @@ qemuMonitorDispose(void *obj) virResetError(&mon->lastError); virCondDestroy(&mon->notify); VIR_FREE(mon->buffer); - virJSONValueFree(mon->options); VIR_FREE(mon->balloonpath); } @@ -992,20 +988,6 @@ qemuMonitorLastError(qemuMonitorPtr mon) } -virJSONValuePtr -qemuMonitorGetOptions(qemuMonitorPtr mon) -{ - return mon->options; -} - - -void -qemuMonitorSetOptions(qemuMonitorPtr mon, virJSONValuePtr options) -{ - mon->options =3D options; -} - - /** * Search the qom objects for the balloon driver object by its known names * of "virtio-balloon-pci" or "virtio-balloon-ccw". The entry for the driv= er @@ -3856,23 +3838,6 @@ qemuMonitorGetEvents(qemuMonitorPtr mon, } -/* Collect the parameters associated with a given command line option. - * Return count of known parameters or -1 on error. */ -int -qemuMonitorGetCommandLineOptionParameters(qemuMonitorPtr mon, - const char *option, - char ***params, - bool *found) -{ - VIR_DEBUG("option=3D%s params=3D%p", option, params); - - QEMU_CHECK_MONITOR(mon); - - return qemuMonitorJSONGetCommandLineOptionParameters(mon, option, - params, found); -} - - GHashTable * qemuMonitorGetCommandLineOptions(qemuMonitorPtr mon) { diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 6b2e435f70..3dcceffef8 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -444,10 +444,6 @@ int qemuMonitorSetLink(qemuMonitorPtr mon, char *qemuMonitorNextCommandID(qemuMonitorPtr mon); int qemuMonitorSend(qemuMonitorPtr mon, qemuMonitorMessagePtr msg) G_GNUC_NO_INLINE; -virJSONValuePtr qemuMonitorGetOptions(qemuMonitorPtr mon) - ATTRIBUTE_NONNULL(1); -void qemuMonitorSetOptions(qemuMonitorPtr mon, virJSONValuePtr options) - ATTRIBUTE_NONNULL(1); int qemuMonitorUpdateVideoMemorySize(qemuMonitorPtr mon, virDomainVideoDefPtr video, const char *videoName) @@ -1284,10 +1280,6 @@ int qemuMonitorGetCommands(qemuMonitorPtr mon, char ***commands); int qemuMonitorGetEvents(qemuMonitorPtr mon, char ***events); -int qemuMonitorGetCommandLineOptionParameters(qemuMonitorPtr mon, - const char *option, - char ***params, - bool *found); GHashTable *qemuMonitorGetCommandLineOptions(qemuMonitorPtr mon); int qemuMonitorGetKVMState(qemuMonitorPtr mon, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 44d0152812..5990163519 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -6450,126 +6450,6 @@ qemuMonitorJSONGetCommandLineOptions(qemuMonitorPtr= mon) } -int -qemuMonitorJSONGetCommandLineOptionParameters(qemuMonitorPtr mon, - const char *option, - char ***params, - bool *found) -{ - int ret =3D -1; - virJSONValuePtr cmd =3D NULL; - virJSONValuePtr reply =3D NULL; - virJSONValuePtr data =3D NULL; - virJSONValuePtr array =3D NULL; - char **paramlist =3D NULL; - size_t n =3D 0; - size_t i; - - *params =3D NULL; - if (found) - *found =3D false; - - /* query-command-line-options has fixed output for a given qemu - * binary; but since callers want to query parameters for one - * option at a time, we cache the option list from qemu. */ - if (!(array =3D qemuMonitorGetOptions(mon))) { - if (!(cmd =3D qemuMonitorJSONMakeCommand("query-command-line-optio= ns", - NULL))) - return -1; - - if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; - - if (qemuMonitorJSONHasError(reply, "CommandNotFound")) { - ret =3D 0; - goto cleanup; - } - - if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; - - if (virJSONValueObjectRemoveKey(reply, "return", &array) <=3D 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("query-command-line-options reply was missing= " - "return data")); - goto cleanup; - } - - if (!virJSONValueIsArray(array)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Malformed query-command-line-options array")= ); - goto cleanup; - } - - qemuMonitorSetOptions(mon, array); - } - - for (i =3D 0; i < virJSONValueArraySize(array); i++) { - virJSONValuePtr child =3D virJSONValueArrayGet(array, i); - const char *tmp; - - if (!(tmp =3D virJSONValueObjectGetString(child, "option"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("query-command-line-options reply data was " - "missing 'option'")); - goto cleanup; - } - if (STREQ(tmp, option)) { - data =3D virJSONValueObjectGet(child, "parameters"); - break; - } - } - - if (!data) { - /* Option not found; return 0 parameters rather than an error. */ - ret =3D 0; - goto cleanup; - } - - if (found) - *found =3D true; - - if (!virJSONValueIsArray(data)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Malformed query-command-line-options parameters = array")); - goto cleanup; - } - n =3D virJSONValueArraySize(data); - - /* null-terminated list */ - paramlist =3D g_new0(char *, n + 1); - - for (i =3D 0; i < n; i++) { - virJSONValuePtr child =3D virJSONValueArrayGet(data, i); - const char *tmp; - - if (!(tmp =3D virJSONValueObjectGetString(child, "name"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("query-command-line-options parameter data wa= s " - "missing 'name'")); - goto cleanup; - } - - paramlist[i] =3D g_strdup(tmp); - } - - ret =3D n; - *params =3D paramlist; - paramlist =3D NULL; - - cleanup: - /* If we failed before getting the JSON array of options, we (try) - * to cache an empty array to speed up the next failure. */ - if (!qemuMonitorGetOptions(mon)) - qemuMonitorSetOptions(mon, virJSONValueNewArray()); - - g_strfreev(paramlist); - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; -} - - int qemuMonitorJSONGetKVMState(qemuMonitorPtr mon, bool *enabled, bool *present) diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 53445b97bb..da988f0d41 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -425,11 +425,6 @@ int qemuMonitorJSONGetCommands(qemuMonitorPtr mon, int qemuMonitorJSONGetEvents(qemuMonitorPtr mon, char ***events) ATTRIBUTE_NONNULL(2); -int qemuMonitorJSONGetCommandLineOptionParameters(qemuMonitorPtr mon, - const char *option, - char ***params, - bool *found) - ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); GHashTable *qemuMonitorJSONGetCommandLineOptions(qemuMonitorPtr mon); int qemuMonitorJSONGetKVMState(qemuMonitorPtr mon, diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 25ebf06eb0..d22a92d3e1 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -616,122 +616,6 @@ testQemuMonitorJSONGetTPMModels(const void *opaque) } -static int -testQemuMonitorJSONGetCommandLineOptionParameters(const void *opaque) -{ - const testGenericData *data =3D opaque; - virDomainXMLOptionPtr xmlopt =3D data->xmlopt; - int ret =3D -1; - char **params =3D NULL; - int nparams =3D 0; - bool found =3D false; - g_autoptr(qemuMonitorTest) test =3D NULL; - - if (!(test =3D qemuMonitorTestNewSchema(xmlopt, data->schema))) - return -1; - - if (qemuMonitorTestAddItem(test, "query-command-line-options", - "{ " - " \"return\": [ " - " {\"parameters\": [], \"option\": \"acpi\= " }," - " {\"parameters\": [" - " {\"name\": \"romfile\", " - " \"type\": \"string\"}, " - " {\"name\": \"bootindex\", " - " \"type\": \"number\"}], " - " \"option\": \"option-rom\"}" - " ]" - "}") < 0) - goto cleanup; - - /* present with params */ - if ((nparams =3D qemuMonitorGetCommandLineOptionParameters(qemuMonitor= TestGetMonitor(test), - "option-rom", - ¶ms, - NULL)) < 0) - goto cleanup; - - if (nparams !=3D 2) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "nparams was %d, expected 2", nparams); - goto cleanup; - } - -#define CHECK(i, wantname) \ - do { \ - if (STRNEQ(params[i], (wantname))) { \ - virReportError(VIR_ERR_INTERNAL_ERROR, \ - "name was %s, expected %s", \ - params[i], (wantname)); \ - goto cleanup; \ - } \ - } while (0) - - CHECK(0, "romfile"); - CHECK(1, "bootindex"); - -#undef CHECK - - g_strfreev(params); - params =3D NULL; - - /* present but empty */ - if ((nparams =3D qemuMonitorGetCommandLineOptionParameters(qemuMonitor= TestGetMonitor(test), - "acpi", - ¶ms, - &found)) < 0) - goto cleanup; - - if (nparams !=3D 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "nparams was %d, expected 0", nparams); - goto cleanup; - } - if (!found) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - "found was false, expected true"); - goto cleanup; - } - if (params && params[0]) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - "unexpected array contents"); - goto cleanup; - } - - g_strfreev(params); - params =3D NULL; - - /* no such option */ - if ((nparams =3D qemuMonitorGetCommandLineOptionParameters(qemuMonitor= TestGetMonitor(test), - "foobar", - ¶ms, - &found)) < 0) - goto cleanup; - - if (nparams !=3D 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "nparams was %d, expected 0", nparams); - goto cleanup; - } - if (found) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - "found was true, expected false"); - goto cleanup; - } - if (params && params[0]) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - "unexpected array contents"); - goto cleanup; - } - - ret =3D 0; - - cleanup: - g_strfreev(params); - return ret; -} - - struct qemuMonitorJSONTestAttachChardevData { qemuMonitorTestPtr test; virDomainChrSourceDefPtr chr; @@ -3256,7 +3140,6 @@ mymain(void) DO_TEST(GetCPUDefinitions); DO_TEST(GetCommands); DO_TEST(GetTPMModels); - DO_TEST(GetCommandLineOptionParameters); if (qemuMonitorJSONTestAttachChardev(driver.xmlopt, qapiData.schema) <= 0) ret =3D -1; DO_TEST(DetachChardev); --=20 2.28.0