From nobody Thu May 2 02:51:27 2024 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 1541216133251229.9643587653618; Fri, 2 Nov 2018 20:35:33 -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 1E5F930001DA; Sat, 3 Nov 2018 03:35:31 +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 C5B755D6A9; Sat, 3 Nov 2018 03:35:30 +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 692E2180B5B7; Sat, 3 Nov 2018 03:35:30 +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 wA33DuxB011344 for ; Fri, 2 Nov 2018 23:13:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4D0C85D75D; Sat, 3 Nov 2018 03:13:56 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6EC535D6A9; Sat, 3 Nov 2018 03:13:55 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:02 -0500 Message-Id: <20181103031338.11600-2-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 01/37] qemu_monitor: Introduce qemuMonitorCPUModelInfoNew 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.46]); Sat, 03 Nov 2018 03:35:31 +0000 (UTC) Content-Type: text/plain; charset="utf-8" A helper function allocates an initializes model name in CPU Model Info structs. Signed-off-by: Chris Venteicher --- src/qemu/qemu_capabilities.c | 2 +- src/qemu/qemu_monitor.c | 32 +++++++++++++++++++++++++++----- src/qemu/qemu_monitor.h | 2 ++ 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 2ca5af3297..eb9dca05f8 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3024,7 +3024,7 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsPtr qemuCa= ps, goto cleanup; } =20 - if (VIR_ALLOC(hostCPU) < 0) + if (!(hostCPU =3D qemuMonitorCPUModelInfoNew(NULL))) goto cleanup; =20 if (!(hostCPU->name =3D virXMLPropString(hostCPUNode, "model"))) { diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 7f7013e115..45a4568fcc 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3670,6 +3670,31 @@ qemuMonitorGetCPUModelExpansion(qemuMonitorPtr mon, } =20 =20 +qemuMonitorCPUModelInfoPtr +qemuMonitorCPUModelInfoNew(const char *name) +{ + qemuMonitorCPUModelInfoPtr ret =3D NULL; + qemuMonitorCPUModelInfoPtr model; + + if (VIR_ALLOC(model) < 0) + return NULL; + + model->name =3D NULL; + model->nprops =3D 0; + model->props =3D NULL; + model->migratability =3D false; + + if (VIR_STRDUP(model->name, name) < 0) + goto cleanup; + + VIR_STEAL_PTR(ret, model); + + cleanup: + qemuMonitorCPUModelInfoFree(model); + return ret; +} + + void qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfoPtr model_info) { @@ -3693,18 +3718,15 @@ qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfo= Ptr model_info) qemuMonitorCPUModelInfoPtr qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModelInfo *orig) { - qemuMonitorCPUModelInfoPtr copy; + qemuMonitorCPUModelInfoPtr copy =3D NULL; size_t i; =20 - if (VIR_ALLOC(copy) < 0) + if (!orig || !(copy =3D qemuMonitorCPUModelInfoNew(orig->name))) goto error; =20 if (VIR_ALLOC_N(copy->props, orig->nprops) < 0) goto error; =20 - if (VIR_STRDUP(copy->name, orig->name) < 0) - goto error; - copy->migratability =3D orig->migratability; copy->nprops =3D orig->nprops; =20 diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 48b142a4f4..d87b5a4ec0 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1042,6 +1042,8 @@ int qemuMonitorGetCPUModelExpansion(qemuMonitorPtr mo= n, =20 void qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfoPtr model_info); =20 +qemuMonitorCPUModelInfoPtr qemuMonitorCPUModelInfoNew(const char *name); + qemuMonitorCPUModelInfoPtr qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModelInfo *orig); =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 154121651611883.80490861127896; Fri, 2 Nov 2018 20:41:56 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EF85E307D922; Sat, 3 Nov 2018 03:41:53 +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 5AFA5600CD; Sat, 3 Nov 2018 03:41:53 +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 687924BB79; Sat, 3 Nov 2018 03:41:52 +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 wA33Dv54011354 for ; Fri, 2 Nov 2018 23:13:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 518775D75D; Sat, 3 Nov 2018 03:13:57 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 850C45D6A9; Sat, 3 Nov 2018 03:13:56 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:03 -0500 Message-Id: <20181103031338.11600-3-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 02/37] qemu_monitor: Introduce qemuMonitorCPUModelInfo / JSON conversion 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Sat, 03 Nov 2018 03:41:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Conversion functions are used convert CPUModelInfo structs into QMP JSON and the reverse. QMP JSON is of form: {"model": {"name": "IvyBridge", "props": {}}} qemuMonitorCPUModelInfoBoolPropAdd is used to add boolean properties to CPUModelInfo struct. qemuMonitorJSONGetCPUModelExpansion makes full use of conversions and propAdd in prep to support input of full cpu model in future. Signed-off-by: Chris Venteicher --- src/qemu/qemu_monitor.c | 24 ++++++ src/qemu/qemu_monitor.h | 5 ++ src/qemu/qemu_monitor_json.c | 154 +++++++++++++++++++++++++---------- 3 files changed, 138 insertions(+), 45 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 45a4568fcc..801c072eff 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3764,6 +3764,30 @@ qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUMode= lInfo *orig) } =20 =20 +int +qemuMonitorCPUModelInfoBoolPropAdd(qemuMonitorCPUModelInfoPtr model, + const char *prop_name, + bool prop_value) +{ + int ret =3D -1; + qemuMonitorCPUProperty prop; + prop.type =3D QEMU_MONITOR_CPU_PROPERTY_BOOLEAN; + prop.value.boolean =3D prop_value; + + if (VIR_STRDUP(prop.name, prop_name) < 0) + goto cleanup; + + if (VIR_APPEND_ELEMENT(model->props, model->nprops, prop) < 0) + goto cleanup; + + ret =3D 0; + + cleanup: + VIR_FREE(prop.name); + return ret; +} + + int qemuMonitorGetCommands(qemuMonitorPtr mon, char ***commands) diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index d87b5a4ec0..0a09590ed1 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1047,6 +1047,11 @@ qemuMonitorCPUModelInfoPtr qemuMonitorCPUModelInfoNe= w(const char *name); qemuMonitorCPUModelInfoPtr qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModelInfo *orig); =20 +int qemuMonitorCPUModelInfoBoolPropAdd(qemuMonitorCPUModelInfoPtr model, + const char *prop_name, + bool prop_value) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); + int qemuMonitorGetCommands(qemuMonitorPtr mon, char ***commands); int qemuMonitorGetEvents(qemuMonitorPtr mon, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 3de298c9e2..f20e9e9379 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5505,6 +5505,101 @@ qemuMonitorJSONParseCPUModelProperty(const char *ke= y, return 0; } =20 + +/* model_json: {"name": "z13-base", "props": {}} + */ +static virJSONValuePtr +qemuMonitorJSONBuildCPUModelInfoToJSON(qemuMonitorCPUModelInfoPtr model) +{ + virJSONValuePtr cpu_props =3D NULL; + virJSONValuePtr model_json =3D NULL; + size_t i; + + if (!model) + goto cleanup; + + if (model->nprops > 0 && !(cpu_props =3D virJSONValueNewObject())) + goto cleanup; + + for (i =3D 0; i < model->nprops; i++) { + qemuMonitorCPUPropertyPtr prop =3D &(model->props[i]); + + switch (prop->type) { + case QEMU_MONITOR_CPU_PROPERTY_BOOLEAN: + if (virJSONValueObjectAppendBoolean(cpu_props, prop->name, + prop->value.boolean) < 0) + goto cleanup; + break; + + case QEMU_MONITOR_CPU_PROPERTY_STRING: + if (virJSONValueObjectAppendString(cpu_props, prop->name, + prop->value.string) < 0) + goto cleanup; + break; + + case QEMU_MONITOR_CPU_PROPERTY_NUMBER: + if (virJSONValueObjectAppendNumberLong(cpu_props, prop->name, + prop->value.number) < 0) + goto cleanup; + break; + + case QEMU_MONITOR_CPU_PROPERTY_LAST: + default: + virReportEnumRangeError(qemuMonitorCPUPropertyPtr, prop->type); + goto cleanup; + } + } + + ignore_value(virJSONValueObjectCreate(&model_json, "s:name", model->na= me, + "A:props", &cpu_props, NULL)); + + cleanup: + virJSONValueFree(cpu_props); + return model_json; +} + + +/* model_json: {"name": "IvyBridge", "props": {}} + */ +static qemuMonitorCPUModelInfoPtr +qemuMonitorJSONBuildCPUModelInfoFromJSON(virJSONValuePtr cpu_model) +{ + virJSONValuePtr cpu_props; + qemuMonitorCPUModelInfoPtr model =3D NULL; + qemuMonitorCPUModelInfoPtr ret =3D NULL; + char const *cpu_name; + + if (!(cpu_name =3D virJSONValueObjectGetString(cpu_model, "name"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Parsed JSON reply missing 'name'")); + goto cleanup; + } + + if (VIR_ALLOC(model) < 0) + goto cleanup; + + if (VIR_STRDUP(model->name, cpu_name) < 0) + goto cleanup; + + if ((cpu_props =3D virJSONValueObjectGetObject(cpu_model, "props"))) { + if (VIR_ALLOC_N(model->props, + virJSONValueObjectKeysNumber(cpu_props)) < 0) + goto cleanup; + + if (virJSONValueObjectForeachKeyValue(cpu_props, + qemuMonitorJSONParseCPUModel= Property, + model) < 0) + goto cleanup; + } + + VIR_STEAL_PTR(ret, model); + + cleanup: + qemuMonitorCPUModelInfoFree(model); + + return ret; +} + int qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr mon, qemuMonitorCPUModelExpansionType type, @@ -5513,32 +5608,25 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr = mon, qemuMonitorCPUModelInfoPtr *model_info) { int ret =3D -1; - virJSONValuePtr model =3D NULL; - virJSONValuePtr props =3D NULL; + virJSONValuePtr json_model_in =3D NULL; virJSONValuePtr cmd =3D NULL; virJSONValuePtr reply =3D NULL; virJSONValuePtr data; virJSONValuePtr cpu_model; - virJSONValuePtr cpu_props; - qemuMonitorCPUModelInfoPtr machine_model =3D NULL; - char const *cpu_name; + qemuMonitorCPUModelInfoPtr model_in =3D NULL; const char *typeStr =3D ""; =20 *model_info =3D NULL; =20 - if (!(model =3D virJSONValueNewObject())) + if (!(model_in =3D qemuMonitorCPUModelInfoNew(model_name))) goto cleanup; =20 - if (virJSONValueObjectAppendString(model, "name", model_name) < 0) + if (!migratable && + qemuMonitorCPUModelInfoBoolPropAdd(model_in, "migratable", false) = < 0) goto cleanup; =20 - if (!migratable) { - if (!(props =3D virJSONValueNewObject()) || - virJSONValueObjectAppendBoolean(props, "migratable", false) < = 0 || - virJSONValueObjectAppend(model, "props", props) < 0) - goto cleanup; - props =3D NULL; - } + if (!(json_model_in =3D qemuMonitorJSONBuildCPUModelInfoToJSON(model_i= n))) + goto cleanup; =20 retry: switch (type) { @@ -5554,7 +5642,7 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr mo= n, =20 if (!(cmd =3D qemuMonitorJSONMakeCommand("query-cpu-model-expansion", "s:type", typeStr, - "a:model", &model, + "a:model", &json_model_in, NULL))) goto cleanup; =20 @@ -5585,7 +5673,9 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr mo= n, * on the result of the initial "static" expansion. */ if (type =3D=3D QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC_FULL) { - if (!(model =3D virJSONValueCopy(cpu_model))) + virJSONValueFree(json_model_in); + + if (!(json_model_in =3D virJSONValueCopy(cpu_model))) goto cleanup; =20 virJSONValueFree(cmd); @@ -5594,42 +5684,16 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr = mon, goto retry; } =20 - if (!(cpu_name =3D virJSONValueObjectGetString(cpu_model, "name"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("query-cpu-model-expansion reply data was missing= 'name'")); - goto cleanup; - } - - if (!(cpu_props =3D virJSONValueObjectGetObject(cpu_model, "props"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("query-cpu-model-expansion reply data was missing= 'props'")); - goto cleanup; - } - - if (VIR_ALLOC(machine_model) < 0) - goto cleanup; - - if (VIR_STRDUP(machine_model->name, cpu_name) < 0) - goto cleanup; - - if (VIR_ALLOC_N(machine_model->props, virJSONValueObjectKeysNumber(cpu= _props)) < 0) - goto cleanup; - - if (virJSONValueObjectForeachKeyValue(cpu_props, - qemuMonitorJSONParseCPUModelProp= erty, - machine_model) < 0) + if (!(*model_info =3D qemuMonitorJSONBuildCPUModelInfoFromJSON(cpu_mod= el))) goto cleanup; =20 ret =3D 0; - *model_info =3D machine_model; - machine_model =3D NULL; =20 cleanup: - qemuMonitorCPUModelInfoFree(machine_model); + qemuMonitorCPUModelInfoFree(model_in); virJSONValueFree(cmd); virJSONValueFree(reply); - virJSONValueFree(model); - virJSONValueFree(props); + virJSONValueFree(json_model_in); return ret; } =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 1541216144242865.8697040761426; Fri, 2 Nov 2018 20:35:44 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 460593001E6E; Sat, 3 Nov 2018 03:35:42 +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 12D3A600D4; Sat, 3 Nov 2018 03:35:42 +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 C16274BB79; Sat, 3 Nov 2018 03:35:41 +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 wA33DwUQ011360 for ; Fri, 2 Nov 2018 23:13:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 706425D760; Sat, 3 Nov 2018 03:13:58 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8BB0B5D6A9; Sat, 3 Nov 2018 03:13:57 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:04 -0500 Message-Id: <20181103031338.11600-4-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 03/37] qemu_capabilities: Introduce virQEMuCapsMigratablePropsDiff 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Sat, 03 Nov 2018 03:35:42 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Create an augmented CPUModelInfo identifying which props are/aren't migratable based on a diff between migratable and non-migratable inputs. This patch pulls existing logic out of virQEMUCapsProbeQMPHostCPU and wraps the existing logic in a standalone function hopefully simplifying both functions and making the inputs and outputs clearer. The patch also sets cpuData->info =3D NULL to make sure bad data does not remain in failure cases. Q) Can the right people quickly determine if they should review this? Signed-off-by: Chris Venteicher --- src/qemu/qemu_capabilities.c | 131 ++++++++++++++++++++++++----------- 1 file changed, 92 insertions(+), 39 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index eb9dca05f8..c8e9b8f65d 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2355,14 +2355,91 @@ virQEMUCapsProbeQMPCPUDefinitions(virQEMUCapsPtr qe= muCaps, } =20 =20 +/* virQEMUCapsMigratablePropsDiff + * @migratable: input where all migratable props have value true + * and non-migratable and unsupported props have value false + * + * @nonMigratable: input where all migratable & non-migratable props + * have value true and unsupported props have value false + * + * @augmented: output including all props listed in @migratable but + * both migratable & non-migratable props have value true, + * unsupported props have value false, + * and prop->migratable is set to VIR_TRISTATE_BOOL_{YES/NO} + * for each supported prop + * + * Differences in expanded CPUModelInfo inputs @migratable and @nonMigrata= ble are + * used to create output @augmented where individual props have prop->migr= atable + * set to indicate if prop is or isn't migratable. + */ +static int +virQEMUCapsMigratablePropsDiff(qemuMonitorCPUModelInfoPtr migratable, + qemuMonitorCPUModelInfoPtr nonMigratable, + qemuMonitorCPUModelInfoPtr *augmented) +{ + int ret =3D -1; + qemuMonitorCPUModelInfoPtr tmp; + qemuMonitorCPUPropertyPtr prop; + qemuMonitorCPUPropertyPtr mProp; + qemuMonitorCPUPropertyPtr nmProp; + virHashTablePtr hash =3D NULL; + size_t i; + + *augmented =3D NULL; + + if (!(tmp =3D qemuMonitorCPUModelInfoCopy(migratable))) + goto cleanup; + + if (!nonMigratable) + goto done; + + if (!(hash =3D virHashCreate(0, NULL))) + goto cleanup; + + for (i =3D 0; i < tmp->nprops; i++) { + prop =3D tmp->props + i; + + if (virHashAddEntry(hash, prop->name, prop) < 0) + goto cleanup; + } + + for (i =3D 0; i < nonMigratable->nprops; i++) { + nmProp =3D nonMigratable->props + i; + + if (!(mProp =3D virHashLookup(hash, nmProp->name)) || + mProp->type !=3D QEMU_MONITOR_CPU_PROPERTY_BOOLEAN || + mProp->type !=3D nmProp->type) + continue; /* In non-migratable list but not in migratable lis= t */ + + if (mProp->value.boolean) { + mProp->migratable =3D VIR_TRISTATE_BOOL_YES; + } else if (nmProp->value.boolean) { + mProp->value.boolean =3D true; + mProp->migratable =3D VIR_TRISTATE_BOOL_NO; + } + } + + tmp->migratability =3D true; + + done: + VIR_STEAL_PTR(*augmented, tmp); + ret =3D 0; + + cleanup: + qemuMonitorCPUModelInfoFree(tmp); + virHashFree(hash); + return ret; +} + + static int virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps, qemuMonitorPtr mon, bool tcg) { - qemuMonitorCPUModelInfoPtr modelInfo =3D NULL; + qemuMonitorCPUModelInfoPtr migratable =3D NULL; qemuMonitorCPUModelInfoPtr nonMigratable =3D NULL; - virHashTablePtr hash =3D NULL; + qemuMonitorCPUModelInfoPtr augmented =3D NULL; const char *model; qemuMonitorCPUModelExpansionType type; virDomainVirtType virtType; @@ -2381,6 +2458,7 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps, } =20 cpuData =3D virQEMUCapsGetHostCPUData(qemuCaps, virtType); + cpuData->info =3D NULL; =20 /* Some x86_64 features defined in cpu_map.xml use spelling which diff= er * from the one preferred by QEMU. Static expansion would give us only= the @@ -2392,54 +2470,29 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps, else type =3D QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC; =20 - if (qemuMonitorGetCPUModelExpansion(mon, type, model, true, &modelInfo= ) < 0) + if (qemuMonitorGetCPUModelExpansion(mon, type, model, true, &migratabl= e) < 0) + goto cleanup; + + if (!migratable) { + ret =3D 0; /* Qemu can't expand the model name, exit without = error */ goto cleanup; + } =20 /* Try to check migratability of each feature. */ - if (modelInfo && - qemuMonitorGetCPUModelExpansion(mon, type, model, false, + if (qemuMonitorGetCPUModelExpansion(mon, type, model, false, &nonMigratable) < 0) goto cleanup; =20 - if (nonMigratable) { - qemuMonitorCPUPropertyPtr prop; - qemuMonitorCPUPropertyPtr nmProp; - size_t i; - - if (!(hash =3D virHashCreate(0, NULL))) - goto cleanup; - - for (i =3D 0; i < modelInfo->nprops; i++) { - prop =3D modelInfo->props + i; - if (virHashAddEntry(hash, prop->name, prop) < 0) - goto cleanup; - } - - for (i =3D 0; i < nonMigratable->nprops; i++) { - nmProp =3D nonMigratable->props + i; - if (!(prop =3D virHashLookup(hash, nmProp->name)) || - prop->type !=3D QEMU_MONITOR_CPU_PROPERTY_BOOLEAN || - prop->type !=3D nmProp->type) - continue; - - if (prop->value.boolean) { - prop->migratable =3D VIR_TRISTATE_BOOL_YES; - } else if (nmProp->value.boolean) { - prop->value.boolean =3D true; - prop->migratable =3D VIR_TRISTATE_BOOL_NO; - } - } - - modelInfo->migratability =3D true; - } + if (virQEMUCapsMigratablePropsDiff(migratable, nonMigratable, &augment= ed) < 0) + goto cleanup; =20 - VIR_STEAL_PTR(cpuData->info, modelInfo); + VIR_STEAL_PTR(cpuData->info, augmented); ret =3D 0; =20 cleanup: - virHashFree(hash); + qemuMonitorCPUModelInfoFree(migratable); qemuMonitorCPUModelInfoFree(nonMigratable); - qemuMonitorCPUModelInfoFree(modelInfo); + qemuMonitorCPUModelInfoFree(augmented); =20 return ret; } --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 1541216099872219.95946819606922; Fri, 2 Nov 2018 20:34:59 -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 24995811C0; Sat, 3 Nov 2018 03:34:57 +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 D45431055009; Sat, 3 Nov 2018 03:34:56 +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 8B61F4CA95; Sat, 3 Nov 2018 03:34:56 +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 wA33DxEZ011368 for ; Fri, 2 Nov 2018 23:13:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7ED8C5D76A; Sat, 3 Nov 2018 03:13:59 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id B33C85D6A9; Sat, 3 Nov 2018 03:13:58 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:05 -0500 Message-Id: <20181103031338.11600-5-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 04/37] qemu_monitor: qemuMonitorGetCPUModelExpansion inputs and outputs CPUModelInfo 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.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sat, 03 Nov 2018 03:34:57 +0000 (UTC) Content-Type: text/plain; charset="utf-8" A Full CPUModelInfo structure with props is sent to QEMU for expansion. virQEMUCapsProbeQMPHostCPU migratability logic partitioned into new function for clarity. Signed-off-by: Chris Venteicher --- src/qemu/qemu_capabilities.c | 8 +++++--- src/qemu/qemu_monitor.c | 31 ++++++++++++++++++++++++++----- src/qemu/qemu_monitor.h | 5 +++-- src/qemu/qemu_monitor_json.c | 16 +++++++++++----- src/qemu/qemu_monitor_json.h | 6 +++--- tests/cputest.c | 11 ++++++++--- 6 files changed, 56 insertions(+), 21 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index c8e9b8f65d..b2bb2347fd 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2437,6 +2437,7 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps, qemuMonitorPtr mon, bool tcg) { + qemuMonitorCPUModelInfoPtr input; qemuMonitorCPUModelInfoPtr migratable =3D NULL; qemuMonitorCPUModelInfoPtr nonMigratable =3D NULL; qemuMonitorCPUModelInfoPtr augmented =3D NULL; @@ -2470,7 +2471,8 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps, else type =3D QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC; =20 - if (qemuMonitorGetCPUModelExpansion(mon, type, model, true, &migratabl= e) < 0) + if (!(input =3D qemuMonitorCPUModelInfoNew(model)) || + qemuMonitorGetCPUModelExpansion(mon, type, true, input, &migratabl= e) < 0) goto cleanup; =20 if (!migratable) { @@ -2479,8 +2481,7 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps, } =20 /* Try to check migratability of each feature. */ - if (qemuMonitorGetCPUModelExpansion(mon, type, model, false, - &nonMigratable) < 0) + if (qemuMonitorGetCPUModelExpansion(mon, type, false, input, &nonMigra= table) < 0) goto cleanup; =20 if (virQEMUCapsMigratablePropsDiff(migratable, nonMigratable, &augment= ed) < 0) @@ -2490,6 +2491,7 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps, ret =3D 0; =20 cleanup: + qemuMonitorCPUModelInfoFree(input); qemuMonitorCPUModelInfoFree(migratable); qemuMonitorCPUModelInfoFree(nonMigratable); qemuMonitorCPUModelInfoFree(augmented); diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 801c072eff..4c0c2decf7 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3653,20 +3653,41 @@ qemuMonitorCPUDefInfoFree(qemuMonitorCPUDefInfoPtr = cpu) } =20 =20 +/** + * qemuMonitorGetCPUModelExpansion: + * @mon: + * @type: qemuMonitorCPUModelExpansionType + * @migratable: Prompt QEMU to include non-migratable props for X86 models= if false + * @input: Input model + * @expansion: Expanded output model (or NULL if QEMU rejects model or req= uest) + * + * Re-represent @input CPU props using a new CPUModelInfo constructed + * by naming a STATIC or DYNAMIC model cooresponding to a set of propertie= s and + * a FULL or PARTIAL (only deltas from model) property list. + * + * if @type =3D=3D QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC + * construct @expansion using STATIC model name and a PARTIAL (delta) pr= operty list + * + * if @type =3D=3D QEMU_MONITOR_CPU_MODEL_EXPANSION_FULL + * construct @expansion using DYNAMIC model name and a FULL property list + * + * if @type =3D=3D QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC_FULL + * construct @expansion using STATIC model name and a FULL property list + */ int qemuMonitorGetCPUModelExpansion(qemuMonitorPtr mon, qemuMonitorCPUModelExpansionType type, - const char *model_name, bool migratable, - qemuMonitorCPUModelInfoPtr *model_info) + qemuMonitorCPUModelInfoPtr input, + qemuMonitorCPUModelInfoPtr *expansion + ) { VIR_DEBUG("type=3D%d model_name=3D%s migratable=3D%d", - type, model_name, migratable); + type, input->name, migratable); =20 QEMU_CHECK_MONITOR(mon); =20 - return qemuMonitorJSONGetCPUModelExpansion(mon, type, model_name, - migratable, model_info); + return qemuMonitorJSONGetCPUModelExpansion(mon, type, migratable, inpu= t, expansion); } =20 =20 diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 0a09590ed1..d3efd37099 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1036,9 +1036,10 @@ typedef enum { =20 int qemuMonitorGetCPUModelExpansion(qemuMonitorPtr mon, qemuMonitorCPUModelExpansionType type, - const char *model_name, bool migratable, - qemuMonitorCPUModelInfoPtr *model_info= ); + qemuMonitorCPUModelInfoPtr input, + qemuMonitorCPUModelInfoPtr *expansion) + ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5); =20 void qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfoPtr model_info); =20 diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index f20e9e9379..2eabfdac70 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5600,12 +5600,13 @@ qemuMonitorJSONBuildCPUModelInfoFromJSON(virJSONVal= uePtr cpu_model) return ret; } =20 + int qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr mon, qemuMonitorCPUModelExpansionType type, - const char *model_name, bool migratable, - qemuMonitorCPUModelInfoPtr *model_info) + qemuMonitorCPUModelInfoPtr input, + qemuMonitorCPUModelInfoPtr *expansion) { int ret =3D -1; virJSONValuePtr json_model_in =3D NULL; @@ -5613,12 +5614,13 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr = mon, virJSONValuePtr reply =3D NULL; virJSONValuePtr data; virJSONValuePtr cpu_model; + qemuMonitorCPUModelInfoPtr expanded_model =3D NULL; qemuMonitorCPUModelInfoPtr model_in =3D NULL; const char *typeStr =3D ""; =20 - *model_info =3D NULL; + *expansion =3D NULL; =20 - if (!(model_in =3D qemuMonitorCPUModelInfoNew(model_name))) + if (!(model_in =3D qemuMonitorCPUModelInfoCopy(input))) goto cleanup; =20 if (!migratable && @@ -5684,13 +5686,17 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr = mon, goto retry; } =20 - if (!(*model_info =3D qemuMonitorJSONBuildCPUModelInfoFromJSON(cpu_mod= el))) + if (!(expanded_model =3D qemuMonitorJSONBuildCPUModelInfoFromJSON(cpu_= model))) goto cleanup; =20 + VIR_STEAL_PTR(*expansion, expanded_model); ret =3D 0; =20 cleanup: + VIR_FREE(expanded_model); /* Free structure but not reused contents */ qemuMonitorCPUModelInfoFree(model_in); + qemuMonitorCPUModelInfoFree(expanded_model); + virJSONValueFree(cmd); virJSONValueFree(reply); virJSONValueFree(json_model_in); diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index da267b15b0..2d5679094e 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -367,10 +367,10 @@ int qemuMonitorJSONGetCPUDefinitions(qemuMonitorPtr m= on, =20 int qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr mon, qemuMonitorCPUModelExpansionType t= ype, - const char *model_name, bool migratable, - qemuMonitorCPUModelInfoPtr *model_= info) - ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(5); + qemuMonitorCPUModelInfoPtr input, + qemuMonitorCPUModelInfoPtr *expans= ion) + ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5); =20 int qemuMonitorJSONGetCommands(qemuMonitorPtr mon, char ***commands) diff --git a/tests/cputest.c b/tests/cputest.c index 339119c63f..c438a8d09e 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -483,6 +483,7 @@ cpuTestMakeQEMUCaps(const struct data *data) virQEMUCapsPtr qemuCaps =3D NULL; qemuMonitorTestPtr testMon =3D NULL; qemuMonitorCPUModelInfoPtr model =3D NULL; + qemuMonitorCPUModelInfoPtr expansion =3D NULL; char *json =3D NULL; =20 if (virAsprintf(&json, "%s/cputestdata/%s-cpuid-%s.json", @@ -492,9 +493,12 @@ cpuTestMakeQEMUCaps(const struct data *data) if (!(testMon =3D qemuMonitorTestNewFromFile(json, driver.xmlopt, true= ))) goto error; =20 + if (!(model =3D qemuMonitorCPUModelInfoNew("host"))) + goto cleanup; + if (qemuMonitorGetCPUModelExpansion(qemuMonitorTestGetMonitor(testMon), QEMU_MONITOR_CPU_MODEL_EXPANSION_S= TATIC, - "host", true, &model) < 0) + true, model, &expansion) < 0) goto error; =20 if (!(qemuCaps =3D virQEMUCapsNew())) @@ -506,8 +510,8 @@ cpuTestMakeQEMUCaps(const struct data *data) virQEMUCapsSet(qemuCaps, QEMU_CAPS_QUERY_CPU_DEFINITIONS); =20 virQEMUCapsSetArch(qemuCaps, data->arch); - virQEMUCapsSetCPUModelInfo(qemuCaps, VIR_DOMAIN_VIRT_KVM, model); - model =3D NULL; + virQEMUCapsSetCPUModelInfo(qemuCaps, VIR_DOMAIN_VIRT_KVM, expansion); + expansion =3D NULL; =20 if (virQEMUCapsProbeQMPCPUDefinitions(qemuCaps, qemuMonitorTestGetMonitor(testMo= n), @@ -516,6 +520,7 @@ cpuTestMakeQEMUCaps(const struct data *data) =20 cleanup: qemuMonitorCPUModelInfoFree(model); + qemuMonitorCPUModelInfoFree(expansion); qemuMonitorTestFree(testMon); VIR_FREE(json); =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 1541216530132686.6404802387273; Fri, 2 Nov 2018 20:42:10 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C1B743001E70; Sat, 3 Nov 2018 03:42:07 +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 8906C5C1B2; Sat, 3 Nov 2018 03:42:07 +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 3FB681808872; Sat, 3 Nov 2018 03:42:07 +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 wA33E0Dk011385 for ; Fri, 2 Nov 2018 23:14:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id A7F295D760; Sat, 3 Nov 2018 03:14:00 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id C24EF5D6A9; Sat, 3 Nov 2018 03:13:59 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:06 -0500 Message-Id: <20181103031338.11600-6-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 05/37] qemu_process: Move process code from qemu_capabilities to qemu_process 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Sat, 03 Nov 2018 03:42:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Qemu process code in qemu_capabilities.c is moved to qemu_process.c in order to make the code usable outside the original capabilities usecases. This process code activates and manages Qemu processes without establishing a guest domain. This patch is a straight cut/paste move between files. Following patches modify the process code making it more generic and consistent with qemu_process. Signed-off-by: Chris Venteicher --- src/qemu/qemu_capabilities.c | 218 +---------------------------------- src/qemu/qemu_process.c | 201 ++++++++++++++++++++++++++++++++ src/qemu/qemu_process.h | 29 +++++ 3 files changed, 231 insertions(+), 217 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index b2bb2347fd..d5e63aca5c 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -47,6 +47,7 @@ #define __QEMU_CAPSPRIV_H_ALLOW__ #include "qemu_capspriv.h" #include "qemu_qapi.h" +#include "qemu_process.h" =20 #include #include @@ -3972,18 +3973,6 @@ virQEMUCapsIsValid(void *data, } =20 =20 -static void virQEMUCapsMonitorNotify(qemuMonitorPtr mon ATTRIBUTE_UNUSED, - virDomainObjPtr vm ATTRIBUTE_UNUSED, - void *opaque ATTRIBUTE_UNUSED) -{ -} - -static qemuMonitorCallbacks callbacks =3D { - .eofNotify =3D virQEMUCapsMonitorNotify, - .errorNotify =3D virQEMUCapsMonitorNotify, -}; - - /** * virQEMUCapsInitQMPArch: * @qemuCaps: QEMU capabilities @@ -4278,211 +4267,6 @@ virQEMUCapsInitQMPMonitorTCG(virQEMUCapsPtr qemuCap= s ATTRIBUTE_UNUSED, } =20 =20 -typedef struct _virQEMUCapsInitQMPCommand virQEMUCapsInitQMPCommand; -typedef virQEMUCapsInitQMPCommand *virQEMUCapsInitQMPCommandPtr; -struct _virQEMUCapsInitQMPCommand { - char *binary; - uid_t runUid; - gid_t runGid; - char **qmperr; - char *monarg; - char *monpath; - char *pidfile; - virCommandPtr cmd; - qemuMonitorPtr mon; - virDomainChrSourceDef config; - pid_t pid; - virDomainObjPtr vm; -}; - - -static void -virQEMUCapsInitQMPCommandAbort(virQEMUCapsInitQMPCommandPtr cmd) -{ - if (cmd->mon) - virObjectUnlock(cmd->mon); - qemuMonitorClose(cmd->mon); - cmd->mon =3D NULL; - - virCommandAbort(cmd->cmd); - virCommandFree(cmd->cmd); - cmd->cmd =3D NULL; - - if (cmd->monpath) - unlink(cmd->monpath); - - virDomainObjEndAPI(&cmd->vm); - - if (cmd->pid !=3D 0) { - char ebuf[1024]; - - VIR_DEBUG("Killing QMP caps process %lld", (long long)cmd->pid); - if (virProcessKill(cmd->pid, SIGKILL) < 0 && errno !=3D ESRCH) - VIR_ERROR(_("Failed to kill process %lld: %s"), - (long long)cmd->pid, - virStrerror(errno, ebuf, sizeof(ebuf))); - - VIR_FREE(*cmd->qmperr); - } - if (cmd->pidfile) - unlink(cmd->pidfile); - cmd->pid =3D 0; -} - - -static void -virQEMUCapsInitQMPCommandFree(virQEMUCapsInitQMPCommandPtr cmd) -{ - if (!cmd) - return; - - virQEMUCapsInitQMPCommandAbort(cmd); - VIR_FREE(cmd->binary); - VIR_FREE(cmd->monpath); - VIR_FREE(cmd->monarg); - VIR_FREE(cmd->pidfile); - VIR_FREE(cmd); -} - - -static virQEMUCapsInitQMPCommandPtr -virQEMUCapsInitQMPCommandNew(char *binary, - const char *libDir, - uid_t runUid, - gid_t runGid, - char **qmperr) -{ - virQEMUCapsInitQMPCommandPtr cmd =3D NULL; - - if (VIR_ALLOC(cmd) < 0) - goto error; - - if (VIR_STRDUP(cmd->binary, binary) < 0) - goto error; - - cmd->runUid =3D runUid; - cmd->runGid =3D runGid; - cmd->qmperr =3D qmperr; - - /* the ".sock" sufix is important to avoid a possible clash with a qemu - * domain called "capabilities" - */ - if (virAsprintf(&cmd->monpath, "%s/%s", libDir, - "capabilities.monitor.sock") < 0) - goto error; - if (virAsprintf(&cmd->monarg, "unix:%s,server,nowait", cmd->monpath) <= 0) - goto error; - - /* ".pidfile" suffix is used rather than ".pid" to avoid a possible cl= ash - * with a qemu domain called "capabilities" - * Normally we'd use runDir for pid files, but because we're using - * -daemonize we need QEMU to be allowed to create them, rather - * than libvirtd. So we're using libDir which QEMU can write to - */ - if (virAsprintf(&cmd->pidfile, "%s/%s", libDir, "capabilities.pidfile"= ) < 0) - goto error; - - virPidFileForceCleanupPath(cmd->pidfile); - - cmd->config.type =3D VIR_DOMAIN_CHR_TYPE_UNIX; - cmd->config.data.nix.path =3D cmd->monpath; - cmd->config.data.nix.listen =3D false; - - return cmd; - - error: - virQEMUCapsInitQMPCommandFree(cmd); - return NULL; -} - - -/* Returns -1 on fatal error, - * 0 on success, - * 1 when probing QEMU failed - */ -static int -virQEMUCapsInitQMPCommandRun(virQEMUCapsInitQMPCommandPtr cmd, - bool forceTCG) -{ - virDomainXMLOptionPtr xmlopt =3D NULL; - const char *machine; - int status =3D 0; - int ret =3D -1; - - if (forceTCG) - machine =3D "none,accel=3Dtcg"; - else - machine =3D "none,accel=3Dkvm:tcg"; - - VIR_DEBUG("Try to probe capabilities of '%s' via QMP, machine %s", - cmd->binary, machine); - - /* - * We explicitly need to use -daemonize here, rather than - * virCommandDaemonize, because we need to synchronize - * with QEMU creating its monitor socket API. Using - * daemonize guarantees control won't return to libvirt - * until the socket is present. - */ - cmd->cmd =3D virCommandNewArgList(cmd->binary, - "-S", - "-no-user-config", - "-nodefaults", - "-nographic", - "-machine", machine, - "-qmp", cmd->monarg, - "-pidfile", cmd->pidfile, - "-daemonize", - NULL); - virCommandAddEnvPassCommon(cmd->cmd); - virCommandClearCaps(cmd->cmd); - virCommandSetGID(cmd->cmd, cmd->runGid); - virCommandSetUID(cmd->cmd, cmd->runUid); - - virCommandSetErrorBuffer(cmd->cmd, cmd->qmperr); - - /* Log, but otherwise ignore, non-zero status. */ - if (virCommandRun(cmd->cmd, &status) < 0) - goto cleanup; - - if (status !=3D 0) { - VIR_DEBUG("QEMU %s exited with status %d: %s", - cmd->binary, status, *cmd->qmperr); - goto ignore; - } - - if (virPidFileReadPath(cmd->pidfile, &cmd->pid) < 0) { - VIR_DEBUG("Failed to read pidfile %s", cmd->pidfile); - goto ignore; - } - - if (!(xmlopt =3D virDomainXMLOptionNew(NULL, NULL, NULL, NULL, NULL)) = || - !(cmd->vm =3D virDomainObjNew(xmlopt))) - goto cleanup; - - cmd->vm->pid =3D cmd->pid; - - if (!(cmd->mon =3D qemuMonitorOpen(cmd->vm, &cmd->config, true, true, - 0, &callbacks, NULL))) - goto ignore; - - virObjectLock(cmd->mon); - - ret =3D 0; - - cleanup: - if (!cmd->mon) - virQEMUCapsInitQMPCommandAbort(cmd); - virObjectUnref(xmlopt); - - return ret; - - ignore: - ret =3D 1; - goto cleanup; -} - - static int virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, const char *libDir, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 9cf971808c..62886fd910 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8061,3 +8061,204 @@ qemuProcessReconnectAll(virQEMUDriverPtr driver) struct qemuProcessReconnectData data =3D {.driver =3D driver}; virDomainObjListForEach(driver->domains, qemuProcessReconnectHelper, &= data); } + + +static void virQEMUCapsMonitorNotify(qemuMonitorPtr mon ATTRIBUTE_UNUSED, + virDomainObjPtr vm ATTRIBUTE_UNUSED, + void *opaque ATTRIBUTE_UNUSED) +{ +} + +static qemuMonitorCallbacks callbacks =3D { + .eofNotify =3D virQEMUCapsMonitorNotify, + .errorNotify =3D virQEMUCapsMonitorNotify, +}; + + + + +void +virQEMUCapsInitQMPCommandFree(virQEMUCapsInitQMPCommandPtr cmd) +{ + if (!cmd) + return; + + virQEMUCapsInitQMPCommandAbort(cmd); + VIR_FREE(cmd->binary); + VIR_FREE(cmd->monpath); + VIR_FREE(cmd->monarg); + VIR_FREE(cmd->pidfile); + VIR_FREE(cmd); +} + + +virQEMUCapsInitQMPCommandPtr +virQEMUCapsInitQMPCommandNew(char *binary, + const char *libDir, + uid_t runUid, + gid_t runGid, + char **qmperr) +{ + virQEMUCapsInitQMPCommandPtr cmd =3D NULL; + + if (VIR_ALLOC(cmd) < 0) + goto error; + + if (VIR_STRDUP(cmd->binary, binary) < 0) + goto error; + + cmd->runUid =3D runUid; + cmd->runGid =3D runGid; + cmd->qmperr =3D qmperr; + + /* the ".sock" sufix is important to avoid a possible clash with a qemu + * domain called "capabilities" + */ + if (virAsprintf(&cmd->monpath, "%s/%s", libDir, + "capabilities.monitor.sock") < 0) + goto error; + if (virAsprintf(&cmd->monarg, "unix:%s,server,nowait", cmd->monpath) <= 0) + goto error; + + /* ".pidfile" suffix is used rather than ".pid" to avoid a possible cl= ash + * with a qemu domain called "capabilities" + * Normally we'd use runDir for pid files, but because we're using + * -daemonize we need QEMU to be allowed to create them, rather + * than libvirtd. So we're using libDir which QEMU can write to + */ + if (virAsprintf(&cmd->pidfile, "%s/%s", libDir, "capabilities.pidfile"= ) < 0) + goto error; + + virPidFileForceCleanupPath(cmd->pidfile); + + cmd->config.type =3D VIR_DOMAIN_CHR_TYPE_UNIX; + cmd->config.data.nix.path =3D cmd->monpath; + cmd->config.data.nix.listen =3D false; + + return cmd; + + error: + virQEMUCapsInitQMPCommandFree(cmd); + return NULL; +} + + +/* Returns -1 on fatal error, + * 0 on success, + * 1 when probing QEMU failed + */ +int +virQEMUCapsInitQMPCommandRun(virQEMUCapsInitQMPCommandPtr cmd, + bool forceTCG) +{ + virDomainXMLOptionPtr xmlopt =3D NULL; + const char *machine; + int status =3D 0; + int ret =3D -1; + + if (forceTCG) + machine =3D "none,accel=3Dtcg"; + else + machine =3D "none,accel=3Dkvm:tcg"; + + VIR_DEBUG("Try to probe capabilities of '%s' via QMP, machine %s", + cmd->binary, machine); + + /* + * We explicitly need to use -daemonize here, rather than + * virCommandDaemonize, because we need to synchronize + * with QEMU creating its monitor socket API. Using + * daemonize guarantees control won't return to libvirt + * until the socket is present. + */ + cmd->cmd =3D virCommandNewArgList(cmd->binary, + "-S", + "-no-user-config", + "-nodefaults", + "-nographic", + "-machine", machine, + "-qmp", cmd->monarg, + "-pidfile", cmd->pidfile, + "-daemonize", + NULL); + virCommandAddEnvPassCommon(cmd->cmd); + virCommandClearCaps(cmd->cmd); + virCommandSetGID(cmd->cmd, cmd->runGid); + virCommandSetUID(cmd->cmd, cmd->runUid); + + virCommandSetErrorBuffer(cmd->cmd, cmd->qmperr); + + /* Log, but otherwise ignore, non-zero status. */ + if (virCommandRun(cmd->cmd, &status) < 0) + goto cleanup; + + if (status !=3D 0) { + VIR_DEBUG("QEMU %s exited with status %d: %s", + cmd->binary, status, *cmd->qmperr); + goto ignore; + } + + if (virPidFileReadPath(cmd->pidfile, &cmd->pid) < 0) { + VIR_DEBUG("Failed to read pidfile %s", cmd->pidfile); + goto ignore; + } + + if (!(xmlopt =3D virDomainXMLOptionNew(NULL, NULL, NULL, NULL, NULL)) = || + !(cmd->vm =3D virDomainObjNew(xmlopt))) + goto cleanup; + + cmd->vm->pid =3D cmd->pid; + + if (!(cmd->mon =3D qemuMonitorOpen(cmd->vm, &cmd->config, true, true, + 0, &callbacks, NULL))) + goto ignore; + + virObjectLock(cmd->mon); + + ret =3D 0; + + cleanup: + if (!cmd->mon) + virQEMUCapsInitQMPCommandAbort(cmd); + virObjectUnref(xmlopt); + + return ret; + + ignore: + ret =3D 1; + goto cleanup; +} + + +void +virQEMUCapsInitQMPCommandAbort(virQEMUCapsInitQMPCommandPtr cmd) +{ + if (cmd->mon) + virObjectUnlock(cmd->mon); + qemuMonitorClose(cmd->mon); + cmd->mon =3D NULL; + + virCommandAbort(cmd->cmd); + virCommandFree(cmd->cmd); + cmd->cmd =3D NULL; + + if (cmd->monpath) + unlink(cmd->monpath); + + virDomainObjEndAPI(&cmd->vm); + + if (cmd->pid !=3D 0) { + char ebuf[1024]; + + VIR_DEBUG("Killing QMP caps process %lld", (long long)cmd->pid); + if (virProcessKill(cmd->pid, SIGKILL) < 0 && errno !=3D ESRCH) + VIR_ERROR(_("Failed to kill process %lld: %s"), + (long long)cmd->pid, + virStrerror(errno, ebuf, sizeof(ebuf))); + + VIR_FREE(*cmd->qmperr); + } + if (cmd->pidfile) + unlink(cmd->pidfile); + cmd->pid =3D 0; +} diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index 2037467c94..4ba3988e3d 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -214,4 +214,33 @@ int qemuProcessStartManagedPRDaemon(virDomainObjPtr vm= ); =20 void qemuProcessKillManagedPRDaemon(virDomainObjPtr vm); =20 +typedef struct _virQEMUCapsInitQMPCommand virQEMUCapsInitQMPCommand; +typedef virQEMUCapsInitQMPCommand *virQEMUCapsInitQMPCommandPtr; +struct _virQEMUCapsInitQMPCommand { + char *binary; + uid_t runUid; + gid_t runGid; + char **qmperr; + char *monarg; + char *monpath; + char *pidfile; + virCommandPtr cmd; + qemuMonitorPtr mon; + virDomainChrSourceDef config; + pid_t pid; + virDomainObjPtr vm; +}; + +virQEMUCapsInitQMPCommandPtr virQEMUCapsInitQMPCommandNew(char *binary, + const char *libD= ir, + uid_t runUid, + gid_t runGid, + char **qmperr); + +void virQEMUCapsInitQMPCommandFree(virQEMUCapsInitQMPCommandPtr cmd); + +int virQEMUCapsInitQMPCommandRun(virQEMUCapsInitQMPCommandPtr cmd, bool fo= rceTCG); + +void virQEMUCapsInitQMPCommandAbort(virQEMUCapsInitQMPCommandPtr cmd); + #endif /* __QEMU_PROCESS_H__ */ --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 1541216111121345.5301778971732; Fri, 2 Nov 2018 20:35:11 -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 342D4307DAA6; Sat, 3 Nov 2018 03:35:09 +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 EB82E5D763; Sat, 3 Nov 2018 03:35:08 +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 987A64CAA7; Sat, 3 Nov 2018 03:35:08 +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 wA33E1k4011395 for ; Fri, 2 Nov 2018 23:14:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id A7E495D760; Sat, 3 Nov 2018 03:14:01 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2BB55D6A9; Sat, 3 Nov 2018 03:14:00 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:07 -0500 Message-Id: <20181103031338.11600-7-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 06/37] qemu_process: Use qemuProcess prefix 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.42]); Sat, 03 Nov 2018 03:35:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" s/virQEMUCapsInitQMPCommand/qemuProcess/ No functionality change. Use appropriate prefix in moved code. Signed-off-by: Chris Venteicher --- src/qemu/qemu_capabilities.c | 14 +++++++------- src/qemu/qemu_process.c | 28 ++++++++++++++-------------- src/qemu/qemu_process.h | 22 +++++++++++----------- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index d5e63aca5c..6f4d9139bf 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4274,15 +4274,15 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, gid_t runGid, char **qmperr) { - virQEMUCapsInitQMPCommandPtr cmd =3D NULL; + qemuProcessPtr cmd =3D NULL; int ret =3D -1; int rc; =20 - if (!(cmd =3D virQEMUCapsInitQMPCommandNew(qemuCaps->binary, libDir, - runUid, runGid, qmperr))) + if (!(proc =3D qemuProcessNew(qemuCaps->binary, libDir, + runUid, runGid, qmperr))) goto cleanup; =20 - if ((rc =3D virQEMUCapsInitQMPCommandRun(cmd, false)) !=3D 0) { + if ((rc =3D qemuProcessRun(cmd, false)) !=3D 0) { if (rc =3D=3D 1) ret =3D 0; goto cleanup; @@ -4292,8 +4292,8 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, goto cleanup; =20 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) { - virQEMUCapsInitQMPCommandAbort(cmd); - if ((rc =3D virQEMUCapsInitQMPCommandRun(cmd, true)) !=3D 0) { + qemuProcessAbort(cmd); + if ((rc =3D qemuProcessRun(cmd, true)) !=3D 0) { if (rc =3D=3D 1) ret =3D 0; goto cleanup; @@ -4306,7 +4306,7 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, ret =3D 0; =20 cleanup: - virQEMUCapsInitQMPCommandFree(cmd); + qemuProcessFree(cmd); return ret; } =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 62886fd910..2de1362cbb 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8078,12 +8078,12 @@ static qemuMonitorCallbacks callbacks =3D { =20 =20 void -virQEMUCapsInitQMPCommandFree(virQEMUCapsInitQMPCommandPtr cmd) +qemuProcessFree(qemuProcessPtr cmd) { if (!cmd) return; =20 - virQEMUCapsInitQMPCommandAbort(cmd); + qemuProcessAbort(cmd); VIR_FREE(cmd->binary); VIR_FREE(cmd->monpath); VIR_FREE(cmd->monarg); @@ -8092,14 +8092,14 @@ virQEMUCapsInitQMPCommandFree(virQEMUCapsInitQMPCom= mandPtr cmd) } =20 =20 -virQEMUCapsInitQMPCommandPtr -virQEMUCapsInitQMPCommandNew(char *binary, - const char *libDir, - uid_t runUid, - gid_t runGid, - char **qmperr) +qemuProcessPtr +qemuProcessNew(char *binary, + const char *libDir, + uid_t runUid, + gid_t runGid, + char **qmperr) { - virQEMUCapsInitQMPCommandPtr cmd =3D NULL; + qemuProcessPtr cmd =3D NULL; =20 if (VIR_ALLOC(cmd) < 0) goto error; @@ -8138,7 +8138,7 @@ virQEMUCapsInitQMPCommandNew(char *binary, return cmd; =20 error: - virQEMUCapsInitQMPCommandFree(cmd); + qemuProcessFree(cmd); return NULL; } =20 @@ -8148,8 +8148,8 @@ virQEMUCapsInitQMPCommandNew(char *binary, * 1 when probing QEMU failed */ int -virQEMUCapsInitQMPCommandRun(virQEMUCapsInitQMPCommandPtr cmd, - bool forceTCG) +qemuProcessRun(qemuProcessPtr cmd, + bool forceTCG) { virDomainXMLOptionPtr xmlopt =3D NULL; const char *machine; @@ -8219,7 +8219,7 @@ virQEMUCapsInitQMPCommandRun(virQEMUCapsInitQMPComman= dPtr cmd, =20 cleanup: if (!cmd->mon) - virQEMUCapsInitQMPCommandAbort(cmd); + qemuProcessAbort(cmd); virObjectUnref(xmlopt); =20 return ret; @@ -8231,7 +8231,7 @@ virQEMUCapsInitQMPCommandRun(virQEMUCapsInitQMPComman= dPtr cmd, =20 =20 void -virQEMUCapsInitQMPCommandAbort(virQEMUCapsInitQMPCommandPtr cmd) +qemuProcessAbort(qemuProcessPtr cmd) { if (cmd->mon) virObjectUnlock(cmd->mon); diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index 4ba3988e3d..5417cb416f 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -214,9 +214,9 @@ int qemuProcessStartManagedPRDaemon(virDomainObjPtr vm); =20 void qemuProcessKillManagedPRDaemon(virDomainObjPtr vm); =20 -typedef struct _virQEMUCapsInitQMPCommand virQEMUCapsInitQMPCommand; -typedef virQEMUCapsInitQMPCommand *virQEMUCapsInitQMPCommandPtr; -struct _virQEMUCapsInitQMPCommand { +typedef struct _qemuProcess qemuProcess; +typedef qemuProcess *qemuProcessPtr; +struct _qemuProcess { char *binary; uid_t runUid; gid_t runGid; @@ -231,16 +231,16 @@ struct _virQEMUCapsInitQMPCommand { virDomainObjPtr vm; }; =20 -virQEMUCapsInitQMPCommandPtr virQEMUCapsInitQMPCommandNew(char *binary, - const char *libD= ir, - uid_t runUid, - gid_t runGid, - char **qmperr); +qemuProcessPtr qemuProcessNew(char *binary, + const char *libDir, + uid_t runUid, + gid_t runGid, + char **qmperr); =20 -void virQEMUCapsInitQMPCommandFree(virQEMUCapsInitQMPCommandPtr cmd); +void qemuProcessFree(qemuProcessPtr cmd); =20 -int virQEMUCapsInitQMPCommandRun(virQEMUCapsInitQMPCommandPtr cmd, bool fo= rceTCG); +int qemuProcessRun(qemuProcessPtr cmd, bool forceTCG); =20 -void virQEMUCapsInitQMPCommandAbort(virQEMUCapsInitQMPCommandPtr cmd); +void qemuProcessAbort(qemuProcessPtr cmd); =20 #endif /* __QEMU_PROCESS_H__ */ --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 1541216123273375.5408715763707; Fri, 2 Nov 2018 20:35:23 -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 73A973154868; Sat, 3 Nov 2018 03:35:20 +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 1F6E82C8E8; Sat, 3 Nov 2018 03:35:20 +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 ABC2318005AD; Sat, 3 Nov 2018 03:35:19 +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 wA33E2k2011405 for ; Fri, 2 Nov 2018 23:14:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id AC4CD5D760; Sat, 3 Nov 2018 03:14:02 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id E3DF15D6A9; Sat, 3 Nov 2018 03:14:01 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:08 -0500 Message-Id: <20181103031338.11600-8-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 07/37] qemu_process: Limit qemuProcessNew to const input strings 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.41]); Sat, 03 Nov 2018 03:35:21 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Prevent compile errors due to trying to use a const string as a non-const input to qemuProcessNew. No functionality change. Signed-off-by: Chris Venteicher --- src/qemu/qemu_process.c | 2 +- src/qemu/qemu_process.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 2de1362cbb..b93b3d6cf4 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8093,7 +8093,7 @@ qemuProcessFree(qemuProcessPtr cmd) =20 =20 qemuProcessPtr -qemuProcessNew(char *binary, +qemuProcessNew(const char *binary, const char *libDir, uid_t runUid, gid_t runGid, diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index 5417cb416f..39a2368ce5 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -231,7 +231,7 @@ struct _qemuProcess { virDomainObjPtr vm; }; =20 -qemuProcessPtr qemuProcessNew(char *binary, +qemuProcessPtr qemuProcessNew(const char *binary, const char *libDir, uid_t runUid, gid_t runGid, --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 1541216133982435.45789936800224; Fri, 2 Nov 2018 20:35:33 -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 EF08D80F7B; Sat, 3 Nov 2018 03:35:31 +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 B51F52C8C5; Sat, 3 Nov 2018 03:35:31 +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 5213D18005B6; Sat, 3 Nov 2018 03:35:31 +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 wA33E358011413 for ; Fri, 2 Nov 2018 23:14:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id B03935D75D; Sat, 3 Nov 2018 03:14:03 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id E83E25D6A9; Sat, 3 Nov 2018 03:14:02 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:09 -0500 Message-Id: <20181103031338.11600-9-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 08/37] qemu_process: Refer to proc not cmd in process code 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.27]); Sat, 03 Nov 2018 03:35:32 +0000 (UTC) Content-Type: text/plain; charset="utf-8" s/cmd/proc/ in process code imported from qemu_capabilities. No functionality is changed. Process code imported from qemu_capabilities was oriented around starting a process to issue a single QMP command. Future usecases were targeting use a single process for multiple different QMP commands. Patch changes the variable naming to focus on the process not the command. Signed-off-by: Chris Venteicher --- src/qemu/qemu_capabilities.c | 14 ++-- src/qemu/qemu_process.c | 140 +++++++++++++++++------------------ src/qemu/qemu_process.h | 6 +- 3 files changed, 80 insertions(+), 80 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 6f4d9139bf..cf09002523 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4274,7 +4274,7 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, gid_t runGid, char **qmperr) { - qemuProcessPtr cmd =3D NULL; + qemuProcessPtr proc =3D NULL; int ret =3D -1; int rc; =20 @@ -4282,31 +4282,31 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, runUid, runGid, qmperr))) goto cleanup; =20 - if ((rc =3D qemuProcessRun(cmd, false)) !=3D 0) { + if ((rc =3D qemuProcessRun(proc, false)) !=3D 0) { if (rc =3D=3D 1) ret =3D 0; goto cleanup; } =20 - if (virQEMUCapsInitQMPMonitor(qemuCaps, cmd->mon) < 0) + if (virQEMUCapsInitQMPMonitor(qemuCaps, proc->mon) < 0) goto cleanup; =20 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) { - qemuProcessAbort(cmd); - if ((rc =3D qemuProcessRun(cmd, true)) !=3D 0) { + qemuProcessAbort(proc); + if ((rc =3D qemuProcessRun(proc, true)) !=3D 0) { if (rc =3D=3D 1) ret =3D 0; goto cleanup; } =20 - if (virQEMUCapsInitQMPMonitorTCG(qemuCaps, cmd->mon) < 0) + if (virQEMUCapsInitQMPMonitorTCG(qemuCaps, proc->mon) < 0) goto cleanup; } =20 ret =3D 0; =20 cleanup: - qemuProcessFree(cmd); + qemuProcessFree(proc); return ret; } =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index b93b3d6cf4..2d3e8cac7a 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8078,17 +8078,17 @@ static qemuMonitorCallbacks callbacks =3D { =20 =20 void -qemuProcessFree(qemuProcessPtr cmd) +qemuProcessFree(qemuProcessPtr proc) { - if (!cmd) + if (!proc) return; =20 - qemuProcessAbort(cmd); - VIR_FREE(cmd->binary); - VIR_FREE(cmd->monpath); - VIR_FREE(cmd->monarg); - VIR_FREE(cmd->pidfile); - VIR_FREE(cmd); + qemuProcessAbort(proc); + VIR_FREE(proc->binary); + VIR_FREE(proc->monpath); + VIR_FREE(proc->monarg); + VIR_FREE(proc->pidfile); + VIR_FREE(proc); } =20 =20 @@ -8099,25 +8099,25 @@ qemuProcessNew(const char *binary, gid_t runGid, char **qmperr) { - qemuProcessPtr cmd =3D NULL; + qemuProcessPtr proc =3D NULL; =20 - if (VIR_ALLOC(cmd) < 0) + if (VIR_ALLOC(proc) < 0) goto error; =20 - if (VIR_STRDUP(cmd->binary, binary) < 0) + if (VIR_STRDUP(proc->binary, binary) < 0) goto error; =20 - cmd->runUid =3D runUid; - cmd->runGid =3D runGid; - cmd->qmperr =3D qmperr; + proc->runUid =3D runUid; + proc->runGid =3D runGid; + proc->qmperr =3D qmperr; =20 /* the ".sock" sufix is important to avoid a possible clash with a qemu * domain called "capabilities" */ - if (virAsprintf(&cmd->monpath, "%s/%s", libDir, + if (virAsprintf(&proc->monpath, "%s/%s", libDir, "capabilities.monitor.sock") < 0) goto error; - if (virAsprintf(&cmd->monarg, "unix:%s,server,nowait", cmd->monpath) <= 0) + if (virAsprintf(&proc->monarg, "unix:%s,server,nowait", proc->monpath)= < 0) goto error; =20 /* ".pidfile" suffix is used rather than ".pid" to avoid a possible cl= ash @@ -8126,19 +8126,19 @@ qemuProcessNew(const char *binary, * -daemonize we need QEMU to be allowed to create them, rather * than libvirtd. So we're using libDir which QEMU can write to */ - if (virAsprintf(&cmd->pidfile, "%s/%s", libDir, "capabilities.pidfile"= ) < 0) + if (virAsprintf(&proc->pidfile, "%s/%s", libDir, "capabilities.pidfile= ") < 0) goto error; =20 - virPidFileForceCleanupPath(cmd->pidfile); + virPidFileForceCleanupPath(proc->pidfile); =20 - cmd->config.type =3D VIR_DOMAIN_CHR_TYPE_UNIX; - cmd->config.data.nix.path =3D cmd->monpath; - cmd->config.data.nix.listen =3D false; + proc->config.type =3D VIR_DOMAIN_CHR_TYPE_UNIX; + proc->config.data.nix.path =3D proc->monpath; + proc->config.data.nix.listen =3D false; =20 - return cmd; + return proc; =20 error: - qemuProcessFree(cmd); + qemuProcessFree(proc); return NULL; } =20 @@ -8148,7 +8148,7 @@ qemuProcessNew(const char *binary, * 1 when probing QEMU failed */ int -qemuProcessRun(qemuProcessPtr cmd, +qemuProcessRun(qemuProcessPtr proc, bool forceTCG) { virDomainXMLOptionPtr xmlopt =3D NULL; @@ -8162,7 +8162,7 @@ qemuProcessRun(qemuProcessPtr cmd, machine =3D "none,accel=3Dkvm:tcg"; =20 VIR_DEBUG("Try to probe capabilities of '%s' via QMP, machine %s", - cmd->binary, machine); + proc->binary, machine); =20 /* * We explicitly need to use -daemonize here, rather than @@ -8171,55 +8171,55 @@ qemuProcessRun(qemuProcessPtr cmd, * daemonize guarantees control won't return to libvirt * until the socket is present. */ - cmd->cmd =3D virCommandNewArgList(cmd->binary, - "-S", - "-no-user-config", - "-nodefaults", - "-nographic", - "-machine", machine, - "-qmp", cmd->monarg, - "-pidfile", cmd->pidfile, - "-daemonize", - NULL); - virCommandAddEnvPassCommon(cmd->cmd); - virCommandClearCaps(cmd->cmd); - virCommandSetGID(cmd->cmd, cmd->runGid); - virCommandSetUID(cmd->cmd, cmd->runUid); - - virCommandSetErrorBuffer(cmd->cmd, cmd->qmperr); + proc->cmd =3D virCommandNewArgList(proc->binary, + "-S", + "-no-user-config", + "-nodefaults", + "-nographic", + "-machine", machine, + "-qmp", proc->monarg, + "-pidfile", proc->pidfile, + "-daemonize", + NULL); + virCommandAddEnvPassCommon(proc->cmd); + virCommandClearCaps(proc->cmd); + virCommandSetGID(proc->cmd, proc->runGid); + virCommandSetUID(proc->cmd, proc->runUid); + + virCommandSetErrorBuffer(proc->cmd, proc->qmperr); =20 /* Log, but otherwise ignore, non-zero status. */ - if (virCommandRun(cmd->cmd, &status) < 0) + if (virCommandRun(proc->cmd, &status) < 0) goto cleanup; =20 if (status !=3D 0) { VIR_DEBUG("QEMU %s exited with status %d: %s", - cmd->binary, status, *cmd->qmperr); + proc->binary, status, *proc->qmperr); goto ignore; } =20 - if (virPidFileReadPath(cmd->pidfile, &cmd->pid) < 0) { - VIR_DEBUG("Failed to read pidfile %s", cmd->pidfile); + if (virPidFileReadPath(proc->pidfile, &proc->pid) < 0) { + VIR_DEBUG("Failed to read pidfile %s", proc->pidfile); goto ignore; } =20 if (!(xmlopt =3D virDomainXMLOptionNew(NULL, NULL, NULL, NULL, NULL)) = || - !(cmd->vm =3D virDomainObjNew(xmlopt))) + !(proc->vm =3D virDomainObjNew(xmlopt))) goto cleanup; =20 - cmd->vm->pid =3D cmd->pid; + proc->vm->pid =3D proc->pid; =20 - if (!(cmd->mon =3D qemuMonitorOpen(cmd->vm, &cmd->config, true, true, + if (!(proc->mon =3D qemuMonitorOpen(proc->vm, &proc->config, true, tru= e, 0, &callbacks, NULL))) goto ignore; =20 - virObjectLock(cmd->mon); + virObjectLock(proc->mon); =20 ret =3D 0; =20 cleanup: - if (!cmd->mon) - qemuProcessAbort(cmd); + if (!proc->mon) + qemuProcessAbort(proc); virObjectUnref(xmlopt); =20 return ret; @@ -8231,34 +8231,34 @@ qemuProcessRun(qemuProcessPtr cmd, =20 =20 void -qemuProcessAbort(qemuProcessPtr cmd) +qemuProcessAbort(qemuProcessPtr proc) { - if (cmd->mon) - virObjectUnlock(cmd->mon); - qemuMonitorClose(cmd->mon); - cmd->mon =3D NULL; + if (proc->mon) + virObjectUnlock(proc->mon); + qemuMonitorClose(proc->mon); + proc->mon =3D NULL; =20 - virCommandAbort(cmd->cmd); - virCommandFree(cmd->cmd); - cmd->cmd =3D NULL; + virCommandAbort(proc->cmd); + virCommandFree(proc->cmd); + proc->cmd =3D NULL; =20 - if (cmd->monpath) - unlink(cmd->monpath); + if (proc->monpath) + unlink(proc->monpath); =20 - virDomainObjEndAPI(&cmd->vm); + virDomainObjEndAPI(&proc->vm); =20 - if (cmd->pid !=3D 0) { + if (proc->pid !=3D 0) { char ebuf[1024]; =20 - VIR_DEBUG("Killing QMP caps process %lld", (long long)cmd->pid); - if (virProcessKill(cmd->pid, SIGKILL) < 0 && errno !=3D ESRCH) + VIR_DEBUG("Killing QMP caps process %lld", (long long)proc->pid); + if (virProcessKill(proc->pid, SIGKILL) < 0 && errno !=3D ESRCH) VIR_ERROR(_("Failed to kill process %lld: %s"), - (long long)cmd->pid, + (long long)proc->pid, virStrerror(errno, ebuf, sizeof(ebuf))); =20 - VIR_FREE(*cmd->qmperr); + VIR_FREE(*proc->qmperr); } - if (cmd->pidfile) - unlink(cmd->pidfile); - cmd->pid =3D 0; + if (proc->pidfile) + unlink(proc->pidfile); + proc->pid =3D 0; } diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index 39a2368ce5..161311d007 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -237,10 +237,10 @@ qemuProcessPtr qemuProcessNew(const char *binary, gid_t runGid, char **qmperr); =20 -void qemuProcessFree(qemuProcessPtr cmd); +void qemuProcessFree(qemuProcessPtr proc); =20 -int qemuProcessRun(qemuProcessPtr cmd, bool forceTCG); +int qemuProcessRun(qemuProcessPtr proc, bool forceTCG); =20 -void qemuProcessAbort(qemuProcessPtr cmd); +void qemuProcessAbort(qemuProcessPtr proc); =20 #endif /* __QEMU_PROCESS_H__ */ --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 1541216146111551.9870902448722; Fri, 2 Nov 2018 20:35:46 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7DE25308FB8B; Sat, 3 Nov 2018 03:35:43 +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 454CB5C26E; Sat, 3 Nov 2018 03:35:43 +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 E5FF64CAA0; Sat, 3 Nov 2018 03:35:42 +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 wA33E4rJ011420 for ; Fri, 2 Nov 2018 23:14:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id B711C5D76A; Sat, 3 Nov 2018 03:14:04 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id EBB0D5D6A9; Sat, 3 Nov 2018 03:14:03 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:10 -0500 Message-Id: <20181103031338.11600-10-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 09/37] qemu_process: Use consistent name for stop process function 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Sat, 03 Nov 2018 03:35:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" s/qemuProcessAbort/qemuProcessStopQmp/ applied to change function name used to stop QEMU processes in process code moved from qemu_capabilities. No functionality change. The new name, qemuProcessStopQmp, is consistent with the existing function qemuProcessStop used to stop Domain processes. Qmp is added to the end of qemuProcessStop to differentiate between the Domain and new non-domain version of the functions. qemuProcessStartQmp will be used in a future patch to mirror the qemuProcessStart function with a non-domain equivalent. Signed-off-by: Chris Venteicher --- src/qemu/qemu_capabilities.c | 2 +- src/qemu/qemu_process.c | 6 +++--- src/qemu/qemu_process.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index cf09002523..1d83ebdbe0 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4292,7 +4292,7 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, goto cleanup; =20 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) { - qemuProcessAbort(proc); + qemuProcessStopQmp(proc); if ((rc =3D qemuProcessRun(proc, true)) !=3D 0) { if (rc =3D=3D 1) ret =3D 0; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 2d3e8cac7a..70d73cd457 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8083,7 +8083,7 @@ qemuProcessFree(qemuProcessPtr proc) if (!proc) return; =20 - qemuProcessAbort(proc); + qemuProcessStopQmp(proc); VIR_FREE(proc->binary); VIR_FREE(proc->monpath); VIR_FREE(proc->monarg); @@ -8219,7 +8219,7 @@ qemuProcessRun(qemuProcessPtr proc, =20 cleanup: if (!proc->mon) - qemuProcessAbort(proc); + qemuProcessStopQmp(proc); virObjectUnref(xmlopt); =20 return ret; @@ -8231,7 +8231,7 @@ qemuProcessRun(qemuProcessPtr proc, =20 =20 void -qemuProcessAbort(qemuProcessPtr proc) +qemuProcessStopQmp(qemuProcessPtr proc) { if (proc->mon) virObjectUnlock(proc->mon); diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index 161311d007..25343c4592 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -241,6 +241,6 @@ void qemuProcessFree(qemuProcessPtr proc); =20 int qemuProcessRun(qemuProcessPtr proc, bool forceTCG); =20 -void qemuProcessAbort(qemuProcessPtr proc); +void qemuProcessStopQmp(qemuProcessPtr proc); =20 #endif /* __QEMU_PROCESS_H__ */ --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 1541216157232459.16664317223285; Fri, 2 Nov 2018 20:35:57 -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 D96DA356DA; Sat, 3 Nov 2018 03:35:54 +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 9D5D21055008; Sat, 3 Nov 2018 03:35:54 +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 1BEAE18005B5; Sat, 3 Nov 2018 03:35:54 +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 wA33E5ns011435 for ; Fri, 2 Nov 2018 23:14:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id BAC875D6A9; Sat, 3 Nov 2018 03:14:05 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id F11645D75D; Sat, 3 Nov 2018 03:14:04 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:11 -0500 Message-Id: <20181103031338.11600-11-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 10/37] qemu_capabilities: Stop QEMU process before freeing 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.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Sat, 03 Nov 2018 03:35:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Follow the convention established in qemu_process of 1) alloc process structure 2) start process 3) use process 4) stop process 5) free process data structure The process data structure persists after the process activation fails or the process dies or is killed so stderr strings can be retrieved until the process data structure is freed. Signed-off-by: Chris Venteicher --- src/qemu/qemu_capabilities.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 1d83ebdbe0..359b6fbb9b 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4306,6 +4306,7 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, ret =3D 0; =20 cleanup: + qemuProcessStopQmp(proc); qemuProcessFree(proc); return ret; } --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 154121616917811.630312440941225; Fri, 2 Nov 2018 20:36:09 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B62862D7E1; Sat, 3 Nov 2018 03:36:06 +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 541A460BE8; Sat, 3 Nov 2018 03:36:06 +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 F0B564A460; Sat, 3 Nov 2018 03:36:05 +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 wA33E60X011445 for ; Fri, 2 Nov 2018 23:14:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id EC89E5D760; Sat, 3 Nov 2018 03:14:06 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0289E5D6A9; Sat, 3 Nov 2018 03:14:05 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:12 -0500 Message-Id: <20181103031338.11600-12-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 11/37] qemu_process: Use qemuProcess struct for a single process 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Sat, 03 Nov 2018 03:36:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" In new process code, move from model where qemuProcess struct can be used to activate a series of Qemu processes to model where one qemuProcess struct is used for one and only one Qemu process. The forceTCG parameter (use / don't use KVM) will be passed when the qemuProcess struct is initialized since the qemuProcess struct won't be reused. Signed-off-by: Chris Venteicher --- src/qemu/qemu_capabilities.c | 16 ++++++++++++---- src/qemu/qemu_process.c | 11 +++++++---- src/qemu/qemu_process.h | 6 ++++-- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 359b6fbb9b..99a963912c 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4275,14 +4275,16 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, char **qmperr) { qemuProcessPtr proc =3D NULL; + qemuProcessPtr proc_kvm =3D NULL; int ret =3D -1; int rc; + bool forceTCG =3D false; =20 if (!(proc =3D qemuProcessNew(qemuCaps->binary, libDir, - runUid, runGid, qmperr))) + runUid, runGid, qmperr, forceTCG))) goto cleanup; =20 - if ((rc =3D qemuProcessRun(proc, false)) !=3D 0) { + if ((rc =3D qemuProcessRun(proc)) !=3D 0) { if (rc =3D=3D 1) ret =3D 0; goto cleanup; @@ -4293,13 +4295,17 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, =20 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) { qemuProcessStopQmp(proc); - if ((rc =3D qemuProcessRun(proc, true)) !=3D 0) { + + forceTCG =3D true; + proc_kvm =3D qemuProcessNew(qemuCaps->binary, libDir, runUid, runG= id, NULL, forceTCG); + + if ((rc =3D qemuProcessRun(proc_kvm)) !=3D 0) { if (rc =3D=3D 1) ret =3D 0; goto cleanup; } =20 - if (virQEMUCapsInitQMPMonitorTCG(qemuCaps, proc->mon) < 0) + if (virQEMUCapsInitQMPMonitorTCG(qemuCaps, proc_kvm->mon) < 0) goto cleanup; } =20 @@ -4307,7 +4313,9 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, =20 cleanup: qemuProcessStopQmp(proc); + qemuProcessStopQmp(proc_kvm); qemuProcessFree(proc); + qemuProcessFree(proc_kvm); return ret; } =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 70d73cd457..d017efad84 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8097,7 +8097,8 @@ qemuProcessNew(const char *binary, const char *libDir, uid_t runUid, gid_t runGid, - char **qmperr) + char **qmperr, + bool forceTCG) { qemuProcessPtr proc =3D NULL; =20 @@ -8107,10 +8108,13 @@ qemuProcessNew(const char *binary, if (VIR_STRDUP(proc->binary, binary) < 0) goto error; =20 + proc->forceTCG =3D forceTCG; + proc->runUid =3D runUid; proc->runGid =3D runGid; proc->qmperr =3D qmperr; =20 + /* the ".sock" sufix is important to avoid a possible clash with a qemu * domain called "capabilities" */ @@ -8148,15 +8152,14 @@ qemuProcessNew(const char *binary, * 1 when probing QEMU failed */ int -qemuProcessRun(qemuProcessPtr proc, - bool forceTCG) +qemuProcessRun(qemuProcessPtr proc) { virDomainXMLOptionPtr xmlopt =3D NULL; const char *machine; int status =3D 0; int ret =3D -1; =20 - if (forceTCG) + if (proc->forceTCG) machine =3D "none,accel=3Dtcg"; else machine =3D "none,accel=3Dkvm:tcg"; diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index 25343c4592..ab2640ce7c 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -229,17 +229,19 @@ struct _qemuProcess { virDomainChrSourceDef config; pid_t pid; virDomainObjPtr vm; + bool forceTCG; }; =20 qemuProcessPtr qemuProcessNew(const char *binary, const char *libDir, uid_t runUid, gid_t runGid, - char **qmperr); + char **qmperr, + bool forceTCG); =20 void qemuProcessFree(qemuProcessPtr proc); =20 -int qemuProcessRun(qemuProcessPtr proc, bool forceTCG); +int qemuProcessRun(qemuProcessPtr proc); =20 void qemuProcessStopQmp(qemuProcessPtr proc); =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 1541216180680374.35546361194156; Fri, 2 Nov 2018 20:36:20 -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 1C7B190C7A; Sat, 3 Nov 2018 03:36:18 +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 E00F41057048; Sat, 3 Nov 2018 03:36:17 +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 8EEDF41F4E; Sat, 3 Nov 2018 03:36:17 +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 wA33EAbU011461 for ; Fri, 2 Nov 2018 23:14:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 973235D763; Sat, 3 Nov 2018 03:14:10 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id A99CC5D6A9; Sat, 3 Nov 2018 03:14:07 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:13 -0500 Message-Id: <20181103031338.11600-13-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 12/37] qemu_process: Persist stderr in qemuProcess struct 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.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Sat, 03 Nov 2018 03:36:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" A qemuProcess struct tracks the entire lifespan of a single QEMU Process including storing error output when the process terminates or activation fails. Error output remains available until qemuProcessFree is called. The qmperr buffer no longer needs to be maintained outside of the qemuProcess structure because the structure is used for a single QEMU process and the structures can be maintained as long as required to retrieve the process error info. Capabilities init code is refactored but continues to report QEMU process error data only when the initial (non KVM) QEMU process activation fails to result in a usable monitor connection for retrieving capabilities. The VIR_ERR_INTERNAL_ERROR "Failed to probe QEMU binary" reporting is moved into virQEMUCapsInitQMP function and the stderr string is extracted from the qemuProcess struct using a macro to retrieve the string. The same error and log message should be generated, in the same conditions, after this patch as before. Signed-off-by: Chris Venteicher --- src/qemu/qemu_capabilities.c | 27 ++++++++++++--------------- src/qemu/qemu_process.c | 12 ++++-------- src/qemu/qemu_process.h | 6 ++++-- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 99a963912c..9a86838d8a 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4271,8 +4271,7 @@ static int virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, const char *libDir, uid_t runUid, - gid_t runGid, - char **qmperr) + gid_t runGid) { qemuProcessPtr proc =3D NULL; qemuProcessPtr proc_kvm =3D NULL; @@ -4281,7 +4280,7 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, bool forceTCG =3D false; =20 if (!(proc =3D qemuProcessNew(qemuCaps->binary, libDir, - runUid, runGid, qmperr, forceTCG))) + runUid, runGid, forceTCG))) goto cleanup; =20 if ((rc =3D qemuProcessRun(proc)) !=3D 0) { @@ -4297,7 +4296,7 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, qemuProcessStopQmp(proc); =20 forceTCG =3D true; - proc_kvm =3D qemuProcessNew(qemuCaps->binary, libDir, runUid, runG= id, NULL, forceTCG); + proc_kvm =3D qemuProcessNew(qemuCaps->binary, libDir, runUid, runG= id, forceTCG); =20 if ((rc =3D qemuProcessRun(proc_kvm)) !=3D 0) { if (rc =3D=3D 1) @@ -4312,6 +4311,13 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, ret =3D 0; =20 cleanup: + if (proc && !proc->mon) { + char *err =3D QEMU_PROCESS_ERROR(proc) ? QEMU_PROCESS_ERROR(proc) = : _("unknown error"); + + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to probe QEMU binary with QMP: %s"), err); + } + qemuProcessStopQmp(proc); qemuProcessStopQmp(proc_kvm); qemuProcessFree(proc); @@ -4351,7 +4357,6 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch, { virQEMUCapsPtr qemuCaps; struct stat sb; - char *qmperr =3D NULL; =20 if (!(qemuCaps =3D virQEMUCapsNew())) goto error; @@ -4378,15 +4383,8 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch, goto error; } =20 - if (virQEMUCapsInitQMP(qemuCaps, libDir, runUid, runGid, &qmperr) < 0)= { - virQEMUCapsLogProbeFailure(binary); - goto error; - } - - if (!qemuCaps->usedQMP) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to probe QEMU binary with QMP: %s"), - qmperr ? qmperr : _("unknown error")); + if (virQEMUCapsInitQMP(qemuCaps, libDir, runUid, runGid) < 0 || + !qemuCaps->usedQMP) { virQEMUCapsLogProbeFailure(binary); goto error; } @@ -4405,7 +4403,6 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch, } =20 cleanup: - VIR_FREE(qmperr); return qemuCaps; =20 error: diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index d017efad84..99b720b380 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8088,6 +8088,7 @@ qemuProcessFree(qemuProcessPtr proc) VIR_FREE(proc->monpath); VIR_FREE(proc->monarg); VIR_FREE(proc->pidfile); + VIR_FREE(proc->qmperr); VIR_FREE(proc); } =20 @@ -8097,7 +8098,6 @@ qemuProcessNew(const char *binary, const char *libDir, uid_t runUid, gid_t runGid, - char **qmperr, bool forceTCG) { qemuProcessPtr proc =3D NULL; @@ -8112,8 +8112,6 @@ qemuProcessNew(const char *binary, =20 proc->runUid =3D runUid; proc->runGid =3D runGid; - proc->qmperr =3D qmperr; - =20 /* the ".sock" sufix is important to avoid a possible clash with a qemu * domain called "capabilities" @@ -8152,8 +8150,7 @@ qemuProcessNew(const char *binary, * 1 when probing QEMU failed */ int -qemuProcessRun(qemuProcessPtr proc) -{ +qemuProcessRun(qemuProcessPtr proc){ virDomainXMLOptionPtr xmlopt =3D NULL; const char *machine; int status =3D 0; @@ -8189,7 +8186,7 @@ qemuProcessRun(qemuProcessPtr proc) virCommandSetGID(proc->cmd, proc->runGid); virCommandSetUID(proc->cmd, proc->runUid); =20 - virCommandSetErrorBuffer(proc->cmd, proc->qmperr); + virCommandSetErrorBuffer(proc->cmd, &(proc->qmperr)); =20 /* Log, but otherwise ignore, non-zero status. */ if (virCommandRun(proc->cmd, &status) < 0) @@ -8197,7 +8194,7 @@ qemuProcessRun(qemuProcessPtr proc) =20 if (status !=3D 0) { VIR_DEBUG("QEMU %s exited with status %d: %s", - proc->binary, status, *proc->qmperr); + proc->binary, status, proc->qmperr); goto ignore; } =20 @@ -8259,7 +8256,6 @@ qemuProcessStopQmp(qemuProcessPtr proc) (long long)proc->pid, virStrerror(errno, ebuf, sizeof(ebuf))); =20 - VIR_FREE(*proc->qmperr); } if (proc->pidfile) unlink(proc->pidfile); diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index ab2640ce7c..abd80baf5c 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -220,7 +220,7 @@ struct _qemuProcess { char *binary; uid_t runUid; gid_t runGid; - char **qmperr; + char *qmperr; /* qemu process stderr */ char *monarg; char *monpath; char *pidfile; @@ -232,11 +232,13 @@ struct _qemuProcess { bool forceTCG; }; =20 +#define QEMU_PROCESS_ERROR(proc) \ + ((char *) (proc ? proc->qmperr: NULL)) + qemuProcessPtr qemuProcessNew(const char *binary, const char *libDir, uid_t runUid, gid_t runGid, - char **qmperr, bool forceTCG); =20 void qemuProcessFree(qemuProcessPtr proc); --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 1541216543625353.58535110581204; Fri, 2 Nov 2018 20:42:23 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7680B394D51; Sat, 3 Nov 2018 03:42:21 +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 443B260BE8; Sat, 3 Nov 2018 03:42:21 +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 E46E718005AD; Sat, 3 Nov 2018 03:42:20 +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 wA33ED7v011471 for ; Fri, 2 Nov 2018 23:14:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id EBA905D75D; Sat, 3 Nov 2018 03:14:13 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id E6FD25D6A9; Sat, 3 Nov 2018 03:14:10 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:14 -0500 Message-Id: <20181103031338.11600-14-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 13/37] qemu_capabilities: Detect caps probe failure by checking monitor ptr 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sat, 03 Nov 2018 03:42:22 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Failure to connect to QEMU to probe capabilities is not considered a error = case and does not result in a negative return value. Check for a NULL monitor connection pointer before trying to send capabilit= ies commands to QEMU rather than depending on a special positive return value. This simplifies logic and is more consistent with the operation of existing qemu_process functions. A macro is introduced to easily obtain the monitor pointer from the qemuProcess structure. Signed-off-by: Chris Venteicher --- src/qemu/qemu_capabilities.c | 28 ++++++++++++++++++---------- src/qemu/qemu_process.c | 9 +-------- src/qemu/qemu_process.h | 3 +++ 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 9a86838d8a..48b58ca02a 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4275,43 +4275,51 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, { qemuProcessPtr proc =3D NULL; qemuProcessPtr proc_kvm =3D NULL; + qemuMonitorPtr mon =3D NULL; + qemuMonitorPtr mon_kvm =3D NULL; int ret =3D -1; - int rc; bool forceTCG =3D false; =20 if (!(proc =3D qemuProcessNew(qemuCaps->binary, libDir, runUid, runGid, forceTCG))) goto cleanup; =20 - if ((rc =3D qemuProcessRun(proc)) !=3D 0) { - if (rc =3D=3D 1) - ret =3D 0; + + if (qemuProcessRun(proc) < 0) + goto cleanup; + + if (!(mon =3D QEMU_PROCESS_MONITOR(proc))) { + ret =3D 0; /* Failure probing QEMU not considered error case */ goto cleanup; } =20 - if (virQEMUCapsInitQMPMonitor(qemuCaps, proc->mon) < 0) + /* Pull capabilities from QEMU */ + if (virQEMUCapsInitQMPMonitor(qemuCaps, mon) < 0) goto cleanup; =20 + /* Pull capabilities again if KVM supported */ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) { qemuProcessStopQmp(proc); =20 forceTCG =3D true; proc_kvm =3D qemuProcessNew(qemuCaps->binary, libDir, runUid, runG= id, forceTCG); =20 - if ((rc =3D qemuProcessRun(proc_kvm)) !=3D 0) { - if (rc =3D=3D 1) - ret =3D 0; + if (qemuProcessRun(proc_kvm) < 0) + goto cleanup; + + if (!(mon_kvm =3D QEMU_PROCESS_MONITOR(proc_kvm))) { + ret =3D 0; /* Failure probing QEMU not considered error case */ goto cleanup; } =20 - if (virQEMUCapsInitQMPMonitorTCG(qemuCaps, proc_kvm->mon) < 0) + if (virQEMUCapsInitQMPMonitorTCG(qemuCaps, mon_kvm) < 0) goto cleanup; } =20 ret =3D 0; =20 cleanup: - if (proc && !proc->mon) { + if (!mon) { char *err =3D QEMU_PROCESS_ERROR(proc) ? QEMU_PROCESS_ERROR(proc) = : _("unknown error"); =20 virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 99b720b380..140c657087 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8145,10 +8145,6 @@ qemuProcessNew(const char *binary, } =20 =20 -/* Returns -1 on fatal error, - * 0 on success, - * 1 when probing QEMU failed - */ int qemuProcessRun(qemuProcessPtr proc){ virDomainXMLOptionPtr xmlopt =3D NULL; @@ -8215,6 +8211,7 @@ qemuProcessRun(qemuProcessPtr proc){ =20 virObjectLock(proc->mon); =20 + ignore: ret =3D 0; =20 cleanup: @@ -8223,10 +8220,6 @@ qemuProcessRun(qemuProcessPtr proc){ virObjectUnref(xmlopt); =20 return ret; - - ignore: - ret =3D 1; - goto cleanup; } =20 =20 diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index abd80baf5c..37194e2501 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -235,6 +235,9 @@ struct _qemuProcess { #define QEMU_PROCESS_ERROR(proc) \ ((char *) (proc ? proc->qmperr: NULL)) =20 +#define QEMU_PROCESS_MONITOR(proc) \ + ((qemuMonitorPtr) (proc ? proc->mon : NULL)) + qemuProcessPtr qemuProcessNew(const char *binary, const char *libDir, uid_t runUid, --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 1541216191924350.44261307136844; Fri, 2 Nov 2018 20:36:31 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DEAB5C033460; Sat, 3 Nov 2018 03:36:29 +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 A79CC60BE8; Sat, 3 Nov 2018 03:36:29 +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 50A283FADE; Sat, 3 Nov 2018 03:36:29 +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 wA33EFnX011476 for ; Fri, 2 Nov 2018 23:14:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 085C55D75D; Sat, 3 Nov 2018 03:14:15 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3AD215D6A9; Sat, 3 Nov 2018 03:14:14 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:15 -0500 Message-Id: <20181103031338.11600-15-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 14/37] qemu_process: Introduce qemuProcessStartQmp 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Sat, 03 Nov 2018 03:36:30 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Move a step closer to the function structure used elsewhere in qemu_process where qemuProcessStart and qemuProcessStop are the exposed functions. qemuProcessStartQmp mirrors qemuProcessStart in calling sub functions to intialize, launch the process and connect the monitor to the QEMU process. static functions qemuProcessInitQmp, qemuProcessLaunchQmp and qemuConnectMonitorQmp are also introduced. qemuProcessLaunchQmp is just renamed from qemuProcessRun and encapsulates all of the original code. qemuProcessInitQmp and qemuProcessMonitorQmp are introduced as empty wrappers into which subsequent patches will partition code from qemuProcessLaunchQmp. Signed-off-by: Chris Venteicher --- src/qemu/qemu_capabilities.c | 4 +- src/qemu/qemu_process.c | 96 +++++++++++++++++++++++++++++++++++- src/qemu/qemu_process.h | 2 +- 3 files changed, 97 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 48b58ca02a..5cbc726bb9 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4285,7 +4285,7 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, goto cleanup; =20 =20 - if (qemuProcessRun(proc) < 0) + if (qemuProcessStartQmp(proc) < 0) goto cleanup; =20 if (!(mon =3D QEMU_PROCESS_MONITOR(proc))) { @@ -4304,7 +4304,7 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, forceTCG =3D true; proc_kvm =3D qemuProcessNew(qemuCaps->binary, libDir, runUid, runG= id, forceTCG); =20 - if (qemuProcessRun(proc_kvm) < 0) + if (qemuProcessStartQmp(proc_kvm) < 0) goto cleanup; =20 if (!(mon_kvm =3D QEMU_PROCESS_MONITOR(proc_kvm))) { diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 140c657087..1d96a43206 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8145,8 +8145,29 @@ qemuProcessNew(const char *binary, } =20 =20 -int -qemuProcessRun(qemuProcessPtr proc){ +/* Initialize configuration and paths prior to starting QEMU + */ +static int +qemuProcessInitQmp(qemuProcessPtr proc) +{ + int ret =3D -1; + + VIR_DEBUG("Beginning VM startup process" + "emulator=3D%s", + proc->binary); + + ret =3D 0; + + VIR_DEBUG("ret=3D%i", ret); + return ret; +} + + +/* Launch QEMU Process + */ +static int +qemuProcessLaunchQmp(qemuProcessPtr proc) +{ virDomainXMLOptionPtr xmlopt =3D NULL; const char *machine; int status =3D 0; @@ -8223,6 +8244,77 @@ qemuProcessRun(qemuProcessPtr proc){ } =20 =20 +/* Connect Monitor to QEMU Process + */ +static int +qemuConnectMonitorQmp(qemuProcessPtr proc) +{ + int ret =3D -1; + + VIR_DEBUG("proc=3D%p, emulator=3D%s, proc->pid=3D%lld", + proc, NULLSTR(proc->binary), (long long) proc->pid); + + ret =3D 0; + + VIR_DEBUG("ret=3D%i", ret); + return ret; +} + + +/** + * qemuProcessStartQmp: + * @proc: Stores Process and Connection State + * + * Start and connect to QEMU binary so QMP queries can be made. + * + * Usage: + * proc =3D qemuProcessNew(binary, forceTCG, libDir, runUid, runGid); + * qemuProcessStartQmp(proc); + * mon =3D QEMU_PROCESS_MONITOR(proc); + * ** Send QMP Queries to QEMU using monitor ** + * qemuProcessStopQmp(proc); + * qemuProcessFree(proc); + * + * Check monitor is not NULL before using. + * + * QEMU probing failure results in monitor being NULL but is not considered + * an error case and does not result in a negative return value. + * + * Both qemuProcessStopQmp and qemuProcessFree must be called to cleanup a= nd + * free resources, even in activation failure cases. + * + * Process error output (proc->qmperr) remains available in qemuProcess st= ruct + * until qemuProcessFree is called. + */ +int +qemuProcessStartQmp(qemuProcessPtr proc) +{ + int ret =3D -1; + + VIR_DEBUG("emulator=3D%s", + proc->binary); + + if (qemuProcessInitQmp(proc) < 0) + goto cleanup; + + if (qemuProcessLaunchQmp(proc) < 0) + goto stop; + + if (qemuConnectMonitorQmp(proc) < 0) + goto stop; + + ret =3D 0; + + cleanup: + VIR_DEBUG("ret=3D%i", ret); + return ret; + + stop: + qemuProcessStopQmp(proc); + goto cleanup; +} + + void qemuProcessStopQmp(qemuProcessPtr proc) { diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index 37194e2501..c34ca52ef5 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -246,7 +246,7 @@ qemuProcessPtr qemuProcessNew(const char *binary, =20 void qemuProcessFree(qemuProcessPtr proc); =20 -int qemuProcessRun(qemuProcessPtr proc); +int qemuProcessStartQmp(qemuProcessPtr proc); =20 void qemuProcessStopQmp(qemuProcessPtr proc); =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 1541216555040965.977849361948; Fri, 2 Nov 2018 20:42:35 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4E4CC308338E; Sat, 3 Nov 2018 03:42:33 +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 1CC1C6146E; Sat, 3 Nov 2018 03:42:33 +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 C07AA180474F; Sat, 3 Nov 2018 03:42:32 +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 wA33EGgm011486 for ; Fri, 2 Nov 2018 23:14:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 084345D75D; Sat, 3 Nov 2018 03:14:16 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4453F5D6A9; Sat, 3 Nov 2018 03:14:15 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:16 -0500 Message-Id: <20181103031338.11600-16-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 15/37] qemu_process: Add debug message in qemuProcessLaunchQmp 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Sat, 03 Nov 2018 03:42:33 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Chris Venteicher --- src/qemu/qemu_process.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 1d96a43206..758c8bed05 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8173,6 +8173,9 @@ qemuProcessLaunchQmp(qemuProcessPtr proc) int status =3D 0; int ret =3D -1; =20 + VIR_DEBUG("proc=3D%p, emulator=3D%s", + proc, NULLSTR(proc->binary)); + if (proc->forceTCG) machine =3D "none,accel=3Dtcg"; else --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 154121615976526.817098072005138; Fri, 2 Nov 2018 20:35:59 -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 98CFE81F0D; Sat, 3 Nov 2018 03:35:57 +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 5CFB11054FDE; Sat, 3 Nov 2018 03:35: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 0C7144CAAE; Sat, 3 Nov 2018 03:35:57 +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 wA33EHH6011496 for ; Fri, 2 Nov 2018 23:14:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0A07C5D760; Sat, 3 Nov 2018 03:14:17 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 447CB5D6A9; Sat, 3 Nov 2018 03:14:16 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:17 -0500 Message-Id: <20181103031338.11600-17-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 16/37] qemu_process: Collect monitor code in single function 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.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sat, 03 Nov 2018 03:35:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" qemuMonitor code lives in qemuConnectMonitorQmp rather than in qemuProcessNew and qemuProcessLaunchQmp. This is consistent with existing structure in qemu_process.c where qemuConnectMonitor function contains monitor code for domain process activation. Simple code moves in this patch. Improvements in later patch. Only intended functional change in this patch is we don't move (include) code to initiate process stop on failure to create monitor. As comments in qemuProcessStartQmp say... Client must always call qemuProcessStop and qemuProcessFree, even in error cases. Signed-off-by: Chris Venteicher --- src/qemu/qemu_process.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 758c8bed05..f109e6e19b 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8133,10 +8133,6 @@ qemuProcessNew(const char *binary, =20 virPidFileForceCleanupPath(proc->pidfile); =20 - proc->config.type =3D VIR_DOMAIN_CHR_TYPE_UNIX; - proc->config.data.nix.path =3D proc->monpath; - proc->config.data.nix.listen =3D false; - return proc; =20 error: @@ -8168,7 +8164,6 @@ qemuProcessInitQmp(qemuProcessPtr proc) static int qemuProcessLaunchQmp(qemuProcessPtr proc) { - virDomainXMLOptionPtr xmlopt =3D NULL; const char *machine; int status =3D 0; int ret =3D -1; @@ -8223,26 +8218,10 @@ qemuProcessLaunchQmp(qemuProcessPtr proc) goto ignore; } =20 - if (!(xmlopt =3D virDomainXMLOptionNew(NULL, NULL, NULL, NULL, NULL)) = || - !(proc->vm =3D virDomainObjNew(xmlopt))) - goto cleanup; - - proc->vm->pid =3D proc->pid; - - if (!(proc->mon =3D qemuMonitorOpen(proc->vm, &proc->config, true, tru= e, - 0, &callbacks, NULL))) - goto ignore; - - virObjectLock(proc->mon); - ignore: ret =3D 0; =20 cleanup: - if (!proc->mon) - qemuProcessStopQmp(proc); - virObjectUnref(xmlopt); - return ret; } =20 @@ -8253,13 +8232,33 @@ static int qemuConnectMonitorQmp(qemuProcessPtr proc) { int ret =3D -1; + virDomainXMLOptionPtr xmlopt =3D NULL; =20 VIR_DEBUG("proc=3D%p, emulator=3D%s, proc->pid=3D%lld", proc, NULLSTR(proc->binary), (long long) proc->pid); =20 + proc->config.type =3D VIR_DOMAIN_CHR_TYPE_UNIX; + proc->config.data.nix.path =3D proc->monpath; + proc->config.data.nix.listen =3D false; + + if (!(xmlopt =3D virDomainXMLOptionNew(NULL, NULL, NULL, NULL, NULL)) = || + !(proc->vm =3D virDomainObjNew(xmlopt))) + goto cleanup; + + proc->vm->pid =3D proc->pid; + + if (!(proc->mon =3D qemuMonitorOpen(proc->vm, &proc->config, true, tru= e, + 0, &callbacks, NULL))) + goto ignore; + + virObjectLock(proc->mon); + + ignore: ret =3D 0; =20 + cleanup: VIR_DEBUG("ret=3D%i", ret); + virObjectUnref(xmlopt); return ret; } =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 1541216203730898.1499779415667; Fri, 2 Nov 2018 20:36:43 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B841080470; Sat, 3 Nov 2018 03:36:41 +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 75CAF5C225; Sat, 3 Nov 2018 03:36:41 +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 0C11F18005AD; Sat, 3 Nov 2018 03:36:41 +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 wA33EJn2011512 for ; Fri, 2 Nov 2018 23:14:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7ED375D6A9; Sat, 3 Nov 2018 03:14:19 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id B3D2E5D760; Sat, 3 Nov 2018 03:14:17 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:18 -0500 Message-Id: <20181103031338.11600-18-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 17/37] qemu_process: Store libDir in qemuProcess struct 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Sat, 03 Nov 2018 03:36:42 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Store libDir path in the qemuProcess struct in anticipation of moving path construction code into qemuProcessInitQmp function. Signed-off-by: Chris Venteicher --- src/qemu/qemu_process.c | 8 +++++--- src/qemu/qemu_process.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index f109e6e19b..804ec998af 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8085,6 +8085,7 @@ qemuProcessFree(qemuProcessPtr proc) =20 qemuProcessStopQmp(proc); VIR_FREE(proc->binary); + VIR_FREE(proc->libDir); VIR_FREE(proc->monpath); VIR_FREE(proc->monarg); VIR_FREE(proc->pidfile); @@ -8105,7 +8106,8 @@ qemuProcessNew(const char *binary, if (VIR_ALLOC(proc) < 0) goto error; =20 - if (VIR_STRDUP(proc->binary, binary) < 0) + if (VIR_STRDUP(proc->binary, binary) < 0 || + VIR_STRDUP(proc->libDir, libDir) < 0) goto error; =20 proc->forceTCG =3D forceTCG; @@ -8116,7 +8118,7 @@ qemuProcessNew(const char *binary, /* the ".sock" sufix is important to avoid a possible clash with a qemu * domain called "capabilities" */ - if (virAsprintf(&proc->monpath, "%s/%s", libDir, + if (virAsprintf(&proc->monpath, "%s/%s", proc->libDir, "capabilities.monitor.sock") < 0) goto error; if (virAsprintf(&proc->monarg, "unix:%s,server,nowait", proc->monpath)= < 0) @@ -8128,7 +8130,7 @@ qemuProcessNew(const char *binary, * -daemonize we need QEMU to be allowed to create them, rather * than libvirtd. So we're using libDir which QEMU can write to */ - if (virAsprintf(&proc->pidfile, "%s/%s", libDir, "capabilities.pidfile= ") < 0) + if (virAsprintf(&proc->pidfile, "%s/%s", proc->libDir, "capabilities.p= idfile") < 0) goto error; =20 virPidFileForceCleanupPath(proc->pidfile); diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index c34ca52ef5..1b8f743861 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -218,6 +218,7 @@ typedef struct _qemuProcess qemuProcess; typedef qemuProcess *qemuProcessPtr; struct _qemuProcess { char *binary; + char *libDir; uid_t runUid; gid_t runGid; char *qmperr; /* qemu process stderr */ --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 1541216566555590.2646464122611; Fri, 2 Nov 2018 20:42:46 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A3E29307DAAC; Sat, 3 Nov 2018 03:42:44 +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 6FC4A67C63; Sat, 3 Nov 2018 03:42:44 +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 294B1180BAD0; Sat, 3 Nov 2018 03:42:44 +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 wA33EKtv011520 for ; Fri, 2 Nov 2018 23:14:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 833385D76A; Sat, 3 Nov 2018 03:14:20 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB70B5D75D; Sat, 3 Nov 2018 03:14:19 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:19 -0500 Message-Id: <20181103031338.11600-19-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 18/37] qemu_process: Setup paths within qemuProcessInitQmp 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Sat, 03 Nov 2018 03:42:45 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Move code for setting paths and prepping file system from qemuProcessNew to qemuProcessInitQmp. This keeps qemuProcessNew limited to structure initialization and most closely mirrors pattern established in qemuProcessInit within qemuProcessInitQmp. The patch is a non-functional, cut / paste change, however goto is now "cleanup" rather than "error". Signed-off-by: Chris Venteicher --- src/qemu/qemu_process.c | 42 +++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 804ec998af..70b0b61aef 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8115,26 +8115,6 @@ qemuProcessNew(const char *binary, proc->runUid =3D runUid; proc->runGid =3D runGid; =20 - /* the ".sock" sufix is important to avoid a possible clash with a qemu - * domain called "capabilities" - */ - if (virAsprintf(&proc->monpath, "%s/%s", proc->libDir, - "capabilities.monitor.sock") < 0) - goto error; - if (virAsprintf(&proc->monarg, "unix:%s,server,nowait", proc->monpath)= < 0) - goto error; - - /* ".pidfile" suffix is used rather than ".pid" to avoid a possible cl= ash - * with a qemu domain called "capabilities" - * Normally we'd use runDir for pid files, but because we're using - * -daemonize we need QEMU to be allowed to create them, rather - * than libvirtd. So we're using libDir which QEMU can write to - */ - if (virAsprintf(&proc->pidfile, "%s/%s", proc->libDir, "capabilities.p= idfile") < 0) - goto error; - - virPidFileForceCleanupPath(proc->pidfile); - return proc; =20 error: @@ -8154,8 +8134,30 @@ qemuProcessInitQmp(qemuProcessPtr proc) "emulator=3D%s", proc->binary); =20 + /* the ".sock" sufix is important to avoid a possible clash with a qemu + * domain called "capabilities" + */ + if (virAsprintf(&proc->monpath, "%s/%s", proc->libDir, + "capabilities.monitor.sock") < 0) + goto cleanup; + + if (virAsprintf(&proc->monarg, "unix:%s,server,nowait", proc->monpath)= < 0) + goto cleanup; + + /* ".pidfile" suffix is used rather than ".pid" to avoid a possible cl= ash + * with a qemu domain called "capabilities" + * Normally we'd use runDir for pid files, but because we're using + * -daemonize we need QEMU to be allowed to create them, rather + * than libvirtd. So we're using libDir which QEMU can write to + */ + if (virAsprintf(&proc->pidfile, "%s/%s", proc->libDir, "capabilities.p= idfile") < 0) + goto cleanup; + + virPidFileForceCleanupPath(proc->pidfile); + ret =3D 0; =20 + cleanup: VIR_DEBUG("ret=3D%i", ret); return ret; } --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 154121617109337.43894695264123; Fri, 2 Nov 2018 20:36:11 -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 229AC34CC; Sat, 3 Nov 2018 03:36:09 +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 CC0BE60BF1; Sat, 3 Nov 2018 03:36:08 +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 5018D18005B6; Sat, 3 Nov 2018 03:36:08 +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 wA33ELpS011527 for ; Fri, 2 Nov 2018 23:14:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8706F5D763; Sat, 3 Nov 2018 03:14:21 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id C07735D75D; Sat, 3 Nov 2018 03:14:20 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:20 -0500 Message-Id: <20181103031338.11600-20-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 19/37] qemu_process: Stop retaining Qemu Monitor config in qemuProcess 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.29]); Sat, 03 Nov 2018 03:36:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The monitor config data is removed from the qemuProcess struct. The monitor config data can be initialized immediately before call to qemuMonitorOpen and does not need to be maintained after the call because qemuMonitorOpen copies any strings it needs. Signed-off-by: Chris Venteicher --- src/qemu/qemu_process.c | 9 +++++---- src/qemu/qemu_process.h | 1 - 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 70b0b61aef..70ca82dd55 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8237,13 +8237,14 @@ qemuConnectMonitorQmp(qemuProcessPtr proc) { int ret =3D -1; virDomainXMLOptionPtr xmlopt =3D NULL; + virDomainChrSourceDef monConfig; =20 VIR_DEBUG("proc=3D%p, emulator=3D%s, proc->pid=3D%lld", proc, NULLSTR(proc->binary), (long long) proc->pid); =20 - proc->config.type =3D VIR_DOMAIN_CHR_TYPE_UNIX; - proc->config.data.nix.path =3D proc->monpath; - proc->config.data.nix.listen =3D false; + monConfig.type =3D VIR_DOMAIN_CHR_TYPE_UNIX; + monConfig.data.nix.path =3D proc->monpath; + monConfig.data.nix.listen =3D false; =20 if (!(xmlopt =3D virDomainXMLOptionNew(NULL, NULL, NULL, NULL, NULL)) = || !(proc->vm =3D virDomainObjNew(xmlopt))) @@ -8251,7 +8252,7 @@ qemuConnectMonitorQmp(qemuProcessPtr proc) =20 proc->vm->pid =3D proc->pid; =20 - if (!(proc->mon =3D qemuMonitorOpen(proc->vm, &proc->config, true, tru= e, + if (!(proc->mon =3D qemuMonitorOpen(proc->vm, &monConfig, true, true, 0, &callbacks, NULL))) goto ignore; =20 diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index 1b8f743861..d1541d5407 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -227,7 +227,6 @@ struct _qemuProcess { char *pidfile; virCommandPtr cmd; qemuMonitorPtr mon; - virDomainChrSourceDef config; pid_t pid; virDomainObjPtr vm; bool forceTCG; --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 1541216217292229.2121633543029; Fri, 2 Nov 2018 20:36:57 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 10E2731256CD; Sat, 3 Nov 2018 03:36:55 +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 CABDB6012B; Sat, 3 Nov 2018 03:36:54 +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 720013FA5D; Sat, 3 Nov 2018 03:36:54 +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 wA33EMPh011537 for ; Fri, 2 Nov 2018 23:14:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 888235D760; Sat, 3 Nov 2018 03:14:22 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id C37A05D6A9; Sat, 3 Nov 2018 03:14:21 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:21 -0500 Message-Id: <20181103031338.11600-21-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 20/37] qemu_process: Don't open monitor if process failed 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Sat, 03 Nov 2018 03:36:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Gracefully handle case when proc activation failed prior to calling. Consistent with the existing code for qemuConnectMonitor (for domains) in qemu_process.c... - Handle qemMonitorOpen failure with INFO message and NULL ptr - Identify parameters passed to qemuMonitorOpen Monitor callbacks will be removed in future patch so we prep for passing NULL for the callback pointer. Set proc->mon to NULL then use VIR_STEAL_PTR if successful to be consistent with other functions. Signed-off-by: Chris Venteicher --- src/qemu/qemu_process.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 70ca82dd55..af6b20713a 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8236,25 +8236,48 @@ static int qemuConnectMonitorQmp(qemuProcessPtr proc) { int ret =3D -1; + qemuMonitorPtr mon =3D NULL; + unsigned long long timeout =3D 0; + bool retry =3D true; + bool enableJson =3D true; + virQEMUDriverPtr driver =3D NULL; + qemuMonitorCallbacksPtr monCallbacks =3D &callbacks; virDomainXMLOptionPtr xmlopt =3D NULL; virDomainChrSourceDef monConfig; =20 VIR_DEBUG("proc=3D%p, emulator=3D%s, proc->pid=3D%lld", proc, NULLSTR(proc->binary), (long long) proc->pid); =20 + if (!proc || !proc->pid) + goto ignore; + + proc->mon =3D NULL; + monConfig.type =3D VIR_DOMAIN_CHR_TYPE_UNIX; monConfig.data.nix.path =3D proc->monpath; monConfig.data.nix.listen =3D false; =20 + /* Create a NULL Domain object for qemuMonitor */ if (!(xmlopt =3D virDomainXMLOptionNew(NULL, NULL, NULL, NULL, NULL)) = || !(proc->vm =3D virDomainObjNew(xmlopt))) goto cleanup; =20 proc->vm->pid =3D proc->pid; =20 - if (!(proc->mon =3D qemuMonitorOpen(proc->vm, &monConfig, true, true, - 0, &callbacks, NULL))) + mon =3D qemuMonitorOpen(proc->vm, + &monConfig, + enableJson, + retry, + timeout, + monCallbacks, + driver); + + if (!mon) { + VIR_INFO("Failed to connect monitor to emulator %s", proc->binary); goto ignore; + } + + VIR_STEAL_PTR(proc->mon, mon); =20 virObjectLock(proc->mon); =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 1541216183586314.3444500437588; Fri, 2 Nov 2018 20:36:23 -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 8DF28307DAAE; Sat, 3 Nov 2018 03:36:21 +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 087AB1057048; Sat, 3 Nov 2018 03:36:21 +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 AC02B41091; Sat, 3 Nov 2018 03:36:20 +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 wA33ENdf011547 for ; Fri, 2 Nov 2018 23:14:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 893775D75D; Sat, 3 Nov 2018 03:14:23 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id C3ADC5D6A9; Sat, 3 Nov 2018 03:14:22 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:22 -0500 Message-Id: <20181103031338.11600-22-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 21/37] qemu_process: Cleanup qemuProcess alloc function 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.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Sat, 03 Nov 2018 03:36:22 +0000 (UTC) Content-Type: text/plain; charset="utf-8" qemuProcessNew is one of the 4 public functions used to create and manage a qemu process for QMP command exchanges outside of domain operations. Add descriptive comment block, Debug statement and make source consistent with the cleanup / VIR_STEAL_PTR format used elsewhere. No functional changes are made. Signed-off-by: Chris Venteicher --- src/qemu/qemu_process.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index af6b20713a..104ed58cea 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8094,6 +8094,18 @@ qemuProcessFree(qemuProcessPtr proc) } =20 =20 +/** + * qemuProcessNew: + * @binary: Qemu binary + * @libDir: Directory for process and connection artifacts + * @runUid: UserId for Qemu Process + * @runGid: GroupId for Qemu Process + * @forceTCG: Force TCG mode if true + * + * Allocate and initialize domain structure encapsulating + * QEMU Process state and monitor connection to QEMU + * for completing QMP Queries. + */ qemuProcessPtr qemuProcessNew(const char *binary, const char *libDir, @@ -8101,25 +8113,29 @@ qemuProcessNew(const char *binary, gid_t runGid, bool forceTCG) { + qemuProcessPtr ret =3D NULL; qemuProcessPtr proc =3D NULL; =20 + VIR_DEBUG("exec=3D%s, libDir=3D%s, runUid=3D%u, runGid=3D%u, forceTCG= =3D%d", + NULLSTR(binary), NULLSTR(libDir), runUid, runGid, forceTCG); + if (VIR_ALLOC(proc) < 0) - goto error; + goto cleanup; =20 if (VIR_STRDUP(proc->binary, binary) < 0 || VIR_STRDUP(proc->libDir, libDir) < 0) - goto error; + goto cleanup; =20 proc->forceTCG =3D forceTCG; =20 proc->runUid =3D runUid; proc->runGid =3D runGid; =20 - return proc; + VIR_STEAL_PTR(ret, proc); =20 - error: + cleanup: qemuProcessFree(proc); - return NULL; + return ret; } =20 =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 15412165774598.776082442083748; Fri, 2 Nov 2018 20:42:57 -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 620A180F90; Sat, 3 Nov 2018 03:42:55 +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 247BC5D760; Sat, 3 Nov 2018 03:42:55 +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 C940B180474F; Sat, 3 Nov 2018 03:42:54 +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 wA33EOwY011560 for ; Fri, 2 Nov 2018 23:14:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8D7D45D75D; Sat, 3 Nov 2018 03:14:24 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id C56D55D6A9; Sat, 3 Nov 2018 03:14:23 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:23 -0500 Message-Id: <20181103031338.11600-23-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 22/37] qemu_process: Cleanup qemuProcessStopQmp function 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.27]); Sat, 03 Nov 2018 03:42:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" qemuProcessStopQmp is one of the 4 public functions used to crate and manage a Qemu process for QMP command exchanges. Add comment header and debug message. Other minor code formatting cleanup. No change in functionality is intended. Signed-off-by: Chris Venteicher --- src/qemu/qemu_process.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 104ed58cea..cb2902be02 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8360,14 +8360,27 @@ qemuProcessStartQmp(qemuProcessPtr proc) goto cleanup; } =20 - -void -qemuProcessStopQmp(qemuProcessPtr proc) +/** + * qemuProcessStop: + * @proc: Stores Process and Connection State + * + * Stop Monitor Connection and QEMU Process + */ +void qemuProcessStopQmp(qemuProcessPtr proc) { - if (proc->mon) - virObjectUnlock(proc->mon); - qemuMonitorClose(proc->mon); - proc->mon =3D NULL; + qemuMonitorPtr mon =3D NULL; + + if (!proc) + return; + + VIR_DEBUG("Shutting down proc=3D%p emulator=3D%s mon=3D%p pid=3D%lld", + proc, proc->binary, proc->mon, (long long)proc->pid); + + if ((mon =3D QEMU_PROCESS_MONITOR(proc))) { + virObjectUnlock(mon); + qemuMonitorClose(mon); + proc->mon =3D NULL; + } =20 virCommandAbort(proc->cmd); virCommandFree(proc->cmd); @@ -8388,7 +8401,9 @@ qemuProcessStopQmp(qemuProcessPtr proc) virStrerror(errno, ebuf, sizeof(ebuf))); =20 } + if (proc->pidfile) unlink(proc->pidfile); + proc->pid =3D 0; } --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 1541216194876424.88420603138445; Fri, 2 Nov 2018 20:36:34 -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 F080A5A1F9; Sat, 3 Nov 2018 03:36:32 +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 9F3BD611AB; Sat, 3 Nov 2018 03:36:32 +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 319453FA56; Sat, 3 Nov 2018 03:36:32 +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 wA33EPmA011567 for ; Fri, 2 Nov 2018 23:14:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9258A5D760; Sat, 3 Nov 2018 03:14:25 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id C92DA5D6A9; Sat, 3 Nov 2018 03:14:24 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:24 -0500 Message-Id: <20181103031338.11600-24-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 23/37] qemu_process: Catch process free before process stop 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.28]); Sat, 03 Nov 2018 03:36:33 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Catch execution paths where qemuProcessFree is called before qemuProcessStopQmp then report error and force stop before proceeding. Also added public function header and debug message. Signed-off-by: Chris Venteicher --- src/qemu/qemu_process.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index cb2902be02..9d3ce4eb6d 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8075,15 +8075,28 @@ static qemuMonitorCallbacks callbacks =3D { }; =20 =20 - - +/** + * qemuProcessFree: + * @proc: Stores Process and Connection State + * + * Free process data structure. + */ void qemuProcessFree(qemuProcessPtr proc) { + VIR_DEBUG("proc=3D%p, proc->mon=3D%p", proc, (proc ? proc->mon : NULL)= ); + if (!proc) return; =20 - qemuProcessStopQmp(proc); + /* This should never be non-NULL if we get here, but just in case... */ + if (proc->mon || proc->pid) { + VIR_ERROR(_("Unexpected QEMU still active during process free" + " emulator: %s, pid: %lld, mon: %p"), + NULLSTR(proc->binary), (long long) proc->pid, proc->mo= n); + qemuProcessStopQmp(proc); + } + VIR_FREE(proc->binary); VIR_FREE(proc->libDir); VIR_FREE(proc->monpath); --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 1541216228325439.3385880067351; Fri, 2 Nov 2018 20:37:08 -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 546743078AAA; Sat, 3 Nov 2018 03:37:06 +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 167962C8E7; Sat, 3 Nov 2018 03:37:06 +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 ACEE8180474F; Sat, 3 Nov 2018 03:37:05 +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 wA33ETiH011583 for ; Fri, 2 Nov 2018 23:14:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5D6F65D760; Sat, 3 Nov 2018 03:14:29 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 95BB15D6A9; Sat, 3 Nov 2018 03:14:25 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:25 -0500 Message-Id: <20181103031338.11600-25-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 24/37] qemu_monitor: Make monitor callbacks optional 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.48]); Sat, 03 Nov 2018 03:37:06 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Qemu process code for capababilities doesn't use monitor callbacks and defines empty callback functions. Allow NULL to be passed to qemuMonitorOpen for callbacks and remove the empty functions from the QMP process code. Signed-off-by: Chris Venteicher --- src/qemu/qemu_monitor.c | 4 ++-- src/qemu/qemu_process.c | 14 +------------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 4c0c2decf7..2071c6e846 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -813,12 +813,12 @@ qemuMonitorOpenInternal(virDomainObjPtr vm, { qemuMonitorPtr mon; =20 - if (!cb->eofNotify) { + if (cb && !cb->eofNotify) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("EOF notify callback must be supplied")); return NULL; } - if (!cb->errorNotify) { + if (cb && !cb->errorNotify) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Error notify callback must be supplied")); return NULL; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 9d3ce4eb6d..f545fc3b33 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8063,18 +8063,6 @@ qemuProcessReconnectAll(virQEMUDriverPtr driver) } =20 =20 -static void virQEMUCapsMonitorNotify(qemuMonitorPtr mon ATTRIBUTE_UNUSED, - virDomainObjPtr vm ATTRIBUTE_UNUSED, - void *opaque ATTRIBUTE_UNUSED) -{ -} - -static qemuMonitorCallbacks callbacks =3D { - .eofNotify =3D virQEMUCapsMonitorNotify, - .errorNotify =3D virQEMUCapsMonitorNotify, -}; - - /** * qemuProcessFree: * @proc: Stores Process and Connection State @@ -8270,7 +8258,7 @@ qemuConnectMonitorQmp(qemuProcessPtr proc) bool retry =3D true; bool enableJson =3D true; virQEMUDriverPtr driver =3D NULL; - qemuMonitorCallbacksPtr monCallbacks =3D &callbacks; + qemuMonitorCallbacksPtr monCallbacks =3D NULL; virDomainXMLOptionPtr xmlopt =3D NULL; virDomainChrSourceDef monConfig; =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 1541216240784173.60038700102677; Fri, 2 Nov 2018 20:37:20 -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 C2A52C033460; Sat, 3 Nov 2018 03:37:18 +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 7B36D5EDE0; Sat, 3 Nov 2018 03:37:18 +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 1978D180474F; Sat, 3 Nov 2018 03:37:18 +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 wA33EWJX011593 for ; Fri, 2 Nov 2018 23:14:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id B7D535D760; Sat, 3 Nov 2018 03:14:32 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 978D25D6A9; Sat, 3 Nov 2018 03:14:29 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:26 -0500 Message-Id: <20181103031338.11600-26-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 25/37] qemu_process: Enter QMP command mode when starting QEMU Process 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.32]); Sat, 03 Nov 2018 03:37:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" qemuProcessStartQmp starts a QEMU process and monitor connection that can be used by multiple functions possibly for multiple QMP commands. The QMP exchange to exit capabilities negotiation mode and enter command mo= de can only be performed once after the monitor connection is established. Move responsibility for entering QMP command mode into the qemuProcess code so multiple functions can issue QMP commands in arbitrary orders. This also simplifies the functions using the connection provided by qemuProcessStartQmp to issue QMP commands. Test code now needs to call qemuMonitorSetCapabilities to send the message to switch to command mode because the test code does not use the qemuProcess command that internally calls qemuMonitorSetCapabilities. Signed-off-by: Chris Venteicher --- src/qemu/qemu_capabilities.c | 14 -------------- src/qemu/qemu_process.c | 8 ++++++++ tests/qemucapabilitiestest.c | 7 +++++++ 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 5cbc726bb9..dd7c07f6e2 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4068,13 +4068,6 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, =20 /* @mon is supposed to be locked by callee */ =20 - if (qemuMonitorSetCapabilities(mon) < 0) { - VIR_DEBUG("Failed to set monitor capabilities %s", - virGetLastErrorMessage()); - ret =3D 0; - goto cleanup; - } - if (qemuMonitorGetVersion(mon, &major, &minor, µ, &package) < 0) { @@ -4248,13 +4241,6 @@ virQEMUCapsInitQMPMonitorTCG(virQEMUCapsPtr qemuCaps= ATTRIBUTE_UNUSED, { int ret =3D -1; =20 - if (qemuMonitorSetCapabilities(mon) < 0) { - VIR_DEBUG("Failed to set monitor capabilities %s", - virGetLastErrorMessage()); - ret =3D 0; - goto cleanup; - } - if (virQEMUCapsProbeQMPCPUDefinitions(qemuCaps, mon, true) < 0) goto cleanup; =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index f545fc3b33..1bb11b2089 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8298,6 +8298,14 @@ qemuConnectMonitorQmp(qemuProcessPtr proc) =20 virObjectLock(proc->mon); =20 + /* Exit capabilities negotiation mode and enter QEMU command mode + * by issuing qmp_capabilities command to QEMU */ + if (qemuMonitorSetCapabilities(proc->mon) < 0) { + VIR_DEBUG("Failed to set monitor capabilities %s", + virGetLastErrorMessage()); + goto ignore; + } + ignore: ret =3D 0; =20 diff --git a/tests/qemucapabilitiestest.c b/tests/qemucapabilitiestest.c index 8fe5a55e1d..ea4671739b 100644 --- a/tests/qemucapabilitiestest.c +++ b/tests/qemucapabilitiestest.c @@ -58,6 +58,9 @@ testQemuCaps(const void *opaque) if (!(mon =3D qemuMonitorTestNewFromFileFull(repliesFile, &data->drive= r, NULL))) goto cleanup; =20 + if (qemuMonitorSetCapabilities(qemuMonitorTestGetMonitor(mon)) < 0) + goto cleanup; + if (!(capsActual =3D virQEMUCapsNew()) || virQEMUCapsInitQMPMonitor(capsActual, qemuMonitorTestGetMonitor(mon)) < 0) @@ -65,6 +68,10 @@ testQemuCaps(const void *opaque) =20 if (virQEMUCapsGet(capsActual, QEMU_CAPS_KVM)) { qemuMonitorResetCommandID(qemuMonitorTestGetMonitor(mon)); + + if (qemuMonitorSetCapabilities(qemuMonitorTestGetMonitor(mon)) < 0) + goto cleanup; + if (virQEMUCapsInitQMPMonitorTCG(capsActual, qemuMonitorTestGetMonitor(mon)) <= 0) goto cleanup; --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 1541216590174434.92113389650615; Fri, 2 Nov 2018 20:43:10 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B62AD3082B6F; Sat, 3 Nov 2018 03:43:07 +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 7E6D353B27; Sat, 3 Nov 2018 03:43:07 +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 1CAF718005B5; Sat, 3 Nov 2018 03:43:07 +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 wA33EXHq011601 for ; Fri, 2 Nov 2018 23:14:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id BB1615D75D; Sat, 3 Nov 2018 03:14:33 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id F2D675D6A9; Sat, 3 Nov 2018 03:14:32 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:27 -0500 Message-Id: <20181103031338.11600-27-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 26/37] qemu_process: Use unique directories for QMP processes 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Sat, 03 Nov 2018 03:43:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Multiple QEMU processes for QMP commands can operate concurrently. Use a unique directory under libDir for each QEMU processes to avoid pidfile and unix socket collision between processes. The pid file name is changed from "capabilities.pidfile" to "qmp.pid" because we no longer need to avoid a possible clash with a qemu domain called "capabilities" now that the processes artifacts are stored in their own unique temporary directories. "Capabilities" was changed to "qmp" in the pid file name because these processes are no longer specific to the capabilities usecase and are more generic in terms of being used for any general purpose QMP message exchanges with a QEMU process that is not associated with a domain. Signed-off-by: Chris Venteicher --- src/qemu/qemu_process.c | 26 ++++++++++++++++---------- src/qemu/qemu_process.h | 1 + 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 1bb11b2089..08522a1580 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8087,6 +8087,7 @@ qemuProcessFree(qemuProcessPtr proc) =20 VIR_FREE(proc->binary); VIR_FREE(proc->libDir); + VIR_FREE(proc->uniqDir); VIR_FREE(proc->monpath); VIR_FREE(proc->monarg); VIR_FREE(proc->pidfile); @@ -8145,33 +8146,33 @@ qemuProcessNew(const char *binary, static int qemuProcessInitQmp(qemuProcessPtr proc) { + char *template =3D NULL; int ret =3D -1; =20 VIR_DEBUG("Beginning VM startup process" "emulator=3D%s", proc->binary); =20 - /* the ".sock" sufix is important to avoid a possible clash with a qemu - * domain called "capabilities" - */ - if (virAsprintf(&proc->monpath, "%s/%s", proc->libDir, - "capabilities.monitor.sock") < 0) + if (virAsprintf(&template, "%s/qemu.XXXXXX", proc->libDir) < 0) + goto cleanup; + + proc->uniqDir =3D mkdtemp(template); + + if (virAsprintf(&proc->monpath, "%s/%s", proc->uniqDir, + "qmp.monitor") < 0) goto cleanup; =20 if (virAsprintf(&proc->monarg, "unix:%s,server,nowait", proc->monpath)= < 0) goto cleanup; =20 - /* ".pidfile" suffix is used rather than ".pid" to avoid a possible cl= ash - * with a qemu domain called "capabilities" + /* * Normally we'd use runDir for pid files, but because we're using * -daemonize we need QEMU to be allowed to create them, rather * than libvirtd. So we're using libDir which QEMU can write to */ - if (virAsprintf(&proc->pidfile, "%s/%s", proc->libDir, "capabilities.p= idfile") < 0) + if (virAsprintf(&proc->pidfile, "%s/%s", proc->uniqDir, "qmp.pid") < 0) goto cleanup; =20 - virPidFileForceCleanupPath(proc->pidfile); - ret =3D 0; =20 cleanup: @@ -8415,4 +8416,9 @@ void qemuProcessStopQmp(qemuProcessPtr proc) unlink(proc->pidfile); =20 proc->pid =3D 0; + + + if (proc->uniqDir) + rmdir(proc->uniqDir); + } diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index d1541d5407..f66fc0c82c 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -225,6 +225,7 @@ struct _qemuProcess { char *monarg; char *monpath; char *pidfile; + char *uniqDir; virCommandPtr cmd; qemuMonitorPtr mon; pid_t pid; --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 1541216601052686.396716717105; Fri, 2 Nov 2018 20:43:21 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 070FA31256A9; Sat, 3 Nov 2018 03:43:19 +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 C54E360BEC; Sat, 3 Nov 2018 03:43:18 +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 76EDA180BAD1; Sat, 3 Nov 2018 03:43:18 +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 wA33EYuc011608 for ; Fri, 2 Nov 2018 23:14:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id BA09E5D760; Sat, 3 Nov 2018 03:14:34 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01EC45D6A9; Sat, 3 Nov 2018 03:14:33 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:28 -0500 Message-Id: <20181103031338.11600-28-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 27/37] qemu_process: Stop locking QMP process monitor immediately 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Sat, 03 Nov 2018 03:43:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Locking the monitor object immediately after call to qemuMonitorOpen doesn't make sense now that we have expanded the QEMU process code to cover more than the original capabilities usecase. Removing the monitor lock makes the qemuConnectMonitorQmp code consistent with the qemuConnectMonitor code used to establish the monitor when QEMU process is started for domains. Signed-off-by: Chris Venteicher --- src/qemu/qemu_process.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 08522a1580..6bd3da97ca 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8297,8 +8297,6 @@ qemuConnectMonitorQmp(qemuProcessPtr proc) =20 VIR_STEAL_PTR(proc->mon, mon); =20 - virObjectLock(proc->mon); - /* Exit capabilities negotiation mode and enter QEMU command mode * by issuing qmp_capabilities command to QEMU */ if (qemuMonitorSetCapabilities(proc->mon) < 0) { --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 154121620822332.30002581949532; Fri, 2 Nov 2018 20:36:48 -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 EE4953001E6A; Sat, 3 Nov 2018 03:36:45 +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 A45D8611B6; Sat, 3 Nov 2018 03:36:45 +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 32FEC3FA5B; Sat, 3 Nov 2018 03:36:45 +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 wA33EZ1K011618 for ; Fri, 2 Nov 2018 23:14:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id D33C35D75D; Sat, 3 Nov 2018 03:14:35 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1AA6D5D6A9; Sat, 3 Nov 2018 03:14:34 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:29 -0500 Message-Id: <20181103031338.11600-29-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 28/37] qemu_capabilities: Introduce CPUModelInfo to virCPUDef function 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.47]); Sat, 03 Nov 2018 03:36:46 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Move existing code to convert between cpu model info structures (qemuMonitorCPUModelInfoPtr into virCPUDef) into a reusable function. The new function is used in this and future patches. Signed-off-by: Chris Venteicher --- src/qemu/qemu_capabilities.c | 84 ++++++++++++++++++++++++++---------- src/qemu/qemu_capabilities.h | 3 ++ 2 files changed, 64 insertions(+), 23 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index dd7c07f6e2..dcd6ffb876 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2797,7 +2797,8 @@ virQEMUCapsInitCPUModelS390(virQEMUCapsPtr qemuCaps, virCPUDefPtr cpu, bool migratable) { - size_t i; + virCPUDefPtr tmp =3D NULL; + int ret =3D -1; =20 if (!modelInfo) { if (type =3D=3D VIR_DOMAIN_VIRT_KVM) { @@ -2810,32 +2811,18 @@ virQEMUCapsInitCPUModelS390(virQEMUCapsPtr qemuCaps, return 2; } =20 - if (VIR_STRDUP(cpu->model, modelInfo->name) < 0 || - VIR_ALLOC_N(cpu->features, modelInfo->nprops) < 0) - return -1; - - cpu->nfeatures_max =3D modelInfo->nprops; - cpu->nfeatures =3D 0; - - for (i =3D 0; i < modelInfo->nprops; i++) { - virCPUFeatureDefPtr feature =3D cpu->features + cpu->nfeatures; - qemuMonitorCPUPropertyPtr prop =3D modelInfo->props + i; + if (!(tmp =3D virQEMUCapsCPUModelInfoToCPUDef(migratable, modelInfo))) + goto cleanup; =20 - if (prop->type !=3D QEMU_MONITOR_CPU_PROPERTY_BOOLEAN) - continue; + /* Free original then copy over model, vendor, vendor_id and features = */ + virCPUDefStealModel(cpu, tmp, true); =20 - if (VIR_STRDUP(feature->name, prop->name) < 0) - return -1; + ret =3D 0; =20 - if (!prop->value.boolean || - (migratable && prop->migratable =3D=3D VIR_TRISTATE_BOOL_NO)) - feature->policy =3D VIR_CPU_FEATURE_DISABLE; - else - feature->policy =3D VIR_CPU_FEATURE_REQUIRE; - cpu->nfeatures++; - } + cleanup: + virCPUDefFree(tmp); =20 - return 0; + return ret; } =20 =20 @@ -3633,6 +3620,57 @@ virQEMUCapsLoadCache(virArch hostArch, } =20 =20 +/* qemuMonitorCPUModelInfo name =3D> virCPUDef model + * qemuMonitorCPUModelInfo boolean properties =3D> virCPUDef features + * + * migratable true: mark non-migratable features as disabled + * false: allow all features as required + */ +virCPUDefPtr +virQEMUCapsCPUModelInfoToCPUDef(bool migratable, qemuMonitorCPUModelInfoPt= r model) +{ + virCPUDefPtr cpu =3D NULL; + virCPUDefPtr ret =3D NULL; + size_t i; + + if (!model || VIR_ALLOC(cpu) < 0) + goto cleanup; + + VIR_DEBUG("model->name=3D %s", NULLSTR(model->name)); + + if (VIR_STRDUP(cpu->model, model->name) < 0 || + VIR_ALLOC_N(cpu->features, model->nprops) < 0) + goto cleanup; + + cpu->nfeatures_max =3D model->nprops; + cpu->nfeatures =3D 0; + + for (i =3D 0; i < model->nprops; i++) { + virCPUFeatureDefPtr feature =3D cpu->features + cpu->nfeatures; + qemuMonitorCPUPropertyPtr prop =3D model->props + i; + + if (prop->type !=3D QEMU_MONITOR_CPU_PROPERTY_BOOLEAN) + continue; + + if (VIR_STRDUP(feature->name, prop->name) < 0) + goto cleanup; + + if (!prop->value.boolean || + (migratable && prop->migratable =3D=3D VIR_TRISTATE_BOOL_NO)) + feature->policy =3D VIR_CPU_FEATURE_DISABLE; + else + feature->policy =3D VIR_CPU_FEATURE_REQUIRE; + + cpu->nfeatures++; + } + + VIR_STEAL_PTR(ret, cpu); + + cleanup: + virCPUDefFree(cpu); + return ret; +} + static void virQEMUCapsFormatHostCPUModelInfo(virQEMUCapsPtr qemuCaps, virBufferPtr buf, diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 6bb9a2c8f0..a377d7b912 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -572,6 +572,9 @@ int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuC= aps, void virQEMUCapsFilterByMachineType(virQEMUCapsPtr qemuCaps, const char *machineType); =20 +virCPUDefPtr virQEMUCapsCPUModelInfoToCPUDef(bool migratable, + qemuMonitorCPUModelInfoPtr mo= del); + virFileCachePtr virQEMUCapsCacheNew(const char *libDir, const char *cacheDir, uid_t uid, --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 1541216611807702.3184710831194; Fri, 2 Nov 2018 20:43:31 -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 DDB3D3082B61; Sat, 3 Nov 2018 03:43:29 +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 ACF75104C53C; Sat, 3 Nov 2018 03:43:29 +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 5C1154BB79; Sat, 3 Nov 2018 03:43:29 +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 wA33EaGI011628 for ; Fri, 2 Nov 2018 23:14:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id D5C3F5D75D; Sat, 3 Nov 2018 03:14:36 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 19A215D6A9; Sat, 3 Nov 2018 03:14:35 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:30 -0500 Message-Id: <20181103031338.11600-30-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 29/37] qemu_capabilities: Introduce virCPUDef to CPUModelInfo function 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.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Sat, 03 Nov 2018 03:43:30 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Create public function to convert virCPUDef data structure into qemuMonitorCPUModelInfoPtr data structure. There was no existing code to reuse to create this function so this new virQEMUCapsCPUModelInfoFromCPUDef function was based on reversing the action of the existing virQEMUCapsCPUModelInfoToCPUDef function. Signed-off-by: Chris Venteicher --- src/qemu/qemu_capabilities.c | 46 ++++++++++++++++++++++++++++++++++++ src/qemu/qemu_capabilities.h | 1 + 2 files changed, 47 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index dcd6ffb876..54b94c4dda 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3620,6 +3620,51 @@ virQEMUCapsLoadCache(virArch hostArch, } =20 =20 +/* virCPUDef model =3D> qemuMonitorCPUModelInfo name + * virCPUDef features =3D> qemuMonitorCPUModelInfo boolean properties */ +qemuMonitorCPUModelInfoPtr +virQEMUCapsCPUModelInfoFromCPUDef(const virCPUDef *cpuDef) +{ + size_t i; + qemuMonitorCPUModelInfoPtr cpuModel =3D NULL; + qemuMonitorCPUModelInfoPtr ret =3D NULL; + + if (!cpuDef || (VIR_ALLOC(cpuModel) < 0)) + goto cleanup; + + VIR_DEBUG("cpuDef->model =3D %s", NULLSTR(cpuDef->model)); + + if (VIR_STRDUP(cpuModel->name, cpuDef->model) < 0 || + VIR_ALLOC_N(cpuModel->props, cpuDef->nfeatures) < 0) + goto cleanup; + + cpuModel->nprops =3D 0; + + for (i =3D 0; i < cpuDef->nfeatures; i++) { + qemuMonitorCPUPropertyPtr prop =3D &(cpuModel->props[cpuModel->npr= ops]); + virCPUFeatureDefPtr feature =3D &(cpuDef->features[i]); + + if (!(feature->name) || + VIR_STRDUP(prop->name, feature->name) < 0) + goto cleanup; + + prop->type =3D QEMU_MONITOR_CPU_PROPERTY_BOOLEAN; + + prop->value.boolean =3D feature->policy =3D=3D -1 || /* policy und= efined */ + feature->policy =3D=3D VIR_CPU_FEATURE_FORCE= || + feature->policy =3D=3D VIR_CPU_FEATURE_REQUI= RE; + + cpuModel->nprops++; + } + + VIR_STEAL_PTR(ret, cpuModel); + + cleanup: + qemuMonitorCPUModelInfoFree(cpuModel); + return ret; +} + + /* qemuMonitorCPUModelInfo name =3D> virCPUDef model * qemuMonitorCPUModelInfo boolean properties =3D> virCPUDef features * @@ -3671,6 +3716,7 @@ virQEMUCapsCPUModelInfoToCPUDef(bool migratable, qemu= MonitorCPUModelInfoPtr mode return ret; } =20 + static void virQEMUCapsFormatHostCPUModelInfo(virQEMUCapsPtr qemuCaps, virBufferPtr buf, diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index a377d7b912..ea5e021ca6 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -572,6 +572,7 @@ int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuC= aps, void virQEMUCapsFilterByMachineType(virQEMUCapsPtr qemuCaps, const char *machineType); =20 +qemuMonitorCPUModelInfoPtr virQEMUCapsCPUModelInfoFromCPUDef(const virCPUD= ef *cpuDef); virCPUDefPtr virQEMUCapsCPUModelInfoToCPUDef(bool migratable, qemuMonitorCPUModelInfoPtr mo= del); =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 1541216624790523.3211416690467; Fri, 2 Nov 2018 20:43:44 -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 9B4373082E22; Sat, 3 Nov 2018 03:43:40 +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 689E3611AB; Sat, 3 Nov 2018 03:43:40 +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 12D7418005AD; Sat, 3 Nov 2018 03:43:40 +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 wA33EbVg011633 for ; Fri, 2 Nov 2018 23:14:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id DEF5F5D760; Sat, 3 Nov 2018 03:14:37 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 22F505D6A9; Sat, 3 Nov 2018 03:14:36 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:31 -0500 Message-Id: <20181103031338.11600-31-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 30/37] qemu_monitor: Support query-cpu-model-baseline QMP command 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.46]); Sat, 03 Nov 2018 03:43:41 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Introduce monitor functions to use QEMU to compute baseline cpu from an input of two cpu models. Signed-off-by: Chris Venteicher --- src/qemu/qemu_monitor.c | 12 ++++++++ src/qemu/qemu_monitor.h | 6 ++++ src/qemu/qemu_monitor_json.c | 60 ++++++++++++++++++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 6 ++++ 4 files changed, 84 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 2071c6e846..edbaee1a53 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4495,3 +4495,15 @@ qemuMonitorGetPRManagerInfo(qemuMonitorPtr mon, virHashFree(info); return ret; } + + +int +qemuMonitorGetCPUModelBaseline(qemuMonitorPtr mon, + qemuMonitorCPUModelInfoPtr model_a, + qemuMonitorCPUModelInfoPtr model_b, + qemuMonitorCPUModelInfoPtr *model_baseline) +{ + QEMU_CHECK_MONITOR(mon); + + return qemuMonitorJSONGetCPUModelBaseline(mon, model_a, model_b, model= _baseline); +} diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index d3efd37099..d46e9378ea 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1196,4 +1196,10 @@ struct _qemuMonitorPRManagerInfo { int qemuMonitorGetPRManagerInfo(qemuMonitorPtr mon, virHashTablePtr *retinfo); =20 +int qemuMonitorGetCPUModelBaseline(qemuMonitorPtr mon, + qemuMonitorCPUModelInfoPtr model_a, + qemuMonitorCPUModelInfoPtr model_b, + qemuMonitorCPUModelInfoPtr *model_basel= ine) + ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); + #endif /* QEMU_MONITOR_H */ diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 2eabfdac70..84da721f8d 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -8464,3 +8464,63 @@ qemuMonitorJSONGetPRManagerInfo(qemuMonitorPtr mon, return ret; =20 } + + +int +qemuMonitorJSONGetCPUModelBaseline(qemuMonitorPtr mon, + qemuMonitorCPUModelInfoPtr model_a, + qemuMonitorCPUModelInfoPtr model_b, + qemuMonitorCPUModelInfoPtr *model_basel= ine) +{ + int ret =3D -1; + virJSONValuePtr cmd =3D NULL; + virJSONValuePtr reply =3D NULL; + virJSONValuePtr data =3D NULL; + virJSONValuePtr modela =3D NULL; + virJSONValuePtr modelb =3D NULL; + virJSONValuePtr cpu_model =3D NULL; + + *model_baseline =3D NULL; + + if (!(modela =3D qemuMonitorJSONBuildCPUModelInfoToJSON(model_a)) || + !(modelb =3D qemuMonitorJSONBuildCPUModelInfoToJSON(model_b))) + goto cleanup; + + if (!(cmd =3D qemuMonitorJSONMakeCommand("query-cpu-model-baseline", + "a:modela", &modela, + "a:modelb", &modelb, + NULL))) + goto cleanup; + + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + goto cleanup; + + if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) { + virReportError(VIR_ERR_INVALID_ARG, + _("QEMU doesn't support baseline or recognize model= %s or %s"), + model_a->name, + model_b->name); + goto cleanup; + } + + data =3D virJSONValueObjectGetObject(reply, "return"); + + if (!(cpu_model =3D virJSONValueObjectGetObject(data, "model"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("query-cpu-model-baseline reply data was missing = 'model'")); + goto cleanup; + } + + if (!(*model_baseline =3D qemuMonitorJSONBuildCPUModelInfoFromJSON(cpu= _model))) + goto cleanup; + + ret =3D 0; + + cleanup: + virJSONValueFree(cmd); + virJSONValueFree(reply); + virJSONValueFree(modela); + virJSONValueFree(modelb); + + return ret; +} diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 2d5679094e..117a4a6cd0 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -577,4 +577,10 @@ int qemuMonitorJSONGetPRManagerInfo(qemuMonitorPtr mon, virHashTablePtr info) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); =20 +int qemuMonitorJSONGetCPUModelBaseline(qemuMonitorPtr mon, + qemuMonitorCPUModelInfoPtr model_a, + qemuMonitorCPUModelInfoPtr model_b, + qemuMonitorCPUModelInfoPtr *model_b= aseline) + ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); + #endif /* QEMU_MONITOR_JSON_H */ --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 1541216252939531.1832858854149; Fri, 2 Nov 2018 20:37:32 -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 C296680F95; Sat, 3 Nov 2018 03:37:30 +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 8EE285D760; Sat, 3 Nov 2018 03:37:30 +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 31B3B18005B3; Sat, 3 Nov 2018 03:37:30 +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 wA33EdTs011649 for ; Fri, 2 Nov 2018 23:14:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0894C5D75D; Sat, 3 Nov 2018 03:14:39 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 29CBC5D6A9; Sat, 3 Nov 2018 03:14:38 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:32 -0500 Message-Id: <20181103031338.11600-32-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 31/37] qemu_driver: Consolidate code to baseline using libvirt 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.27]); Sat, 03 Nov 2018 03:37:31 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Simple cut/paste operations within function qemuConnectBaselineHypervisorCPU to group together code specific to computing baseline using only libvirt utility functions. This is done in anticipation of creating new utility functions for 1) baseline using libvirt utilities (this code) 2) baseline using qemu qmp command (future) Future patches are easier to follow if the code for using libvirt is consolidated. Signed-off-by: Chris Venteicher --- src/qemu/qemu_driver.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a52e2495d5..83f5fe0db0 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13425,7 +13425,6 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn, virQEMUCapsPtr qemuCaps =3D NULL; virArch arch; virDomainVirtType virttype; - virDomainCapsCPUModelsPtr cpuModels; bool migratable; virCPUDefPtr cpu =3D NULL; char *cpustr =3D NULL; @@ -13437,8 +13436,6 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn, if (virConnectBaselineHypervisorCPUEnsureACL(conn) < 0) goto cleanup; =20 - migratable =3D !!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE); - if (!(cpus =3D virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_AUTO))) goto cleanup; =20 @@ -13451,17 +13448,21 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr co= nn, if (!qemuCaps) goto cleanup; =20 - if (!(cpuModels =3D virQEMUCapsGetCPUDefinitions(qemuCaps, virttype)) = || - cpuModels->nmodels =3D=3D 0) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, - _("QEMU '%s' does not support any CPU models for " - "virttype '%s'"), - virQEMUCapsGetBinary(qemuCaps), - virDomainVirtTypeToString(virttype)); - goto cleanup; - } - if (ARCH_IS_X86(arch)) { + migratable =3D !!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE); + + virDomainCapsCPUModelsPtr cpuModels; + + if (!(cpuModels =3D virQEMUCapsGetCPUDefinitions(qemuCaps, virttyp= e)) || + cpuModels->nmodels =3D=3D 0) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("QEMU '%s' does not support any CPU models fo= r " + "virttype '%s'"), + virQEMUCapsGetBinary(qemuCaps), + virDomainVirtTypeToString(virttype)); + goto cleanup; + } + int rc =3D virQEMUCapsGetCPUFeatures(qemuCaps, virttype, migratable, &features); if (rc < 0) --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 1541216264747975.3640343511554; Fri, 2 Nov 2018 20:37:44 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 91C4431256AD; Sat, 3 Nov 2018 03:37:42 +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 5F9A560BEC; Sat, 3 Nov 2018 03:37:42 +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 19B2C4BB79; Sat, 3 Nov 2018 03:37:42 +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 wA33Ee1L011654 for ; Fri, 2 Nov 2018 23:14:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id 21EDA5D760; Sat, 3 Nov 2018 03:14:40 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C0005D6A9; Sat, 3 Nov 2018 03:14:39 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:33 -0500 Message-Id: <20181103031338.11600-33-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 32/37] qemu_driver: Decouple code for baseline using libvirt 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Sat, 03 Nov 2018 03:37:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Create utility function encapsulating code to calculate hypervisor baseline cpu using the local libvirt utility functions. Similar function encapsulating code to calculating hypervisor baseline using QEMU QMP messages will be introduced in later commit. Patch is a cut and paste of existing code into a utility function wrapper. s/cpu/*baseline/ (change output variable name ) and initialize variable "rc" are the only code changes. Signed-off-by: Chris Venteicher --- src/qemu/qemu_driver.c | 78 ++++++++++++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 26 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 83f5fe0db0..54f7b8b26d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13410,6 +13410,55 @@ qemuConnectBaselineCPU(virConnectPtr conn ATTRIBUT= E_UNUSED, } =20 =20 +static int +qemuConnectBaselineHypervisorCPUViaLibvirt( + virQEMUCapsPtr qemuCaps, + bool migratable, + virDomainVirtType virttype, + virArch arch, + virCPUDefPtr *cpus, + unsigned int ncpus, + virCPUDefPtr *baseline) +{ + char **features =3D NULL; + int ret =3D -1; + int rc =3D -1; + virDomainCapsCPUModelsPtr cpuModels; + + *baseline =3D NULL; + + if (!(cpuModels =3D virQEMUCapsGetCPUDefinitions(qemuCaps, virttype)) = || + cpuModels->nmodels =3D=3D 0) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("QEMU '%s' does not support any CPU models for " + "virttype '%s'"), + virQEMUCapsGetBinary(qemuCaps), + virDomainVirtTypeToString(virttype)); + goto cleanup; + } + + rc =3D virQEMUCapsGetCPUFeatures(qemuCaps, virttype, + migratable, &features); + if (rc < 0) + goto cleanup; + if (features && rc =3D=3D 0) { + /* We got only migratable features from QEMU if we asked for them, + * no further filtering in virCPUBaseline is desired. */ + migratable =3D false; + } + + if (!(*baseline =3D virCPUBaseline(arch, cpus, ncpus, cpuModels, + (const char **)features, migratable))) + goto cleanup; + + ret =3D 0; + + cleanup: + virStringListFree(features); + return ret; +} + + static char * qemuConnectBaselineHypervisorCPU(virConnectPtr conn, const char *emulator, @@ -13428,7 +13477,6 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn, bool migratable; virCPUDefPtr cpu =3D NULL; char *cpustr =3D NULL; - char **features =3D NULL; =20 virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES | VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL); @@ -13451,30 +13499,9 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr con= n, if (ARCH_IS_X86(arch)) { migratable =3D !!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE); =20 - virDomainCapsCPUModelsPtr cpuModels; - - if (!(cpuModels =3D virQEMUCapsGetCPUDefinitions(qemuCaps, virttyp= e)) || - cpuModels->nmodels =3D=3D 0) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, - _("QEMU '%s' does not support any CPU models fo= r " - "virttype '%s'"), - virQEMUCapsGetBinary(qemuCaps), - virDomainVirtTypeToString(virttype)); - goto cleanup; - } - - int rc =3D virQEMUCapsGetCPUFeatures(qemuCaps, virttype, - migratable, &features); - if (rc < 0) - goto cleanup; - if (features && rc =3D=3D 0) { - /* We got only migratable features from QEMU if we asked for t= hem, - * no further filtering in virCPUBaseline is desired. */ - migratable =3D false; - } - - if (!(cpu =3D virCPUBaseline(arch, cpus, ncpus, cpuModels, - (const char **)features, migratable))) + if (qemuConnectBaselineHypervisorCPUViaLibvirt(qemuCaps, migratabl= e, + virttype, arch, + cpus, ncpus, &cpu) = < 0) goto cleanup; } else { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, @@ -13495,7 +13522,6 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn, virCPUDefListFree(cpus); virCPUDefFree(cpu); virObjectUnref(qemuCaps); - virStringListFree(features); =20 return cpustr; } --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 1541216633555881.32587506656; Fri, 2 Nov 2018 20:43:53 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A44B43001E72; Sat, 3 Nov 2018 03:43:51 +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 7550A600CD; Sat, 3 Nov 2018 03:43:51 +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 2DDD14CA94; Sat, 3 Nov 2018 03:43:51 +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 wA33EfMc011665 for ; Fri, 2 Nov 2018 23:14:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2411D5D760; Sat, 3 Nov 2018 03:14:41 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5DA7A5D6A9; Sat, 3 Nov 2018 03:14:40 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:34 -0500 Message-Id: <20181103031338.11600-34-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 33/37] qemu_driver: Identify using libvirt as a distinct way to compute baseline 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Sat, 03 Nov 2018 03:43:52 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Hypervisor baseline cpu can be computed locally using libvirt utility functions or remotely using QEMU QMP commands. Likewise, cpu feature expansion can be computed locally using libvirt utility functions or remotely using QEMU QMP commands. This patch identifies using libvirt as a distinct case in the hypervisor baseline logic and triggers that case when the X86 architecture is being baselined. There is one functionality change introduced by this patch. Local libvirt functions are only used for feature expansion when the local utility functions are used for CPU baseline and an error is generated when no method is available to expand cpu featues. The useQEMU option will be introduced in a future patch for using QEMU to compute baseline rather than using libvirt. Signed-off-by: Chris Venteicher --- src/qemu/qemu_driver.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 54f7b8b26d..632b756c89 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13477,6 +13477,7 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn, bool migratable; virCPUDefPtr cpu =3D NULL; char *cpustr =3D NULL; + bool useLibvirt =3D false; =20 virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES | VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL); @@ -13496,7 +13497,9 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn, if (!qemuCaps) goto cleanup; =20 - if (ARCH_IS_X86(arch)) { + useLibvirt =3D ARCH_IS_X86(arch); + + if (useLibvirt) { migratable =3D !!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE); =20 if (qemuConnectBaselineHypervisorCPUViaLibvirt(qemuCaps, migratabl= e, @@ -13512,9 +13515,17 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr con= n, =20 cpu->fallback =3D VIR_CPU_FALLBACK_FORBID; =20 - if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) && - virCPUExpandFeatures(arch, cpu) < 0) - goto cleanup; + if (flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) { + if (useLibvirt && virCPUExpandFeatures(arch, cpu) < 0) { + goto cleanup; + } else { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("expand features while " + "computing baseline hypervisor CPU is not sup= ported " + "for arch %s"), virArchToString(arch)); + goto cleanup; + } + } =20 cpustr =3D virCPUDefFormat(cpu, NULL); =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 1541216220084658.4274426799625; Fri, 2 Nov 2018 20:37:00 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 73E9C30DDBB1; Sat, 3 Nov 2018 03:36:57 +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 389DA6012D; Sat, 3 Nov 2018 03:36: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 E549F3D3D3; Sat, 3 Nov 2018 03:36:56 +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 wA33EgkC011674 for ; Fri, 2 Nov 2018 23:14:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2DB6E5D760; Sat, 3 Nov 2018 03:14:42 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 620845D6A9; Sat, 3 Nov 2018 03:14:41 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:35 -0500 Message-Id: <20181103031338.11600-35-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 34/37] qemu_driver: Support baseline calculation using QEMU 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Sat, 03 Nov 2018 03:36:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add capability to calculate hypervisor baseline using QMP message exchanges with QEMU in addition to existing capability to calculate baseline using libvirt utility functions. A new utility function encapsulates the core logic for interacting with QEMU using QMP baseline messages. The QMP messages only allow two cpu models to be evaluated at a time so a sequence of QMP baseline messages must be used to include all the models in the baseline when more than 2 cpu models are input. A QEMU process must be started prior to sending the series of QEMU messages to compute baseline. The QEMU process is started and maintained in the main hypervisor baseline function and only a pointer to the QEMU process monitor is passed to the baseline utility function. The QEMU process is maintained in the main hypervisor baseline function because the process will also be used for feature expansion (via QEMU) in a later patch. Signed-off-by: Chris Venteicher --- src/qemu/qemu_driver.c | 100 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 632b756c89..8b5c3e1fb5 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13410,6 +13410,78 @@ qemuConnectBaselineCPU(virConnectPtr conn ATTRIBUT= E_UNUSED, } =20 =20 +/* in: + * cpus[0]->model =3D "z14"; + * cpus[0]->features[0].name =3D "xxx"; + * cpus[0]->features[1].name =3D "yyy"; + * *** + * cpus[n]->model =3D "z13"; + * cpus[n]->features[0].name =3D "xxx"; + * cpus[n]->features[1].name =3D "yyy"; + * + * out: + * *baseline->model =3D "z13-base"; + * *baseline->features[0].name =3D "yyy"; + */ +static int +qemuConnectBaselineHypervisorCPUViaQEMU(qemuMonitorPtr mon, + virCPUDefPtr *cpus, + virCPUDefPtr *baseline) +{ + qemuMonitorCPUModelInfoPtr model_baseline =3D NULL; + qemuMonitorCPUModelInfoPtr new_model_baseline =3D NULL; + qemuMonitorCPUModelInfoPtr next_model =3D NULL; + bool migratable =3D true; + int ret =3D -1; + size_t i; + + *baseline =3D NULL; + + if (!cpus || !cpus[0]) { + virReportError(VIR_ERR_INVALID_ARG, "%s", _("no cpus")); + goto cleanup; + } + + for (i =3D 0; cpus[i]; i++) { /* cpus terminated by NULL element = */ + virCPUDefPtr cpu =3D cpus[i]; + + VIR_DEBUG("cpu[%lu]->model =3D %s", i, NULLSTR(cpu->model)); + + if (!(next_model =3D virQEMUCapsCPUModelInfoFromCPUDef(cpu))) + goto cleanup; + + if (i =3D=3D 0) { + model_baseline =3D next_model; + continue; + } + + if (qemuMonitorGetCPUModelBaseline(mon, model_baseline, + next_model, &new_model_baseline= ) < 0) + goto cleanup; + + qemuMonitorCPUModelInfoFree(model_baseline); + qemuMonitorCPUModelInfoFree(next_model); + + next_model =3D NULL; + + model_baseline =3D new_model_baseline; + } + + if (!(*baseline =3D virQEMUCapsCPUModelInfoToCPUDef(migratable, model_= baseline))) + goto cleanup; + + VIR_DEBUG("baseline->model =3D %s", (*baseline)->model); + + ret =3D 0; + + cleanup: + qemuMonitorCPUModelInfoFree(model_baseline); + qemuMonitorCPUModelInfoFree(next_model); + + return ret; +} + + static int qemuConnectBaselineHypervisorCPUViaLibvirt( virQEMUCapsPtr qemuCaps, @@ -13478,6 +13550,12 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr con= n, virCPUDefPtr cpu =3D NULL; char *cpustr =3D NULL; bool useLibvirt =3D false; + bool useQemu =3D false; + bool forceTCG =3D false; + qemuMonitorCPUModelInfoPtr modelInfo =3D NULL; + qemuMonitorCPUModelInfoPtr expansion =3D NULL; + qemuProcessPtr proc =3D NULL; + qemuMonitorPtr mon =3D NULL; =20 virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES | VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL); @@ -13498,6 +13576,7 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn, goto cleanup; =20 useLibvirt =3D ARCH_IS_X86(arch); + useQemu =3D ARCH_IS_S390(arch); =20 if (useLibvirt) { migratable =3D !!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE); @@ -13506,6 +13585,23 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr con= n, virttype, arch, cpus, ncpus, &cpu) = < 0) goto cleanup; + + } else if (useQemu) { + const char *binary =3D virQEMUCapsGetBinary(qemuCaps); + virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); + + if (!(proc =3D qemuProcessNew(binary, cfg->libDir, + cfg->user, cfg->group, forceTCG))) + goto cleanup; + + if (qemuProcessStartQmp(proc) < 0) + goto cleanup; + + mon =3D QEMU_PROCESS_MONITOR(proc); + + if ((qemuConnectBaselineHypervisorCPUViaQEMU(mon, cpus, &cpu) < 0)= || !cpu) + goto cleanup; + } else { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("computing baseline hypervisor CPU is not support= ed " @@ -13533,6 +13629,10 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr con= n, virCPUDefListFree(cpus); virCPUDefFree(cpu); virObjectUnref(qemuCaps); + qemuMonitorCPUModelInfoFree(modelInfo); + qemuMonitorCPUModelInfoFree(expansion); + qemuProcessStopQmp(proc); + qemuProcessFree(proc); =20 return cpustr; } --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 1541216231885526.1041200066114; Fri, 2 Nov 2018 20:37:11 -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 99F4D3154867; Sat, 3 Nov 2018 03:37:08 +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 57D3E2636A; Sat, 3 Nov 2018 03:37:08 +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 E8D7F3D382; Sat, 3 Nov 2018 03:37:07 +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 wA33EhFu011689 for ; Fri, 2 Nov 2018 23:14:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4BC9C5D763; Sat, 3 Nov 2018 03:14:43 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BC235D6A9; Sat, 3 Nov 2018 03:14:42 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:36 -0500 Message-Id: <20181103031338.11600-36-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 35/37] qemu_driver: Support feature expansion via QEMU when baselining cpu 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.41]); Sat, 03 Nov 2018 03:37:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Support using QEMU to do feature expansion when also using QEMU to compute hypervisor baseline. A QEMU process is already created to send the QMP messages to baseline using QEMU. The same QEMU process is used for the CPU feature expansion. QEMU only returns migratable features when expanding CPU model in architectures where QEMU is used for baseline so no attempt is made to ask for non-migratable features in expansions when using QEMU for baseline. Signed-off-by: Chris Venteicher --- src/qemu/qemu_driver.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8b5c3e1fb5..73707cce46 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13614,6 +13614,27 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr con= n, if (flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) { if (useLibvirt && virCPUExpandFeatures(arch, cpu) < 0) { goto cleanup; + } else if (useQemu && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPA= NSION)) { + + if (!(modelInfo =3D virQEMUCapsCPUModelInfoFromCPUDef(cpu))) + goto cleanup; + + virCPUDefFree(cpu); + cpu =3D NULL; + + /* QEMU can only include migratable features + for all archs that use QEMU for baseline calculation */ + migratable =3D true; + + if (qemuMonitorGetCPUModelExpansion(mon, + QEMU_MONITOR_CPU_MODEL_EXP= ANSION_FULL, + migratable, modelInfo, &ex= pansion) < 0) + goto cleanup; + + if (!(cpu =3D virQEMUCapsCPUModelInfoToCPUDef(migratable, expa= nsion))) + goto cleanup; + } else { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("expand features while " --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 1541216276383122.18203312335038; Fri, 2 Nov 2018 20:37:56 -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 4C78D315487B; Sat, 3 Nov 2018 03:37:54 +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 C1AFC1057047; Sat, 3 Nov 2018 03:37:53 +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 767CF1804750; Sat, 3 Nov 2018 03:37:53 +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 wA33EiaO011699 for ; Fri, 2 Nov 2018 23:14:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 68C4B5D75D; Sat, 3 Nov 2018 03:14:44 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8DAFB5D6A9; Sat, 3 Nov 2018 03:14:43 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:37 -0500 Message-Id: <20181103031338.11600-37-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 36/37] qemu_driver: Remove unsupported props in expanded hypervisor baseline output 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.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Sat, 03 Nov 2018 03:37:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Hypervisor baseline has an expansion mode where the cpu property / feature list is fully expanded to list all supported (true) features. The output (expanded) cpu model should not list properties that are false (unsupported.) QEMU expansion output enumerates both true (supported) and false (unsupported) properties. This patch removes the false (unsupported) entries from the output cpu property list. This change makes the expanded output consistent when both the internal libvirt utility functions and QEMU QMP commands are used to expand the property list. qemu_monitor: Introduce removal of true/false CPUModelInfo props A utility function is created to squash CPU properties list in qemuMonitorCPUmodelInfo structure by removing boolean properties of matching value. Signed-off-by: Chris Venteicher --- src/qemu/qemu_driver.c | 4 ++++ src/qemu/qemu_monitor.c | 30 ++++++++++++++++++++++++++++++ src/qemu/qemu_monitor.h | 4 ++++ 3 files changed, 38 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 73707cce46..604c21d311 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13632,6 +13632,10 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr con= n, migratable, modelInfo, &ex= pansion) < 0) goto cleanup; =20 + /* Expansion enumerates all features + * Baselines output enumerates only in-model (true) features */ + qemuMonitorCPUModelInfoRemovePropByBoolValue(expansion, false); + if (!(cpu =3D virQEMUCapsCPUModelInfoToCPUDef(migratable, expa= nsion))) goto cleanup; =20 diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index edbaee1a53..12feb034fd 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3785,6 +3785,36 @@ qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUMode= lInfo *orig) } =20 =20 +/* Squash CPU Model Info property list + * removing props of type boolean matching value */ +void +qemuMonitorCPUModelInfoRemovePropByBoolValue(qemuMonitorCPUModelInfoPtr mo= del, + bool value) +{ + qemuMonitorCPUPropertyPtr src; + qemuMonitorCPUPropertyPtr dst; + size_t i; + size_t dst_nprops =3D 0; + + for (i =3D 0; i < model->nprops; i++) { + src =3D &(model->props[i]); + dst =3D &(model->props[dst_nprops]); + + if (src->type =3D=3D QEMU_MONITOR_CPU_PROPERTY_BOOLEAN && + src->value.boolean =3D=3D value) + continue; + + *dst =3D *src; + + dst_nprops++; + } + + model->nprops =3D dst_nprops; + + ignore_value(VIR_REALLOC_N_QUIET(model->props, dst_nprops)); +} + + int qemuMonitorCPUModelInfoBoolPropAdd(qemuMonitorCPUModelInfoPtr model, const char *prop_name, diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index d46e9378ea..f6052ab852 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1053,6 +1053,10 @@ int qemuMonitorCPUModelInfoBoolPropAdd(qemuMonitorCP= UModelInfoPtr model, bool prop_value) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); =20 +void qemuMonitorCPUModelInfoRemovePropByBoolValue(qemuMonitorCPUModelInfoP= tr model, + bool value) + ATTRIBUTE_NONNULL(1); + int qemuMonitorGetCommands(qemuMonitorPtr mon, char ***commands); int qemuMonitorGetEvents(qemuMonitorPtr mon, --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 02:51:27 2024 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 1541216242067863.8724688077909; Fri, 2 Nov 2018 20:37:22 -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 1151780472; Sat, 3 Nov 2018 03:37:20 +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 AA7EB60BF1; Sat, 3 Nov 2018 03:37:19 +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 4B93A18045C2; Sat, 3 Nov 2018 03:37:19 +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 wA33EmI8011714 for ; Fri, 2 Nov 2018 23:14:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id 02DF15D76A; Sat, 3 Nov 2018 03:14:48 +0000 (UTC) Received: from cv1.lan (ovpn-124-15.rdu2.redhat.com [10.10.124.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 304105D75D; Sat, 3 Nov 2018 03:14:44 +0000 (UTC) From: Chris Venteicher To: libvir-list@redhat.com Date: Fri, 2 Nov 2018 22:13:38 -0500 Message-Id: <20181103031338.11600-38-cventeic@redhat.com> In-Reply-To: <20181103031338.11600-1-cventeic@redhat.com> References: <20181103031338.11600-1-cventeic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: walling@linux.ibm.com, Chris Venteicher , david@redhat.com Subject: [libvirt] [PATCH v4 37/37] qemu_monitor: Default props to migratable when expanding cpu model 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.28]); Sat, 03 Nov 2018 03:37:20 +0000 (UTC) Content-Type: text/plain; charset="utf-8" QEMU only returns migratable props when expanding model unless explicitly told to also include non-migratable props. Props will be marked migratable when we are certain QEMU returned only migratable props resulting in consistent information and expansion output for s390 that is consistent with x86. After this change, immediately default prop->migratable =3D _YES for all props when we know QEMU only included migratable props in CPU Model. Set model->migratability =3D true when we have set prop->migratable. Signed-off-by: Chris Venteicher --- src/qemu/qemu_monitor.c | 53 ++++++++++++++- src/qemu/qemu_monitor.h | 7 +- .../caps_2.10.0.s390x.xml | 60 ++++++++--------- .../caps_2.11.0.s390x.xml | 58 ++++++++--------- .../caps_2.12.0.s390x.xml | 56 ++++++++-------- .../qemucapabilitiesdata/caps_2.8.0.s390x.xml | 32 +++++----- .../qemucapabilitiesdata/caps_2.9.0.s390x.xml | 34 +++++----- .../qemucapabilitiesdata/caps_3.0.0.s390x.xml | 64 +++++++++---------- 8 files changed, 210 insertions(+), 154 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 12feb034fd..845cb929a6 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3682,12 +3682,31 @@ qemuMonitorGetCPUModelExpansion(qemuMonitorPtr mon, qemuMonitorCPUModelInfoPtr *expansion ) { + int ret =3D -1; + qemuMonitorCPUModelInfoPtr tmp; + VIR_DEBUG("type=3D%d model_name=3D%s migratable=3D%d", type, input->name, migratable); =20 + *expansion =3D NULL; + QEMU_CHECK_MONITOR(mon); =20 - return qemuMonitorJSONGetCPUModelExpansion(mon, type, migratable, inpu= t, expansion); + if ((ret =3D qemuMonitorJSONGetCPUModelExpansion(mon, type, migratable= , input, &tmp)) < 0) + goto cleanup; + + if (migratable) { + /* Only migratable props were included in expanded CPU model */ + *expansion =3D qemuMonitorCPUModelInfoCopyDefaultMigratable(tmp); + } else { + VIR_STEAL_PTR(*expansion, tmp); + } + + ret =3D 0; + + cleanup: + qemuMonitorCPUModelInfoFree(tmp); + return ret; } =20 =20 @@ -3785,6 +3804,38 @@ qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUMode= lInfo *orig) } =20 =20 +qemuMonitorCPUModelInfoPtr +qemuMonitorCPUModelInfoCopyDefaultMigratable(const qemuMonitorCPUModelInfo= *orig) +{ + qemuMonitorCPUModelInfoPtr ret =3D NULL; + qemuMonitorCPUModelInfoPtr tmp =3D NULL; + qemuMonitorCPUPropertyPtr prop =3D NULL; + size_t i; + + if (!(tmp =3D qemuMonitorCPUModelInfoCopy(orig))) + goto cleanup; + + for (i =3D 0; i < tmp->nprops; i++) { + prop =3D tmp->props + i; + + /* Default prop thats in cpu model (true) to migratable (_YES) + * unless prop already explicitly set not migratable (_NO) + */ + if (prop->type =3D=3D QEMU_MONITOR_CPU_PROPERTY_BOOLEAN && + prop->value.boolean && + prop->migratable !=3D VIR_TRISTATE_BOOL_NO) + prop->migratable =3D VIR_TRISTATE_BOOL_YES; + } + + tmp->migratability =3D true; /* prop->migratable =3D YES/NO for all CP= U props */ + + VIR_STEAL_PTR(ret, tmp); + + cleanup: + return ret; +} + + /* Squash CPU Model Info property list * removing props of type boolean matching value */ void diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index f6052ab852..9216f45f59 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1025,7 +1025,7 @@ struct _qemuMonitorCPUModelInfo { char *name; size_t nprops; qemuMonitorCPUPropertyPtr props; - bool migratability; + bool migratability; /* true if prop->migratable is YES/NO for all CPU = props */ }; =20 typedef enum { @@ -1048,6 +1048,11 @@ qemuMonitorCPUModelInfoPtr qemuMonitorCPUModelInfoNe= w(const char *name); qemuMonitorCPUModelInfoPtr qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModelInfo *orig); =20 +qemuMonitorCPUModelInfoPtr +qemuMonitorCPUModelInfoCopyDefaultMigratable(const qemuMonitorCPUModelInfo= *orig) + ATTRIBUTE_NONNULL(1); + + int qemuMonitorCPUModelInfoBoolPropAdd(qemuMonitorCPUModelInfoPtr model, const char *prop_name, bool prop_value) diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml b/tests/qemuc= apabilitiesdata/caps_2.10.0.s390x.xml index e000aac384..391bee4f06 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml @@ -118,36 +118,36 @@ 306247 s390x - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml b/tests/qemuc= apabilitiesdata/caps_2.11.0.s390x.xml index 4eb8a39d94..d63f56be7d 100644 --- a/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml @@ -125,35 +125,35 @@ 345099 s390x - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml b/tests/qemuc= apabilitiesdata/caps_2.12.0.s390x.xml index 79320d5229..ea3bce232e 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml @@ -133,34 +133,34 @@ 374287 s390x - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml b/tests/qemuca= pabilitiesdata/caps_2.8.0.s390x.xml index b010f731a5..858bc49918 100644 --- a/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml @@ -108,22 +108,22 @@ 244554 s390x - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml b/tests/qemuca= pabilitiesdata/caps_2.9.0.s390x.xml index 5a4371ab83..621036c914 100644 --- a/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml @@ -112,23 +112,23 @@ 267973 s390x - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml b/tests/qemuca= pabilitiesdata/caps_3.0.0.s390x.xml index 3b5f9818a5..7bb42d211c 100644 --- a/tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml @@ -135,38 +135,38 @@ 387601 s390x - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list