From patchwork Tue Jul 20 12:53:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 1507510 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=TDv1XplR; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GTf832w2rz9sSs for ; Tue, 20 Jul 2021 23:05:07 +1000 (AEST) Received: from localhost ([::1]:41088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m5pQn-0005J7-26 for incoming@patchwork.ozlabs.org; Tue, 20 Jul 2021 09:05:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51066) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGZ-0005LQ-Ex for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24662) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGX-0008LX-GY for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626785668; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ooqr9i89smTm1LP2t+3BtIJJ0XQ2K2fh0uJlziD7rFo=; b=TDv1XplRbp9tKkOE4VnFFBH7j7BjuiIlFNVJQbanS57tyjvV/VrAMuv+Y6YFpim/ZifQFN yxHGb37Uz4P6tXD6PnseResXzta0uhRSr3Zl5o8KMyD/j9KD5iQENFURDyw+U5vapIbT1F rt6LaCcXRB9Io9gVhEyjAG6uNv7dfec= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-230-qiLJ5blfMGaOGWFbiNJhKg-1; Tue, 20 Jul 2021 08:54:25 -0400 X-MC-Unique: qiLJ5blfMGaOGWFbiNJhKg-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id BEE33101F7A3; Tue, 20 Jul 2021 12:54:24 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-187.ams2.redhat.com [10.36.114.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7802369CB4; Tue, 20 Jul 2021 12:54:10 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E9654112D841; Tue, 20 Jul 2021 14:54:08 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 01/16] error: Use error_fatal to simplify obvious fatal errors (again) Date: Tue, 20 Jul 2021 14:53:53 +0200 Message-Id: <20210720125408.387910-2-armbru@redhat.com> In-Reply-To: <20210720125408.387910-1-armbru@redhat.com> References: <20210720125408.387910-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.474, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= , Juan Quintela , Peter Xu , Gerd Hoffmann , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Cornelia Huck , Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" We did this with scripts/coccinelle/use-error_fatal.cocci before, in commit 50beeb68094 and 007b06578ab. This commit cleans up rarer variations that don't seem worth matching with Coccinelle. Cc: Thomas Huth Cc: Cornelia Huck Cc: Peter Xu Cc: Juan Quintela Cc: Stefan Hajnoczi Cc: Paolo Bonzini Cc: Marc-André Lureau Cc: Gerd Hoffmann Cc: Daniel P. Berrangé Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Peter Xu Reviewed-by: Philippe Mathieu-Daudé --- hw/s390x/ipl.c | 6 +----- migration/migration.c | 7 +------ qemu-img.c | 6 +----- qemu-io.c | 6 +----- qemu-nbd.c | 5 +---- scsi/qemu-pr-helper.c | 11 +++-------- softmmu/vl.c | 7 +------ target/i386/sev.c | 8 +------- ui/console.c | 6 ++---- ui/spice-core.c | 7 +------ 10 files changed, 13 insertions(+), 56 deletions(-) diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index 8c863cf386..1821c6faee 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -711,7 +711,6 @@ int s390_ipl_pv_unpack(void) void s390_ipl_prepare_cpu(S390CPU *cpu) { S390IPLState *ipl = get_ipl_device(); - Error *err = NULL; cpu->env.psw.addr = ipl->start_addr; cpu->env.psw.mask = IPL_PSW_MASK; @@ -723,10 +722,7 @@ void s390_ipl_prepare_cpu(S390CPU *cpu) } } if (ipl->netboot) { - if (load_netboot_image(&err) < 0) { - error_report_err(err); - exit(1); - } + load_netboot_image(&error_fatal); ipl->qipl.netboot_start_addr = cpu_to_be64(ipl->start_addr); } s390_ipl_set_boot_menu(ipl); diff --git a/migration/migration.c b/migration/migration.c index 2d306582eb..231dc24414 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -187,8 +187,6 @@ static gint page_request_addr_cmp(gconstpointer ap, gconstpointer bp) void migration_object_init(void) { - Error *err = NULL; - /* This can only be called once. */ assert(!current_migration); current_migration = MIGRATION_OBJ(object_new(TYPE_MIGRATION)); @@ -209,10 +207,7 @@ void migration_object_init(void) qemu_mutex_init(¤t_incoming->page_request_mutex); current_incoming->page_requested = g_tree_new(page_request_addr_cmp); - if (!migration_object_check(current_migration, &err)) { - error_report_err(err); - exit(1); - } + migration_object_check(current_migration, &error_fatal); blk_mig_init(); ram_mig_init(); diff --git a/qemu-img.c b/qemu-img.c index 797742a443..e0b438182e 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -5310,7 +5310,6 @@ int main(int argc, char **argv) { const img_cmd_t *cmd; const char *cmdname; - Error *local_error = NULL; int c; static const struct option long_options[] = { {"help", no_argument, 0, 'h'}, @@ -5328,10 +5327,7 @@ int main(int argc, char **argv) module_call_init(MODULE_INIT_TRACE); qemu_init_exec_dir(argv[0]); - if (qemu_init_main_loop(&local_error)) { - error_report_err(local_error); - exit(EXIT_FAILURE); - } + qemu_init_main_loop(&error_fatal); qcrypto_init(&error_fatal); diff --git a/qemu-io.c b/qemu-io.c index 57f07501df..3924639b92 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -529,7 +529,6 @@ int main(int argc, char **argv) int flags = BDRV_O_UNMAP; int ret; bool writethrough = true; - Error *local_error = NULL; QDict *opts = NULL; const char *format = NULL; bool force_share = false; @@ -629,10 +628,7 @@ int main(int argc, char **argv) exit(1); } - if (qemu_init_main_loop(&local_error)) { - error_report_err(local_error); - exit(1); - } + qemu_init_main_loop(&error_fatal); if (!trace_init_backends()) { exit(1); diff --git a/qemu-nbd.c b/qemu-nbd.c index 26ffbf15af..65ebec598f 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -963,10 +963,7 @@ int main(int argc, char **argv) } } - if (qemu_init_main_loop(&local_err)) { - error_report_err(local_err); - exit(EXIT_FAILURE); - } + qemu_init_main_loop(&error_fatal); bdrv_init(); atexit(qemu_nbd_shutdown); diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c index 7b9389b47b..f281daeced 100644 --- a/scsi/qemu-pr-helper.c +++ b/scsi/qemu-pr-helper.c @@ -1044,10 +1044,7 @@ int main(int argc, char **argv) } } - if (qemu_init_main_loop(&local_err)) { - error_report_err(local_err); - exit(EXIT_FAILURE); - } + qemu_init_main_loop(&error_fatal); server_watch = qio_channel_add_watch(QIO_CHANNEL(server_ioc), G_IO_IN, @@ -1061,10 +1058,8 @@ int main(int argc, char **argv) } } - if ((daemonize || pidfile_specified) && - !qemu_write_pidfile(pidfile, &local_err)) { - error_report_err(local_err); - exit(EXIT_FAILURE); + if (daemonize || pidfile_specified) { + qemu_write_pidfile(pidfile, &error_fatal); } #ifdef CONFIG_LIBCAP_NG diff --git a/softmmu/vl.c b/softmmu/vl.c index 4df1496101..0d2db1abc3 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2673,12 +2673,7 @@ void qmp_x_exit_preconfig(Error **errp) qemu_machine_creation_done(); if (loadvm) { - Error *local_err = NULL; - if (!load_snapshot(loadvm, NULL, false, NULL, &local_err)) { - error_report_err(local_err); - autostart = 0; - exit(1); - } + load_snapshot(loadvm, NULL, false, NULL, &error_fatal); } if (replay_mode != REPLAY_MODE_NONE) { replay_vmstate_init(); diff --git a/target/i386/sev.c b/target/i386/sev.c index 83df8c09f6..0b2c8f594a 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -737,7 +737,6 @@ static void sev_launch_finish(SevGuestState *sev) { int ret, error; - Error *local_err = NULL; trace_kvm_sev_launch_finish(); ret = sev_ioctl(sev->sev_fd, KVM_SEV_LAUNCH_FINISH, 0, &error); @@ -752,12 +751,7 @@ sev_launch_finish(SevGuestState *sev) /* add migration blocker */ error_setg(&sev_mig_blocker, "SEV: Migration is not implemented"); - ret = migrate_add_blocker(sev_mig_blocker, &local_err); - if (local_err) { - error_report_err(local_err); - error_free(sev_mig_blocker); - exit(1); - } + migrate_add_blocker(sev_mig_blocker, &error_fatal); } static void diff --git a/ui/console.c b/ui/console.c index 1103b65314..5d2e6178ff 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1508,7 +1508,6 @@ void register_displaychangelistener(DisplayChangeListener *dcl) "This VM has no graphic display device."; static DisplaySurface *dummy; QemuConsole *con; - Error *err = NULL; assert(!dcl->ds); @@ -1523,9 +1522,8 @@ void register_displaychangelistener(DisplayChangeListener *dcl) dcl->con->gl = dcl; } - if (dcl->con && !dpy_compatible_with(dcl->con, dcl, &err)) { - error_report_err(err); - exit(1); + if (dcl->con) { + dpy_compatible_with(dcl->con, dcl, &error_fatal); } trace_displaychangelistener_register(dcl, dcl->ops->dpy_name); diff --git a/ui/spice-core.c b/ui/spice-core.c index 86d43783ac..bbd7ad070b 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -671,18 +671,13 @@ static void qemu_spice_init(void) } passwordSecret = qemu_opt_get(opts, "password-secret"); if (passwordSecret) { - Error *local_err = NULL; if (qemu_opt_get(opts, "password")) { error_report("'password' option is mutually exclusive with " "'password-secret'"); exit(1); } password = qcrypto_secret_lookup_as_utf8(passwordSecret, - &local_err); - if (!password) { - error_report_err(local_err); - exit(1); - } + &error_fatal); } else { str = qemu_opt_get(opts, "password"); if (str) { From patchwork Tue Jul 20 12:53:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 1507499 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=EhhkDHCe; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GTdwx5jBpz9sWq for ; Tue, 20 Jul 2021 22:55:29 +1000 (AEST) Received: from localhost ([::1]:43948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m5pHT-00052J-4P for incoming@patchwork.ozlabs.org; Tue, 20 Jul 2021 08:55:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50818) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGM-0004eb-QY for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56725) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGK-0008G5-0o for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626785653; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GS1Z57kHAgWZRtOO6uxALRKUYy2PtHX4ycWEiudgAS8=; b=EhhkDHCewa+M0CdbmP31/o4VUWuGufFB+yBOmvalVZPJk80pRd0/l0g5ItCRtd83XTil3r 4AVPtllQIJnlflJ78a6NSf4P3rjaGlT0/u3DAflYSPjJBV1Y2kEWCCt63dX50O8VSjU49F pr0o6/HcHS5lRTR8lGb/W64gs7/RqNs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-199-c0W4a7JHON6_FMzxA8PiFA-1; Tue, 20 Jul 2021 08:54:12 -0400 X-MC-Unique: c0W4a7JHON6_FMzxA8PiFA-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id B5C4E800050; Tue, 20 Jul 2021 12:54:10 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-187.ams2.redhat.com [10.36.114.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 858F45C1D1; Tue, 20 Jul 2021 12:54:10 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id EC30D112D842; Tue, 20 Jul 2021 14:54:08 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 02/16] spapr: Plug memory leak when we can't add a migration blocker Date: Tue, 20 Jul 2021 14:53:54 +0200 Message-Id: <20210720125408.387910-3-armbru@redhat.com> In-Reply-To: <20210720125408.387910-1-armbru@redhat.com> References: <20210720125408.387910-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.474, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Aravinda Prasad , Ganesh Goudar , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Fixes: 2500fb423adb17995485de0b4d507cf2f09e3a7f Cc: Aravinda Prasad Cc: Ganesh Goudar Cc: David Gibson Signed-off-by: Markus Armbruster Acked-by: David Gibson Reviewed-by: Philippe Mathieu-Daudé --- hw/ppc/spapr_events.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c index 0cfc19be19..a8f2cc6bdc 100644 --- a/hw/ppc/spapr_events.c +++ b/hw/ppc/spapr_events.c @@ -872,7 +872,6 @@ void spapr_mce_req_event(PowerPCCPU *cpu, bool recovered) SpaprMachineState *spapr = SPAPR_MACHINE(qdev_get_machine()); CPUState *cs = CPU(cpu); int ret; - Error *local_err = NULL; if (spapr->fwnmi_machine_check_addr == -1) { /* Non-FWNMI case, deliver it like an architected CPU interrupt. */ @@ -912,7 +911,7 @@ void spapr_mce_req_event(PowerPCCPU *cpu, bool recovered) } } - ret = migrate_add_blocker(spapr->fwnmi_migration_blocker, &local_err); + ret = migrate_add_blocker(spapr->fwnmi_migration_blocker, NULL); if (ret == -EBUSY) { /* * We don't want to abort so we let the migration to continue. From patchwork Tue Jul 20 12:53:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 1507500 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ikmsuJIG; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GTdz921pJz9sWl for ; Tue, 20 Jul 2021 22:57:25 +1000 (AEST) Received: from localhost ([::1]:52012 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m5pJK-00028z-Vj for incoming@patchwork.ozlabs.org; Tue, 20 Jul 2021 08:57:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50820) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGM-0004ey-QU for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:48972) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGK-0008Gq-1J for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626785655; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GZ1q2MYPGu49QOTbjqzdIl9/u+FXvgLsoW4DA3BJq4Q=; b=ikmsuJIGoc0/+Erfh6gWdmICk4nV2hzj6grqf2JzWXfhx3iICCid0q46Tr9aOlA+dynXaL bk7n//C7Xg+JCVVJk/w4M8AamM9p0yDop00VetANqi/JHbyQNvHq5eDyGWnQFT6qayh34/ qs20a7bJuM9W/IrJZ7xiHarQydxQaJI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-199-gOCnyc92PWS94GMmpZk0gA-1; Tue, 20 Jul 2021 08:54:12 -0400 X-MC-Unique: gOCnyc92PWS94GMmpZk0gA-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id B970A81C85E; Tue, 20 Jul 2021 12:54:10 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-187.ams2.redhat.com [10.36.114.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 858845C1CF; Tue, 20 Jul 2021 12:54:10 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id EFC4D112D844; Tue, 20 Jul 2021 14:54:08 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 03/16] spapr: Explain purpose of ->fwnmi_migration_blocker more clearly Date: Tue, 20 Jul 2021 14:53:55 +0200 Message-Id: <20210720125408.387910-4-armbru@redhat.com> In-Reply-To: <20210720125408.387910-1-armbru@redhat.com> References: <20210720125408.387910-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.474, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Aravinda Prasad , Ganesh Goudar , "Dr . David Alan Gilbert" , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" spapr_mce_req_event() makes an effort to prevent migration from degrading the reporting of FWNMIs. It adds a migration blocker when it receives one, and deletes it when it's done handling it. This is a best effort. Commit 2500fb423a "migration: Include migration support for machine check handling" tried to explain this in a comment. Rewrite the comment for clarity, and reposition it to make it clear it applies to all failure modes, not just "migration already in progress". Cc: David Gibson Cc: Aravinda Prasad Cc: Ganesh Goudar Cc: Dr. David Alan Gilbert Signed-off-by: Markus Armbruster Acked-by: David Gibson --- hw/ppc/spapr_events.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c index a8f2cc6bdc..7d6876f12d 100644 --- a/hw/ppc/spapr_events.c +++ b/hw/ppc/spapr_events.c @@ -911,16 +911,17 @@ void spapr_mce_req_event(PowerPCCPU *cpu, bool recovered) } } + /* + * Try to block migration while FWNMI is being handled, so the + * machine check handler runs where the information passed to it + * actually makes sense. This shouldn't actually block migration, + * only delay it slightly, assuming migration is retried. If the + * attempt to block fails, carry on. Unfortunately, it always + * fails when running with -only-migrate. A proper interface to + * delay migration completion for a bit could avoid that. + */ ret = migrate_add_blocker(spapr->fwnmi_migration_blocker, NULL); if (ret == -EBUSY) { - /* - * We don't want to abort so we let the migration to continue. - * In a rare case, the machine check handler will run on the target. - * Though this is not preferable, it is better than aborting - * the migration or killing the VM. It is okay to call - * migrate_del_blocker on a blocker that was not added (which the - * nmi-interlock handler would do when it's called after this). - */ warn_report("Received a fwnmi while migration was in progress"); } From patchwork Tue Jul 20 12:53:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 1507506 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=h7jxHZnd; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GTf2f0LGdz9sXJ for ; Tue, 20 Jul 2021 23:00:25 +1000 (AEST) Received: from localhost ([::1]:60594 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m5pMF-0007r1-5Y for incoming@patchwork.ozlabs.org; Tue, 20 Jul 2021 09:00:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51016) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGS-0004pm-5V for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:22272) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGO-0008IV-Gl for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626785659; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rs9zwa5qSsRspBnzyLbulXj8LtHbZMghQ8qhtcBNeUY=; b=h7jxHZndLESmU4K52jHZ9ARH/IGZeJI5qGT9YD3Z9Hq3qY+hVHqJQeTPwa35/k8XPoD62a oED7SVitiVO3R0YUoDSSVJRqQaGl5BjrUaZDv3VtKq8Akg+vyQW8K8alCx9+6erJADmZjZ U2w8Z6EhjGizYx7izJVsJqVjCvhuwtg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-19-d6q1XpkaP_y6OrdGcje5ww-1; Tue, 20 Jul 2021 08:54:16 -0400 X-MC-Unique: d6q1XpkaP_y6OrdGcje5ww-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9E99719251A1; Tue, 20 Jul 2021 12:54:15 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-187.ams2.redhat.com [10.36.114.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 792BA5D9D3; Tue, 20 Jul 2021 12:54:10 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id F3012112D845; Tue, 20 Jul 2021 14:54:08 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 04/16] multi-process: Fix pci_proxy_dev_realize() error handling Date: Tue, 20 Jul 2021 14:53:56 +0200 Message-Id: <20210720125408.387910-5-armbru@redhat.com> In-Reply-To: <20210720125408.387910-1-armbru@redhat.com> References: <20210720125408.387910-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) DKIMWL_WL_HIGH=-1.474, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Elena Ufimtseva , John G Johnson , Jagannathan Raman , Stefan Hajnoczi Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The Error ** argument must be NULL, &error_abort, &error_fatal, or a pointer to a variable containing NULL. Passing an argument of the latter kind twice without clearing it in between is wrong: if the first call sets an error, it no longer points to NULL for the second call. pci_proxy_dev_realize() is wrong that way: it passes @errp to qio_channel_new_fd() without checking for failure. If it runs into another failure, it trips error_setv()'s assertion. Fix it to check for failure properly. Fixes: 9f8112073aad8e485ac012ee18809457ab7f23a6 Cc: Elena Ufimtseva Cc: Jagannathan Raman Cc: John G Johnson Cc: Stefan Hajnoczi Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daudé Acked-by: Jagannathan Raman --- hw/remote/proxy.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hw/remote/proxy.c b/hw/remote/proxy.c index 6dda705fc2..499f540c94 100644 --- a/hw/remote/proxy.c +++ b/hw/remote/proxy.c @@ -102,10 +102,18 @@ static void pci_proxy_dev_realize(PCIDevice *device, Error **errp) } dev->ioc = qio_channel_new_fd(fd, errp); + if (!dev->ioc) { + close(fd); + return; + } error_setg(&dev->migration_blocker, "%s does not support migration", TYPE_PCI_PROXY_DEV); - migrate_add_blocker(dev->migration_blocker, errp); + if (migrate_add_blocker(dev->migration_blocker, errp) < 0) { + error_free(dev->migration_blocker); + object_unref(dev->ioc); + return; + } qemu_mutex_init(&dev->io_mutex); qio_channel_set_blocking(dev->ioc, true, NULL); From patchwork Tue Jul 20 12:53:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 1507503 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KZTC662P; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GTdzG01pSz9s24 for ; Tue, 20 Jul 2021 22:57:30 +1000 (AEST) Received: from localhost ([::1]:52406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m5pJP-0002OC-MP for incoming@patchwork.ozlabs.org; Tue, 20 Jul 2021 08:57:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50986) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGQ-0004nz-Tb for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:48064) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGN-0008Ho-7u for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626785658; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tG45zN/Yo+X4/PVK2K1UnA3+Ntv2MO61J9bSokSZ6Cg=; b=KZTC662PlToayICyanovGyoJsgMO3LBm4tBeu9gIqCGCDxLsmpHGv7P8G4eaZWTEj7ReO0 ICvpTpHMQB2xG855rSnUfXrKmZ8PTXU6Cc9CLqycIzAyRTuXeQfrwFEFIKayzLY3ptWRwY c2V0VNInaPWVrPkL5AumDEcJr3yiyiA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-21-N9ODFjFePw2-6bc37huCDA-1; Tue, 20 Jul 2021 08:54:17 -0400 X-MC-Unique: N9ODFjFePw2-6bc37huCDA-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3ADA5800050 for ; Tue, 20 Jul 2021 12:54:16 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-187.ams2.redhat.com [10.36.114.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4A82919C79; Tue, 20 Jul 2021 12:54:12 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 021ED112D848; Tue, 20 Jul 2021 14:54:09 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 05/16] vhost-scsi: Plug memory leak on migrate_add_blocker() failure Date: Tue, 20 Jul 2021 14:53:57 +0200 Message-Id: <20210720125408.387910-6-armbru@redhat.com> In-Reply-To: <20210720125408.387910-1-armbru@redhat.com> References: <20210720125408.387910-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.474, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Cc: Michael S. Tsirkin Signed-off-by: Markus Armbruster --- hw/scsi/vhost-scsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index 8c611bfd2d..039caf2614 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -208,7 +208,6 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp) "target SCSI device state or use shared storage over network), " "set 'migratable' property to true to enable migration."); if (migrate_add_blocker(vsc->migration_blocker, errp) < 0) { - error_free(vsc->migration_blocker); goto free_virtio; } } @@ -233,11 +232,12 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp) return; free_vqs: + g_free(vsc->dev.vqs); if (!vsc->migratable) { migrate_del_blocker(vsc->migration_blocker); } - g_free(vsc->dev.vqs); free_virtio: + error_free(vsc->migration_blocker); virtio_scsi_common_unrealize(dev); close_fd: close(vhostfd); From patchwork Tue Jul 20 12:53:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 1507498 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=HCfS5gyX; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GTdwg0bDCz9sX2 for ; Tue, 20 Jul 2021 22:55:15 +1000 (AEST) Received: from localhost ([::1]:43550 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m5pHE-0004kj-GK for incoming@patchwork.ozlabs.org; Tue, 20 Jul 2021 08:55:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50872) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGN-0004h7-8y for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:34993) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGK-0008GX-0v for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626785654; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ypcqcc5J//ZIGihgb1dDHeWeRJy0Ogt44IIsDEFb0Kw=; b=HCfS5gyXnmwl6V7vWOlwoKiG92RUjFWdIUOKmvlJUhAQMQ1rmf2za9USYvIviACf/y6/od csFwxECjkG+mHlgGsfyYK5ebV42o/4BE/EmbHKTFb4SnI9g2r2V9Mue88LZ/kgTVj9i+gd Gfes87pO8U/raMltywJPUEip2WLWWGY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-49-7HVTMmvNPUyMh5NRNDLPRA-1; Tue, 20 Jul 2021 08:54:13 -0400 X-MC-Unique: 7HVTMmvNPUyMh5NRNDLPRA-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 773FC804308 for ; Tue, 20 Jul 2021 12:54:12 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-187.ams2.redhat.com [10.36.114.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4926F60843; Tue, 20 Jul 2021 12:54:12 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 05737112D849; Tue, 20 Jul 2021 14:54:09 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 06/16] i386: Never free migration blocker objects instead of sometimes Date: Tue, 20 Jul 2021 14:53:58 +0200 Message-Id: <20210720125408.387910-7-armbru@redhat.com> In-Reply-To: <20210720125408.387910-1-armbru@redhat.com> References: <20210720125408.387910-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.474, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Marcelo Tosatti , Eduardo Habkost Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" invtsc_mig_blocker has static storage duration. When a CPU with certain features is initialized, and invtsc_mig_blocker is still null, we add a migration blocker and store it in invtsc_mig_blocker. The object is freed when migrate_add_blocker() fails, leaving invtsc_mig_blocker dangling. It is not freed on later failures. Same for hv_passthrough_mig_blocker and hv_no_nonarch_cs_mig_blocker. All failures are actually fatal, so whether we free or not doesn't really matter, except as bad examples to be copied / imitated. Clean this up in a minimal way: never free these blocker objects. Cc: Paolo Bonzini Cc: Marcelo Tosatti Cc: Eduardo Habkost Signed-off-by: Markus Armbruster --- target/i386/kvm/kvm.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 59ed8327ac..8e1bb905ca 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -1423,7 +1423,6 @@ static int hyperv_init_vcpu(X86CPU *cpu) ret = migrate_add_blocker(hv_passthrough_mig_blocker, &local_err); if (local_err) { error_report_err(local_err); - error_free(hv_passthrough_mig_blocker); return ret; } } @@ -1438,7 +1437,6 @@ static int hyperv_init_vcpu(X86CPU *cpu) ret = migrate_add_blocker(hv_no_nonarch_cs_mig_blocker, &local_err); if (local_err) { error_report_err(local_err); - error_free(hv_no_nonarch_cs_mig_blocker); return ret; } } @@ -1878,7 +1876,6 @@ int kvm_arch_init_vcpu(CPUState *cs) r = migrate_add_blocker(invtsc_mig_blocker, &local_err); if (local_err) { error_report_err(local_err); - error_free(invtsc_mig_blocker); return r; } } From patchwork Tue Jul 20 12:53:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 1507502 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=FFTNsCJz; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GTdzB441Nz9sWl for ; Tue, 20 Jul 2021 22:57:26 +1000 (AEST) Received: from localhost ([::1]:52164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m5pJM-0002Ew-9R for incoming@patchwork.ozlabs.org; Tue, 20 Jul 2021 08:57:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50956) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGQ-0004kp-5O for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:47074) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGN-0008Hk-3n for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626785658; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MSt/m+s0UORwtA1r2YnMv27vH4CYgJo6nJKJj2HO3Mk=; b=FFTNsCJz7xGqrrOlam3KHRiQREq2HaVl7O7+damWjAN5/kNdp99Fa5GB0fWQXpKk4fYS9y lioAvI3JRBZF8dU1PJrJgSSugpIs+VspQkUEl6Ye5hoITCvtrDGWWMrfCTGkgUCWf88iQL wqllGOa9Z5tYuDhJ4r3gZEsZrFqe9Ao= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-111-f9BOkJZGN5umoj_wqrCyMA-1; Tue, 20 Jul 2021 08:54:17 -0400 X-MC-Unique: f9BOkJZGN5umoj_wqrCyMA-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3A6F410151E2; Tue, 20 Jul 2021 12:54:16 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-187.ams2.redhat.com [10.36.114.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 49FD45D9FC; Tue, 20 Jul 2021 12:54:12 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 08C11112D84A; Tue, 20 Jul 2021 14:54:09 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 07/16] vfio: Avoid error_propagate() after migrate_add_blocker() Date: Tue, 20 Jul 2021 14:53:59 +0200 Message-Id: <20210720125408.387910-8-armbru@redhat.com> In-Reply-To: <20210720125408.387910-1-armbru@redhat.com> References: <20210720125408.387910-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.474, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kirti Wankhede , Alex Williamson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" When migrate_add_blocker(blocker, &errp) is followed by error_propagate(errp, err), we can often just as well do migrate_add_blocker(..., errp). This is the case in vfio_migration_probe(). Prior art: commit 386f6c07d2 "error: Avoid error_propagate() after migrate_add_blocker()". Cc: Kirti Wankhede Cc: Alex Williamson Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daudé --- hw/vfio/migration.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 82f654afb6..ff6b45de6b 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -858,7 +858,6 @@ int vfio_migration_probe(VFIODevice *vbasedev, Error **errp) { VFIOContainer *container = vbasedev->group->container; struct vfio_region_info *info = NULL; - Error *local_err = NULL; int ret = -ENOTSUP; if (!vbasedev->enable_migration || !container->dirty_pages_supported) { @@ -885,9 +884,8 @@ add_blocker: "VFIO device doesn't support migration"); g_free(info); - ret = migrate_add_blocker(vbasedev->migration_blocker, &local_err); - if (local_err) { - error_propagate(errp, local_err); + ret = migrate_add_blocker(vbasedev->migration_blocker, errp); + if (ret < 0) { error_free(vbasedev->migration_blocker); vbasedev->migration_blocker = NULL; } From patchwork Tue Jul 20 12:54:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 1507497 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=DmKAAcpk; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GTdwd1ct9z9sWq for ; Tue, 20 Jul 2021 22:55:13 +1000 (AEST) Received: from localhost ([::1]:43644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m5pHC-0004oi-VD for incoming@patchwork.ozlabs.org; Tue, 20 Jul 2021 08:55:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50874) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGN-0004h8-BL for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23728) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGK-0008Gt-16 for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626785655; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X3v+sDvfDpEXWEOyZd3eiE7uTqOOpLSjWifvhqIPbRs=; b=DmKAAcpkDFOUNR2i/HW/i55TRkmKzRdHsOJqHZwTM1ALTeFWSylZeE5dU7dX+JeHtx9aDs ApuUcWMMBFyHEFi942of7ddfDAT1yxbyiQVUlblv/5QDYJ/s12gkKwFmRdb3meiBHgnJex MG9vLpNDbJH5bzQ8jpnW6+aSiDieRe4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-557-c0eIokMZPDaBy6u9B9v1_A-1; Tue, 20 Jul 2021 08:54:13 -0400 X-MC-Unique: c0eIokMZPDaBy6u9B9v1_A-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9F167101F7AB; Tue, 20 Jul 2021 12:54:12 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-187.ams2.redhat.com [10.36.114.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 494E069CB6; Tue, 20 Jul 2021 12:54:12 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 0BFE6112D84B; Tue, 20 Jul 2021 14:54:09 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 08/16] whpx nvmm: Drop useless migrate_del_blocker() Date: Tue, 20 Jul 2021 14:54:00 +0200 Message-Id: <20210720125408.387910-9-armbru@redhat.com> In-Reply-To: <20210720125408.387910-1-armbru@redhat.com> References: <20210720125408.387910-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) DKIMWL_WL_HIGH=-1.474, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sunil Muthuswamy , Reinoud Zandijk , Kamil Rytarowski Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" There is nothing to delete after migrate_add_blocker() failed. Trying anyway is safe, but useless. Don't. Cc: Sunil Muthuswamy Cc: Kamil Rytarowski Cc: Reinoud Zandijk Signed-off-by: Markus Armbruster Reviewed-by: Reinoud Zandijk --- target/i386/nvmm/nvmm-all.c | 1 - target/i386/whpx/whpx-all.c | 1 - 2 files changed, 2 deletions(-) diff --git a/target/i386/nvmm/nvmm-all.c b/target/i386/nvmm/nvmm-all.c index dfa690d65d..7bb0d9e30e 100644 --- a/target/i386/nvmm/nvmm-all.c +++ b/target/i386/nvmm/nvmm-all.c @@ -929,7 +929,6 @@ nvmm_init_vcpu(CPUState *cpu) (void)migrate_add_blocker(nvmm_migration_blocker, &local_error); if (local_error) { error_report_err(local_error); - migrate_del_blocker(nvmm_migration_blocker); error_free(nvmm_migration_blocker); return -EINVAL; } diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index f832f286ac..cc8c0b984b 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -1349,7 +1349,6 @@ int whpx_init_vcpu(CPUState *cpu) (void)migrate_add_blocker(whpx_migration_blocker, &local_error); if (local_error) { error_report_err(local_error); - migrate_del_blocker(whpx_migration_blocker); error_free(whpx_migration_blocker); ret = -EINVAL; goto error; From patchwork Tue Jul 20 12:54:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 1507496 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=aE5IIhwI; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GTdwY5VCbz9s24 for ; Tue, 20 Jul 2021 22:55:09 +1000 (AEST) Received: from localhost ([::1]:43542 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m5pH9-0004kM-Fh for incoming@patchwork.ozlabs.org; Tue, 20 Jul 2021 08:55:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGO-0004hf-64 for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:29068) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGL-0008HI-5P for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626785656; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eDA6OMzuuNafnaDgrGqqKn+q8ASuHBGX0GdykCIu9Ow=; b=aE5IIhwIlbPIKCuj8WHOFM05srFpAtmDfFmiF9X35ycIKlfg0qReynbtFiX05dSd9pgvP3 6JxB/y0zJywQ/9I+SiDfw7y9CdYSNDvvzyK+DqBqwaIocV2LLx5jyyvnn8hyI9wx9eTPeP o487s0zi1SUW1i1xvaDcHvXOKFeoR3I= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-589-nAyoMjfFOqOSo8pOPPcX_A-1; Tue, 20 Jul 2021 08:54:15 -0400 X-MC-Unique: nAyoMjfFOqOSo8pOPPcX_A-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5D7B680365C for ; Tue, 20 Jul 2021 12:54:14 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-187.ams2.redhat.com [10.36.114.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 085CB5D719 for ; Tue, 20 Jul 2021 12:54:14 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 0F2D4112D84C; Tue, 20 Jul 2021 14:54:09 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 09/16] migration: Unify failure check for migrate_add_blocker() Date: Tue, 20 Jul 2021 14:54:01 +0200 Message-Id: <20210720125408.387910-10-armbru@redhat.com> In-Reply-To: <20210720125408.387910-1-armbru@redhat.com> References: <20210720125408.387910-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.474, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Most callers check the return value. Some check whether it set an error. Functionally equivalent, but the former tends to be easier on the eyes, so do that everywhere. Prior art: commit c6ecec43b2 "qemu-option: Check return value instead of @err where convenient". Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daudé --- backends/tpm/tpm_emulator.c | 3 +-- hw/display/qxl.c | 8 ++++---- hw/virtio/vhost.c | 2 +- target/i386/kvm/kvm.c | 6 +++--- target/i386/nvmm/nvmm-all.c | 3 +-- target/i386/whpx/whpx-all.c | 3 +-- 6 files changed, 11 insertions(+), 14 deletions(-) diff --git a/backends/tpm/tpm_emulator.c b/backends/tpm/tpm_emulator.c index e5f1063ab6..f8095d23d5 100644 --- a/backends/tpm/tpm_emulator.c +++ b/backends/tpm/tpm_emulator.c @@ -492,8 +492,7 @@ static int tpm_emulator_block_migration(TPMEmulator *tpm_emu) error_setg(&tpm_emu->migration_blocker, "Migration disabled: TPM emulator does not support " "migration"); - migrate_add_blocker(tpm_emu->migration_blocker, &err); - if (err) { + if (migrate_add_blocker(tpm_emu->migration_blocker, &err) < 0) { error_report_err(err); error_free(tpm_emu->migration_blocker); tpm_emu->migration_blocker = NULL; diff --git a/hw/display/qxl.c b/hw/display/qxl.c index 84f99088e0..436399db76 100644 --- a/hw/display/qxl.c +++ b/hw/display/qxl.c @@ -680,12 +680,12 @@ static int interface_get_command(QXLInstance *sin, struct QXLCommandExt *ext) msg < (void *)qxl->vga.vram_ptr || msg > ((void *)qxl->vga.vram_ptr + qxl->vga.vram_size))) { if (!qxl->migration_blocker) { - Error *local_err = NULL; + Error *err = NULL; + error_setg(&qxl->migration_blocker, "qxl: guest bug: command not in ram bar"); - migrate_add_blocker(qxl->migration_blocker, &local_err); - if (local_err) { - error_report_err(local_err); + if (migrate_add_blocker(qxl->migration_blocker, &err) < 0) { + error_report_err(err); } } } diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index e8f85a5d2d..dbbc6b6915 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1372,7 +1372,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque, if (hdev->migration_blocker != NULL) { r = migrate_add_blocker(hdev->migration_blocker, errp); - if (*errp) { + if (r < 0) { error_free(hdev->migration_blocker); goto fail_busyloop; } diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 8e1bb905ca..bb72c233cc 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -1421,7 +1421,7 @@ static int hyperv_init_vcpu(X86CPU *cpu) "'hv-passthrough' CPU flag prevents migration, use explicit" " set of hv-* flags instead"); ret = migrate_add_blocker(hv_passthrough_mig_blocker, &local_err); - if (local_err) { + if (ret < 0) { error_report_err(local_err); return ret; } @@ -1435,7 +1435,7 @@ static int hyperv_init_vcpu(X86CPU *cpu) " make sure SMT is disabled and/or that vCPUs are properly" " pinned)"); ret = migrate_add_blocker(hv_no_nonarch_cs_mig_blocker, &local_err); - if (local_err) { + if (ret < 0) { error_report_err(local_err); return ret; } @@ -1874,7 +1874,7 @@ int kvm_arch_init_vcpu(CPUState *cs) "State blocked by non-migratable CPU device" " (invtsc flag)"); r = migrate_add_blocker(invtsc_mig_blocker, &local_err); - if (local_err) { + if (r < 0) { error_report_err(local_err); return r; } diff --git a/target/i386/nvmm/nvmm-all.c b/target/i386/nvmm/nvmm-all.c index 7bb0d9e30e..28dee4c5ee 100644 --- a/target/i386/nvmm/nvmm-all.c +++ b/target/i386/nvmm/nvmm-all.c @@ -926,8 +926,7 @@ nvmm_init_vcpu(CPUState *cpu) error_setg(&nvmm_migration_blocker, "NVMM: Migration not supported"); - (void)migrate_add_blocker(nvmm_migration_blocker, &local_error); - if (local_error) { + if (migrate_add_blocker(nvmm_migration_blocker, &local_error) < 0) { error_report_err(local_error); error_free(nvmm_migration_blocker); return -EINVAL; diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index cc8c0b984b..3e925b9da7 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -1346,8 +1346,7 @@ int whpx_init_vcpu(CPUState *cpu) "State blocked due to non-migratable CPUID feature support," "dirty memory tracking support, and XSAVE/XRSTOR support"); - (void)migrate_add_blocker(whpx_migration_blocker, &local_error); - if (local_error) { + if (migrate_add_blocker(whpx_migration_blocker, &local_error) < 0) { error_report_err(local_error); error_free(whpx_migration_blocker); ret = -EINVAL; From patchwork Tue Jul 20 12:54:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 1507501 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=D46j3QqO; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GTdzB4L1dz9sWq for ; Tue, 20 Jul 2021 22:57:26 +1000 (AEST) Received: from localhost ([::1]:52130 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m5pJM-0002De-AE for incoming@patchwork.ozlabs.org; Tue, 20 Jul 2021 08:57:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50880) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGN-0004h9-Fd for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:41570) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGK-0008HE-Sm for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626785656; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ow5EZF0Cxpv+F/l8BY+nsz9ITyykqMN2+eXVzDHHjLw=; b=D46j3QqOWu+j4Xy0gU1369NmjRuInzqU0urgMyCJflVYF7wITJKUHjPZXE5WIzR6tlVQ4j IzxuH49I2RVE58kwLZfPSUuHGxALSDlWlBw8a5tFa5/dAdS0VcvFSeDqhiV+YUi0Ke1/HD l4gB5ICzBcUeqV7ilCEBp+lVLL/To7A= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-85-WG9Pa-3pO1CTmHroVpTzzg-1; Tue, 20 Jul 2021 08:54:15 -0400 X-MC-Unique: WG9Pa-3pO1CTmHroVpTzzg-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 376E08030D2 for ; Tue, 20 Jul 2021 12:54:14 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-187.ams2.redhat.com [10.36.114.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 083CF5DAA5; Tue, 20 Jul 2021 12:54:14 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 125D6112D84D; Tue, 20 Jul 2021 14:54:09 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 10/16] migration: Handle migration_incoming_setup() errors consistently Date: Tue, 20 Jul 2021 14:54:02 +0200 Message-Id: <20210720125408.387910-11-armbru@redhat.com> In-Reply-To: <20210720125408.387910-1-armbru@redhat.com> References: <20210720125408.387910-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.474, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Dr . David Alan Gilbert" , Juan Quintela Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Commit b673eab4e2 "multifd: Make multifd_load_setup() get an Error parameter" changed migration_incoming_setup() to take an Error ** argument, and adjusted the callers accordingly. It neglected to change adjust multifd_load_setup(): it still exit()s on error. Clean that up. The error now gets propagated up two call chains: via migration_fd_process_incoming() to rdma_accept_incoming_migration(), and via migration_ioc_process_incoming() to migration_channel_process_incoming(). Both chain ends report the error with error_report_err(), but otherwise ignore it. Behavioral change: we no longer exit() on this error. This is consistent with how we handle other errors here, e.g. from multifd_recv_new_channel() via migration_ioc_process_incoming() to migration_channel_process_incoming(). Wether it's consistently right or consistently wrong I can't tell. Also clean up the return value from the unusual 0 on success, 1 on error to the more common true on success, false on error. Cc: Juan Quintela Cc: Dr. David Alan Gilbert Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Pankaj Gupta --- migration/migration.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 231dc24414..c1c0a48647 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -609,30 +609,25 @@ fail: } /** - * @migration_incoming_setup: Setup incoming migration - * - * Returns 0 for no error or 1 for error - * + * migration_incoming_setup: Setup incoming migration * @f: file for main migration channel * @errp: where to put errors + * + * Returns: %true on success, %false on error. */ -static int migration_incoming_setup(QEMUFile *f, Error **errp) +static bool migration_incoming_setup(QEMUFile *f, Error **errp) { MigrationIncomingState *mis = migration_incoming_get_current(); - Error *local_err = NULL; - if (multifd_load_setup(&local_err) != 0) { - /* We haven't been able to create multifd threads - nothing better to do */ - error_report_err(local_err); - exit(EXIT_FAILURE); + if (multifd_load_setup(errp) != 0) { + return false; } if (!mis->from_src_file) { mis->from_src_file = f; } qemu_file_set_blocking(f, false); - return 0; + return true; } void migration_incoming_process(void) @@ -675,14 +670,11 @@ static bool postcopy_try_recover(QEMUFile *f) void migration_fd_process_incoming(QEMUFile *f, Error **errp) { - Error *local_err = NULL; - if (postcopy_try_recover(f)) { return; } - if (migration_incoming_setup(f, &local_err)) { - error_propagate(errp, local_err); + if (!migration_incoming_setup(f, errp)) { return; } migration_incoming_process(); @@ -703,8 +695,7 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) return; } - if (migration_incoming_setup(f, &local_err)) { - error_propagate(errp, local_err); + if (!migration_incoming_setup(f, errp)) { return; } From patchwork Tue Jul 20 12:54:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 1507507 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=cD87NcfE; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GTf2d71j6z9sX5 for ; Tue, 20 Jul 2021 23:00:21 +1000 (AEST) Received: from localhost ([::1]:60646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m5pM9-0007sd-Pp for incoming@patchwork.ozlabs.org; Tue, 20 Jul 2021 09:00:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51014) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGS-0004pL-1d for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:32467) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGO-0008IX-GJ for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626785659; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kmyyrQh4WbaJa96S+gdsxXqP2gWB1mm55dgiENtRKF8=; b=cD87NcfEKfeK9vMs3zJWSfoyEoxTj8oZlzxZn6cVaVWb8zVWr0fqItUawLNj60LeRMC0aK No7Jh+G1kbzKD+Y0zfTG3BPgJNR09n0GN/kPA4DDt+ZFLhYNiztqHmpbt9Aozbhz5d8WoU qxG8Ju8hrON/DPbNl0W/LEN3MHhyDsg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-222-IqIFePIHN-ytwQUYH6ht9w-1; Tue, 20 Jul 2021 08:54:18 -0400 X-MC-Unique: IqIFePIHN-ytwQUYH6ht9w-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CCB4A81C85F for ; Tue, 20 Jul 2021 12:54:17 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-187.ams2.redhat.com [10.36.114.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 085225D6D7; Tue, 20 Jul 2021 12:54:14 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1589E112D84E; Tue, 20 Jul 2021 14:54:09 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 11/16] microvm: Drop dead error handling in microvm_machine_state_init() Date: Tue, 20 Jul 2021 14:54:03 +0200 Message-Id: <20210720125408.387910-12-armbru@redhat.com> In-Reply-To: <20210720125408.387910-1-armbru@redhat.com> References: <20210720125408.387910-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.474, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sergio Lopez Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Stillborn in commit 0ebf007dda "hw/i386: Introduce the microvm machine type". Cc: Sergio Lopez Signed-off-by: Markus Armbruster Reviewed-by: Sergio Lopez Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Pankaj Gupta --- hw/i386/microvm.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c index aba0c83219..f257ec5a0b 100644 --- a/hw/i386/microvm.c +++ b/hw/i386/microvm.c @@ -458,15 +458,10 @@ static void microvm_machine_state_init(MachineState *machine) { MicrovmMachineState *mms = MICROVM_MACHINE(machine); X86MachineState *x86ms = X86_MACHINE(machine); - Error *local_err = NULL; microvm_memory_init(mms); x86_cpus_init(x86ms, CPU_VERSION_LATEST); - if (local_err) { - error_report_err(local_err); - exit(1); - } microvm_devices_init(mms); } From patchwork Tue Jul 20 12:54:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 1507505 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=MIA3R9y8; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GTf2L6Pc6z9sWl for ; Tue, 20 Jul 2021 23:00:10 +1000 (AEST) Received: from localhost ([::1]:60498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m5pLz-0007nE-Pq for incoming@patchwork.ozlabs.org; Tue, 20 Jul 2021 09:00:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51024) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGS-0004t3-Pw for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56097) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGO-0008If-Jh for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626785660; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5lcuUhLpFx5x66QANuw8RMIjKw5nsdw9ExuMGaIhc24=; b=MIA3R9y8Y72O9wWsMUS/P0HpbeF+HdOm5zoqUmNUTrvS+8XjlIIovGQL2dXLIPPDc72vPC ru9anzPe2X5x+CMVIlHLaQe9dKwPTRirNfds/164xai6XeJ7MGWeKUfew/mU9hNPyWFVbL ExbNl0A/P6YM/MXElqUuUt03JsUEUr0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-373-rOLH2m6hNRG-G4MxDYf4ig-1; Tue, 20 Jul 2021 08:54:18 -0400 X-MC-Unique: rOLH2m6hNRG-G4MxDYf4ig-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id B7A9D101F7A1 for ; Tue, 20 Jul 2021 12:54:17 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-187.ams2.redhat.com [10.36.114.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 07F3F60C82; Tue, 20 Jul 2021 12:54:14 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 18B39112D850; Tue, 20 Jul 2021 14:54:09 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 12/16] vhost: Clean up how VhostOpts method vhost_get_config() fails Date: Tue, 20 Jul 2021 14:54:04 +0200 Message-Id: <20210720125408.387910-13-armbru@redhat.com> In-Reply-To: <20210720125408.387910-1-armbru@redhat.com> References: <20210720125408.387910-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.474, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" vhost_user_get_config() can fail without setting an error. Unclean. Its caller vhost_dev_get_config() compensates by substituting a generic error then. Goes back to commit 50de51387f "vhost: Distinguish errors in vhost_dev_get_config()". Clean up by moving the generic error from vhost_dev_get_config() to all the failure paths that neglect to set an error. Cc: Kevin Wolf Cc: Michael S. Tsirkin Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daudé --- hw/virtio/vhost-user.c | 2 ++ hw/virtio/vhost.c | 10 ++-------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 29ea2b4fce..dbbd6fbc25 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -2139,10 +2139,12 @@ static int vhost_user_get_config(struct vhost_dev *dev, uint8_t *config, msg.payload.config.offset = 0; msg.payload.config.size = config_len; if (vhost_user_write(dev, &msg, NULL, 0) < 0) { + error_setg_errno(errp, -EPROTO, "vhost_get_config failed"); return -EPROTO; } if (vhost_user_read(dev, &msg) < 0) { + error_setg_errno(errp, -EPROTO, "vhost_get_config failed"); return -EPROTO; } diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index dbbc6b6915..88f8a397dc 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1564,17 +1564,11 @@ void vhost_ack_features(struct vhost_dev *hdev, const int *feature_bits, int vhost_dev_get_config(struct vhost_dev *hdev, uint8_t *config, uint32_t config_len, Error **errp) { - ERRP_GUARD(); - int ret; - assert(hdev->vhost_ops); if (hdev->vhost_ops->vhost_get_config) { - ret = hdev->vhost_ops->vhost_get_config(hdev, config, config_len, errp); - if (ret < 0 && !*errp) { - error_setg_errno(errp, -ret, "vhost_get_config failed"); - } - return ret; + return hdev->vhost_ops->vhost_get_config(hdev, config, config_len, + errp); } error_setg(errp, "vhost_get_config not implemented"); From patchwork Tue Jul 20 12:54:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 1507513 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Xoi32yAy; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GTfC26bKPz9sWl for ; Tue, 20 Jul 2021 23:07:42 +1000 (AEST) Received: from localhost ([::1]:48986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m5pTI-0002Fq-JE for incoming@patchwork.ozlabs.org; Tue, 20 Jul 2021 09:07:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51054) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGX-0005Bm-5U for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:27085) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGQ-0008JK-Lw for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626785662; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gz9LhF2oTT5mao087ujU+bzlIFTt5GBr0gQoxyvJCJA=; b=Xoi32yAyCjNyZXeK2Q7dlt2FrpegywyL4QH1plFVn5bZRjVP6kqMtA1TMzCeYseltRSpTQ 8iJfWJb9WV386Z39huexJ2Tw13UfTJ1WdIXeyN+7G0fem3XWUDm1twJrIns0vpuZzEW53/ 5Ntki0dg457i0hn8MYoN3kgjb8pQvDQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-235-g4NM3T41Pp2iHe0UfvXZTg-1; Tue, 20 Jul 2021 08:54:18 -0400 X-MC-Unique: g4NM3T41Pp2iHe0UfvXZTg-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id B9157804308 for ; Tue, 20 Jul 2021 12:54:17 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-187.ams2.redhat.com [10.36.114.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BCCDD60CA1; Tue, 20 Jul 2021 12:54:15 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1BF04112D851; Tue, 20 Jul 2021 14:54:09 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 13/16] vhost: Clean up how VhostOpts method vhost_backend_init() fails Date: Tue, 20 Jul 2021 14:54:05 +0200 Message-Id: <20210720125408.387910-14-armbru@redhat.com> In-Reply-To: <20210720125408.387910-1-armbru@redhat.com> References: <20210720125408.387910-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.474, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" vhost_user_backend_init() can fail without setting an error. Unclean. Its caller vhost_dev_init() compensates by substituting a generic error then. Goes back to commit 28770ff935 "vhost: Distinguish errors in vhost_backend_init()". Clean up by moving the generic error from vhost_dev_init() to all the failure paths that neglect to set an error. Cc: Kevin Wolf Cc: Michael S. Tsirkin Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daudé --- hw/virtio/vhost-user.c | 6 ++++++ hw/virtio/vhost.c | 4 ---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index dbbd6fbc25..b4a4998088 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -1876,6 +1876,7 @@ static int vhost_user_backend_init(struct vhost_dev *dev, void *opaque, err = vhost_user_get_features(dev, &features); if (err < 0) { + error_setg_errno(errp, -err, "vhost_backend_init failed"); return err; } @@ -1885,6 +1886,7 @@ static int vhost_user_backend_init(struct vhost_dev *dev, void *opaque, err = vhost_user_get_u64(dev, VHOST_USER_GET_PROTOCOL_FEATURES, &protocol_features); if (err < 0) { + error_setg_errno(errp, EPROTO, "vhost_backend_init failed"); return -EPROTO; } @@ -1903,6 +1905,7 @@ static int vhost_user_backend_init(struct vhost_dev *dev, void *opaque, err = vhost_user_set_protocol_features(dev, dev->protocol_features); if (err < 0) { + error_setg_errno(errp, EPROTO, "vhost_backend_init failed"); return -EPROTO; } @@ -1911,6 +1914,7 @@ static int vhost_user_backend_init(struct vhost_dev *dev, void *opaque, err = vhost_user_get_u64(dev, VHOST_USER_GET_QUEUE_NUM, &dev->max_queues); if (err < 0) { + error_setg_errno(errp, EPROTO, "vhost_backend_init failed"); return -EPROTO; } } else { @@ -1940,6 +1944,7 @@ static int vhost_user_backend_init(struct vhost_dev *dev, void *opaque, } else { err = vhost_user_get_max_memslots(dev, &ram_slots); if (err < 0) { + error_setg_errno(errp, EPROTO, "vhost_backend_init failed"); return -EPROTO; } @@ -1966,6 +1971,7 @@ static int vhost_user_backend_init(struct vhost_dev *dev, void *opaque, if (dev->vq_index == 0) { err = vhost_setup_slave_channel(dev); if (err < 0) { + error_setg_errno(errp, EPROTO, "vhost_backend_init failed"); return -EPROTO; } } diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 88f8a397dc..3c0b537f89 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1289,7 +1289,6 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque, VhostBackendType backend_type, uint32_t busyloop_timeout, Error **errp) { - ERRP_GUARD(); uint64_t features; int i, r, n_initialized_vqs = 0; @@ -1301,9 +1300,6 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque, r = hdev->vhost_ops->vhost_backend_init(hdev, opaque, errp); if (r < 0) { - if (!*errp) { - error_setg_errno(errp, -r, "vhost_backend_init failed"); - } goto fail; } From patchwork Tue Jul 20 12:54:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 1507508 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=SnMos88H; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GTf2z5W6mz9s24 for ; Tue, 20 Jul 2021 23:00:43 +1000 (AEST) Received: from localhost ([::1]:60916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m5pMW-000838-Rq for incoming@patchwork.ozlabs.org; Tue, 20 Jul 2021 09:00:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50954) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGQ-0004kh-36 for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:39841) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGN-0008Hi-3y for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626785658; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Z4fOhUHD38CgOY3nRti/WJ+aN3U6LSY5qEu72LmphDI=; b=SnMos88HMDrMWEbjIzfiMNr3orO0EiUeyChDgOkDUAy2OPlv+Lmjno0uEQ6z6iQ4xLexrq mLhBM8g/vObItWsv8ggED62IF9PXmYRo+P8XZ8/rHSyT4eEF+8OrOfp+yRkxrmCOOOp6hl 7tgAqptm0KV3Q6d3v4s+caZLI+Z0QG8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-111-9jUP1urLOnmoVhpjPDlJlA-1; Tue, 20 Jul 2021 08:54:17 -0400 X-MC-Unique: 9jUP1urLOnmoVhpjPDlJlA-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 39D5119251A3 for ; Tue, 20 Jul 2021 12:54:16 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-187.ams2.redhat.com [10.36.114.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BCD295C1CF for ; Tue, 20 Jul 2021 12:54:15 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1F3A0112D853; Tue, 20 Jul 2021 14:54:09 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 14/16] Remove superfluous ERRP_GUARD() Date: Tue, 20 Jul 2021 14:54:06 +0200 Message-Id: <20210720125408.387910-15-armbru@redhat.com> In-Reply-To: <20210720125408.387910-1-armbru@redhat.com> References: <20210720125408.387910-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) DKIMWL_WL_HIGH=-1.474, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Macro ERRP_GUARD() is only needed when we want to dereference @errp or pass it to error_prepend() or error_append_hint(). Delete superfluous ones. Signed-off-by: Markus Armbruster --- hw/remote/mpqemu-link.c | 3 --- qga/commands-posix-ssh.c | 17 ----------------- qga/commands-win32.c | 1 - softmmu/vl.c | 1 - ui/console.c | 1 - 5 files changed, 23 deletions(-) diff --git a/hw/remote/mpqemu-link.c b/hw/remote/mpqemu-link.c index e67a5de72c..7e841820e5 100644 --- a/hw/remote/mpqemu-link.c +++ b/hw/remote/mpqemu-link.c @@ -34,7 +34,6 @@ */ bool mpqemu_msg_send(MPQemuMsg *msg, QIOChannel *ioc, Error **errp) { - ERRP_GUARD(); bool iolock = qemu_mutex_iothread_locked(); bool iothread = qemu_in_iothread(); struct iovec send[2] = {}; @@ -97,7 +96,6 @@ bool mpqemu_msg_send(MPQemuMsg *msg, QIOChannel *ioc, Error **errp) static ssize_t mpqemu_read(QIOChannel *ioc, void *buf, size_t len, int **fds, size_t *nfds, Error **errp) { - ERRP_GUARD(); struct iovec iov = { .iov_base = buf, .iov_len = len }; bool iolock = qemu_mutex_iothread_locked(); bool iothread = qemu_in_iothread(); @@ -192,7 +190,6 @@ fail: uint64_t mpqemu_msg_send_and_await_reply(MPQemuMsg *msg, PCIProxyDev *pdev, Error **errp) { - ERRP_GUARD(); MPQemuMsg msg_reply = {0}; uint64_t ret = UINT64_MAX; diff --git a/qga/commands-posix-ssh.c b/qga/commands-posix-ssh.c index 2dda136d64..f3a580b8cc 100644 --- a/qga/commands-posix-ssh.c +++ b/qga/commands-posix-ssh.c @@ -45,8 +45,6 @@ get_passwd_entry(const char *username, Error **errp) g_autoptr(GError) err = NULL; struct passwd *p; - ERRP_GUARD(); - p = g_unix_get_passwd_entry_qemu(username, &err); if (p == NULL) { error_setg(errp, "failed to lookup user '%s': %s", @@ -61,8 +59,6 @@ static bool mkdir_for_user(const char *path, const struct passwd *p, mode_t mode, Error **errp) { - ERRP_GUARD(); - if (g_mkdir(path, mode) == -1) { error_setg(errp, "failed to create directory '%s': %s", path, g_strerror(errno)); @@ -87,8 +83,6 @@ mkdir_for_user(const char *path, const struct passwd *p, static bool check_openssh_pub_key(const char *key, Error **errp) { - ERRP_GUARD(); - /* simple sanity-check, we may want more? */ if (!key || key[0] == '#' || strchr(key, '\n')) { error_setg(errp, "invalid OpenSSH public key: '%s'", key); @@ -104,8 +98,6 @@ check_openssh_pub_keys(strList *keys, size_t *nkeys, Error **errp) size_t n = 0; strList *k; - ERRP_GUARD(); - for (k = keys; k != NULL; k = k->next) { if (!check_openssh_pub_key(k->value, errp)) { return false; @@ -126,8 +118,6 @@ write_authkeys(const char *path, const GStrv keys, g_autofree char *contents = NULL; g_autoptr(GError) err = NULL; - ERRP_GUARD(); - contents = g_strjoinv("\n", keys); if (!g_file_set_contents(path, contents, -1, &err)) { error_setg(errp, "failed to write to '%s': %s", path, err->message); @@ -155,8 +145,6 @@ read_authkeys(const char *path, Error **errp) g_autoptr(GError) err = NULL; g_autofree char *contents = NULL; - ERRP_GUARD(); - if (!g_file_get_contents(path, &contents, NULL, &err)) { error_setg(errp, "failed to read '%s': %s", path, err->message); return NULL; @@ -178,7 +166,6 @@ qmp_guest_ssh_add_authorized_keys(const char *username, strList *keys, strList *k; size_t nkeys, nauthkeys; - ERRP_GUARD(); reset = has_reset && reset; if (!check_openssh_pub_keys(keys, &nkeys, errp)) { @@ -228,8 +215,6 @@ qmp_guest_ssh_remove_authorized_keys(const char *username, strList *keys, GStrv a; size_t nkeys = 0; - ERRP_GUARD(); - if (!check_openssh_pub_keys(keys, NULL, errp)) { return; } @@ -277,8 +262,6 @@ qmp_guest_ssh_get_authorized_keys(const char *username, Error **errp) g_autoptr(GuestAuthorizedKeys) ret = NULL; int i; - ERRP_GUARD(); - p = get_passwd_entry(username, errp); if (p == NULL) { return NULL; diff --git a/qga/commands-win32.c b/qga/commands-win32.c index a099acb34d..a6d2c0d88e 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -976,7 +976,6 @@ out: GuestDiskInfoList *qmp_guest_get_disks(Error **errp) { - ERRP_GUARD(); GuestDiskInfoList *ret = NULL; HDEVINFO dev_info; SP_DEVICE_INTERFACE_DATA dev_iface_data; diff --git a/softmmu/vl.c b/softmmu/vl.c index 0d2db1abc3..f9ffeb8d4d 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -1539,7 +1539,6 @@ machine_parse_property_opt(QemuOptsList *opts_list, const char *propname, { QDict *opts, *prop; bool help = false; - ERRP_GUARD(); prop = keyval_parse(arg, opts_list->implied_opt_name, &help, errp); if (help) { diff --git a/ui/console.c b/ui/console.c index 5d2e6178ff..eabbbc951c 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1481,7 +1481,6 @@ static bool displaychangelistener_has_dmabuf(DisplayChangeListener *dcl) static bool dpy_compatible_with(QemuConsole *con, DisplayChangeListener *dcl, Error **errp) { - ERRP_GUARD(); int flags; flags = con->hw_ops->get_flags ? con->hw_ops->get_flags(con->hw) : 0; From patchwork Tue Jul 20 12:54:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 1507509 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=imZ5dT3y; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GTf814zGwz9sSs for ; Tue, 20 Jul 2021 23:05:04 +1000 (AEST) Received: from localhost ([::1]:40800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m5pQj-00056j-Qf for incoming@patchwork.ozlabs.org; Tue, 20 Jul 2021 09:05:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51030) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGU-00052Y-R5 for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:48420) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGN-0008Hd-01 for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626785658; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1W55TDbA6w0lNfwPGSJWgrGEpkj82bG0uWUcGoXhooU=; b=imZ5dT3ynsahlfUuOQL+vaYUp/VqpFjBo2pGwxVIIVisFdF9C16Aa3ksqG1tVwyL7Nh+3M Zm2l924AAk1qp6ZqvJiSaXBG754DwpsI4ptpKs10OoOvlpXUk60zEuqa7obROSb5EE7V4k 5fTl4Mk6YM4DSvBuVSox9l1TL0E94Ag= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-15-QqgJcHFMMpSZBxywSO41Rw-1; Tue, 20 Jul 2021 08:54:17 -0400 X-MC-Unique: QqgJcHFMMpSZBxywSO41Rw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3A25A34657 for ; Tue, 20 Jul 2021 12:54:16 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-187.ams2.redhat.com [10.36.114.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DFEED5D6A1; Tue, 20 Jul 2021 12:54:15 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 22835112D855; Tue, 20 Jul 2021 14:54:09 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 15/16] vl: Clean up -smp error handling Date: Tue, 20 Jul 2021 14:54:07 +0200 Message-Id: <20210720125408.387910-16-armbru@redhat.com> In-Reply-To: <20210720125408.387910-1-armbru@redhat.com> References: <20210720125408.387910-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.474, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The Error ** argument must be NULL, &error_abort, &error_fatal, or a pointer to a variable containing NULL. Passing an argument of the latter kind twice without clearing it in between is wrong: if the first call sets an error, it no longer points to NULL for the second call. machine_parse_property_opt() is wrong that way: it passes @errp to keyval_parse() without checking for failure, then passes it to keyval_merge(). Harmless, since the only caller passes &error_fatal. Clean up: drop the parameter, and use &error_fatal directly. Cc: Paolo Bonzini Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daudé --- softmmu/vl.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index f9ffeb8d4d..ce0ecc736b 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -1535,19 +1535,19 @@ static void machine_help_func(const QDict *qdict) static void machine_parse_property_opt(QemuOptsList *opts_list, const char *propname, - const char *arg, Error **errp) + const char *arg) { QDict *opts, *prop; bool help = false; - prop = keyval_parse(arg, opts_list->implied_opt_name, &help, errp); + prop = keyval_parse(arg, opts_list->implied_opt_name, &help, &error_fatal); if (help) { qemu_opts_print_help(opts_list, true); return; } opts = qdict_new(); qdict_put(opts, propname, prop); - keyval_merge(machine_opts_dict, opts, errp); + keyval_merge(machine_opts_dict, opts, &error_fatal); qobject_unref(opts); } @@ -3321,7 +3321,8 @@ void qemu_init(int argc, char **argv, char **envp) } break; case QEMU_OPTION_smp: - machine_parse_property_opt(qemu_find_opts("smp-opts"), "smp", optarg, &error_fatal); + machine_parse_property_opt(qemu_find_opts("smp-opts"), + "smp", optarg); break; case QEMU_OPTION_vnc: vnc_parse(optarg); From patchwork Tue Jul 20 12:54:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 1507511 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Q84GWFft; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GTf872XGLz9sSs for ; Tue, 20 Jul 2021 23:05:11 +1000 (AEST) Received: from localhost ([::1]:41324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m5pQr-0005Su-1f for incoming@patchwork.ozlabs.org; Tue, 20 Jul 2021 09:05:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50968) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGQ-0004m2-GI for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55659) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5pGN-0008He-3X for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:54:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626785658; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=A5+apKCmdzHiZuhEkLwuaiHTwdXxk3U0EfkxM0ycIO8=; b=Q84GWFftd1+tD/r81VuHDzOQMKNXYnoJhR4K3tzjHuM6V9hF/Fjk2ktz8dXrrDrOWKihdn 3iOdQ2J/QMqGUUvWYmzxGzUkIVC3XCPxFZXZJqGfS/Za94CG0AfqX4cajyh56D/qHzTkjI syEsCstnizc7v88A7Eyku4qaOtJXS7o= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-506-C93DQFuuM1CNZa6aJ87opw-1; Tue, 20 Jul 2021 08:54:16 -0400 X-MC-Unique: C93DQFuuM1CNZa6aJ87opw-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1A49010151E0 for ; Tue, 20 Jul 2021 12:54:16 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-114-187.ams2.redhat.com [10.36.114.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DFC3210016F8; Tue, 20 Jul 2021 12:54:15 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 25B95112D856; Tue, 20 Jul 2021 14:54:09 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 16/16] vl: Don't continue after -smp help. Date: Tue, 20 Jul 2021 14:54:08 +0200 Message-Id: <20210720125408.387910-17-armbru@redhat.com> In-Reply-To: <20210720125408.387910-1-armbru@redhat.com> References: <20210720125408.387910-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.474, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" We continue after -smp help: $ qemu-system-x86_64 -smp help -display none -monitor stdio smp-opts options: cores= cpus= dies= maxcpus= sockets= threads= QEMU 6.0.50 monitor - type 'help' for more information (qemu) Other options, such as -object help and -device help, don't. Adjust -smp not to continue either. Cc: Paolo Bonzini Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Pankaj Gupta --- softmmu/vl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index ce0ecc736b..8f9d97635a 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -1543,7 +1543,7 @@ machine_parse_property_opt(QemuOptsList *opts_list, const char *propname, prop = keyval_parse(arg, opts_list->implied_opt_name, &help, &error_fatal); if (help) { qemu_opts_print_help(opts_list, true); - return; + exit(0); } opts = qdict_new(); qdict_put(opts, propname, prop);