From nobody Tue Nov 4 23:51:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531840141779520.5655310392513; Tue, 17 Jul 2018 08:09:01 -0700 (PDT) Received: from localhost ([::1]:59866 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffRb2-0006AU-G3 for importer@patchew.org; Tue, 17 Jul 2018 11:09:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48413) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffRZ9-00052g-0f for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffRZ7-0007AX-Hp for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:02 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54062 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ffRZ7-00079y-Bw for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:01 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 04448407541C; Tue, 17 Jul 2018 15:07:01 +0000 (UTC) Received: from 640k.localdomain.com (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B2F62026D68; Tue, 17 Jul 2018 15:06:58 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 17 Jul 2018 17:06:43 +0200 Message-Id: <1531840015-28804-2-git-send-email-pbonzini@redhat.com> In-Reply-To: <1531840015-28804-1-git-send-email-pbonzini@redhat.com> References: <1531840015-28804-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 17 Jul 2018 15:07:01 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 17 Jul 2018 15:07:01 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'pbonzini@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 01/13] dump: add kernel_gs_base to QEMU CPU state X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Viktor Prutyanov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Viktor Prutyanov This patch adds field with content of KERNEL_GS_BASE MSR to QEMU note in ELF dump. On Windows, if all vCPUs are running usermode tasks at the time the dump is created, this can be helpful in the discovery of guest system structures during conversion ELF dump to MEMORY.DMP dump. Signed-off-by: Viktor Prutyanov Message-Id: <20180714123000.11326-1-viktor.prutyanov@virtuozzo.com> Signed-off-by: Paolo Bonzini --- target/i386/arch_dump.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/target/i386/arch_dump.c b/target/i386/arch_dump.c index 35b55fc..004141f 100644 --- a/target/i386/arch_dump.c +++ b/target/i386/arch_dump.c @@ -258,6 +258,12 @@ struct QEMUCPUState { QEMUCPUSegment cs, ds, es, fs, gs, ss; QEMUCPUSegment ldt, tr, gdt, idt; uint64_t cr[5]; + /* + * Fields below are optional and are being added at the end without + * changing the version. External tools may identify their presence + * by checking 'size' field. + */ + uint64_t kernel_gs_base; }; =20 typedef struct QEMUCPUState QEMUCPUState; @@ -315,6 +321,10 @@ static void qemu_get_cpustate(QEMUCPUState *s, CPUX86S= tate *env) s->cr[2] =3D env->cr[2]; s->cr[3] =3D env->cr[3]; s->cr[4] =3D env->cr[4]; + +#ifdef TARGET_X86_64 + s->kernel_gs_base =3D env->kernelgsbase; +#endif } =20 static inline int cpu_write_qemu_note(WriteCoreDumpFunction f, --=20 1.8.3.1 From nobody Tue Nov 4 23:51:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531840395656393.86855958287583; Tue, 17 Jul 2018 08:13:15 -0700 (PDT) Received: from localhost ([::1]:59889 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffRf8-0001Lv-45 for importer@patchew.org; Tue, 17 Jul 2018 11:13:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48439) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffRZE-000575-OI for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffRZ9-0007BO-29 for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:08 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54068 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ffRZ8-0007B7-TM for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:03 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8561A4075789; Tue, 17 Jul 2018 15:07:02 +0000 (UTC) Received: from 640k.localdomain.com (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6ABC42026D68; Tue, 17 Jul 2018 15:07:01 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 17 Jul 2018 17:06:44 +0200 Message-Id: <1531840015-28804-3-git-send-email-pbonzini@redhat.com> In-Reply-To: <1531840015-28804-1-git-send-email-pbonzini@redhat.com> References: <1531840015-28804-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 17 Jul 2018 15:07:02 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 17 Jul 2018 15:07:02 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'pbonzini@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 02/13] accel: Fix typo and grammar in comment X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Weil Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Stefan Weil The typo was found by codespell. Signed-off-by: Stefan Weil Message-Id: <20180712194454.26765-1-sw@weilnetz.de> Signed-off-by: Paolo Bonzini --- accel/tcg/translate-all.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 49d77fa..1571987 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1795,7 +1795,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, tb->jmp_dest[0] =3D (uintptr_t)NULL; tb->jmp_dest[1] =3D (uintptr_t)NULL; =20 - /* init original jump addresses wich has been set during tcg_gen_code(= ) */ + /* init original jump addresses which have been set during tcg_gen_cod= e() */ if (tb->jmp_reset_offset[0] !=3D TB_JMP_RESET_OFFSET_INVALID) { tb_reset_jump(tb, 0); } --=20 1.8.3.1 From nobody Tue Nov 4 23:51:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531840224985789.43619058082; Tue, 17 Jul 2018 08:10:24 -0700 (PDT) Received: from localhost ([::1]:59872 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffRcN-0007Oj-Sf for importer@patchew.org; Tue, 17 Jul 2018 11:10:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48430) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffRZB-00054k-Md for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffRZA-0007CI-IA for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:05 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54078 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ffRZA-0007C3-B0 for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:04 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F20AE4075789; Tue, 17 Jul 2018 15:07:03 +0000 (UTC) Received: from 640k.localdomain.com (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF1782026D68; Tue, 17 Jul 2018 15:07:02 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 17 Jul 2018 17:06:45 +0200 Message-Id: <1531840015-28804-4-git-send-email-pbonzini@redhat.com> In-Reply-To: <1531840015-28804-1-git-send-email-pbonzini@redhat.com> References: <1531840015-28804-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 17 Jul 2018 15:07:04 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 17 Jul 2018 15:07:04 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'pbonzini@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 03/13] hyperv: rename vcpu_id to vp_index X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Kagan Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Roman Kagan In Hyper-V-related code, vCPUs are identified by their VP (virtual processor) index. Since it's customary for "vcpu_id" in QEMU to mean APIC id, rename the respective variables to "vp_index" to make the distinction clear. Signed-off-by: Roman Kagan Message-Id: <20180702134156.13404-2-rkagan@virtuozzo.com> Signed-off-by: Paolo Bonzini --- hw/misc/hyperv_testdev.c | 16 ++++++++-------- target/i386/hyperv.c | 6 +++--- target/i386/hyperv.h | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/hw/misc/hyperv_testdev.c b/hw/misc/hyperv_testdev.c index dbd7cdd..bf6bbfa 100644 --- a/hw/misc/hyperv_testdev.c +++ b/hw/misc/hyperv_testdev.c @@ -57,7 +57,7 @@ static void free_sint_route_index(HypervTestDev *dev, int= i) dev->sint_route[i] =3D NULL; } =20 -static int find_sint_route_index(HypervTestDev *dev, uint32_t vcpu_id, +static int find_sint_route_index(HypervTestDev *dev, uint32_t vp_index, uint32_t sint) { HvSintRoute *sint_route; @@ -65,7 +65,7 @@ static int find_sint_route_index(HypervTestDev *dev, uint= 32_t vcpu_id, =20 for (i =3D 0; i < ARRAY_SIZE(dev->sint_route); i++) { sint_route =3D dev->sint_route[i]; - if (sint_route && sint_route->vcpu_id =3D=3D vcpu_id && + if (sint_route && sint_route->vp_index =3D=3D vp_index && sint_route->sint =3D=3D sint) { return i; } @@ -74,7 +74,7 @@ static int find_sint_route_index(HypervTestDev *dev, uint= 32_t vcpu_id, } =20 static void hv_synic_test_dev_control(HypervTestDev *dev, uint32_t ctl, - uint32_t vcpu_id, uint32_t sint) + uint32_t vp_index, uint32_t sint) { int i; HvSintRoute *sint_route; @@ -83,19 +83,19 @@ static void hv_synic_test_dev_control(HypervTestDev *de= v, uint32_t ctl, case HV_TEST_DEV_SINT_ROUTE_CREATE: i =3D alloc_sint_route_index(dev); assert(i >=3D 0); - sint_route =3D kvm_hv_sint_route_create(vcpu_id, sint, NULL); + sint_route =3D kvm_hv_sint_route_create(vp_index, sint, NULL); assert(sint_route); dev->sint_route[i] =3D sint_route; break; case HV_TEST_DEV_SINT_ROUTE_DESTROY: - i =3D find_sint_route_index(dev, vcpu_id, sint); + i =3D find_sint_route_index(dev, vp_index, sint); assert(i >=3D 0); sint_route =3D dev->sint_route[i]; kvm_hv_sint_route_destroy(sint_route); free_sint_route_index(dev, i); break; case HV_TEST_DEV_SINT_ROUTE_SET_SINT: - i =3D find_sint_route_index(dev, vcpu_id, sint); + i =3D find_sint_route_index(dev, vp_index, sint); assert(i >=3D 0); sint_route =3D dev->sint_route[i]; kvm_hv_sint_route_set_sint(sint_route); @@ -117,8 +117,8 @@ static void hv_test_dev_control(void *opaque, hwaddr ad= dr, uint64_t data, case HV_TEST_DEV_SINT_ROUTE_DESTROY: case HV_TEST_DEV_SINT_ROUTE_SET_SINT: { uint8_t sint =3D data & 0xFF; - uint8_t vcpu_id =3D (data >> 8ULL) & 0xFF; - hv_synic_test_dev_control(dev, ctl, vcpu_id, sint); + uint8_t vp_index =3D (data >> 8ULL) & 0xFF; + hv_synic_test_dev_control(dev, ctl, vp_index, sint); break; } default: diff --git a/target/i386/hyperv.c b/target/i386/hyperv.c index a050c9d..7cc0fbb 100644 --- a/target/i386/hyperv.c +++ b/target/i386/hyperv.c @@ -72,7 +72,7 @@ static void kvm_hv_sint_ack_handler(EventNotifier *notifi= er) } } =20 -HvSintRoute *kvm_hv_sint_route_create(uint32_t vcpu_id, uint32_t sint, +HvSintRoute *kvm_hv_sint_route_create(uint32_t vp_index, uint32_t sint, HvSintAckClb sint_ack_clb) { HvSintRoute *sint_route; @@ -92,7 +92,7 @@ HvSintRoute *kvm_hv_sint_route_create(uint32_t vcpu_id, u= int32_t sint, event_notifier_set_handler(&sint_route->sint_ack_notifier, kvm_hv_sint_ack_handler); =20 - gsi =3D kvm_irqchip_add_hv_sint_route(kvm_state, vcpu_id, sint); + gsi =3D kvm_irqchip_add_hv_sint_route(kvm_state, vp_index, sint); if (gsi < 0) { goto err_gsi; } @@ -105,7 +105,7 @@ HvSintRoute *kvm_hv_sint_route_create(uint32_t vcpu_id,= uint32_t sint, } sint_route->gsi =3D gsi; sint_route->sint_ack_clb =3D sint_ack_clb; - sint_route->vcpu_id =3D vcpu_id; + sint_route->vp_index =3D vp_index; sint_route->sint =3D sint; =20 return sint_route; diff --git a/target/i386/hyperv.h b/target/i386/hyperv.h index 0c3b562..eaf3df3 100644 --- a/target/i386/hyperv.h +++ b/target/i386/hyperv.h @@ -23,7 +23,7 @@ typedef void (*HvSintAckClb)(HvSintRoute *sint_route); =20 struct HvSintRoute { uint32_t sint; - uint32_t vcpu_id; + uint32_t vp_index; int gsi; EventNotifier sint_set_notifier; EventNotifier sint_ack_notifier; @@ -32,7 +32,7 @@ struct HvSintRoute { =20 int kvm_hv_handle_exit(X86CPU *cpu, struct kvm_hyperv_exit *exit); =20 -HvSintRoute *kvm_hv_sint_route_create(uint32_t vcpu_id, uint32_t sint, +HvSintRoute *kvm_hv_sint_route_create(uint32_t vp_index, uint32_t sint, HvSintAckClb sint_ack_clb); =20 void kvm_hv_sint_route_destroy(HvSintRoute *sint_route); --=20 1.8.3.1 From nobody Tue Nov 4 23:51:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531840664447580.026045132812; Tue, 17 Jul 2018 08:17:44 -0700 (PDT) Received: from localhost ([::1]:59920 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffRjT-0005Me-CN for importer@patchew.org; Tue, 17 Jul 2018 11:17:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48463) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffRZI-00059x-GM for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffRZB-0007DV-Uh for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:12 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54080 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ffRZB-0007D2-Ok for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:05 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 662DF4075798; Tue, 17 Jul 2018 15:07:05 +0000 (UTC) Received: from 640k.localdomain.com (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 65F7F2026D68; Tue, 17 Jul 2018 15:07:04 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 17 Jul 2018 17:06:46 +0200 Message-Id: <1531840015-28804-5-git-send-email-pbonzini@redhat.com> In-Reply-To: <1531840015-28804-1-git-send-email-pbonzini@redhat.com> References: <1531840015-28804-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 17 Jul 2018 15:07:05 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 17 Jul 2018 15:07:05 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'pbonzini@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 04/13] hyperv: ensure VP index equal to QEMU cpu_index X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Kagan Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Roman Kagan Hyper-V identifies vCPUs by Virtual Processor (VP) index which can be queried by the guest via HV_X64_MSR_VP_INDEX msr. It is defined by the spec as a sequential number which can't exceed the maximum number of vCPUs per VM. It has to be owned by QEMU in order to preserve it across migration. However, the initial implementation in KVM didn't allow to set this msr, and KVM used its own notion of VP index. Fortunately, the way vCPUs are created in QEMU/KVM makes it likely that the KVM value is equal to QEMU cpu_index. So choose cpu_index as the value for vp_index, and push that to KVM on kernels that support setting the msr. On older ones that don't, query the kernel value and assert that it's in sync with QEMU. Besides, since handling errors from vCPU init at hotplug time is impossible, disable vCPU hotplug. This patch also introduces accessor functions to encapsulate the mapping between a vCPU and its vp_index. Signed-off-by: Roman Kagan Message-Id: <20180702134156.13404-3-rkagan@virtuozzo.com> Signed-off-by: Paolo Bonzini --- hw/i386/pc.c | 5 +++++ target/i386/hyperv.c | 10 ++++++++++ target/i386/hyperv.h | 3 +++ target/i386/kvm-stub.c | 5 +++++ target/i386/kvm.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ target/i386/kvm_i386.h | 2 ++ 6 files changed, 72 insertions(+) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 50d5553..83a4444 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1999,6 +1999,11 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_= dev, } cpu->thread_id =3D topo.smt_id; =20 + if (cpu->hyperv_vpindex && !kvm_hv_vpindex_settable()) { + error_setg(errp, "kernel doesn't allow setting HyperV VP_INDEX"); + return; + } + cs =3D CPU(cpu); cs->cpu_index =3D idx; =20 diff --git a/target/i386/hyperv.c b/target/i386/hyperv.c index 7cc0fbb..3065d76 100644 --- a/target/i386/hyperv.c +++ b/target/i386/hyperv.c @@ -16,6 +16,16 @@ #include "hyperv.h" #include "hyperv-proto.h" =20 +uint32_t hyperv_vp_index(X86CPU *cpu) +{ + return CPU(cpu)->cpu_index; +} + +X86CPU *hyperv_find_vcpu(uint32_t vp_index) +{ + return X86_CPU(qemu_get_cpu(vp_index)); +} + int kvm_hv_handle_exit(X86CPU *cpu, struct kvm_hyperv_exit *exit) { CPUX86State *env =3D &cpu->env; diff --git a/target/i386/hyperv.h b/target/i386/hyperv.h index eaf3df3..00c9b45 100644 --- a/target/i386/hyperv.h +++ b/target/i386/hyperv.h @@ -39,4 +39,7 @@ void kvm_hv_sint_route_destroy(HvSintRoute *sint_route); =20 int kvm_hv_sint_route_set_sint(HvSintRoute *sint_route); =20 +uint32_t hyperv_vp_index(X86CPU *cpu); +X86CPU *hyperv_find_vcpu(uint32_t vp_index); + #endif diff --git a/target/i386/kvm-stub.c b/target/i386/kvm-stub.c index bda4dc2..e7a673e 100644 --- a/target/i386/kvm-stub.c +++ b/target/i386/kvm-stub.c @@ -40,3 +40,8 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint= 32_t function, abort(); } #endif + +bool kvm_hv_vpindex_settable(void) +{ + return false; +} diff --git a/target/i386/kvm.c b/target/i386/kvm.c index ebb2d23..9313602 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -85,6 +85,7 @@ static bool has_msr_hv_hypercall; static bool has_msr_hv_crash; static bool has_msr_hv_reset; static bool has_msr_hv_vpindex; +static bool hv_vpindex_settable; static bool has_msr_hv_runtime; static bool has_msr_hv_synic; static bool has_msr_hv_stimer; @@ -162,6 +163,11 @@ bool kvm_enable_x2apic(void) has_x2apic_api); } =20 +bool kvm_hv_vpindex_settable(void) +{ + return hv_vpindex_settable; +} + static int kvm_get_tsc(CPUState *cs) { X86CPU *cpu =3D X86_CPU(cs); @@ -745,6 +751,37 @@ static int hyperv_handle_properties(CPUState *cs) return 0; } =20 +static int hyperv_init_vcpu(X86CPU *cpu) +{ + if (cpu->hyperv_vpindex && !hv_vpindex_settable) { + /* + * the kernel doesn't support setting vp_index; assert that its va= lue + * is in sync + */ + int ret; + struct { + struct kvm_msrs info; + struct kvm_msr_entry entries[1]; + } msr_data =3D { + .info.nmsrs =3D 1, + .entries[0].index =3D HV_X64_MSR_VP_INDEX, + }; + + ret =3D kvm_vcpu_ioctl(CPU(cpu), KVM_GET_MSRS, &msr_data); + if (ret < 0) { + return ret; + } + assert(ret =3D=3D 1); + + if (msr_data.entries[0].data !=3D hyperv_vp_index(cpu)) { + error_report("kernel's vp_index !=3D QEMU's vp_index"); + return -ENXIO; + } + } + + return 0; +} + static Error *invtsc_mig_blocker; =20 #define KVM_MAX_CPUID_ENTRIES 100 @@ -1160,6 +1197,11 @@ int kvm_arch_init_vcpu(CPUState *cs) has_msr_tsc_aux =3D false; } =20 + r =3D hyperv_init_vcpu(cpu); + if (r) { + goto fail; + } + return 0; =20 fail: @@ -1351,6 +1393,8 @@ int kvm_arch_init(MachineState *ms, KVMState *s) has_pit_state2 =3D kvm_check_extension(s, KVM_CAP_PIT_STATE2); #endif =20 + hv_vpindex_settable =3D kvm_check_extension(s, KVM_CAP_HYPERV_VP_INDEX= ); + ret =3D kvm_get_supported_msrs(s); if (ret < 0) { return ret; @@ -1900,6 +1944,9 @@ static int kvm_put_msrs(X86CPU *cpu, int level) if (has_msr_hv_runtime) { kvm_msr_entry_add(cpu, HV_X64_MSR_VP_RUNTIME, env->msr_hv_runt= ime); } + if (cpu->hyperv_vpindex && hv_vpindex_settable) { + kvm_msr_entry_add(cpu, HV_X64_MSR_VP_INDEX, hyperv_vp_index(cp= u)); + } if (cpu->hyperv_synic) { int j; =20 diff --git a/target/i386/kvm_i386.h b/target/i386/kvm_i386.h index e5df24c..3057ba4 100644 --- a/target/i386/kvm_i386.h +++ b/target/i386/kvm_i386.h @@ -63,4 +63,6 @@ void kvm_put_apicbase(X86CPU *cpu, uint64_t value); =20 bool kvm_enable_x2apic(void); bool kvm_has_x2apic_api(void); + +bool kvm_hv_vpindex_settable(void); #endif --=20 1.8.3.1 From nobody Tue Nov 4 23:51:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531840159935777.7711613026925; Tue, 17 Jul 2018 08:09:19 -0700 (PDT) Received: from localhost ([::1]:59870 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffRbG-0006Pd-Ta for importer@patchew.org; Tue, 17 Jul 2018 11:09:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48474) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffRZJ-0005Ae-AZ for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffRZF-0007F0-6k for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:13 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47108 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ffRZF-0007Eh-0J for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:09 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 974D877886; Tue, 17 Jul 2018 15:07:08 +0000 (UTC) Received: from 640k.localdomain.com (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 145E32026D68; Tue, 17 Jul 2018 15:07:05 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 17 Jul 2018 17:06:47 +0200 Message-Id: <1531840015-28804-6-git-send-email-pbonzini@redhat.com> In-Reply-To: <1531840015-28804-1-git-send-email-pbonzini@redhat.com> References: <1531840015-28804-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 17 Jul 2018 15:07:08 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 17 Jul 2018 15:07:08 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'pbonzini@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 05/13] vhost-user-test: added proper TestServer *dest initialization in test_migrate() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Emanuele Giuseppe Esposito Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito server->bus in _test_server_free() could be NULL, since TestServer *dest in test_migrate() was not properly initialized like TestServer *s. Added init_virtio_dev(dest) and uninit_virtio_dev(dest), so the fields are properly set and when test_server_free(dest); is called, they can be correctly freed. The reason for that is init_virtio_dev() calls qpci_init_pc(), that creates a QPCIBusPC * (returned as QPCIBus *), while test_server_free() calls qpci_free_pc(), that frees the QPCIBus *. Not calling init_virtio_dev() would leave the QPCIBus * of TestServer unset. Problem came out once I modified pci-pc.c and pci-pc.h, modifying QPCIBusPC by adding another field before QPCIBus bus. Re-running the tests showed vhost-user-test failing. Signed-off-by: Emanuele Giuseppe Esposito Message-Id: <1530022733-29581-1-git-send-email-esposem@usi.ch> Signed-off-by: Paolo Bonzini --- tests/vhost-user-test.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index 8ff2106..fecc832 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -537,6 +537,7 @@ static gboolean _test_server_free(TestServer *server) g_free(server->mig_path); =20 g_free(server->chr_name); + g_assert(server->bus); qpci_free_pc(server->bus); =20 g_free(server); @@ -684,6 +685,7 @@ static void test_migrate(void) g_free(cmd); =20 init_virtio_dev(s, 1u << VIRTIO_NET_F_MAC); + init_virtio_dev(dest, 1u << VIRTIO_NET_F_MAC); wait_for_fds(s); size =3D get_log_size(s); g_assert_cmpint(size, =3D=3D, (2 * 1024 * 1024) / (VHOST_LOG_PAGE * 8)= ); @@ -739,6 +741,7 @@ static void test_migrate(void) read_guest_mem_server(dest); =20 uninit_virtio_dev(s); + uninit_virtio_dev(dest); =20 g_source_destroy(source); g_source_unref(source); --=20 1.8.3.1 From nobody Tue Nov 4 23:51:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531840539769850.751171506115; Tue, 17 Jul 2018 08:15:39 -0700 (PDT) Received: from localhost ([::1]:59906 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffRhO-0003cA-Jr for importer@patchew.org; Tue, 17 Jul 2018 11:15:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48456) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffRZH-00059X-Va for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffRZG-0007Fh-GO for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:11 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54088 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ffRZG-0007FT-B8 for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:10 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ECA0B4075789; Tue, 17 Jul 2018 15:07:09 +0000 (UTC) Received: from 640k.localdomain.com (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A7702026D68; Tue, 17 Jul 2018 15:07:08 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 17 Jul 2018 17:06:48 +0200 Message-Id: <1531840015-28804-7-git-send-email-pbonzini@redhat.com> In-Reply-To: <1531840015-28804-1-git-send-email-pbonzini@redhat.com> References: <1531840015-28804-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 17 Jul 2018 15:07:09 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 17 Jul 2018 15:07:09 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'pbonzini@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 06/13] PC Chipset: Improve serial divisor calculation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Calvin Lee Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Calvin Lee This fixes several problems I found in the UART serial implementation. Now all divisor values are allowed, while before divisor values of zero and below the base baud rate were rejected. All changes are in reference to http://www.sci.muni.cz/docs/pc/serport.txt Signed-off-by: Calvin Lee Message-Id: <20180512000545.966-2-cyrus296@gmail.com> Signed-off-by: Paolo Bonzini --- hw/char/serial.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/hw/char/serial.c b/hw/char/serial.c index cd7d747..d3b75f0 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -150,13 +150,10 @@ static void serial_update_irq(SerialState *s) =20 static void serial_update_parameters(SerialState *s) { - int speed, parity, data_bits, stop_bits, frame_size; + float speed; + int parity, data_bits, stop_bits, frame_size; QEMUSerialSetParams ssp; =20 - if (s->divider =3D=3D 0 || s->divider > s->baudbase) { - return; - } - /* Start bit. */ frame_size =3D 1; if (s->lcr & 0x08) { @@ -169,14 +166,16 @@ static void serial_update_parameters(SerialState *s) } else { parity =3D 'N'; } - if (s->lcr & 0x04) + if (s->lcr & 0x04) { stop_bits =3D 2; - else + } else { stop_bits =3D 1; + } =20 data_bits =3D (s->lcr & 0x03) + 5; frame_size +=3D data_bits + stop_bits; - speed =3D s->baudbase / s->divider; + /* Zero divisor should give about 3500 baud */ + speed =3D (s->divider =3D=3D 0) ? 3500 : (float) s->baudbase / s->divi= der; ssp.speed =3D speed; ssp.parity =3D parity; ssp.data_bits =3D data_bits; @@ -184,7 +183,7 @@ static void serial_update_parameters(SerialState *s) s->char_transmit_time =3D (NANOSECONDS_PER_SECOND / speed) * frame_si= ze; qemu_chr_fe_ioctl(&s->chr, CHR_IOCTL_SERIAL_SET_PARAMS, &ssp); =20 - DPRINTF("speed=3D%d parity=3D%c data=3D%d stop=3D%d\n", + DPRINTF("speed=3D%.2f parity=3D%c data=3D%d stop=3D%d\n", speed, parity, data_bits, stop_bits); } =20 @@ -341,7 +340,11 @@ static void serial_ioport_write(void *opaque, hwaddr a= ddr, uint64_t val, default: case 0: if (s->lcr & UART_LCR_DLAB) { - s->divider =3D (s->divider & 0xff00) | val; + if (size =3D=3D 2) { + s->divider =3D (s->divider & 0xff00) | val; + } else if (size =3D=3D 4) { + s->divider =3D val; + } serial_update_parameters(s); } else { s->thr =3D (uint8_t) val; --=20 1.8.3.1 From nobody Tue Nov 4 23:51:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531840307439913.2265204298658; Tue, 17 Jul 2018 08:11:47 -0700 (PDT) Received: from localhost ([::1]:59882 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffRdi-00009h-AI for importer@patchew.org; Tue, 17 Jul 2018 11:11:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48512) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffRZN-0005EZ-PK for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffRZH-0007GY-Q9 for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:17 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47112 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ffRZH-0007GI-Lf for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:11 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4B58A83221 for ; Tue, 17 Jul 2018 15:07:11 +0000 (UTC) Received: from 640k.localdomain.com (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D7962026D68; Tue, 17 Jul 2018 15:07:10 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 17 Jul 2018 17:06:49 +0200 Message-Id: <1531840015-28804-8-git-send-email-pbonzini@redhat.com> In-Reply-To: <1531840015-28804-1-git-send-email-pbonzini@redhat.com> References: <1531840015-28804-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 17 Jul 2018 15:07:11 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 17 Jul 2018 15:07:11 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'pbonzini@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 07/13] hw/char/serial: retry write if EAGAIN X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Marc-Andr=C3=A9 Lureau If the chardev returns -1 with EAGAIN errno on write(), it should try to send it again (EINTR is handled by the chardev itself). This fixes commit 019288bf137183bf3407c9824655b753bfafc99f "hw/char/serial: Only retry if qemu_chr_fe_write returns 0" Tested-by: Igor Mammedov Signed-off-by: Marc-Andr=C3=83=C2=A9 Lureau Message-Id: <20180716110755.12499-1-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- hw/char/serial.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/hw/char/serial.c b/hw/char/serial.c index d3b75f0..251f40f 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -260,15 +260,20 @@ static void serial_xmit(SerialState *s) if (s->mcr & UART_MCR_LOOP) { /* in loopback mode, say that we just received a char */ serial_receive1(s, &s->tsr, 1); - } else if (qemu_chr_fe_write(&s->chr, &s->tsr, 1) =3D=3D 0 && - s->tsr_retry < MAX_XMIT_RETRY) { - assert(s->watch_tag =3D=3D 0); - s->watch_tag =3D - qemu_chr_fe_add_watch(&s->chr, G_IO_OUT | G_IO_HUP, - serial_watch_cb, s); - if (s->watch_tag > 0) { - s->tsr_retry++; - return; + } else { + int rc =3D qemu_chr_fe_write(&s->chr, &s->tsr, 1); + + if ((rc =3D=3D 0 || + (rc =3D=3D -1 && errno =3D=3D EAGAIN)) && + s->tsr_retry < MAX_XMIT_RETRY) { + assert(s->watch_tag =3D=3D 0); + s->watch_tag =3D + qemu_chr_fe_add_watch(&s->chr, G_IO_OUT | G_IO_HUP, + serial_watch_cb, s); + if (s->watch_tag > 0) { + s->tsr_retry++; + return; + } } } s->tsr_retry =3D 0; --=20 1.8.3.1 From nobody Tue Nov 4 23:51:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531840402457517.6591639909343; Tue, 17 Jul 2018 08:13:22 -0700 (PDT) Received: from localhost ([::1]:59891 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffRfF-0001SY-CE for importer@patchew.org; Tue, 17 Jul 2018 11:13:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48490) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffRZK-0005Bf-BK for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffRZJ-0007HM-67 for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:14 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44332 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ffRZJ-0007H2-0F for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:13 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A2861401EF0C for ; Tue, 17 Jul 2018 15:07:12 +0000 (UTC) Received: from 640k.localdomain.com (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id B16772026D68; Tue, 17 Jul 2018 15:07:11 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 17 Jul 2018 17:06:50 +0200 Message-Id: <1531840015-28804-9-git-send-email-pbonzini@redhat.com> In-Reply-To: <1531840015-28804-1-git-send-email-pbonzini@redhat.com> References: <1531840015-28804-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 17 Jul 2018 15:07:12 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 17 Jul 2018 15:07:12 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'pbonzini@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 08/13] qdev: add HotplugHandler->post_plug() callback X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi The ->pre_plug() callback is invoked before the device is realized. The ->plug() callback is invoked when the device is being realized but before it is reset. This patch adds a ->post_plug() callback which is invoked after the device has been reset. This callback is needed by HotplugHandlers that need to wait until after ->reset(). Signed-off-by: Stefan Hajnoczi Message-Id: <20180716083732.3347-2-stefanha@redhat.com> Signed-off-by: Paolo Bonzini --- hw/core/hotplug.c | 10 ++++++++++ hw/core/qdev.c | 4 ++++ include/hw/hotplug.h | 11 +++++++++++ 3 files changed, 25 insertions(+) diff --git a/hw/core/hotplug.c b/hw/core/hotplug.c index 17ac986..2253072 100644 --- a/hw/core/hotplug.c +++ b/hw/core/hotplug.c @@ -35,6 +35,16 @@ void hotplug_handler_plug(HotplugHandler *plug_handler, } } =20 +void hotplug_handler_post_plug(HotplugHandler *plug_handler, + DeviceState *plugged_dev) +{ + HotplugHandlerClass *hdc =3D HOTPLUG_HANDLER_GET_CLASS(plug_handler); + + if (hdc->post_plug) { + hdc->post_plug(plug_handler, plugged_dev); + } +} + void hotplug_handler_unplug_request(HotplugHandler *plug_handler, DeviceState *plugged_dev, Error **errp) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index cf0db4b..529b82d 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -867,6 +867,10 @@ static void device_set_realized(Object *obj, bool valu= e, Error **errp) device_reset(dev); } dev->pending_deleted_event =3D false; + + if (hotplug_ctrl) { + hotplug_handler_post_plug(hotplug_ctrl, dev); + } } else if (!value && dev->realized) { Error **local_errp =3D NULL; QLIST_FOREACH(bus, &dev->child_bus, sibling) { diff --git a/include/hw/hotplug.h b/include/hw/hotplug.h index 1a0516a..51541d6 100644 --- a/include/hw/hotplug.h +++ b/include/hw/hotplug.h @@ -47,6 +47,8 @@ typedef void (*hotplug_fn)(HotplugHandler *plug_handler, * @parent: Opaque parent interface. * @pre_plug: pre plug callback called at start of device.realize(true) * @plug: plug callback called at end of device.realize(true). + * @post_plug: post plug callback called after device.realize(true) and de= vice + * reset * @unplug_request: unplug request callback. * Used as a means to initiate device unplug for devices = that * require asynchronous unplug handling. @@ -61,6 +63,7 @@ typedef struct HotplugHandlerClass { /* */ hotplug_fn pre_plug; hotplug_fn plug; + void (*post_plug)(HotplugHandler *plug_handler, DeviceState *plugged_d= ev); hotplug_fn unplug_request; hotplug_fn unplug; } HotplugHandlerClass; @@ -84,6 +87,14 @@ void hotplug_handler_pre_plug(HotplugHandler *plug_handl= er, Error **errp); =20 /** + * hotplug_handler_post_plug: + * + * Call #HotplugHandlerClass.post_plug callback of @plug_handler. + */ +void hotplug_handler_post_plug(HotplugHandler *plug_handler, + DeviceState *plugged_dev); + +/** * hotplug_handler_unplug_request: * * Calls #HotplugHandlerClass.unplug_request callback of @plug_handler. --=20 1.8.3.1 From nobody Tue Nov 4 23:51:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531840808372872.2749715130482; Tue, 17 Jul 2018 08:20:08 -0700 (PDT) Received: from localhost ([::1]:59931 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffRlb-000701-0h for importer@patchew.org; Tue, 17 Jul 2018 11:19:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48534) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffRZQ-0005HA-FB for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffRZK-0007IN-NR for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:20 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47118 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ffRZK-0007I9-HL for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:14 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 38C6E83221 for ; Tue, 17 Jul 2018 15:07:14 +0000 (UTC) Received: from 640k.localdomain.com (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 145952026D68; Tue, 17 Jul 2018 15:07:12 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 17 Jul 2018 17:06:51 +0200 Message-Id: <1531840015-28804-10-git-send-email-pbonzini@redhat.com> In-Reply-To: <1531840015-28804-1-git-send-email-pbonzini@redhat.com> References: <1531840015-28804-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 17 Jul 2018 15:07:14 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 17 Jul 2018 15:07:14 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'pbonzini@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 09/13] virtio-scsi: fix hotplug ->reset() vs event race X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi There is a race condition during hotplug when iothread is used. It occurs because virtio-scsi may be processing command queues in the iothread while the monitor performs SCSI device hotplug. When a SCSI device is hotplugged the HotplugHandler->plug() callback is invoked and virtio-scsi emits a rescan event to the guest. If the guest submits a SCSI command at this point then it may be cancelled before hotplug completes. This happens because ->reset() is called by hw/core/qdev.c:device_set_realized() after HotplugHandler->plug() has been called and hw/scsi/scsi-disk.c:scsi_disk_reset() purges all requests. This patch uses the new HotplugHandler->post_plug() callback to emit the rescan event after ->reset(). This eliminates the race conditions where requests could be cancelled. Reported-by: l00284672 Cc: Paolo Bonzini Cc: Fam Zheng Signed-off-by: Stefan Hajnoczi Message-Id: <20180716083732.3347-3-stefanha@redhat.com> Signed-off-by: Paolo Bonzini --- hw/scsi/virtio-scsi.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index 3aa9971..5a3057d 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -797,8 +797,16 @@ static void virtio_scsi_hotplug(HotplugHandler *hotplu= g_dev, DeviceState *dev, virtio_scsi_acquire(s); blk_set_aio_context(sd->conf.blk, s->ctx); virtio_scsi_release(s); - } +} + +/* Announce the new device after it has been plugged */ +static void virtio_scsi_post_hotplug(HotplugHandler *hotplug_dev, + DeviceState *dev) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(hotplug_dev); + VirtIOSCSI *s =3D VIRTIO_SCSI(vdev); + SCSIDevice *sd =3D SCSI_DEVICE(dev); =20 if (virtio_vdev_has_feature(vdev, VIRTIO_SCSI_F_HOTPLUG)) { virtio_scsi_acquire(s); @@ -968,6 +976,7 @@ static void virtio_scsi_class_init(ObjectClass *klass, = void *data) vdc->start_ioeventfd =3D virtio_scsi_dataplane_start; vdc->stop_ioeventfd =3D virtio_scsi_dataplane_stop; hc->plug =3D virtio_scsi_hotplug; + hc->post_plug =3D virtio_scsi_post_hotplug; hc->unplug =3D virtio_scsi_hotunplug; } =20 --=20 1.8.3.1 From nobody Tue Nov 4 23:51:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531840477315995.5723884432106; Tue, 17 Jul 2018 08:14:37 -0700 (PDT) Received: from localhost ([::1]:59895 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffRgM-0002Uk-7Z for importer@patchew.org; Tue, 17 Jul 2018 11:14:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48505) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffRZN-0005Df-2x for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffRZM-0007J1-3X for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:17 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54094 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ffRZL-0007Il-Ti for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:16 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8BFA74075789 for ; Tue, 17 Jul 2018 15:07:15 +0000 (UTC) Received: from 640k.localdomain.com (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E51C2026D68; Tue, 17 Jul 2018 15:07:14 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 17 Jul 2018 17:06:52 +0200 Message-Id: <1531840015-28804-11-git-send-email-pbonzini@redhat.com> In-Reply-To: <1531840015-28804-1-git-send-email-pbonzini@redhat.com> References: <1531840015-28804-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 17 Jul 2018 15:07:15 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 17 Jul 2018 15:07:15 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'pbonzini@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 10/13] i386: fix regression parsing multiboot initrd modules X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Daniel P. Berrang=C3=A9 The logic for parsing the multiboot initrd modules was messed up in commit 950c4e6c94b15cd0d8b63891dddd7a8dbf458e6a Author: Daniel P. Berrang=C3=A9 Date: Mon Apr 16 12:17:43 2018 +0100 opts: don't silently truncate long option values Causing the length to be undercounter, and the number of modules over counted. It also passes NULL to get_opt_value() which was not robust at accepting a NULL value. Signed-off-by: Daniel P. Berrang=C3=A9 Message-Id: <20180514171913.17664-2-berrange@redhat.com> Reviewed-by: Eduardo Habkost Tested-by: Roman Kagan Signed-off-by: Paolo Bonzini --- hw/i386/multiboot.c | 3 +-- util/qemu-option.c | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c index 7a2953e..8e26545 100644 --- a/hw/i386/multiboot.c +++ b/hw/i386/multiboot.c @@ -292,8 +292,7 @@ int load_multiboot(FWCfgState *fw_cfg, cmdline_len +=3D strlen(kernel_cmdline) + 1; if (initrd_filename) { const char *r =3D get_opt_value(initrd_filename, NULL); - cmdline_len +=3D strlen(r) + 1; - mbs.mb_mods_avail =3D 1; + cmdline_len +=3D strlen(initrd_filename) + 1; while (1) { mbs.mb_mods_avail++; r =3D get_opt_value(r, NULL); diff --git a/util/qemu-option.c b/util/qemu-option.c index 19761e3..834217f 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -75,7 +75,9 @@ const char *get_opt_value(const char *p, char **value) size_t capacity =3D 0, length; const char *offset; =20 - *value =3D NULL; + if (value) { + *value =3D NULL; + } while (1) { offset =3D qemu_strchrnul(p, ','); length =3D offset - p; --=20 1.8.3.1 From nobody Tue Nov 4 23:51:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531840597707509.955200758621; Tue, 17 Jul 2018 08:16:37 -0700 (PDT) Received: from localhost ([::1]:59917 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffRiO-0004Xo-PR for importer@patchew.org; Tue, 17 Jul 2018 11:16:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48559) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffRZT-0005K5-CK for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffRZN-0007Jn-EP for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:23 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47128 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ffRZN-0007JR-8R for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:17 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E15ED7B2B3 for ; Tue, 17 Jul 2018 15:07:16 +0000 (UTC) Received: from 640k.localdomain.com (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id F360B2026D68; Tue, 17 Jul 2018 15:07:15 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 17 Jul 2018 17:06:53 +0200 Message-Id: <1531840015-28804-12-git-send-email-pbonzini@redhat.com> In-Reply-To: <1531840015-28804-1-git-send-email-pbonzini@redhat.com> References: <1531840015-28804-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 17 Jul 2018 15:07:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 17 Jul 2018 15:07:16 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'pbonzini@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 11/13] i386: only parse the initrd_filename once for multiboot modules X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Daniel P. Berrang=C3=A9 The multiboot code parses the initrd_filename twice, first to count how many entries there are, and second to process each entry. This changes the first loop to store the parse module names in a list, and the second loop can now use these names. This avoids having to pass NULL to the get_opt_value() method which means it can safely assume a non-NULL param. Signed-off-by: Daniel P. Berrang=C3=A9 Message-Id: <20180514171913.17664-3-berrange@redhat.com> Reviewed-by: Eduardo Habkost Tested-by: Roman Kagan Signed-off-by: Paolo Bonzini --- hw/i386/multiboot.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c index 8e26545..d519e20 100644 --- a/hw/i386/multiboot.c +++ b/hw/i386/multiboot.c @@ -161,6 +161,7 @@ int load_multiboot(FWCfgState *fw_cfg, uint8_t bootinfo[MBI_SIZE]; uint8_t *mb_bootinfo_data; uint32_t cmdline_len; + GList *mods =3D NULL; =20 /* Ok, let's see if it is a multiboot image. The header is 12x32bit long, so the latest entry may be 8192 - 48. = */ @@ -291,15 +292,16 @@ int load_multiboot(FWCfgState *fw_cfg, cmdline_len =3D strlen(kernel_filename) + 1; cmdline_len +=3D strlen(kernel_cmdline) + 1; if (initrd_filename) { - const char *r =3D get_opt_value(initrd_filename, NULL); + const char *r =3D initrd_filename; cmdline_len +=3D strlen(initrd_filename) + 1; - while (1) { + while (*r) { + char *value; + r =3D get_opt_value(r, &value); mbs.mb_mods_avail++; - r =3D get_opt_value(r, NULL); - if (!*r) { - break; + mods =3D g_list_append(mods, value); + if (*r) { + r++; } - r++; } } =20 @@ -314,20 +316,16 @@ int load_multiboot(FWCfgState *fw_cfg, mbs.offset_cmdlines =3D mbs.offset_mbinfo + mbs.mb_mods_avail * MB_M= OD_SIZE; mbs.offset_bootloader =3D mbs.offset_cmdlines + cmdline_len; =20 - if (initrd_filename) { - const char *next_initrd; - char not_last; - char *one_file =3D NULL; - + if (mods) { + GList *tmpl =3D mods; mbs.offset_mods =3D mbs.mb_buf_size; =20 - do { + while (tmpl) { char *next_space; int mb_mod_length; uint32_t offs =3D mbs.mb_buf_size; + char *one_file =3D tmpl->data; =20 - next_initrd =3D get_opt_value(initrd_filename, &one_file); - not_last =3D *next_initrd; /* if a space comes after the module filename, treat everything after that as parameters */ hwaddr c =3D mb_add_cmdline(&mbs, one_file); @@ -352,10 +350,10 @@ int load_multiboot(FWCfgState *fw_cfg, mb_debug("mod_start: %p\nmod_end: %p\n cmdline: "TARGET_FMT= _plx, (char *)mbs.mb_buf + offs, (char *)mbs.mb_buf + offs + mb_mod_length, c); - initrd_filename =3D next_initrd+1; g_free(one_file); - one_file =3D NULL; - } while (not_last); + tmpl =3D tmpl->next; + } + g_list_free(mods); } =20 /* Commandline support */ --=20 1.8.3.1 From nobody Tue Nov 4 23:51:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531840323132730.6871793970803; Tue, 17 Jul 2018 08:12:03 -0700 (PDT) Received: from localhost ([::1]:59887 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffRdy-0000OP-5M for importer@patchew.org; Tue, 17 Jul 2018 11:12:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48537) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffRZQ-0005HD-H8 for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffRZO-0007Kj-O1 for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:20 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47130 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ffRZO-0007KR-J4 for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:18 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 40F017B2B3 for ; Tue, 17 Jul 2018 15:07:18 +0000 (UTC) Received: from 640k.localdomain.com (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5252A2026D68; Tue, 17 Jul 2018 15:07:17 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 17 Jul 2018 17:06:54 +0200 Message-Id: <1531840015-28804-13-git-send-email-pbonzini@redhat.com> In-Reply-To: <1531840015-28804-1-git-send-email-pbonzini@redhat.com> References: <1531840015-28804-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 17 Jul 2018 15:07:18 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 17 Jul 2018 15:07:18 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'pbonzini@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 12/13] opts: remove redundant check for NULL parameter X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Daniel P. Berrang=C3=A9 No callers of get_opt_value() pass in a NULL for the "value" parameter, so the check is redundant. Signed-off-by: Daniel P. Berrang=C3=A9 Message-Id: <20180514171913.17664-4-berrange@redhat.com> Reviewed-by: Eduardo Habkost Tested-by: Roman Kagan Signed-off-by: Paolo Bonzini --- util/qemu-option.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/util/qemu-option.c b/util/qemu-option.c index 834217f..01886ef 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -75,20 +75,16 @@ const char *get_opt_value(const char *p, char **value) size_t capacity =3D 0, length; const char *offset; =20 - if (value) { - *value =3D NULL; - } + *value =3D NULL; while (1) { offset =3D qemu_strchrnul(p, ','); length =3D offset - p; if (*offset !=3D '\0' && *(offset + 1) =3D=3D ',') { length++; } - if (value) { - *value =3D g_renew(char, *value, capacity + length + 1); - strncpy(*value + capacity, p, length); - (*value)[capacity + length] =3D '\0'; - } + *value =3D g_renew(char, *value, capacity + length + 1); + strncpy(*value + capacity, p, length); + (*value)[capacity + length] =3D '\0'; capacity +=3D length; if (*offset =3D=3D '\0' || *(offset + 1) !=3D ',') { --=20 1.8.3.1 From nobody Tue Nov 4 23:51:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531840481924261.81119543273473; Tue, 17 Jul 2018 08:14:41 -0700 (PDT) Received: from localhost ([::1]:59900 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffRgW-0002hA-U7 for importer@patchew.org; Tue, 17 Jul 2018 11:14:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48546) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffRZR-0005I6-7A for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffRZQ-0007La-7G for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:21 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47132 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ffRZQ-0007LC-1x for qemu-devel@nongnu.org; Tue, 17 Jul 2018 11:07:20 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A42287B2B3; Tue, 17 Jul 2018 15:07:19 +0000 (UTC) Received: from 640k.localdomain.com (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id A5AB92026D68; Tue, 17 Jul 2018 15:07:18 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 17 Jul 2018 17:06:55 +0200 Message-Id: <1531840015-28804-14-git-send-email-pbonzini@redhat.com> In-Reply-To: <1531840015-28804-1-git-send-email-pbonzini@redhat.com> References: <1531840015-28804-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 17 Jul 2018 15:07:19 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 17 Jul 2018 15:07:19 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'pbonzini@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 13/13] Document command line options with single dash X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: BALATON Zoltan QEMU options have a single dash (but also work as double dash for convenience and compatibility). Most options are listed with single dash in command line help but some were listed with two dashes. Normalize these to have the same format as the others. Left --preconfig as that is mentioned as double dash everywhere so I assume that is the preferred form for that. Signed-off-by: BALATON Zoltan Acked-by: Thomas Huth Message-Id: <20180716193312.A5BA17456B9@zero.eik.bme.hu> Signed-off-by: Paolo Bonzini --- qemu-options.hx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qemu-options.hx b/qemu-options.hx index 654e69c..1a186fb 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -471,7 +471,7 @@ STEXI @item -balloon virtio[,addr=3D@var{addr}] @findex -balloon Enable virtio balloon device, optionally with PCI address @var{addr}. This -option is deprecated, use @option{--device virtio-balloon} instead. +option is deprecated, use @option{-device virtio-balloon} instead. ETEXI =20 DEF("device", HAS_ARG, QEMU_OPTION_device, @@ -2005,7 +2005,7 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev, "-netdev hubport,id=3Dstr,hubid=3Dn[,netdev=3Dnd]\n" " configure a hub port on the hub with ID 'n'\n", QEMU_= ARCH_ALL) DEF("nic", HAS_ARG, QEMU_OPTION_nic, - "--nic [tap|bridge|" + "-nic [tap|bridge|" #ifdef CONFIG_SLIRP "user|" #endif @@ -2024,7 +2024,7 @@ DEF("nic", HAS_ARG, QEMU_OPTION_nic, "socket][,option][,...][mac=3Dmacaddr]\n" " initialize an on-board / default host NIC (using MAC = address\n" " macaddr) and connect it to the given host network bac= kend\n" - "--nic none use it alone to have zero network devices (the defaul= t is to\n" + "-nic none use it alone to have zero network devices (the defaul= t is to\n" " provided a 'user' network connection)\n", QEMU_ARCH_ALL) DEF("net", HAS_ARG, QEMU_OPTION_net, @@ -3338,7 +3338,7 @@ mlocking qemu and guest memory can be enabled via @op= tion{mlock=3Don} ETEXI =20 DEF("overcommit", HAS_ARG, QEMU_OPTION_overcommit, - "--overcommit [mem-lock=3Don|off][cpu-pm=3Don|off]\n" + "-overcommit [mem-lock=3Don|off][cpu-pm=3Don|off]\n" " run qemu with overcommit hints\n" " mem-lock=3Don|off controls memory lock support (defau= lt: off)\n" " cpu-pm=3Don|off controls cpu power management (defaul= t: off)\n", --=20 1.8.3.1