Various error handling fixes and cleanups
cover Various error handling fixes and cleanups
I doubt the fixes are 6.1 material at this late stage. If you disagree, let me know.
Markus Armbruster (16):
error: Use error_fatal to simplify obvious fatal errors (again)
spapr: Plug memory leak when we can't add a migration blocker
spapr: Explain purpose of ->fwnmi_migration_blocker more clearly
multi-process: Fix pci_proxy_dev_realize() error handling
vhost-scsi: Plug memory leak on migrate_add_blocker() failure
i386: Never free migration blocker objects instead of sometimes
vfio: Avoid error_propagate() after migrate_add_blocker() whpx nvmm: Drop useless migrate_del_blocker()
migration: Unify failure check for migrate_add_blocker()
migration: Handle migration_incoming_setup() errors consistently
microvm: Drop dead error handling in microvm_machine_state_init()
vhost: Clean up how VhostOpts method vhost_get_config() fails
vhost: Clean up how VhostOpts method vhost_backend_init() fails Remove superfluous ERRP_GUARD()
vl: Clean up -smp error handling
vl: Don't continue after -smp help.
backends/tpm/tpm_emulator.c | 3 +-- hw/display/qxl.c | 8 ++++---- hw/i386/microvm.c | 5 ----- hw/ppc/spapr_events.c | 20 ++++++++++---------- hw/remote/mpqemu-link.c | 3 --- hw/remote/proxy.c | 10 +++++++++- hw/s390x/ipl.c | 6 +----- hw/scsi/vhost-scsi.c | 4 ++-- hw/vfio/migration.c | 6 ++---- hw/virtio/vhost-user.c | 8 ++++++++ hw/virtio/vhost.c | 16 +++------------- migration/migration.c | 34 ++++++++++------------------------ qemu-img.c | 6 +----- qemu-io.c | 6 +----- qemu-nbd.c | 5 +---- qga/commands-posix-ssh.c | 17 ----------------- qga/commands-win32.c | 1 - scsi/qemu-pr-helper.c | 11 +++-------- softmmu/vl.c | 19 +++++++------------ target/i386/kvm/kvm.c | 9 +++------ target/i386/nvmm/nvmm-all.c | 4 +--- target/i386/sev.c | 8 +------- target/i386/whpx/whpx-all.c | 4 +--- ui/console.c | 7 ++----- ui/spice-core.c | 7 +------ 25 files changed, 72 insertions(+), 155 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/16 error: Use error_fatal to simplify obvious fatal errors (again)
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.
--- 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(-)
hw/s390x/ipl.c +1 -5
@@ -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);
migration/migration.c +1 -6
@@ -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 ();
qemu-img.c +1 -5
@@ -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);
qemu-io.c +1 -5
@@ -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 );
qemu-nbd.c +1 -4
@@ -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);
scsi/qemu-pr-helper.c +3 -8
@@ -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
softmmu/vl.c +1 -6
@@ -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 ();
target/i386/sev.c +1 -7
@@ -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
ui/console.c +2 -4
@@ -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);
ui/spice-core.c +1 -6
@@ -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) {
Signature · 1 line
2.31.1
Re: [PATCH 01/16] error: Use error_fatal to simplify obvious fatal errors (again)
Quoted 14 lines · Markus Armbruster
We did this with
scripts/coccinelle/use-error_fatal.coccibefore, in commit50beeb68094and007b06578ab. This commit cleans up rarer variations that don't seem worth matching with Coccinelle.Cc Thomas Huth <[email protected]>Cc Cornelia Huck <[email protected]>Cc Peter Xu <[email protected]>Cc Juan Quintela <[email protected]>Cc Stefan Hajnoczi <[email protected]>Cc Paolo Bonzini <[email protected]>Cc Marc-André Lureau <[email protected]>Cc Gerd Hoffmann <[email protected]>Cc Daniel P. Berrangé <[email protected]>Signed-off-by Markus Armbruster <[email protected]>
Quoted 1 line
---
I agree with your assessment that this is not bug-fix material needed in 6.1.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [PATCH 01/16] error: Use error_fatal to simplify obvious fatal errors (again)
In reply to Markus ArmbrusterQuoted 4 lines · Markus Armbruster
We did this with
scripts/coccinelle/use-error_fatal.coccibefore, in commit50beeb68094and007b06578ab. This commit cleans up rarer variations that don't seem worth matching with Coccinelle.
Quoted 10 lines
Cc Thomas Huth <[email protected]>Cc Cornelia Huck <[email protected]>Cc Peter Xu <[email protected]>Cc Juan Quintela <[email protected]>Cc Stefan Hajnoczi <[email protected]>Cc Paolo Bonzini <[email protected]>Cc Marc-André Lureau <[email protected]>Cc Gerd Hoffmann <[email protected]>Cc Daniel P. Berrangé <[email protected]>Signed-off-by Markus Armbruster <[email protected]>
Signature · 1 line
Peter Xu
Re: [PATCH 01/16] error: Use error_fatal to simplify obvious fatal errors (again)
In reply to Markus ArmbrusterQuoted 32 lines · Markus Armbruster
We did this with
scripts/coccinelle/use-error_fatal.coccibefore, in commit50beeb68094and007b06578ab. This commit cleans up rarer variations that don't seem worth matching with Coccinelle.Cc Thomas Huth <[email protected]>Cc Cornelia Huck <[email protected]>Cc Peter Xu <[email protected]>Cc Juan Quintela <[email protected]>Cc Stefan Hajnoczi <[email protected]>Cc Paolo Bonzini <[email protected]>Cc Marc-André Lureau <[email protected]>Cc Gerd Hoffmann <[email protected]>Cc Daniel P. Berrangé <[email protected]>Signed-off-by Markus Armbruster <[email protected]>--- 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(-)softmmu/vl.c +0
-0
softmmu/vl.c void qmp_x_exit_preconfig(Error **errp) · line 2679
Quoted 7 lines
softmmu/vl.c +0
-4@@ -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 ;
Uh, odd assignment...
softmmu/vl.c void qmp_x_exit_preconfig(Error **errp) · line 2679
Quoted 6 lines
softmmu/vl.c +1
-2-exit (1 ); - } +load_snapshot (loadvm,NULL , false,NULL , &error_fatal); }if (replay_mode !=REPLAY_MODE_NONE ) {replay_vmstate_init ();
Re: [PATCH 01/16] error: Use error_fatal to simplify obvious fatal errors (again)
Quoted 35 lines · Philippe Mathieu-Daudé
Quoted 34 lines · Markus Armbruster
We did this with
scripts/coccinelle/use-error_fatal.coccibefore, in commit50beeb68094and007b06578ab. This commit cleans up rarer variations that don't seem worth matching with Coccinelle.Cc Thomas Huth <[email protected]>Cc Cornelia Huck <[email protected]>Cc Peter Xu <[email protected]>Cc Juan Quintela <[email protected]>Cc Stefan Hajnoczi <[email protected]>Cc Paolo Bonzini <[email protected]>Cc Marc-André Lureau <[email protected]>Cc Gerd Hoffmann <[email protected]>Cc Daniel P. Berrangé <[email protected]>Signed-off-by Markus Armbruster <[email protected]>--- 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(-)softmmu/vl.c +0
-0@@ -2673,12 +2673,7 @@ void qmp_x_exit_preconfig(Error **errp)qemu_machine_creation_done ();
Quoted 7 lines
softmmu/vl.c void qmp_x_exit_preconfig(Error **errp) · line 2679
Quoted 5 lines
softmmu/vl.c +0
-4if (loadvm) { -Error *local_err =NULL ; -if (!load_snapshot (loadvm,NULL , false,NULL , &local_err)) { -error_report_err (local_err); - autostart =0 ;Uh, odd assignment...
Yup.
Commit 05f2401eb2 "make load_vmstate() return errors" added the assignment:
@@ -6030,8 +6030,11 @@ int main(int argc, char **argv, char **envp)
exit(1);
}
- if (loadvm)
- load_vmstate(cur_mon, loadvm);
+ if (loadvm) {
+ if (load_vmstate(cur_mon, loadvm) < 0) {
+ autostart = 0;
+ }
+ }
if (incoming) {
qemu_start_incoming_migration(incoming);
827beacb47 "Add a hint message to loadvm and exits on failure" added the exit(1) without deleting the now useless assignment:
@@ -4530,6 +4530,7 @@ int main(int argc, char **argv, char **envp)
if (load_snapshot(loadvm, &local_err) < 0) {
error_report_err(local_err);
autostart = 0;
+ exit(1);
}
}Quoted 8 lines
softmmu/vl.c void qmp_x_exit_preconfig(Error **errp) · line 2679
Quoted 6 lines
softmmu/vl.c +1
-2-exit (1 ); - } +load_snapshot (loadvm,NULL , false,NULL , &error_fatal); }if (replay_mode !=REPLAY_MODE_NONE ) {replay_vmstate_init ();Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Thanks!
PATCH 2/16 spapr: Plug memory leak when we can't add a migration blocker
In reply to Markus Armbruster--- hw/ppc/spapr_events.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
hw/ppc/spapr_events.c +1 -2
@@ -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.
Signature · 1 line
2.31.1
Re: [PATCH 02/16] spapr: Plug memory leak when we can't add a migration blocker
Quoted 5 lines · Markus Armbruster
Fixes 2500fb423adb17995485de0b4d507cf2f09e3a7fCc Aravinda Prasad <[email protected]>Cc Ganesh Goudar <[email protected]>Cc David Gibson <[email protected]>Signed-off-by Markus Armbruster <[email protected]>
Quoted 25 lines
--- hw/ppc/spapr_events.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)hw/ppc/spapr_events.c +1
-2@@ -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.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [PATCH 02/16] spapr: Plug memory leak when we can't add a migration blocker
In reply to Markus ArmbrusterQuoted 8 lines · Markus Armbruster
Fixes 2500fb423adb17995485de0b4d507cf2f09e3a7fCc Aravinda Prasad <[email protected]>Cc Ganesh Goudar <[email protected]>Cc David Gibson <[email protected]>Signed-off-by Markus Armbruster <[email protected]>--- hw/ppc/spapr_events.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
PATCH 3/16 spapr: Explain purpose of ->fwnmi_migration_blocker more clearly
In reply to Markus Armbrusterspapr_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".
--- hw/ppc/spapr_events.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
hw/ppc/spapr_events.c +9 -8
@@ -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" ); }
Signature · 1 line
2.31.1
Re: [PATCH 03/16] spapr: Explain purpose of ->fwnmi_migration_blocker more clearly
Quoted 10 lines · Markus Armbruster
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".
Quoted 5 lines
Cc David Gibson <[email protected]>Cc Aravinda Prasad <[email protected]>Cc Ganesh Goudar <[email protected]>Cc Dr. David Alan Gilbert <[email protected]>Signed-off-by Markus Armbruster <[email protected]>
Quoted 34 lines
--- hw/ppc/spapr_events.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)hw/ppc/spapr_events.c +9
-8@@ -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" ); }
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
PATCH 4/16 multi-process: Fix pci_proxy_dev_realize() error handling
In reply to Markus ArmbrusterThe 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.
--- hw/remote/proxy.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
hw/remote/proxy.c +9 -1
@@ -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 );
Signature · 1 line
2.31.1
Re: [PATCH 04/16] multi-process: Fix pci_proxy_dev_realize() error handling
Quoted 18 lines · Markus Armbruster
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 toqio_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 9f8112073aad8e485ac012ee18809457ab7f23a6Cc Elena Ufimtseva <[email protected]>Cc Jagannathan Raman <[email protected]>Cc John G Johnson <[email protected]>Cc Stefan Hajnoczi <[email protected]>Signed-off-by Markus Armbruster <[email protected]>
Quoted 3 lines
--- hw/remote/proxy.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
Re: [PATCH 04/16] multi-process: Fix pci_proxy_dev_realize() error handling
In reply to Markus ArmbrusterQuoted 22 lines · Markus Armbruster
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 toqio_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 9f8112073aad8e485ac012ee18809457ab7f23a6Cc Elena Ufimtseva <[email protected]>Cc Jagannathan Raman <[email protected]>Cc John G Johnson <[email protected]>Cc Stefan Hajnoczi <[email protected]>Signed-off-by Markus Armbruster <[email protected]>
Quoted 3 lines
---
hw/remote/proxy.c| 10 +++++++++-1 file changed, 9 insertions(+), 1 deletion(-)
PATCH 5/16 vhost-scsi: Plug memory leak on migrate_add_blocker() failure
In reply to Markus Armbruster--- hw/scsi/vhost-scsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/scsi/vhost-scsi.c +2 -2
@@ -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);
Signature · 1 line
2.31.1
PATCH 6/16 i386: Never free migration blocker objects instead of sometimes
In reply to Markus Armbrusterinvtsc_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.
--- target/i386/kvm/kvm.c | 3 --- 1 file changed, 3 deletions(-)
target/i386/kvm/kvm.c +0 -3
@@ -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; } }
Signature · 1 line
2.31.1
PATCH 7/16 vfio: Avoid error_propagate() after migrate_add_blocker()
In reply to Markus ArmbrusterWhen 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()".
--- hw/vfio/migration.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
hw/vfio/migration.c +2 -4
@@ -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 ; }
Signature · 1 line
2.31.1
Re: [PATCH 07/16] vfio: Avoid error_propagate() after migrate_add_blocker()
Quoted 8 lines · Markus Armbruster
When
migrate_add_blocker(blocker, &errp)is followed byerror_propagate(errp, err), we can often just as well domigrate_add_blocker(..., errp). This is the case invfio_migration_probe().Prior art: commit
386f6c07d2"error: Avoiderror_propagate()aftermigrate_add_blocker()".
Quoted 6 lines
Cc Kirti Wankhede <[email protected]>Cc Alex Williamson <[email protected]>Signed-off-by Markus Armbruster <[email protected]>--- hw/vfio/migration.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
Re: [PATCH 07/16] vfio: Avoid error_propagate() after migrate_add_blocker()
In reply to Markus ArmbrusterQuoted 30 lines · Markus Armbruster
When
migrate_add_blocker(blocker, &errp)is followed byerror_propagate(errp, err), we can often just as well domigrate_add_blocker(..., errp). This is the case invfio_migration_probe().Prior art: commit
386f6c07d2"error: Avoiderror_propagate()aftermigrate_add_blocker()".Cc Kirti Wankhede <[email protected]>Cc Alex Williamson <[email protected]>Signed-off-by Markus Armbruster <[email protected]>--- hw/vfio/migration.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)hw/vfio/migration.c +0
-1@@ -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");
hw/vfio/migration.c add_blocker: · line 891
Quoted 10 lines
hw/vfio/migration.c +2
-3g_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 ; }
Reviewed by: Kirti Wankhede <[email protected]>
Re: [PATCH 07/16] vfio: Avoid error_propagate() after migrate_add_blocker()
In reply to Markus ArmbrusterQuoted 1 line · Markus Armbruster
When
migrate_add_blocker(blocker, &errp)is followed by
Just a nit, &err.
Paolo
Quoted 3 lines
error_propagate(errp, err), we can often just as well domigrate_add_blocker(..., errp). This is the case invfio_migration_probe().
Re: [PATCH 07/16] vfio: Avoid error_propagate() after migrate_add_blocker()
Quoted 4 lines · Paolo Bonzini
Quoted 1 line · Markus Armbruster
When
migrate_add_blocker(blocker, &errp)is followed byJust a nit, &err.
Wll fix, thanks!
Quoted 5 lines
Paolo
Quoted 3 lines
error_propagate(errp, err), we can often just as well domigrate_add_blocker(..., errp). This is the case invfio_migration_probe().
PATCH 8/16 whpx nvmm: Drop useless migrate_del_blocker()
In reply to Markus ArmbrusterThere is nothing to delete after migrate_add_blocker() failed. Trying anyway is safe, but useless. Don't.
--- target/i386/nvmm/nvmm-all.c | 1 - target/i386/whpx/whpx-all.c | 1 - 2 files changed, 2 deletions(-)
target/i386/nvmm/nvmm-all.c +0 -1
@@ -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 ; }
target/i386/whpx/whpx-all.c +0 -1
@@ -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;
Signature · 1 line
2.31.1
Re: [PATCH 08/16] whpx nvmm: Drop useless migrate_del_blocker()
Quoted 17 lines · Markus Armbruster
There is nothing to delete after
migrate_add_blocker()failed. Trying anyway is safe, but useless. Don't.Cc Sunil Muthuswamy <[email protected]>Cc Kamil Rytarowski <[email protected]>Cc Reinoud Zandijk <[email protected]>Signed-off-by Markus Armbruster <[email protected]>--- target/i386/nvmm/nvmm-all.c | 1 - target/i386/whpx/whpx-all.c | 1 - 2 files changed, 2 deletions(-)target/i386/nvmm/nvmm-all.c +0
-0
target/i386/nvmm/nvmm-all.c nvmm_init_vcpu(CPUState *cpu) · line 934
Quoted 7 lines
target/i386/nvmm/nvmm-all.c +0
-1@@ -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 ; }
No problem with it
PATCH 9/16 migration: Unify failure check for migrate_add_blocker()
In reply to Markus ArmbrusterMost 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".
--- 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(-)
backends/tpm/tpm_emulator.c +1 -2
@@ -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 ;
hw/display/qxl.c +4 -4
@@ -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); } } }
hw/virtio/vhost.c +1 -1
@@ -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; }
target/i386/kvm/kvm.c +3 -3
@@ -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; }
target/i386/nvmm/nvmm-all.c +1 -2
@@ -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 ;
target/i386/whpx/whpx-all.c +1 -2
@@ -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 ;
Signature · 1 line
2.31.1
Re: [PATCH 09/16] migration: Unify failure check for migrate_add_blocker()
Quoted 8 lines · Markus Armbruster
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 <[email protected]>
Quoted 8 lines
--- 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(-)
PATCH 10/16 migration: Handle migration_incoming_setup() errors consistently
In reply to Markus ArmbrusterCommit 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.
--- migration/migration.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-)
migration/migration.c +9 -18
@@ -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 ; }
Signature · 1 line
2.31.1
Re: [PATCH 10/16] migration: Handle migration_incoming_setup() errors consistently
Quoted 13 lines · Markus Armbruster
Commit
b673eab4e2"multifd: Makemultifd_load_setup()get an Error parameter" changedmigration_incoming_setup()to take an Error ** argument, and adjusted the callers accordingly. It neglected to change adjustmultifd_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()tordma_accept_incoming_migration(), and viamigration_ioc_process_incoming()tomigration_channel_process_incoming(). Both chain ends report the error witherror_report_err(), but otherwise ignore it. Behavioral
change: we no longerexit()on this error.
Quoted 3 lines
This is consistent with how we handle other errors here, e.g. from
multifd_recv_new_channel()viamigration_ioc_process_incoming()tomigration_channel_process_incoming(). Wether it's consistently right
Whether
Quoted 5 lines
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.
Quoted 7 lines
Cc Juan Quintela <[email protected]>Cc Dr. David Alan Gilbert <[email protected]>Signed-off-by Markus Armbruster <[email protected]>--- migration/migration.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [PATCH 10/16] migration: Handle migration_incoming_setup() errors consistently
Quoted 14 lines · Eric Blake
Quoted 13 lines · Markus Armbruster
Commit
b673eab4e2"multifd: Makemultifd_load_setup()get an Error parameter" changedmigration_incoming_setup()to take an Error ** argument, and adjusted the callers accordingly. It neglected to change adjustmultifd_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()tordma_accept_incoming_migration(), and viamigration_ioc_process_incoming()tomigration_channel_process_incoming(). Both chain ends report the error witherror_report_err(), but otherwise ignore it. Behavioral
change: we no longerexit()on this error.
Quoted 5 lines
Quoted 3 lines
This is consistent with how we handle other errors here, e.g. from
multifd_recv_new_channel()viamigration_ioc_process_incoming()tomigration_channel_process_incoming(). Wether it's consistently rightWhether
ACK
Quoted 13 lines
Quoted 5 lines
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.
Quoted 7 lines
Cc Juan Quintela <[email protected]>Cc Dr. David Alan Gilbert <[email protected]>Signed-off-by Markus Armbruster <[email protected]>--- migration/migration.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-)
Quoted 1 line
Reviewed-by Eric Blake <[email protected]>
Thanks!
Re: [PATCH 10/16] migration: Handle migration_incoming_setup() errors consistently
In reply to Markus ArmbrusterQuoted 87 lines
Commit
b673eab4e2"multifd: Makemultifd_load_setup()get an Error parameter" changedmigration_incoming_setup()to take an Error ** argument, and adjusted the callers accordingly. It neglected to change adjustmultifd_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()tordma_accept_incoming_migration(), and viamigration_ioc_process_incoming()tomigration_channel_process_incoming(). Both chain ends report the error witherror_report_err(), but otherwise ignore it. Behavioral
change: we no longerexit()on this error.This is consistent with how we handle other errors here, e.g. from
multifd_recv_new_channel()viamigration_ioc_process_incoming()tomigration_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 <[email protected]>Cc Dr. David Alan Gilbert <[email protected]>Signed-off-by Markus Armbruster <[email protected]>--- migration/migration.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-)migration/migration.c +8
-16@@ -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 ();
migration/migration.c void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp) · line 701
Quoted 9 lines
migration/migration.c +1
-2@@ -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 ; }
Re: [PATCH 10/16] migration: Handle migration_incoming_setup() errors consistently
In reply to Markus ArmbrusterQuoted 50 lines · * Markus Armbruster ([email protected]) wrote:
Commit
b673eab4e2"multifd: Makemultifd_load_setup()get an Error parameter" changedmigration_incoming_setup()to take an Error ** argument, and adjusted the callers accordingly. It neglected to change adjustmultifd_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()tordma_accept_incoming_migration(), and viamigration_ioc_process_incoming()tomigration_channel_process_incoming(). Both chain ends report the error witherror_report_err(), but otherwise ignore it. Behavioral
change: we no longerexit()on this error.This is consistent with how we handle other errors here, e.g. from
multifd_recv_new_channel()viamigration_ioc_process_incoming()tomigration_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 <[email protected]>Cc Dr. David Alan Gilbert <[email protected]>Signed-off-by Markus Armbruster <[email protected]>--- migration/migration.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-)migration/migration.c +4
-5@@ -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 ();
migration/migration.c fail: · line 624
Quoted 10 lines
migration/migration.c +2
-6-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; }
What I don't know is how well that will survive; for example in multifd_load_setup it creates multiple threads and calls the recv_setup member on each thread; now if one of those fails what happens - if we don't exit, is it cleaned up enough so you can try another migrate_incoming or is it just going to fall over?
Dave
Quoted 39 lines
migration/migration.c +3
-7if (!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 ; }Signature · 1 line
2.31.1
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Re: [PATCH 10/16] migration: Handle migration_incoming_setup() errors consistently
Quoted 53 lines · Dr. David Alan Gilbert
Quoted 52 lines · * Markus Armbruster ([email protected]) wrote:
Commit
b673eab4e2"multifd: Makemultifd_load_setup()get an Error parameter" changedmigration_incoming_setup()to take an Error ** argument, and adjusted the callers accordingly. It neglected to change adjustmultifd_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()tordma_accept_incoming_migration(), and viamigration_ioc_process_incoming()tomigration_channel_process_incoming(). Both chain ends report the error witherror_report_err(), but otherwise ignore it. Behavioral
change: we no longerexit()on this error.This is consistent with how we handle other errors here, e.g. from
multifd_recv_new_channel()viamigration_ioc_process_incoming()tomigration_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 <[email protected]>Cc Dr. David Alan Gilbert <[email protected]>Signed-off-by Markus Armbruster <[email protected]>--- migration/migration.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-)migration/migration.c +4
-6@@ -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 ;
Quoted 14 lines
migration/migration.c fail: · line 624
Quoted 8 lines
migration/migration.c +2
-5-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; }What I don't know is how well that will survive; for example in
multifd_load_setupit creates multiple threads and calls therecv_setupmember on each thread; now if one of those fails what happens - if we don't exit, is it cleaned up enough so you can try anothermigrate_incomingor is it just going to fall over?
I don't know, either.
The inconsistent error handling we have is not good. More consistent error handling that unmasks bad error handling could be worse, unless we fix the unmasked badness.
How can we move forward with this patch?
One way *I* could move forward is to tack a FIXME comment to the problematic exit(1) instead of removing it.
[...]
Re: [PATCH 10/16] migration: Handle migration_incoming_setup() errors consistently
Quoted 76 lines · Markus Armbruster
Quoted 53 lines · Dr. David Alan Gilbert
Quoted 52 lines · * Markus Armbruster ([email protected]) wrote:
Commit
b673eab4e2"multifd: Makemultifd_load_setup()get an Error parameter" changedmigration_incoming_setup()to take an Error ** argument, and adjusted the callers accordingly. It neglected to change adjustmultifd_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()tordma_accept_incoming_migration(), and viamigration_ioc_process_incoming()tomigration_channel_process_incoming(). Both chain ends report the error witherror_report_err(), but otherwise ignore it. Behavioral
change: we no longerexit()on this error.This is consistent with how we handle other errors here, e.g. from
multifd_recv_new_channel()viamigration_ioc_process_incoming()tomigration_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 <[email protected]>Cc Dr. David Alan Gilbert <[email protected]>Signed-off-by Markus Armbruster <[email protected]>--- migration/migration.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-)migration/migration.c +4
-6@@ -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 ;Quoted 14 lines
migration/migration.c fail: · line 624
Quoted 8 lines
migration/migration.c +2
-5-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; }What I don't know is how well that will survive; for example in
multifd_load_setupit creates multiple threads and calls therecv_setupmember on each thread; now if one of those fails what happens - if we don't exit, is it cleaned up enough so you can try anothermigrate_incomingor is it just going to fall over?I don't know, either.
The inconsistent error handling we have is not good. More consistent error handling that unmasks bad error handling could be worse, unless we fix the unmasked badness.
Quoted 6 lines
How can we move forward with this patch?
One way *I* could move forward is to tack a FIXME comment to the problematic exit(1) instead of removing it.
[...]
I forgot this was still undecided, and included the patch in my pull request. It has become commit 7d6f6933aa7. Feel free to revert it, or to ask me to restore the exit() on failure.
PATCH 11/16 microvm: Drop dead error handling in microvm_machine_state_init()
In reply to Markus ArmbrusterStillborn in commit 0ebf007dda "hw/i386: Introduce the microvm machine type".
--- hw/i386/microvm.c | 5 ----- 1 file changed, 5 deletions(-)
hw/i386/microvm.c +0 -5
@@ -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); }
Signature · 1 line
2.31.1
Re: [PATCH 11/16] microvm: Drop dead error handling in microvm_machine_state_init()
Quoted 32 lines · Markus Armbruster
Stillborn in commit
0ebf007dda"hw/i386: Introduce the microvm machine type".Cc Sergio Lopez <[email protected]>Signed-off-by Markus Armbruster <[email protected]>--- hw/i386/microvm.c | 5 ----- 1 file changed, 5 deletions(-)hw/i386/microvm.c +0
-5@@ -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); }Signature · 1 line
2.31.1
Re: [PATCH 11/16] microvm: Drop dead error handling in microvm_machine_state_init()
In reply to Markus ArmbrusterQuoted 8 lines · Markus Armbruster
Stillborn in commit
0ebf007dda"hw/i386: Introduce the microvm machine type".Cc Sergio Lopez <[email protected]>Signed-off-by Markus Armbruster <[email protected]>--- hw/i386/microvm.c | 5 ----- 1 file changed, 5 deletions(-)
Re: [PATCH 11/16] microvm: Drop dead error handling in microvm_machine_state_init()
In reply to Markus ArmbrusterQuoted 30 lines
Stillborn in commit
0ebf007dda"hw/i386: Introduce the microvm machine type".Cc Sergio Lopez <[email protected]>Signed-off-by Markus Armbruster <[email protected]>--- hw/i386/microvm.c | 5 ----- 1 file changed, 5 deletions(-)hw/i386/microvm.c +0
-6@@ -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); } --
Quoted 1 line
2.31.1
PATCH 12/16 vhost: Clean up how VhostOpts method vhost_get_config() fails
In reply to Markus Armbrustervhost_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.
--- hw/virtio/vhost-user.c | 2 ++ hw/virtio/vhost.c | 10 ++-------- 2 files changed, 4 insertions(+), 8 deletions(-)
hw/virtio/vhost-user.c +2 -0
@@ -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 ; }
hw/virtio/vhost.c +2 -8
@@ -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" );
Signature · 1 line
2.31.1
Re: [PATCH 12/16] vhost: Clean up how VhostOpts method vhost_get_config() fails
Quoted 22 lines · Markus Armbruster
vhost_user_get_config()can fail without setting an error. Unclean. Its callervhost_dev_get_config()compensates by substituting a generic error then. Goes back to commit50de51387f"vhost:
Distinguish errors invhost_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 <[email protected]>Cc Michael S. Tsirkin <[email protected]>Signed-off-by Markus Armbruster <[email protected]>--- hw/virtio/vhost-user.c | 2 ++ hw/virtio/vhost.c | 10 ++-------- 2 files changed, 4 insertions(+), 8 deletions(-)hw/virtio/vhost-user.c +0
-0@@ -2139,10 +2139,12 @@ static int vhost_user_get_config(struct vhost_dev *dev, uint8_t *config, msg.payload.config.offset =0 ;
hw/virtio/vhost-user.c static int vhost_user_get_config(struct vhost_dev *dev, uint8_t *config, · line 2149
Quoted 10 lines
hw/virtio/vhost-user.c +2
-0msg.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 ; }
Oops, should be error_setg_errno(EPROTO)!
Re: [PATCH 12/16] vhost: Clean up how VhostOpts method vhost_get_config() fails
Quoted 29 lines · Philippe Mathieu-Daudé
Quoted 28 lines · Markus Armbruster
vhost_user_get_config()can fail without setting an error. Unclean. Its callervhost_dev_get_config()compensates by substituting a generic error then. Goes back to commit50de51387f"vhost:
Distinguish errors invhost_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 <[email protected]>Cc Michael S. Tsirkin <[email protected]>Signed-off-by Markus Armbruster <[email protected]>--- hw/virtio/vhost-user.c | 2 ++ hw/virtio/vhost.c | 10 ++-------- 2 files changed, 4 insertions(+), 8 deletions(-)hw/virtio/vhost-user.c +1
-0@@ -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 ; }
Quoted 6 lines
hw/virtio/vhost-user.c static int vhost_user_get_config(struct vhost_dev *dev, uint8_t *config, · line 2149
Quoted 4 lines
hw/virtio/vhost-user.c +1
-0if (vhost_user_read (dev, &msg) <0 ) { +error_setg_errno (errp, -EPROTO ,"vhost_get_config failed" );return -EPROTO ; }Oops, should be
error_setg_errno(EPROTO)!
D'oh! Thanks!
Re: [PATCH 12/16] vhost: Clean up how VhostOpts method vhost_get_config() fails
In reply to Markus ArmbrusterQuoted 8 lines · Markus Armbruster
vhost_user_get_config()can fail without setting an error. Unclean. Its callervhost_dev_get_config()compensates by substituting a generic error then. Goes back to commit50de51387f"vhost:
Distinguish errors invhost_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.
Quoted 7 lines
Cc Kevin Wolf <[email protected]>Cc Michael S. Tsirkin <[email protected]>Signed-off-by Markus Armbruster <[email protected]>--- hw/virtio/vhost-user.c | 2 ++ hw/virtio/vhost.c | 10 ++-------- 2 files changed, 4 insertions(+), 8 deletions(-)
PATCH 13/16 vhost: Clean up how VhostOpts method vhost_backend_init() fails
In reply to Markus Armbrustervhost_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.
--- hw/virtio/vhost-user.c | 6 ++++++ hw/virtio/vhost.c | 4 ---- 2 files changed, 6 insertions(+), 4 deletions(-)
hw/virtio/vhost-user.c +6 -0
@@ -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 ; } }
hw/virtio/vhost.c +0 -4
@@ -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; }
Signature · 1 line
2.31.1
Re: [PATCH 13/16] vhost: Clean up how VhostOpts method vhost_backend_init() fails
Quoted 8 lines · Markus Armbruster
vhost_user_backend_init()can fail without setting an error. Unclean. Its callervhost_dev_init()compensates by substituting a generic error then. Goes back to commit28770ff935"vhost: Distinguish errors invhost_backend_init()".Clean up by moving the generic error from
vhost_dev_init()to all the failure paths that neglect to set an error.
Quoted 7 lines
Cc Kevin Wolf <[email protected]>Cc Michael S. Tsirkin <[email protected]>Signed-off-by Markus Armbruster <[email protected]>--- hw/virtio/vhost-user.c | 6 ++++++ hw/virtio/vhost.c | 4 ---- 2 files changed, 6 insertions(+), 4 deletions(-)
PATCH 14/16 Remove superfluous ERRP_GUARD()
In reply to Markus ArmbrusterMacro ERRP_GUARD() is only needed when we want to dereference @errp or pass it to error_prepend() or error_append_hint(). Delete superfluous ones.
--- 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(-)
hw/remote/mpqemu-link.c +0 -3
@@ -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 ;
qga/commands-posix-ssh.c +0 -17
@@ -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 ;
qga/commands-win32.c +0 -1
@@ -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;
softmmu/vl.c +0 -1
@@ -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) {
ui/console.c +0 -1
@@ -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 ;
Signature · 1 line
2.31.1
Re: [PATCH 14/16] Remove superfluous ERRP_GUARD()
Cc'ing Marc-André as he recently disagreed with this.
Quoted 162 lines · Markus Armbruster
Macro
ERRP_GUARD()is only needed when we want to dereference @errp or pass it toerror_prepend()orerror_append_hint(). Delete superfluous ones.Signed-off-by Markus Armbruster <[email protected]>--- 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(-)hw/remote/mpqemu-link.c +0
-3@@ -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 ;qga/commands-posix-ssh.c +0
-17@@ -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 ;qga/commands-win32.c +0
-1@@ -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;softmmu/vl.c +0
-1@@ -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) {ui/console.c +0
-1@@ -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 ;
PATCH 15/16 vl: Clean up -smp error handling
In reply to Markus ArmbrusterThe 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.
--- softmmu/vl.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
softmmu/vl.c +5 -4
@@ -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);
Signature · 1 line
2.31.1
Re: [PATCH 15/16] vl: Clean up -smp error handling
Quoted 10 lines · Markus Armbruster
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 tokeyval_parse()without checking for failure, then passes it tokeyval_merge(). Harmless, since the only caller passes&error_fatal.
Quoted 7 lines
Clean up: drop the parameter, and use
&error_fataldirectly.Cc Paolo Bonzini <[email protected]>Signed-off-by Markus Armbruster <[email protected]>--- softmmu/vl.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
PATCH 16/16 vl: Don't continue after -smp help.
In reply to Markus ArmbrusterWe continue after -smp help:
$ qemu-system-x86_64 -smp help -display none -monitor stdio
smp-opts options:
cores=<num>
cpus=<num>
dies=<num>
maxcpus=<num>
sockets=<num>
threads=<num>
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.
--- softmmu/vl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
softmmu/vl.c +1 -1
@@ -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);
Signature · 1 line
2.31.1
Re: [PATCH-for-6.1? 16/16] vl: Don't continue after -smp help.
Quoted 29 lines · Markus Armbruster
We continue after -smp help:
$ qemu-system-x86_64 -smp help -display none -monitor stdio smp-opts options: cores=<num> cpus=<num> dies=<num> maxcpus=<num> sockets=<num> threads=<num> 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 <[email protected]>Signed-off-by Markus Armbruster <[email protected]>--- softmmu/vl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)softmmu/vl.c +0
-0
softmmu/vl.c machine_parse_property_opt(QemuOptsList *opts_list, const char *propname, · line 1549
Quoted 8 lines
softmmu/vl.c +1
-1@@ -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);
Easy one for 6.1.
Re: [PATCH 16/16] vl: Don't continue after -smp help.
In reply to Markus ArmbrusterQuoted 28 lines
We continue after -smp help:
$ qemu-system-x86_64 -smp help -display none -monitor stdio smp-opts options: cores=<num> cpus=<num> dies=<num> maxcpus=<num> sockets=<num> threads=<num> 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 <[email protected]>Signed-off-by Markus Armbruster <[email protected]>--- softmmu/vl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)softmmu/vl.c +0
-0
softmmu/vl.c machine_parse_property_opt(QemuOptsList *opts_list, const char *propname,
Quoted 9 lines
softmmu/vl.c +1
-2@@ -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); --
Quoted 21 lines · Markus Armbruster
I doubt the fixes are 6.1 material at this late stage. If you disagree, let me know.
Cc Alex Williamson <[email protected]>Cc Aravinda Prasad <[email protected]>Cc Cornelia Huck <[email protected]>Cc Daniel P. Berrangé <[email protected]>Cc David Gibson <[email protected]>Cc Dr. David Alan Gilbert <[email protected]>Cc Eduardo Habkost <[email protected]>Cc Elena Ufimtseva <[email protected]>Cc Ganesh Goudar <[email protected]>Cc Gerd Hoffmann <[email protected]>Cc Jagannathan Raman <[email protected]>Cc John G Johnson <[email protected]>Cc Juan Quintela <[email protected]>Cc Kamil Rytarowski <[email protected]>Cc Kevin Wolf <[email protected]>Cc Kirti Wankhede <[email protected]>Cc Marc-André Lureau <[email protected]>Cc Marcelo Tosatti <[email protected]>
Quoted 8 lines
Cc Michael S. Tsirkin <[email protected]>Cc Paolo Bonzini <[email protected]>Cc Peter Xu <[email protected]>Cc Reinoud Zandijk <[email protected]>Cc Sergio Lopez <[email protected]>Cc Stefan Hajnoczi <[email protected]>Cc Sunil Muthuswamy <[email protected]>Cc Thomas Huth <[email protected]>
agree it's not 6.1 material
Quoted 47 lines
Markus Armbruster (16):
error: Useerror_fatalto simplify obvious fatal errors (again)
spapr: Plug memory leak when we can't add a migration blocker
spapr: Explain purpose of ->fwnmi_migration_blocker more clearly
multi-process: Fixpci_proxy_dev_realize()error handling
vhost-scsi: Plug memory leak onmigrate_add_blocker()failure
i386: Never free migration blocker objects instead of sometimes
vfio: Avoiderror_propagate()aftermigrate_add_blocker()whpx nvmm: Drop uselessmigrate_del_blocker()
migration: Unify failure check formigrate_add_blocker()
migration: Handlemigration_incoming_setup()errors consistently
microvm: Drop dead error handling inmicrovm_machine_state_init()
vhost: Clean up how VhostOpts methodvhost_get_config()fails
vhost: Clean up how VhostOpts methodvhost_backend_init()fails Remove superfluousERRP_GUARD()
vl: Clean up -smp error handling
vl: Don't continue after -smp help.backends/tpm/tpm_emulator.c | 3 +-- hw/display/qxl.c | 8 ++++---- hw/i386/microvm.c | 5 ----- hw/ppc/spapr_events.c | 20 ++++++++++---------- hw/remote/mpqemu-link.c | 3 --- hw/remote/proxy.c | 10 +++++++++- hw/s390x/ipl.c | 6 +----- hw/scsi/vhost-scsi.c | 4 ++-- hw/vfio/migration.c | 6 ++---- hw/virtio/vhost-user.c | 8 ++++++++ hw/virtio/vhost.c | 16 +++------------- migration/migration.c | 34 ++++++++++------------------------ qemu-img.c | 6 +----- qemu-io.c | 6 +----- qemu-nbd.c | 5 +---- qga/commands-posix-ssh.c | 17 ----------------- qga/commands-win32.c | 1 - scsi/qemu-pr-helper.c | 11 +++-------- softmmu/vl.c | 19 +++++++------------ target/i386/kvm/kvm.c | 9 +++------ target/i386/nvmm/nvmm-all.c | 4 +--- target/i386/sev.c | 8 +------- target/i386/whpx/whpx-all.c | 4 +--- ui/console.c | 7 ++----- ui/spice-core.c | 7 +------ 25 files changed, 72 insertions(+), 155 deletions(-)Signature · 1 line
2.31.1
Quoted 2 lines · Markus Armbruster
I doubt the fixes are 6.1 material at this late stage. If you disagree, let me know.
PATCH 16 has become commit 3e61a13af3. Remainder queued for 6.2; additional review is welcome all the same.
Thanks, guys!