Skip to contentSkip to conversation

Error reporting patches for 2019-12-16

GIT PULL Markus Armbruster 3 participants 40 messages Dec 17, 2019 – Dec 18, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

The following changes since commit cb88904a54903ef6ba21a68a61d9cd51e2166304:

Merge remote-tracking branch 'remotes/amarkovic/tags/mips-queue-dec-16-2019' into staging (2019-12-16 14:07:56 +0000)

are available in the Git repository at:

git://repo.or.cz/qemu/armbru.git tags/pull-error-2019-12-16

for you to fetch changes up to 0e7f83bab6559775cd71e418b12a49145e59faa7:

nbd: assert that Error** is not NULL in nbd_iter_channel_error (2019-12-16 20:50:16 +0100)

----------------------------------------------------------------
Error reporting patches for 2019-12-16

----------------------------------------------------------------
Markus Armbruster (14):
error: Fix -msg timestamp default
crypto: Fix certificate file error handling crash bug
crypto: Fix typo in QCryptoTLSSession's <example> comment
io: Fix Error usage in a comment <example>
tests: Clean up initialization of Error *err variables
exec: Fix file_ram_alloc() error API violations hw/acpi: Fix legacy CPU plug error API violations hw/core: Fix fit_load_fdt() error API violations hw/ipmi: Fix realize() error API violations
qga: Fix guest-get-fsinfo error API violations
memory-device: Fix memory pre-plug error API violations
error: Clean up unusual names of Error * variables hw/intc/s390: Simplify error handling in kvm_s390_flic_realize()
tests-blockjob: Use error_free_or_abort()

Vladimir Sementsov-Ogievskiy (20):
net/net: Clean up variable shadowing in net_client_init()
error: make Error **errp const where it is appropriate
hmp: drop Error pointer indirection in hmp_handle_error
vnc: drop Error pointer indirection in vnc_client_io_error
qdev-monitor: make Error **errp const where it is appropriate
ppc: make Error **errp const where it is appropriate 9pfs: make Error **errp const where it is appropriate hw/core/qdev: cleanup Error ** variables
block/snapshot: rename Error ** parameter to more common errp hw/i386/amd_iommu: rename Error ** parameter to more common errp
qga: rename Error ** parameter to more common errp monitor/qmp-cmds: rename Error ** parameter to more common errp hw/s390x: rename Error ** parameter to more common errp hw/sd: drop extra whitespace in sdhci_sysbus_realize() header hw/tpm: rename Error ** parameter to more common errp hw/usb: rename Error ** parameter to more common errp include/qom/object.h: rename Error ** parameter to more common errp backends/cryptodev: drop local_err from cryptodev_backend_complete() hw/vfio/ap: drop local_err from vfio_ap_realize
nbd: assert that Error** is not NULL in nbd_iter_channel_error

 include/block/snapshot.h            |   2 +-
 include/crypto/tlssession.h         |   2 +-
 include/io/task.h                   |   2 +-
 include/monitor/hmp.h               |   2 +-
 include/qapi/error.h                |   6 +-
 include/qemu/error-report.h         |   3 +-
 include/qom/object.h                |   4 +-
 target/ppc/kvm_ppc.h                |   4 +-
 ui/vnc.h                            |   2 +-
 backends/cryptodev.c                |  11 +--
 block/nbd.c                         |   1 +
 block/snapshot.c                    |   4 +-
 crypto/tlscredsx509.c               |   2 +-
 dump/dump-hmp-cmds.c                |   4 +-
 exec.c                              |   6 +-
 hw/9pfs/9p-local.c                  |   2 +-
 hw/9pfs/9p-proxy.c                  |   2 +-
 hw/acpi/cpu_hotplug.c               |  10 +--
 hw/core/loader-fit.c                |  15 ++--
 hw/core/machine-hmp-cmds.c          |   6 +-
 hw/core/qdev.c                      |  28 +++----
 hw/i386/amd_iommu.c                 |  14 ++--
 hw/intc/s390_flic_kvm.c             |  16 ++--
 hw/ipmi/isa_ipmi_bt.c               |   7 +-
 hw/ipmi/isa_ipmi_kcs.c              |   7 +-
 hw/ipmi/pci_ipmi_bt.c               |   6 +-
 hw/ipmi/pci_ipmi_kcs.c              |   6 +-
 hw/mem/memory-device.c              |   6 +-
 hw/ppc/spapr.c                      |   2 +-
 hw/ppc/spapr_pci.c                  |  16 ++--
 hw/ppc/spapr_pci_nvlink2.c          |  10 +--
 hw/s390x/event-facility.c           |   2 +-
 hw/s390x/s390-stattrib.c            |   3 +-
 hw/sd/sdhci.c                       |   2 +-
 hw/tpm/tpm_emulator.c               |   8 +-
 hw/usb/dev-network.c                |   2 +-
 hw/vfio/ap.c                        |   9 +--
 monitor/hmp-cmds.c                  | 155 ++++++++++++++++++------------------
 monitor/qmp-cmds.c                  |   2 +-
 net/net.c                           |  17 ++--
 qdev-monitor.c                      |  16 ++--
 qga/commands-posix.c                |   8 +-
 qga/commands-win32.c                |   2 +-
 qga/commands.c                      |  12 +--
 qom/qom-hmp-cmds.c                  |   4 +-
 target/ppc/kvm.c                    |   2 +-
 tests/test-blockjob.c               |  15 ++--
 tests/test-qobject-output-visitor.c |   8 +-
 tests/test-string-output-visitor.c  |   4 +-
 ui/vnc.c                            |  20 ++---
 util/error.c                        |   6 +-
 util/qemu-error.c                   |   6 +-
 vl.c                                |   2 +-
 qemu-options.hx                     |  10 ++-
 54 files changed, 260 insertions(+), 263 deletions(-)
Signature · 1 line
2.21.0
#1 lore raw

[PULL 14/34] tests-blockjob: Use error_free_or_abort()

Message-Id: <[email protected]>

---
 tests/test-blockjob.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tests/test-blockjob.c +1 -2
index e670a20617..4eeb184caf 100644
@@ -48,9 +48,8 @@ static BlockJob *mk_job(BlockBackend *blk, const char *id,
             g_assert_cmpstr(job->job.id, ==, blk_name(blk));
         }
     } else {
-        g_assert_nonnull(err);
+        error_free_or_abort(&err);
         g_assert_null(job);
-        error_free(err);
     }
 
     return job;
Signature · 1 line
2.21.0
#2 lore raw

[PULL 04/34] io: Fix Error usage in a comment <example>

In reply to Markus Armbruster
Cc "Daniel P. Berrangé" <[email protected]>

Message-Id: <[email protected]>

---
 include/io/task.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/io/task.h +1 -1
index 5cb9faf9f2..1abbfb8b65 100644
@@ -119,7 +119,7 @@ typedef void (*QIOTaskWorker)(QIOTask *task,
  *   gboolean myobject_operation_timer(gpointer opaque)
  *   {
  *      QIOTask *task = QIO_TASK(opaque);
- *      Error *err;*
+ *      Error *err = NULL;
  *
  *      ...check something important...
  *       if (err) {
Signature · 1 line
2.21.0
#3 lore raw

[PULL 01/34] error: Fix -msg timestamp default

In reply to Markus Armbruster

-msg parameter "timestamp" defaults to "off" if you don't specify msg, and to "on" if you do. Messed up right in commit 5e2ac51917 "add timestamp to error_report()". Mostly harmless, because "timestamp" is the only parameter, so "if you do" is "-msg ''", which nobody does.

Change the default to "off" no matter what.

While there, rename enable_timestamp_msg to error_with_timestamp, and polish documentation.

Message-Id: <[email protected]>

---
 include/qemu/error-report.h |  3 ++-
 util/qemu-error.c           |  6 ++++--
 vl.c                        |  2 +-
 qemu-options.hx             | 10 +++++++---
 4 files changed, 14 insertions(+), 7 deletions(-)
include/qemu/error-report.h +2 -1
index 00d069b20f..87532d8596 100644
@@ -73,6 +73,7 @@ void error_init(const char *argv0);
     })
 
 const char *error_get_progname(void);
-extern bool enable_timestamp_msg;
+
+extern bool error_with_timestamp;
 
 #endif
util/qemu-error.c +4 -2
index f373f3b3b0..dac7c7dc50 100644
@@ -24,6 +24,9 @@ typedef enum {
     REPORT_TYPE_INFO,
 } report_type;
 
+/* Prepend timestamp to messages */
+bool error_with_timestamp;
+
 int error_printf(const char *fmt, ...)
 {
     va_list ap;
@@ -191,7 +194,6 @@ static void print_loc(void)
     }
 }
 
-bool enable_timestamp_msg;
 /*
  * Print a message to current monitor if we have one, else to stderr.
  * @report_type is the type of message: error, warning or informational.
@@ -204,7 +206,7 @@ static void vreport(report_type type, const char *fmt, va_list ap)
     GTimeVal tv;
     gchar *timestr;
 
-    if (enable_timestamp_msg && !cur_mon) {
+    if (error_with_timestamp && !cur_mon) {
         g_get_current_time(&tv);
         timestr = g_time_val_to_iso8601(&tv);
         error_printf("%s ", timestr);
vl.c +1 -1
index c0904b365b..7ed92db055 100644
@@ -1263,7 +1263,7 @@ static void realtime_init(void)
 
 static void configure_msg(QemuOpts *opts)
 {
-    enable_timestamp_msg = qemu_opt_get_bool(opts, "timestamp", true);
+    error_with_timestamp = qemu_opt_get_bool(opts, "timestamp", false);
 }
 
 
qemu-options.hx +7 -3
index 3ff8c4e07a..c9bcd66e98 100644
@@ -4246,13 +4246,17 @@ DEF("no-kvm", 0, QEMU_OPTION_no_kvm, "", QEMU_ARCH_I386)
 
 DEF("msg", HAS_ARG, QEMU_OPTION_msg,
     "-msg timestamp[=on|off]\n"
-    "                change the format of messages\n"
-    "                on|off controls leading timestamps (default:on)\n",
+    "                control error message format\n"
+    "                timestamp=on enables timestamps (default: off)\n",
     QEMU_ARCH_ALL)
 STEXI
 @item -msg timestamp[=on|off]
 @findex -msg
-prepend a timestamp to each log message.(default:on)
+Control error message format.
+@table @option
+@item timestamp=on|off
+Prefix messages with a timestamp.  Default is off.
+@end table
 ETEXI
 
 DEF("dump-vmstate", HAS_ARG, QEMU_OPTION_dump_vmstate,
Signature · 1 line
2.21.0
#4 lore raw

[PULL 02/34] crypto: Fix certificate file error handling crash bug

In reply to Markus Armbruster

qcrypto_tls_creds_load_cert() passes uninitialized GError *gerr by reference to g_file_get_contents(). When g_file_get_contents() fails, it'll try to set a GError. Unless @gerr is null by dumb luck, this logs a ERROR_OVERWRITTEN_WARNING warning message and leaves @gerr unchanged. qcrypto_tls_creds_load_cert() then dereferences the uninitialized @gerr.

Fix by initializing @gerr properly.

Fixes 9a2fd4347c40321f5cbb4ab4220e759fcbf87d03
Cc "Daniel P. Berrangé" <[email protected]>

Message-Id: <[email protected]>

---
 crypto/tlscredsx509.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
crypto/tlscredsx509.c +1 -1
index 01fc304e5d..53a4368f49 100644
@@ -380,7 +380,7 @@ qcrypto_tls_creds_load_cert(QCryptoTLSCredsX509 *creds,
     gnutls_x509_crt_t cert = NULL;
     g_autofree char *buf = NULL;
     gsize buflen;
-    GError *gerr;
+    GError *gerr = NULL;
     int ret = -1;
     int err;
 
Signature · 1 line
2.21.0
#5 lore raw

[PULL 05/34] tests: Clean up initialization of Error *err variables

In reply to Markus Armbruster

Declaring a local Error *err without initializer looks suspicious. Fuse the declaration with the initialization to avoid that.

Message-Id: <[email protected]>

---
 tests/test-qobject-output-visitor.c | 8 ++++----
 tests/test-string-output-visitor.c  | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)
tests/test-qobject-output-visitor.c +4 -4
index 3e993e5ba8..d7761ebf84 100644
@@ -145,10 +145,10 @@ static void test_visitor_out_enum_errors(TestOutputVisitorData *data,
                                          const void *unused)
 {
     EnumOne i, bad_values[] = { ENUM_ONE__MAX, -1 };
-    Error *err;
 
     for (i = 0; i < ARRAY_SIZE(bad_values) ; i++) {
-        err = NULL;
+        Error *err = NULL;
+
         visit_type_EnumOne(data->ov, "unused", &bad_values[i], &err);
         error_free_or_abort(&err);
         visitor_reset(data);
@@ -240,11 +240,11 @@ static void test_visitor_out_struct_errors(TestOutputVisitorData *data,
     EnumOne bad_values[] = { ENUM_ONE__MAX, -1 };
     UserDefOne u = {0};
     UserDefOne *pu = &u;
-    Error *err;
     int i;
 
     for (i = 0; i < ARRAY_SIZE(bad_values) ; i++) {
-        err = NULL;
+        Error *err = NULL;
+
         u.has_enum1 = true;
         u.enum1 = bad_values[i];
         visit_type_UserDefOne(data->ov, "unused", &pu, &err);
tests/test-string-output-visitor.c +2 -2
index 02766c0f65..1be1540767 100644
@@ -207,10 +207,10 @@ static void test_visitor_out_enum_errors(TestOutputVisitorData *data,
                                          const void *unused)
 {
     EnumOne i, bad_values[] = { ENUM_ONE__MAX, -1 };
-    Error *err;
 
     for (i = 0; i < ARRAY_SIZE(bad_values) ; i++) {
-        err = NULL;
+        Error *err = NULL;
+
         visit_type_EnumOne(data->ov, "unused", &bad_values[i], &err);
         error_free_or_abort(&err);
     }
Signature · 1 line
2.21.0
#6 lore raw

[PULL 13/34] hw/intc/s390: Simplify error handling in kvm_s390_flic_realize()

In reply to Markus Armbruster

Message-Id: <[email protected]>

---
 hw/intc/s390_flic_kvm.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
hw/intc/s390_flic_kvm.c +4 -6
index 30d50c2369..dddd33ea61 100644
@@ -586,16 +586,17 @@ static void kvm_s390_flic_realize(DeviceState *dev, Error **errp)
 
     KVM_S390_FLIC_GET_CLASS(dev)->parent_realize(dev, &err);
     if (err) {
-        goto fail;
+        error_propagate(errp, err);
+        return;
     }
     flic_state->fd = -1;
 
     cd.type = KVM_DEV_TYPE_FLIC;
     ret = kvm_vm_ioctl(kvm_state, KVM_CREATE_DEVICE, &cd);
     if (ret < 0) {
-        error_setg_errno(&err, errno, "Creating the KVM device failed");
+        error_setg_errno(errp, errno, "Creating the KVM device failed");
         trace_flic_create_device(errno);
-        goto fail;
+        return;
     }
     flic_state->fd = cd.fd;
 
@@ -603,9 +604,6 @@ static void kvm_s390_flic_realize(DeviceState *dev, Error **errp)
     test_attr.group = KVM_DEV_FLIC_CLEAR_IO_IRQ;
     flic_state->clear_io_supported = !ioctl(flic_state->fd,
                                             KVM_HAS_DEVICE_ATTR, test_attr);
-    return;
-fail:
-    error_propagate(errp, err);
 }
 
 static void kvm_s390_flic_reset(DeviceState *dev)
Signature · 1 line
2.21.0
#7 lore raw

[PULL 03/34] crypto: Fix typo in QCryptoTLSSession's <example> comment

In reply to Markus Armbruster
Cc "Daniel P. Berrangé" <[email protected]>

Message-Id: <[email protected]>

---
 include/crypto/tlssession.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/crypto/tlssession.h +1 -1
index e01e1a9dc2..15b9cef086 100644
@@ -56,7 +56,7 @@
  *
  * static int mysock_run_tls(int sockfd,
  *                           QCryptoTLSCreds *creds,
- *                           Error *errp)
+ *                           Error **errp)
  * {
  *    QCryptoTLSSession *sess;
  *
Signature · 1 line
2.21.0
#8 lore raw

[PULL 08/34] hw/core: Fix fit_load_fdt() error API violations

In reply to Markus Armbruster

fit_load_fdt() passes @errp to fit_image_addr(), then recovers from ENOENT failures. Passing @errp is wrong, because it works only as long as @errp is neither @error_fatal nor @error_abort. Error recovery dereferences @errp. That's also wrong; see the big comment in error.h. Error recovery can leave *errp pointing to a freed Error object. Wrong, it must be null on success. Messed up in commit 3eb99edb48 "loader-fit: Wean off error_printf()".

No caller actually passes such values, or uses *errp on success.

Fix anyway: splice in a local Error *err, and error_propagate().

Message-Id: <[email protected]>

---
 hw/core/loader-fit.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
hw/core/loader-fit.c +8 -7
index 953b16bc82..c465921b8f 100644
@@ -178,11 +178,12 @@ static int fit_load_fdt(const struct fit_loader *ldr, const void *itb,
                         int cfg, void *opaque, const void *match_data,
                         hwaddr kernel_end, Error **errp)
 {
+    Error *err = NULL;
     const char *name;
     const void *data;
     const void *load_data;
     hwaddr load_addr;
-    int img_off, err;
+    int img_off;
     size_t sz;
     int ret;
 
@@ -197,13 +198,13 @@ static int fit_load_fdt(const struct fit_loader *ldr, const void *itb,
         return -EINVAL;
     }
 
-    err = fit_image_addr(itb, img_off, "load", &load_addr, errp);
-    if (err == -ENOENT) {
+    ret = fit_image_addr(itb, img_off, "load", &load_addr, &err);
+    if (ret == -ENOENT) {
         load_addr = ROUND_UP(kernel_end, 64 * KiB) + (10 * MiB);
-        error_free(*errp);
-    } else if (err) {
-        error_prepend(errp, "unable to read FDT load address from FIT: ");
-        ret = err;
+        error_free(err);
+    } else if (ret) {
+        error_propagate_prepend(errp, err,
+                                "unable to read FDT load address from FIT: ");
         goto out;
     }
 
Signature · 1 line
2.21.0
#9 lore raw

[PULL 19/34] qdev-monitor: make Error **errp const where it is appropriate

In reply to Markus Armbruster

From: Vladimir Sementsov-Ogievskiy <[email protected]>

Mostly, Error ** is for returning error from the function, so the callee sets it. However qbus_list_bus and qbus_list_dev get already filled errp parameter. They don't change the pointer itself, only change the internal state of referenced Error object. So we can make it Error *const * errp, to stress the behavior. It will also help coccinelle script (in future) to distinguish such cases from common errp usage.

While there, rename the functions to qbus_error_append_bus_list_hint(), qbus_error_append_dev_list_hint().

Message-Id: <[email protected]>

[Commit message replaced]
---
 qdev-monitor.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
qdev-monitor.c +7 -5
index 29ed73e56a..3465a1e2d0 100644
@@ -328,7 +328,8 @@ static Object *qdev_get_peripheral_anon(void)
     return dev;
 }
 
-static void qbus_list_bus(DeviceState *dev, Error **errp)
+static void qbus_error_append_bus_list_hint(DeviceState *dev,
+                                            Error *const *errp)
 {
     BusState *child;
     const char *sep = " ";
@@ -342,7 +343,8 @@ static void qbus_list_bus(DeviceState *dev, Error **errp)
     error_append_hint(errp, "\n");
 }
 
-static void qbus_list_dev(BusState *bus, Error **errp)
+static void qbus_error_append_dev_list_hint(BusState *bus,
+                                            Error *const *errp)
 {
     BusChild *kid;
     const char *sep = " ";
@@ -500,7 +502,7 @@ static BusState *qbus_find(const char *path, Error **errp)
         if (!dev) {
             error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
                       "Device '%s' not found", elem);
-            qbus_list_dev(bus, errp);
+            qbus_error_append_dev_list_hint(bus, errp);
             return NULL;
         }
 
@@ -518,7 +520,7 @@ static BusState *qbus_find(const char *path, Error **errp)
             if (dev->num_child_bus) {
                 error_setg(errp, "Device '%s' has multiple child buses",
                            elem);
-                qbus_list_bus(dev, errp);
+                qbus_error_append_bus_list_hint(dev, errp);
             } else {
                 error_setg(errp, "Device '%s' has no child bus", elem);
             }
@@ -534,7 +536,7 @@ static BusState *qbus_find(const char *path, Error **errp)
         bus = qbus_find_bus(dev, elem);
         if (!bus) {
             error_setg(errp, "Bus '%s' not found", elem);
-            qbus_list_bus(dev, errp);
+            qbus_error_append_bus_list_hint(dev, errp);
             return NULL;
         }
     }
Signature · 1 line
2.21.0
#10 lore raw

[PULL 33/34] hw/vfio/ap: drop local_err from vfio_ap_realize

In reply to Markus Armbruster

From: Vladimir Sementsov-Ogievskiy <[email protected]>

No reason for local_err here, use errp directly instead.

Message-Id: <[email protected]>

---
 hw/vfio/ap.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
hw/vfio/ap.c +3 -6
index da6a20669d..8fbaa724c2 100644
@@ -89,14 +89,13 @@ static void vfio_ap_realize(DeviceState *dev, Error **errp)
 {
     int ret;
     char *mdevid;
-    Error *local_err = NULL;
     VFIOGroup *vfio_group;
     APDevice *apdev = AP_DEVICE(dev);
     VFIOAPDevice *vapdev = VFIO_AP_DEVICE(apdev);
 
-    vfio_group = vfio_ap_get_group(vapdev, &local_err);
+    vfio_group = vfio_ap_get_group(vapdev, errp);
     if (!vfio_group) {
-        goto out_err;
+        return;
     }
 
     vapdev->vdev.ops = &vfio_ap_ops;
@@ -113,7 +112,7 @@ static void vfio_ap_realize(DeviceState *dev, Error **errp)
      */
     vapdev->vdev.balloon_allowed = true;
 
-    ret = vfio_get_device(vfio_group, mdevid, &vapdev->vdev, &local_err);
+    ret = vfio_get_device(vfio_group, mdevid, &vapdev->vdev, errp);
     if (ret) {
         goto out_get_dev_err;
     }
@@ -123,8 +122,6 @@ static void vfio_ap_realize(DeviceState *dev, Error **errp)
 out_get_dev_err:
     vfio_ap_put_device(vapdev);
     vfio_put_group(vfio_group);
-out_err:
-    error_propagate(errp, local_err);
 }
 
 static void vfio_ap_unrealize(DeviceState *dev, Error **errp)
Signature · 1 line
2.21.0
#11 lore raw

[PULL 11/34] memory-device: Fix memory pre-plug error API violations

In reply to Markus Armbruster

memory_device_get_free_addr() dereferences @errp when memory_device_check_addable() fails. That's wrong; see the big comment in error.h. Introduced in commit 1b6d6af21b "pc-dimm: factor out capacity and slot checks into MemoryDevice".

No caller actually passes null.

Fix anyway: splice in a local Error *err, and error_propagate().

Message-Id: <[email protected]>

---
 hw/mem/memory-device.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
hw/mem/memory-device.c +4 -2
index aef148c1d7..4bc9cf0917 100644
@@ -99,6 +99,7 @@ static uint64_t memory_device_get_free_addr(MachineState *ms,
                                             uint64_t align, uint64_t size,
                                             Error **errp)
 {
+    Error *err = NULL;
     GSList *list = NULL, *item;
     Range as, new = range_empty;
 
@@ -123,8 +124,9 @@ static uint64_t memory_device_get_free_addr(MachineState *ms,
         return 0;
     }
 
-    memory_device_check_addable(ms, size, errp);
-    if (*errp) {
+    memory_device_check_addable(ms, size, &err);
+    if (err) {
+        error_propagate(errp, err);
         return 0;
     }
 
Signature · 1 line
2.21.0
#12 lore raw

[PULL 18/34] vnc: drop Error pointer indirection in vnc_client_io_error

In reply to Markus Armbruster

From: Vladimir Sementsov-Ogievskiy <[email protected]>

We don't need Error **, as all callers pass local Error object, which isn't used after the call, or NULL. Use Error * instead.

Message-Id: <[email protected]>

---
 ui/vnc.h |  2 +-
 ui/vnc.c | 20 +++++++-------------
 2 files changed, 8 insertions(+), 14 deletions(-)
ui/vnc.h +1 -1
index fea79c2fc9..4e2637ce6c 100644
@@ -547,7 +547,7 @@ uint32_t read_u32(uint8_t *data, size_t offset);
 
 /* Protocol stage functions */
 void vnc_client_error(VncState *vs);
-size_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp);
+size_t vnc_client_io_error(VncState *vs, ssize_t ret, Error *err);
 
 void start_client_init(VncState *vs);
 void start_auth_vnc(VncState *vs);
ui/vnc.c +7 -13
index 87b8045afe..4100d6e404 100644
@@ -1312,7 +1312,7 @@ void vnc_disconnect_finish(VncState *vs)
     g_free(vs);
 }
 
-size_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp)
+size_t vnc_client_io_error(VncState *vs, ssize_t ret, Error *err)
 {
     if (ret <= 0) {
         if (ret == 0) {
@@ -1320,15 +1320,11 @@ size_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp)
             vnc_disconnect_start(vs);
         } else if (ret != QIO_CHANNEL_ERR_BLOCK) {
             trace_vnc_client_io_error(vs, vs->ioc,
-                                      errp ? error_get_pretty(*errp) :
-                                      "Unknown");
+                                      err ? error_get_pretty(err) : "Unknown");
             vnc_disconnect_start(vs);
         }
 
-        if (errp) {
-            error_free(*errp);
-            *errp = NULL;
-        }
+        error_free(err);
         return 0;
     }
     return ret;
@@ -1361,10 +1357,9 @@ size_t vnc_client_write_buf(VncState *vs, const uint8_t *data, size_t datalen)
 {
     Error *err = NULL;
     ssize_t ret;
-    ret = qio_channel_write(
-        vs->ioc, (const char *)data, datalen, &err);
+    ret = qio_channel_write(vs->ioc, (const char *)data, datalen, &err);
     VNC_DEBUG("Wrote wire %p %zd -> %ld\n", data, datalen, ret);
-    return vnc_client_io_error(vs, ret, &err);
+    return vnc_client_io_error(vs, ret, err);
 }
 
 
@@ -1488,10 +1483,9 @@ size_t vnc_client_read_buf(VncState *vs, uint8_t *data, size_t datalen)
 {
     ssize_t ret;
     Error *err = NULL;
-    ret = qio_channel_read(
-        vs->ioc, (char *)data, datalen, &err);
+    ret = qio_channel_read(vs->ioc, (char *)data, datalen, &err);
     VNC_DEBUG("Read wire %p %zd -> %ld\n", data, datalen, ret);
-    return vnc_client_io_error(vs, ret, &err);
+    return vnc_client_io_error(vs, ret, err);
 }
 
 
Signature · 1 line
2.21.0
#13 lore raw

[PULL 10/34] qga: Fix guest-get-fsinfo error API violations

In reply to Markus Armbruster

build_guest_fsinfo_for_virtual_device() dereferences @errp when build_guest_fsinfo_for_device() fails. That's wrong; see the big comment in error.h. Introduced in commit 46d4c5723e "qga: Add guest-get-fsinfo command".

No caller actually passes null.

Fix anyway: splice in a local Error *err, and error_propagate().

Message-Id: <[email protected]>

---
 qga/commands-posix.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
qga/commands-posix.c +4 -2
index 0be301a4ea..10d818c3b2 100644
@@ -1060,6 +1060,7 @@ static void build_guest_fsinfo_for_virtual_device(char const *syspath,
                                                   GuestFilesystemInfo *fs,
                                                   Error **errp)
 {
+    Error *err = NULL;
     DIR *dir;
     char *dirpath;
     struct dirent *entry;
@@ -1089,10 +1090,11 @@ static void build_guest_fsinfo_for_virtual_device(char const *syspath,
 
             g_debug(" slave device '%s'", entry->d_name);
             path = g_strdup_printf("%s/slaves/%s", syspath, entry->d_name);
-            build_guest_fsinfo_for_device(path, fs, errp);
+            build_guest_fsinfo_for_device(path, fs, &err);
             g_free(path);
 
-            if (*errp) {
+            if (err) {
+                error_propagate(errp, err);
                 break;
             }
         }
Signature · 1 line
2.21.0
#14 lore raw

[PULL 16/34] error: make Error **errp const where it is appropriate

In reply to Markus Armbruster

From: Vladimir Sementsov-Ogievskiy <[email protected]>

Mostly, Error ** is for returning error from the function, so the callee sets it. However these three functions get already filled errp parameter. They don't change the pointer itself, only change the internal state of referenced Error object. So we can make it Error *const * errp, to stress the behavior. It will also help coccinelle script (in future) to distinguish such cases from common errp usage.

Message-Id: <[email protected]>

---
 include/qapi/error.h | 6 +++---
 util/error.c         | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)
include/qapi/error.h +3 -3
index 3f95141a01..ad5b6e896d 100644
@@ -233,13 +233,13 @@ void error_propagate_prepend(Error **dst_errp, Error *local_err,
  * Prepend some text to @errp's human-readable error message.
  * The text is made by formatting @fmt, @ap like vprintf().
  */
-void error_vprepend(Error **errp, const char *fmt, va_list ap);
+void error_vprepend(Error *const *errp, const char *fmt, va_list ap);
 
 /*
  * Prepend some text to @errp's human-readable error message.
  * The text is made by formatting @fmt, ... like printf().
  */
-void error_prepend(Error **errp, const char *fmt, ...)
+void error_prepend(Error *const *errp, const char *fmt, ...)
     GCC_FMT_ATTR(2, 3);
 
 /*
@@ -256,7 +256,7 @@ void error_prepend(Error **errp, const char *fmt, ...)
  * May be called multiple times.  The resulting hint should end with a
  * newline.
  */
-void error_append_hint(Error **errp, const char *fmt, ...)
+void error_append_hint(Error *const *errp, const char *fmt, ...)
     GCC_FMT_ATTR(2, 3);
 
 /*
util/error.c +3 -3
index d4532ce318..b6c89d1412 100644
@@ -121,7 +121,7 @@ void error_setg_file_open_internal(Error **errp,
                               "Could not open '%s'", filename);
 }
 
-void error_vprepend(Error **errp, const char *fmt, va_list ap)
+void error_vprepend(Error *const *errp, const char *fmt, va_list ap)
 {
     GString *newmsg;
 
@@ -136,7 +136,7 @@ void error_vprepend(Error **errp, const char *fmt, va_list ap)
     (*errp)->msg = g_string_free(newmsg, 0);
 }
 
-void error_prepend(Error **errp, const char *fmt, ...)
+void error_prepend(Error *const *errp, const char *fmt, ...)
 {
     va_list ap;
 
@@ -145,7 +145,7 @@ void error_prepend(Error **errp, const char *fmt, ...)
     va_end(ap);
 }
 
-void error_append_hint(Error **errp, const char *fmt, ...)
+void error_append_hint(Error *const *errp, const char *fmt, ...)
 {
     va_list ap;
     int saved_errno = errno;
Signature · 1 line
2.21.0
#15 lore raw

[PULL 07/34] hw/acpi: Fix legacy CPU plug error API violations

In reply to Markus Armbruster

legacy_acpi_cpu_plug_cb() dereferences @errp when acpi_set_cpu_present_bit() fails. That's wrong; see the big comment in error.h. Introduced in commit cc43364de7 "acpi/cpu-hotplug:
introduce helper function to keep bit setting in one place".

No caller actually passes null, and acpi_set_cpu_present_bit() can't actually fail.

Fix anyway: drop acpi_set_cpu_present_bit()'s @errp parameter.

Message-Id: <[email protected]>

---
 hw/acpi/cpu_hotplug.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
hw/acpi/cpu_hotplug.c +3 -7
index 3ac2045a95..9c3bcc84de 100644
@@ -55,8 +55,7 @@ static const MemoryRegionOps AcpiCpuHotplug_ops = {
     },
 };
 
-static void acpi_set_cpu_present_bit(AcpiCpuHotplug *g, CPUState *cpu,
-                                     Error **errp)
+static void acpi_set_cpu_present_bit(AcpiCpuHotplug *g, CPUState *cpu)
 {
     CPUClass *k = CPU_GET_CLASS(cpu);
     int64_t cpu_id;
@@ -74,10 +73,7 @@ static void acpi_set_cpu_present_bit(AcpiCpuHotplug *g, CPUState *cpu,
 void legacy_acpi_cpu_plug_cb(HotplugHandler *hotplug_dev,
                              AcpiCpuHotplug *g, DeviceState *dev, Error **errp)
 {
-    acpi_set_cpu_present_bit(g, CPU(dev), errp);
-    if (*errp != NULL) {
-        return;
-    }
+    acpi_set_cpu_present_bit(g, CPU(dev));
     acpi_send_event(DEVICE(hotplug_dev), ACPI_CPU_HOTPLUG_STATUS);
 }
 
@@ -92,7 +88,7 @@ void legacy_acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner,
     gpe_cpu->device = owner;
 
     CPU_FOREACH(cpu) {
-        acpi_set_cpu_present_bit(gpe_cpu, cpu, &error_abort);
+        acpi_set_cpu_present_bit(gpe_cpu, cpu);
     }
 }
 
Signature · 1 line
2.21.0
#16 lore raw

[PULL 32/34] backends/cryptodev: drop local_err from cryptodev_backend_complete()

In reply to Markus Armbruster

From: Vladimir Sementsov-Ogievskiy <[email protected]>

No reason for local_err here, use errp directly instead.

Message-Id: <[email protected]>

---
 backends/cryptodev.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
backends/cryptodev.c +1 -10
index 3c071eab95..5a9735684e 100644
@@ -176,19 +176,10 @@ cryptodev_backend_complete(UserCreatable *uc, Error **errp)
 {
     CryptoDevBackend *backend = CRYPTODEV_BACKEND(uc);
     CryptoDevBackendClass *bc = CRYPTODEV_BACKEND_GET_CLASS(uc);
-    Error *local_err = NULL;
 
     if (bc->init) {
-        bc->init(backend, &local_err);
-        if (local_err) {
-            goto out;
-        }
+        bc->init(backend, errp);
     }
-
-    return;
-
-out:
-    error_propagate(errp, local_err);
 }
 
 void cryptodev_backend_set_used(CryptoDevBackend *backend, bool used)
Signature · 1 line
2.21.0
#17 lore raw

[PULL 26/34] monitor/qmp-cmds: rename Error ** parameter to more common errp

In reply to Markus Armbruster

From: Vladimir Sementsov-Ogievskiy <[email protected]>

Message-Id: <[email protected]>

---
 monitor/qmp-cmds.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
monitor/qmp-cmds.c +1 -1
index 0880341a2d..c6faa3eaf0 100644
@@ -109,7 +109,7 @@ void qmp_system_reset(Error **errp)
     qemu_system_reset_request(SHUTDOWN_CAUSE_HOST_QMP_SYSTEM_RESET);
 }
 
-void qmp_system_powerdown(Error **erp)
+void qmp_system_powerdown(Error **errp)
 {
     qemu_system_powerdown_request();
 }
Signature · 1 line
2.21.0
#18 lore raw

[PULL 09/34] hw/ipmi: Fix realize() error API violations

In reply to Markus Armbruster

isa_ipmi_bt_realize(), ipmi_isa_realize(), pci_ipmi_bt_realize(), and pci_ipmi_kcs_realize() dereference @errp when IPMIInterfaceClass method init() fails. That's wrong; see the big comment in error.h. Introduced in commit 0719029c47 "ipmi: Add an ISA KCS low-level interface", then imitated in commit a9b74079cb "ipmi: Add a BT low-level interface" and commit 12f983c6aa "ipmi: Add PCI IPMI interfaces".

No caller actually passes null.

Fix anyway: splice in a local Error *err, and error_propagate().

Message-Id: <[email protected]>

---
 hw/ipmi/isa_ipmi_bt.c  | 7 +++++--
 hw/ipmi/isa_ipmi_kcs.c | 7 +++++--
 hw/ipmi/pci_ipmi_bt.c  | 6 ++++--
 hw/ipmi/pci_ipmi_kcs.c | 6 ++++--
 4 files changed, 18 insertions(+), 8 deletions(-)
hw/ipmi/isa_ipmi_bt.c +5 -2
index 9a87ffd3f0..9fba5ed383 100644
@@ -70,6 +70,7 @@ static void isa_ipmi_bt_lower_irq(IPMIBT *ib)
 
 static void isa_ipmi_bt_realize(DeviceState *dev, Error **errp)
 {
+    Error *err = NULL;
     ISADevice *isadev = ISA_DEVICE(dev);
     ISAIPMIBTDevice *iib = ISA_IPMI_BT(dev);
     IPMIInterface *ii = IPMI_INTERFACE(dev);
@@ -85,9 +86,11 @@ static void isa_ipmi_bt_realize(DeviceState *dev, Error **errp)
     iib->bt.bmc->intf = ii;
     iib->bt.opaque = iib;
 
-    iic->init(ii, 0, errp);
-    if (*errp)
+    iic->init(ii, 0, &err);
+    if (err) {
+        error_propagate(errp, err);
         return;
+    }
 
     if (iib->isairq > 0) {
         isa_init_irq(isadev, &iib->irq, iib->isairq);
hw/ipmi/isa_ipmi_kcs.c +5 -2
index ca3ea36a3f..cc6bd817f2 100644
@@ -69,6 +69,7 @@ static void isa_ipmi_kcs_lower_irq(IPMIKCS *ik)
 
 static void ipmi_isa_realize(DeviceState *dev, Error **errp)
 {
+    Error *err = NULL;
     ISADevice *isadev = ISA_DEVICE(dev);
     ISAIPMIKCSDevice *iik = ISA_IPMI_KCS(dev);
     IPMIInterface *ii = IPMI_INTERFACE(dev);
@@ -84,9 +85,11 @@ static void ipmi_isa_realize(DeviceState *dev, Error **errp)
     iik->kcs.bmc->intf = ii;
     iik->kcs.opaque = iik;
 
-    iic->init(ii, 0, errp);
-    if (*errp)
+    iic->init(ii, 0, &err);
+    if (err) {
+        error_propagate(errp, err);
         return;
+    }
 
     if (iik->isairq > 0) {
         isa_init_irq(isadev, &iik->irq, iik->isairq);
hw/ipmi/pci_ipmi_bt.c +4 -2
index 6ed925a665..ba9cf016b5 100644
@@ -54,6 +54,7 @@ static void pci_ipmi_lower_irq(IPMIBT *ik)
 
 static void pci_ipmi_bt_realize(PCIDevice *pd, Error **errp)
 {
+    Error *err = NULL;
     PCIIPMIBTDevice *pik = PCI_IPMI_BT(pd);
     IPMIInterface *ii = IPMI_INTERFACE(pd);
     IPMIInterfaceClass *iic = IPMI_INTERFACE_GET_CLASS(ii);
@@ -74,8 +75,9 @@ static void pci_ipmi_bt_realize(PCIDevice *pd, Error **errp)
     pik->bt.raise_irq = pci_ipmi_raise_irq;
     pik->bt.lower_irq = pci_ipmi_lower_irq;
 
-    iic->init(ii, 8, errp);
-    if (*errp) {
+    iic->init(ii, 8, &err);
+    if (err) {
+        error_propagate(errp, err);
         return;
     }
     pci_register_bar(pd, 0, PCI_BASE_ADDRESS_SPACE_IO, &pik->bt.io);
hw/ipmi/pci_ipmi_kcs.c +4 -2
index eeba63baa4..99f46152f4 100644
@@ -54,6 +54,7 @@ static void pci_ipmi_lower_irq(IPMIKCS *ik)
 
 static void pci_ipmi_kcs_realize(PCIDevice *pd, Error **errp)
 {
+    Error *err = NULL;
     PCIIPMIKCSDevice *pik = PCI_IPMI_KCS(pd);
     IPMIInterface *ii = IPMI_INTERFACE(pd);
     IPMIInterfaceClass *iic = IPMI_INTERFACE_GET_CLASS(ii);
@@ -74,8 +75,9 @@ static void pci_ipmi_kcs_realize(PCIDevice *pd, Error **errp)
     pik->kcs.raise_irq = pci_ipmi_raise_irq;
     pik->kcs.lower_irq = pci_ipmi_lower_irq;
 
-    iic->init(ii, 8, errp);
-    if (*errp) {
+    iic->init(ii, 8, &err);
+    if (err) {
+        error_propagate(errp, err);
         return;
     }
     pci_register_bar(pd, 0, PCI_BASE_ADDRESS_SPACE_IO, &pik->kcs.io);
Signature · 1 line
2.21.0
#19 lore raw

[PULL 28/34] hw/sd: drop extra whitespace in sdhci_sysbus_realize() header

In reply to Markus Armbruster

From: Vladimir Sementsov-Ogievskiy <[email protected]>

Message-Id: <[email protected]>

---
 hw/sd/sdhci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/sd/sdhci.c +1 -1
index 88404d0e9d..18c0c052ce 100644
@@ -1459,7 +1459,7 @@ static void sdhci_sysbus_finalize(Object *obj)
     sdhci_uninitfn(s);
 }
 
-static void sdhci_sysbus_realize(DeviceState *dev, Error ** errp)
+static void sdhci_sysbus_realize(DeviceState *dev, Error **errp)
 {
     SDHCIState *s = SYSBUS_SDHCI(dev);
     SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
Signature · 1 line
2.21.0
#20 lore raw

[PULL 12/34] error: Clean up unusual names of Error * variables

In reply to Markus Armbruster

Local Error * variables are conventionally named @err or @local_err, and Error ** parameters @errp. Naming local variables like parameters is confusing. Clean that up.

Naming parameters like local variables is also confusing. Left for another day.

Message-Id: <[email protected]>

---
 hw/intc/s390_flic_kvm.c    | 10 +++++-----
 hw/ppc/spapr_pci.c         | 16 ++++++++--------
 hw/ppc/spapr_pci_nvlink2.c | 10 +++++-----
 tests/test-blockjob.c      | 16 ++++++++--------
 4 files changed, 26 insertions(+), 26 deletions(-)
hw/intc/s390_flic_kvm.c +5 -5
index c9ee80eaae..30d50c2369 100644
@@ -582,10 +582,10 @@ static void kvm_s390_flic_realize(DeviceState *dev, Error **errp)
     struct kvm_create_device cd = {0};
     struct kvm_device_attr test_attr = {0};
     int ret;
-    Error *errp_local = NULL;
+    Error *err = NULL;
 
-    KVM_S390_FLIC_GET_CLASS(dev)->parent_realize(dev, &errp_local);
-    if (errp_local) {
+    KVM_S390_FLIC_GET_CLASS(dev)->parent_realize(dev, &err);
+    if (err) {
         goto fail;
     }
     flic_state->fd = -1;
@@ -593,7 +593,7 @@ static void kvm_s390_flic_realize(DeviceState *dev, Error **errp)
     cd.type = KVM_DEV_TYPE_FLIC;
     ret = kvm_vm_ioctl(kvm_state, KVM_CREATE_DEVICE, &cd);
     if (ret < 0) {
-        error_setg_errno(&errp_local, errno, "Creating the KVM device failed");
+        error_setg_errno(&err, errno, "Creating the KVM device failed");
         trace_flic_create_device(errno);
         goto fail;
     }
@@ -605,7 +605,7 @@ static void kvm_s390_flic_realize(DeviceState *dev, Error **errp)
                                             KVM_HAS_DEVICE_ATTR, test_attr);
     return;
 fail:
-    error_propagate(errp, errp_local);
+    error_propagate(errp, err);
 }
 
 static void kvm_s390_flic_reset(DeviceState *dev)
hw/ppc/spapr_pci.c +8 -8
index f6fbcf99ed..723373de73 100644
@@ -2042,13 +2042,13 @@ void spapr_phb_dma_reset(SpaprPhbState *sphb)
 static void spapr_phb_reset(DeviceState *qdev)
 {
     SpaprPhbState *sphb = SPAPR_PCI_HOST_BRIDGE(qdev);
-    Error *errp = NULL;
+    Error *err = NULL;
 
     spapr_phb_dma_reset(sphb);
     spapr_phb_nvgpu_free(sphb);
-    spapr_phb_nvgpu_setup(sphb, &errp);
-    if (errp) {
-        error_report_err(errp);
+    spapr_phb_nvgpu_setup(sphb, &err);
+    if (err) {
+        error_report_err(err);
     }
 
     /* Reset the IOMMU state */
@@ -2326,7 +2326,7 @@ int spapr_dt_phb(SpaprMachineState *spapr, SpaprPhbState *phb,
                                 cpu_to_be32(phb->numa_node)};
     SpaprTceTable *tcet;
     SpaprDrc *drc;
-    Error *errp = NULL;
+    Error *err = NULL;
 
     /* Start populating the FDT */
     _FDT(bus_off = fdt_add_subnode(fdt, 0, phb->dtbusname));
@@ -2408,9 +2408,9 @@ int spapr_dt_phb(SpaprMachineState *spapr, SpaprPhbState *phb,
         return ret;
     }
 
-    spapr_phb_nvgpu_populate_dt(phb, fdt, bus_off, &errp);
-    if (errp) {
-        error_report_err(errp);
+    spapr_phb_nvgpu_populate_dt(phb, fdt, bus_off, &err);
+    if (err) {
+        error_report_err(err);
     }
     spapr_phb_nvgpu_ram_populate_dt(phb, fdt);
 
hw/ppc/spapr_pci_nvlink2.c +5 -5
index 4aa89ede23..8332d5694e 100644
@@ -57,7 +57,7 @@ struct SpaprPhbPciNvGpuConfig {
     uint64_t nv2_atsd_current;
     int num; /* number of non empty (i.e. tgt!=0) entries in slots[] */
     SpaprPhbPciNvGpuSlot slots[NVGPU_MAX_NUM];
-    Error *errp;
+    Error *err;
 };
 
 static SpaprPhbPciNvGpuSlot *
@@ -153,7 +153,7 @@ static void spapr_phb_pci_collect_nvgpu(PCIBus *bus, PCIDevice *pdev,
             spapr_pci_collect_nvnpu(nvgpus, pdev, tgt, MEMORY_REGION(mr_npu),
                                     &local_err);
         }
-        error_propagate(&nvgpus->errp, local_err);
+        error_propagate(&nvgpus->err, local_err);
     }
     if ((pci_default_read_config(pdev, PCI_HEADER_TYPE, 1) !=
          PCI_HEADER_TYPE_BRIDGE)) {
@@ -187,9 +187,9 @@ void spapr_phb_nvgpu_setup(SpaprPhbState *sphb, Error **errp)
     pci_for_each_device(bus, pci_bus_num(bus),
                         spapr_phb_pci_collect_nvgpu, sphb->nvgpus);
 
-    if (sphb->nvgpus->errp) {
-        error_propagate(errp, sphb->nvgpus->errp);
-        sphb->nvgpus->errp = NULL;
+    if (sphb->nvgpus->err) {
+        error_propagate(errp, sphb->nvgpus->err);
+        sphb->nvgpus->err = NULL;
         goto cleanup_exit;
     }
 
tests/test-blockjob.c +8 -8
index 7844c9ffcb..e670a20617 100644
@@ -34,13 +34,13 @@ static BlockJob *mk_job(BlockBackend *blk, const char *id,
                         int flags)
 {
     BlockJob *job;
-    Error *errp = NULL;
+    Error *err = NULL;
 
     job = block_job_create(id, drv, NULL, blk_bs(blk),
                            0, BLK_PERM_ALL, 0, flags, block_job_cb,
-                           NULL, &errp);
+                           NULL, &err);
     if (should_succeed) {
-        g_assert_null(errp);
+        g_assert_null(err);
         g_assert_nonnull(job);
         if (id) {
             g_assert_cmpstr(job->job.id, ==, id);
@@ -48,9 +48,9 @@ static BlockJob *mk_job(BlockBackend *blk, const char *id,
             g_assert_cmpstr(job->job.id, ==, blk_name(blk));
         }
     } else {
-        g_assert_nonnull(errp);
+        g_assert_nonnull(err);
         g_assert_null(job);
-        error_free(errp);
+        error_free(err);
     }
 
     return job;
@@ -80,9 +80,9 @@ static BlockBackend *create_blk(const char *name)
     bdrv_unref(bs);
 
     if (name) {
-        Error *errp = NULL;
-        monitor_add_blk(blk, name, &errp);
-        g_assert_null(errp);
+        Error *err = NULL;
+        monitor_add_blk(blk, name, &err);
+        g_assert_null(err);
     }
 
     return blk;
Signature · 1 line
2.21.0
#21 lore raw

[PULL 06/34] exec: Fix file_ram_alloc() error API violations

In reply to Markus Armbruster

When os_mem_prealloc() fails, file_ram_alloc() calls qemu_ram_munmap() and returns null. Except it doesn't when its @errp argument is null, because it checks for failure with (errp && *errp). Introduced in commit 056b68af77 "fix qemu exit on memory hotplug when allocation fails at prealloc time".

No caller actually passes null.

Fix anyway: splice in a local Error *err, and error_propagate().

Message-Id: <[email protected]>

---
 exec.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
exec.c +4 -2
index a34c348184..6bd4aa1d87 100644
@@ -1843,6 +1843,7 @@ static void *file_ram_alloc(RAMBlock *block,
                             bool truncate,
                             Error **errp)
 {
+    Error *err = NULL;
     MachineState *ms = MACHINE(qdev_get_machine());
     void *area;
 
@@ -1900,8 +1901,9 @@ static void *file_ram_alloc(RAMBlock *block,
     }
 
     if (mem_prealloc) {
-        os_mem_prealloc(fd, area, memory, ms->smp.cpus, errp);
-        if (errp && *errp) {
+        os_mem_prealloc(fd, area, memory, ms->smp.cpus, &err);
+        if (err) {
+            error_propagate(errp, err);
             qemu_ram_munmap(fd, area, memory);
             return NULL;
         }
Signature · 1 line
2.21.0
#22 lore raw

[PULL 22/34] hw/core/qdev: cleanup Error ** variables

In reply to Markus Armbruster

From: Vladimir Sementsov-Ogievskiy <[email protected]>

Rename Error ** parameter in check_only_migratable to common errp.

In device_set_realized:

- Move "if (local_err != NULL)" closer to error setters.

- Drop 'Error **local_errp': it doesn't save any LoCs, but it's very unusual.

Message-Id: <[email protected]>

---
 hw/core/qdev.c | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)
hw/core/qdev.c +13 -15
index cf1ba28fe3..82d3ee590a 100644
@@ -820,12 +820,12 @@ static bool device_get_realized(Object *obj, Error **errp)
     return dev->realized;
 }
 
-static bool check_only_migratable(Object *obj, Error **err)
+static bool check_only_migratable(Object *obj, Error **errp)
 {
     DeviceClass *dc = DEVICE_GET_CLASS(obj);
 
     if (!vmstate_check_only_migratable(dc->vmsd)) {
-        error_setg(err, "Device %s is not migratable, but "
+        error_setg(errp, "Device %s is not migratable, but "
                    "--only-migratable was specified",
                    object_get_typename(obj));
         return false;
@@ -874,10 +874,9 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
 
         if (dc->realize) {
             dc->realize(dev, &local_err);
-        }
-
-        if (local_err != NULL) {
-            goto fail;
+            if (local_err != NULL) {
+                goto fail;
+            }
         }
 
         DEVICE_LISTENER_CALL(realize, Forward, dev);
@@ -918,27 +917,26 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
        }
 
     } else if (!value && dev->realized) {
-        Error **local_errp = NULL;
+        /* We want local_err to track only the first error */
         QLIST_FOREACH(bus, &dev->child_bus, sibling) {
-            local_errp = local_err ? NULL : &local_err;
             object_property_set_bool(OBJECT(bus), false, "realized",
-                                     local_errp);
+                                     local_err ? NULL : &local_err);
         }
         if (qdev_get_vmsd(dev)) {
             vmstate_unregister(dev, qdev_get_vmsd(dev), dev);
         }
         if (dc->unrealize) {
-            local_errp = local_err ? NULL : &local_err;
-            dc->unrealize(dev, local_errp);
+            dc->unrealize(dev, local_err ? NULL : &local_err);
         }
         dev->pending_deleted_event = true;
         DEVICE_LISTENER_CALL(unrealize, Reverse, dev);
-    }
 
-    if (local_err != NULL) {
-        goto fail;
+        if (local_err != NULL) {
+            goto fail;
+        }
     }
 
+    assert(local_err == NULL);
     dev->realized = value;
     return;
 
@@ -976,7 +974,7 @@ static bool device_get_hotpluggable(Object *obj, Error **errp)
                                 qbus_is_hotpluggable(dev->parent_bus));
 }
 
-static bool device_get_hotplugged(Object *obj, Error **err)
+static bool device_get_hotplugged(Object *obj, Error **errp)
 {
     DeviceState *dev = DEVICE(obj);
 
Signature · 1 line
2.21.0
#23 lore raw

[PULL 31/34] include/qom/object.h: rename Error ** parameter to more common errp

In reply to Markus Armbruster

From: Vladimir Sementsov-Ogievskiy <[email protected]>

Message-Id: <[email protected]>

---
 include/qom/object.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/qom/object.h +2 -2
index 128d00c77f..716f6f655d 100644
@@ -1635,9 +1635,9 @@ void object_class_property_add_uint32_ptr(ObjectClass *klass, const char *name,
  * property of type 'uint64'.
  */
 void object_property_add_uint64_ptr(Object *obj, const char *name,
-                                    const uint64_t *v, Error **Errp);
+                                    const uint64_t *v, Error **errp);
 void object_class_property_add_uint64_ptr(ObjectClass *klass, const char *name,
-                                          const uint64_t *v, Error **Errp);
+                                          const uint64_t *v, Error **errp);
 
 /**
  * object_property_add_alias:
Signature · 1 line
2.21.0
#24 lore raw

[PULL 15/34] net/net: Clean up variable shadowing in net_client_init()

In reply to Markus Armbruster

From: Vladimir Sementsov-Ogievskiy <[email protected]>

Variable int err in inner scope shadows Error *err in outer scope.

Message-Id: <[email protected]>

---
 net/net.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
net/net.c +7 -10
index 84aa6d8d00..9e93c3f8a1 100644
@@ -1126,16 +1126,13 @@ static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)
 
             prefix_addr = substrings[0];
 
-            if (substrings[1]) {
-                /* User-specified prefix length.  */
-                int err;
-
-                err = qemu_strtoul(substrings[1], NULL, 10, &prefix_len);
-                if (err) {
-                    error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
-                               "ipv6-prefixlen", "a number");
-                    goto out;
-                }
+            /* Handle user-specified prefix length. */
+            if (substrings[1] &&
+                qemu_strtoul(substrings[1], NULL, 10, &prefix_len))
+            {
+                error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+                           "ipv6-prefixlen", "a number");
+                goto out;
             }
 
             qemu_opt_set(opts, "ipv6-prefix", prefix_addr, &error_abort);
Signature · 1 line
2.21.0
#25 lore raw

[PULL 24/34] hw/i386/amd_iommu: rename Error ** parameter to more common errp

In reply to Markus Armbruster

From: Vladimir Sementsov-Ogievskiy <[email protected]>

Message-Id: <[email protected]>

---
 hw/i386/amd_iommu.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
hw/i386/amd_iommu.c +7 -7
index d55dbf07fc..b1175e52c7 100644
@@ -1533,7 +1533,7 @@ static void amdvi_reset(DeviceState *dev)
     amdvi_init(s);
 }
 
-static void amdvi_realize(DeviceState *dev, Error **err)
+static void amdvi_realize(DeviceState *dev, Error **errp)
 {
     int ret = 0;
     AMDVIState *s = AMD_IOMMU_DEVICE(dev);
@@ -1549,21 +1549,21 @@ static void amdvi_realize(DeviceState *dev, Error **err)
     /* This device should take care of IOMMU PCI properties */
     x86_iommu->type = TYPE_AMD;
     qdev_set_parent_bus(DEVICE(&s->pci), &bus->qbus);
-    object_property_set_bool(OBJECT(&s->pci), true, "realized", err);
+    object_property_set_bool(OBJECT(&s->pci), true, "realized", errp);
     ret = pci_add_capability(&s->pci.dev, AMDVI_CAPAB_ID_SEC, 0,
-                                         AMDVI_CAPAB_SIZE, err);
+                                         AMDVI_CAPAB_SIZE, errp);
     if (ret < 0) {
         return;
     }
     s->capab_offset = ret;
 
     ret = pci_add_capability(&s->pci.dev, PCI_CAP_ID_MSI, 0,
-                             AMDVI_CAPAB_REG_SIZE, err);
+                             AMDVI_CAPAB_REG_SIZE, errp);
     if (ret < 0) {
         return;
     }
     ret = pci_add_capability(&s->pci.dev, PCI_CAP_ID_HT, 0,
-                             AMDVI_CAPAB_REG_SIZE, err);
+                             AMDVI_CAPAB_REG_SIZE, errp);
     if (ret < 0) {
         return;
     }
@@ -1578,8 +1578,8 @@ static void amdvi_realize(DeviceState *dev, Error **err)
     sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->mmio);
     sysbus_mmio_map(SYS_BUS_DEVICE(s), 0, AMDVI_BASE_ADDR);
     pci_setup_iommu(bus, amdvi_host_dma_iommu, s);
-    s->devid = object_property_get_int(OBJECT(&s->pci), "addr", err);
-    msi_init(&s->pci.dev, 0, 1, true, false, err);
+    s->devid = object_property_get_int(OBJECT(&s->pci), "addr", errp);
+    msi_init(&s->pci.dev, 0, 1, true, false, errp);
     amdvi_init(s);
 }
 
Signature · 1 line
2.21.0
#26 lore raw

[PULL 21/34] 9pfs: make Error **errp const where it is appropriate

In reply to Markus Armbruster

From: Vladimir Sementsov-Ogievskiy <[email protected]>

Mostly, Error ** is for returning error from the function, so the callee sets it. However error_append_security_model_hint and error_append_socket_sockfd_hint get already filled errp parameter. They don't change the pointer itself, only change the internal state of referenced Error object. So we can make it Error *const * errp, to stress the behavior. It will also help coccinelle script (in future) to distinguish such cases from common errp usage.

Message-Id: <[email protected]>

[Commit message replaced]
---
 hw/9pfs/9p-local.c | 2 +-
 hw/9pfs/9p-proxy.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
hw/9pfs/9p-local.c +1 -1
index 4708c0bd89..ca641390fb 100644
@@ -1473,7 +1473,7 @@ static void local_cleanup(FsContext *ctx)
     g_free(data);
 }
 
-static void error_append_security_model_hint(Error **errp)
+static void error_append_security_model_hint(Error *const *errp)
 {
     error_append_hint(errp, "Valid options are: security_model="
                       "[passthrough|mapped-xattr|mapped-file|none]\n");
hw/9pfs/9p-proxy.c +1 -1
index 97ab9c58a5..8136e1342d 100644
@@ -1114,7 +1114,7 @@ static int connect_namedsocket(const char *path, Error **errp)
     return sockfd;
 }
 
-static void error_append_socket_sockfd_hint(Error **errp)
+static void error_append_socket_sockfd_hint(Error *const *errp)
 {
     error_append_hint(errp, "Either specify socket=/some/path where /some/path"
                       " points to a listening AF_UNIX socket or sock_fd=fd"
Signature · 1 line
2.21.0
#27 lore raw

[PULL 29/34] hw/tpm: rename Error ** parameter to more common errp

In reply to Markus Armbruster

From: Vladimir Sementsov-Ogievskiy <[email protected]>

Message-Id: <[email protected]>

---
 hw/tpm/tpm_emulator.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
hw/tpm/tpm_emulator.c +4 -4
index 22f9113432..10d587ed40 100644
@@ -155,7 +155,7 @@ static int tpm_emulator_unix_tx_bufs(TPMEmulator *tpm_emu,
                                      const uint8_t *in, uint32_t in_len,
                                      uint8_t *out, uint32_t out_len,
                                      bool *selftest_done,
-                                     Error **err)
+                                     Error **errp)
 {
     ssize_t ret;
     bool is_selftest = false;
@@ -165,20 +165,20 @@ static int tpm_emulator_unix_tx_bufs(TPMEmulator *tpm_emu,
         is_selftest = tpm_util_is_selftest(in, in_len);
     }
 
-    ret = qio_channel_write_all(tpm_emu->data_ioc, (char *)in, in_len, err);
+    ret = qio_channel_write_all(tpm_emu->data_ioc, (char *)in, in_len, errp);
     if (ret != 0) {
         return -1;
     }
 
     ret = qio_channel_read_all(tpm_emu->data_ioc, (char *)out,
-              sizeof(struct tpm_resp_hdr), err);
+              sizeof(struct tpm_resp_hdr), errp);
     if (ret != 0) {
         return -1;
     }
 
     ret = qio_channel_read_all(tpm_emu->data_ioc,
               (char *)out + sizeof(struct tpm_resp_hdr),
-              tpm_cmd_get_size(out) - sizeof(struct tpm_resp_hdr), err);
+              tpm_cmd_get_size(out) - sizeof(struct tpm_resp_hdr), errp);
     if (ret != 0) {
         return -1;
     }
Signature · 1 line
2.21.0
#28 lore raw

[PULL 20/34] ppc: make Error **errp const where it is appropriate

In reply to Markus Armbruster

From: Vladimir Sementsov-Ogievskiy <[email protected]>

Mostly, Error ** is for returning error from the function, so the callee sets it. However kvmppc_hint_smt_possible gets already filled errp parameter. It doesn't change the pointer itself, only change the internal state of referenced Error object. So we can make it Error *const * errp, to stress the behavior. It will also help coccinelle script (in future) to distinguish such cases from common errp usage.

While there, rename the function to
kvmppc_error_append_smt_possible_hint().

Message-Id: <[email protected]>

---
 target/ppc/kvm_ppc.h | 4 ++--
 hw/ppc/spapr.c       | 2 +-
 target/ppc/kvm.c     | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
target/ppc/kvm_ppc.h +2 -2
index 98bd7d5da6..f22daabf51 100644
@@ -28,7 +28,7 @@ void kvmppc_set_papr(PowerPCCPU *cpu);
 int kvmppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr);
 void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy);
 int kvmppc_smt_threads(void);
-void kvmppc_hint_smt_possible(Error **errp);
+void kvmppc_error_append_smt_possible_hint(Error *const *errp);
 int kvmppc_set_smt_threads(int smt);
 int kvmppc_clear_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits);
 int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits);
@@ -164,7 +164,7 @@ static inline int kvmppc_smt_threads(void)
     return 1;
 }
 
-static inline void kvmppc_hint_smt_possible(Error **errp)
+static inline void kvmppc_error_append_smt_possible_hint(Error *const *errp)
 {
     return;
 }
hw/ppc/spapr.c +1 -1
index 3ae7db1563..c5d8f0afb6 100644
@@ -2564,7 +2564,7 @@ static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp)
                                       " requires the use of VSMT mode %d.\n",
                                       smp_threads, kvm_smt, spapr->vsmt);
                 }
-                kvmppc_hint_smt_possible(&local_err);
+                kvmppc_error_append_smt_possible_hint(&local_err);
                 goto out;
             }
         }
target/ppc/kvm.c +1 -1
index c77f9848ec..27ea3ce535 100644
@@ -2076,7 +2076,7 @@ int kvmppc_set_smt_threads(int smt)
     return ret;
 }
 
-void kvmppc_hint_smt_possible(Error **errp)
+void kvmppc_error_append_smt_possible_hint(Error *const *errp)
 {
     int i;
     GString *g;
Signature · 1 line
2.21.0
#29 lore raw

[PULL 23/34] block/snapshot: rename Error ** parameter to more common errp

In reply to Markus Armbruster

From: Vladimir Sementsov-Ogievskiy <[email protected]>

Message-Id: <[email protected]>

---
 include/block/snapshot.h | 2 +-
 block/snapshot.c         | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
include/block/snapshot.h +1 -1
index b5d5084a12..2bfcd57578 100644
@@ -78,7 +78,7 @@ int bdrv_snapshot_load_tmp_by_id_or_name(BlockDriverState *bs,
 
 bool bdrv_all_can_snapshot(BlockDriverState **first_bad_bs);
 int bdrv_all_delete_snapshot(const char *name, BlockDriverState **first_bsd_bs,
-                             Error **err);
+                             Error **errp);
 int bdrv_all_goto_snapshot(const char *name, BlockDriverState **first_bad_bs,
                            Error **errp);
 int bdrv_all_find_snapshot(const char *name, BlockDriverState **first_bad_bs);
block/snapshot.c +2 -2
index 8081616ae9..bd9fb01817 100644
@@ -426,7 +426,7 @@ fail:
 }
 
 int bdrv_all_delete_snapshot(const char *name, BlockDriverState **first_bad_bs,
-                             Error **err)
+                             Error **errp)
 {
     int ret = 0;
     BlockDriverState *bs;
@@ -441,7 +441,7 @@ int bdrv_all_delete_snapshot(const char *name, BlockDriverState **first_bad_bs,
             bdrv_snapshot_find(bs, snapshot, name) >= 0)
         {
             ret = bdrv_snapshot_delete(bs, snapshot->id_str,
-                                       snapshot->name, err);
+                                       snapshot->name, errp);
         }
         aio_context_release(ctx);
         if (ret < 0) {
Signature · 1 line
2.21.0
#30 lore raw

[PULL 34/34] nbd: assert that Error** is not NULL in nbd_iter_channel_error

In reply to Markus Armbruster

From: Vladimir Sementsov-Ogievskiy <[email protected]>

All callers of nbd_iter_channel_error() pass the address of a local_err variable, and only call this function if an error has already occurred, using this function to propagate that error. This is already implied by its name (local_err instead of the classic errp), but it is worth additionally stressing this by adding an assertion to make it part of the function contract.

The local_err parameter is not here to return information about nbd_iter_channel_error failure. Instead it's assumed to be filled when passed to the function. This is already stressed by its name (local_err, instead of classic errp). Stress it additionally by assertion.

Message-Id: <[email protected]>

---
 block/nbd.c | 1 +
 1 file changed, 1 insertion(+)
block/nbd.c +1 -0
index 5f18f78a94..d085554f21 100644
@@ -866,6 +866,7 @@ typedef struct NBDReplyChunkIter {
 static void nbd_iter_channel_error(NBDReplyChunkIter *iter,
                                    int ret, Error **local_err)
 {
+    assert(local_err && *local_err);
     assert(ret < 0);
 
     if (!iter->ret) {
Signature · 1 line
2.21.0
#31 lore raw

Re: [PULL 34/34] nbd: assert that Error** is not NULL in nbd_iter_channel_error

Quoted 9 lines · Markus Armbruster

From: Vladimir Sementsov-Ogievskiy <[email protected]>

All callers of nbd_iter_channel_error() pass the address of a local_err variable, and only call this function if an error has already occurred, using this function to propagate that error. This is already implied by its name (local_err instead of the classic errp), but it is worth additionally stressing this by adding an assertion to make it part of the function contract.

Quoted 5 lines

The local_err parameter is not here to return information about nbd_iter_channel_error failure. Instead it's assumed to be filled when passed to the function. This is already stressed by its name (local_err, instead of classic errp). Stress it additionally by assertion.

Redundant paragraph, but probably too late to worry about it now that we have a pull request.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#32 lore raw

Re: [PULL 34/34] nbd: assert that Error** is not NULL in nbd_iter_channel_error

Quoted 10 lines · Eric Blake
Quoted 9 lines · Markus Armbruster

From: Vladimir Sementsov-Ogievskiy <[email protected]>

All callers of nbd_iter_channel_error() pass the address of a local_err variable, and only call this function if an error has already occurred, using this function to propagate that error. This is already implied by its name (local_err instead of the classic errp), but it is worth additionally stressing this by adding an assertion to make it part of the function contract.

Quoted 8 lines
Quoted 5 lines

The local_err parameter is not here to return information about nbd_iter_channel_error failure. Instead it's assumed to be filled when passed to the function. This is already stressed by its name (local_err, instead of classic errp). Stress it additionally by assertion.

Redundant paragraph, but probably too late to worry about it now that we have a pull request.

I'll have to respin anyway. I'll drop the second paragraph.

#33 lore raw

Re: [PULL 34/34] nbd: assert that Error** is not NULL in nbd_iter_channel_error

Quoted 18 lines · Markus Armbruster
Quoted 16 lines · Eric Blake
Quoted 14 lines · Markus Armbruster

From: Vladimir Sementsov-Ogievskiy <[email protected]>

All callers of nbd_iter_channel_error() pass the address of a local_err variable, and only call this function if an error has already occurred, using this function to propagate that error. This is already implied by its name (local_err instead of the classic errp), but it is worth additionally stressing this by adding an assertion to make it part of the function contract.

The local_err parameter is not here to return information about nbd_iter_channel_error failure. Instead it's assumed to be filled when passed to the function. This is already stressed by its name (local_err, instead of classic errp). Stress it additionally by assertion.

Quoted 4 lines
Quoted 2 lines

Redundant paragraph, but probably too late to worry about it now that we have a pull request.

I'll have to respin anyway. I'll drop the second paragraph.

Rats, I forgot.

#34 lore raw

[PULL 17/34] hmp: drop Error pointer indirection in hmp_handle_error

In reply to Markus Armbruster

From: Vladimir Sementsov-Ogievskiy <[email protected]>

We don't need Error **, as all callers pass local Error object, which isn't used after the call. Use Error * instead.

Message-Id: <[email protected]>

---
 include/monitor/hmp.h      |   2 +-
 dump/dump-hmp-cmds.c       |   4 +-
 hw/core/machine-hmp-cmds.c |   6 +-
 monitor/hmp-cmds.c         | 155 ++++++++++++++++++-------------------
 qdev-monitor.c             |   4 +-
 qom/qom-hmp-cmds.c         |   4 +-
 6 files changed, 87 insertions(+), 88 deletions(-)
include/monitor/hmp.h +1 -1
index a0e9511440..3d329853b2 100644
@@ -16,7 +16,7 @@
 
 #include "qemu/readline.h"
 
-void hmp_handle_error(Monitor *mon, Error **errp);
+void hmp_handle_error(Monitor *mon, Error *err);
 
 void hmp_info_name(Monitor *mon, const QDict *qdict);
 void hmp_info_version(Monitor *mon, const QDict *qdict);
dump/dump-hmp-cmds.c +2 -2
index 3dbf44372c..e5053b04cd 100644
@@ -32,7 +32,7 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
 
     if (zlib + lzo + snappy + win_dmp > 1) {
         error_setg(&err, "only one of '-z|-l|-s|-w' can be set");
-        hmp_handle_error(mon, &err);
+        hmp_handle_error(mon, err);
         return;
     }
 
@@ -66,7 +66,7 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
 
     qmp_dump_guest_memory(paging, prot, true, detach, has_begin, begin,
                           has_length, length, true, dump_format, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
     g_free(prot);
 }
 
hw/core/machine-hmp-cmds.c +3 -3
index cd970cc4c5..b76f7223af 100644
@@ -55,7 +55,7 @@ void hmp_cpu_add(Monitor *mon, const QDict *qdict)
 
     cpuid = qdict_get_int(qdict, "id");
     qmp_cpu_add(cpuid, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict)
@@ -66,7 +66,7 @@ void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict)
     CpuInstanceProperties *c;
 
     if (err != NULL) {
-        hmp_handle_error(mon, &err);
+        hmp_handle_error(mon, err);
         return;
     }
 
@@ -135,7 +135,7 @@ void hmp_info_memdev(Monitor *mon, const QDict *qdict)
     monitor_printf(mon, "\n");
 
     qapi_free_MemdevList(memdev_list);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_info_numa(Monitor *mon, const QDict *qdict)
monitor/hmp-cmds.c +77 -78

599 lines not on this page · raw message

qdev-monitor.c +2 -2
index e6b112eb0a..29ed73e56a 100644
@@ -890,7 +890,7 @@ void hmp_device_add(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
 
     qmp_device_add((QDict *)qdict, NULL, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_device_del(Monitor *mon, const QDict *qdict)
@@ -899,7 +899,7 @@ void hmp_device_del(Monitor *mon, const QDict *qdict)
     Error *err = NULL;
 
     qmp_device_del(id, &err);
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 BlockBackend *blk_by_qdev_id(const char *id, Error **errp)
qom/qom-hmp-cmds.c +2 -2
index a268e01eb4..cd08233a4c 100644
@@ -37,7 +37,7 @@ void hmp_qom_list(Monitor *mon, const QDict *qdict)
         }
         qapi_free_ObjectPropertyInfoList(start);
     }
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 void hmp_qom_set(Monitor *mon, const QDict *qdict)
@@ -59,7 +59,7 @@ void hmp_qom_set(Monitor *mon, const QDict *qdict)
         }
         object_property_parse(obj, value, property, &err);
     }
-    hmp_handle_error(mon, &err);
+    hmp_handle_error(mon, err);
 }
 
 typedef struct QOMCompositionState {
Signature · 1 line
2.21.0
#35 lore raw

[PULL 30/34] hw/usb: rename Error ** parameter to more common errp

In reply to Markus Armbruster

From: Vladimir Sementsov-Ogievskiy <[email protected]>

Message-Id: <[email protected]>

---
 hw/usb/dev-network.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/usb/dev-network.c +1 -1
index 5de6213cc4..b81a8abe83 100644
@@ -1342,7 +1342,7 @@ static NetClientInfo net_usbnet_info = {
     .cleanup = usbnet_cleanup,
 };
 
-static void usb_net_realize(USBDevice *dev, Error **errrp)
+static void usb_net_realize(USBDevice *dev, Error **errp)
 {
     USBNetState *s = USB_NET(dev);
 
Signature · 1 line
2.21.0
#36 lore raw

[PULL 27/34] hw/s390x: rename Error ** parameter to more common errp

In reply to Markus Armbruster

From: Vladimir Sementsov-Ogievskiy <[email protected]>

Message-Id: <[email protected]>

---
 hw/s390x/event-facility.c | 2 +-
 hw/s390x/s390-stattrib.c  | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
hw/s390x/event-facility.c +1 -1
index cdcf9154c4..6afe278cad 100644
@@ -441,7 +441,7 @@ static void sclp_event_set_allow_all_mask_sizes(Object *obj, bool value,
     ef->allow_all_mask_sizes = value;
 }
 
-static bool sclp_event_get_allow_all_mask_sizes(Object *obj, Error **e)
+static bool sclp_event_get_allow_all_mask_sizes(Object *obj, Error **errp)
 {
     SCLPEventFacility *ef = (SCLPEventFacility *)obj;
 
hw/s390x/s390-stattrib.c +2 -1
index bf5ac014c4..58121b9f68 100644
@@ -352,7 +352,8 @@ static void s390_stattrib_class_init(ObjectClass *oc, void *data)
     dc->realize = s390_stattrib_realize;
 }
 
-static inline bool s390_stattrib_get_migration_enabled(Object *obj, Error **e)
+static inline bool s390_stattrib_get_migration_enabled(Object *obj,
+                                                       Error **errp)
 {
     S390StAttribState *s = S390_STATTRIB(obj);
 
Signature · 1 line
2.21.0
#37 lore raw

[PULL 25/34] qga: rename Error ** parameter to more common errp

In reply to Markus Armbruster

From: Vladimir Sementsov-Ogievskiy <[email protected]>

Message-Id: <[email protected]>

---
 qga/commands-posix.c |  2 +-
 qga/commands-win32.c |  2 +-
 qga/commands.c       | 12 ++++++------
 3 files changed, 8 insertions(+), 8 deletions(-)
qga/commands-posix.c +1 -1
index 10d818c3b2..93474ff770 100644
@@ -2794,7 +2794,7 @@ static double ga_get_login_time(struct utmpx *user_info)
     return seconds + useconds;
 }
 
-GuestUserList *qmp_guest_get_users(Error **err)
+GuestUserList *qmp_guest_get_users(Error **errp)
 {
     GHashTable *cache = NULL;
     GuestUserList *head = NULL, *cur_item = NULL;
qga/commands-win32.c +1 -1
index 55ba5b263a..2461fd19bf 100644
@@ -1946,7 +1946,7 @@ typedef struct _GA_WTSINFOA {
 
 } GA_WTSINFOA;
 
-GuestUserList *qmp_guest_get_users(Error **err)
+GuestUserList *qmp_guest_get_users(Error **errp)
 {
 #define QGA_NANOSECONDS 10000000
 
qga/commands.c +6 -6
index 0c7d1385c2..43c323cead 100644
@@ -143,7 +143,7 @@ static GuestExecInfo *guest_exec_info_find(int64_t pid_numeric)
     return NULL;
 }
 
-GuestExecStatus *qmp_guest_exec_status(int64_t pid, Error **err)
+GuestExecStatus *qmp_guest_exec_status(int64_t pid, Error **errp)
 {
     GuestExecInfo *gei;
     GuestExecStatus *ges;
@@ -152,7 +152,7 @@ GuestExecStatus *qmp_guest_exec_status(int64_t pid, Error **err)
 
     gei = guest_exec_info_find(pid);
     if (gei == NULL) {
-        error_setg(err, QERR_INVALID_PARAMETER, "pid");
+        error_setg(errp, QERR_INVALID_PARAMETER, "pid");
         return NULL;
     }
 
@@ -385,7 +385,7 @@ GuestExec *qmp_guest_exec(const char *path,
                        bool has_env, strList *env,
                        bool has_input_data, const char *input_data,
                        bool has_capture_output, bool capture_output,
-                       Error **err)
+                       Error **errp)
 {
     GPid pid;
     GuestExec *ge = NULL;
@@ -405,7 +405,7 @@ GuestExec *qmp_guest_exec(const char *path,
     arglist.next = has_arg ? arg : NULL;
 
     if (has_input_data) {
-        input = qbase64_decode(input_data, -1, &ninput, err);
+        input = qbase64_decode(input_data, -1, &ninput, errp);
         if (!input) {
             return NULL;
         }
@@ -424,7 +424,7 @@ GuestExec *qmp_guest_exec(const char *path,
             guest_exec_task_setup, NULL, &pid, has_input_data ? &in_fd : NULL,
             has_output ? &out_fd : NULL, has_output ? &err_fd : NULL, &gerr);
     if (!ret) {
-        error_setg(err, QERR_QGA_COMMAND_FAILED, gerr->message);
+        error_setg(errp, QERR_QGA_COMMAND_FAILED, gerr->message);
         g_error_free(gerr);
         goto done;
     }
@@ -499,7 +499,7 @@ int ga_parse_whence(GuestFileWhence *whence, Error **errp)
     return -1;
 }
 
-GuestHostName *qmp_guest_get_host_name(Error **err)
+GuestHostName *qmp_guest_get_host_name(Error **errp)
 {
     GuestHostName *result = NULL;
     gchar const *hostname = g_get_host_name();
Signature · 1 line
2.21.0
#38 lore raw
In reply to Markus Armbruster
Quoted 9 lines · Markus Armbruster

The following changes since commit cb88904a54903ef6ba21a68a61d9cd51e2166304:

Merge remote-tracking branch 'remotes/amarkovic/tags/mips-queue-dec-16-2019' into staging (2019-12-16 14:07:56 +0000)

are available in the Git repository at:

git://repo.or.cz/qemu/armbru.git tags/pull-error-2019-12-16

Quoted 8 lines

for you to fetch changes up to 0e7f83bab6559775cd71e418b12a49145e59faa7:

nbd: assert that Error** is not NULL in nbd_iter_channel_error (2019-12-16 20:50:16 +0100)

----------------------------------------------------------------
Error reporting patches for 2019-12-16

----------------------------------------------------------------

This gets conflicts:

target/ppc/kvm.c +0 -0
diff --cc target/ppc/kvm.c
index 7406d18945,27ea3ce535..0000000000
@@@ -2076,7 -2076,7 +2076,11 @@@ int kvmppc_set_smt_threads(int smt
      return ret;
  }

++<<<<<<< HEAD
+void kvmppc_error_append_smt_possible_hint(Error **errp_in)
++=======
+ void kvmppc_error_append_smt_possible_hint(Error *const *errp) ++>>>>>>> remotes/armbru/tags/pull-error-2019-12-16

  {
      int i;
      GString *g;
target/ppc/kvm_ppc.h +0 -0
diff --cc target/ppc/kvm_ppc.h
index 47b08a4030,f22daabf51..0000000000
@@@ -28,7 -28,7 +28,11 @@@ void kvmppc_set_papr(PowerPCCPU *cpu)
  int kvmppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr);
  void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy);
  int kvmppc_smt_threads(void);
++<<<<<<< HEAD
 +void kvmppc_error_append_smt_possible_hint(Error **errp_in);
++=======
+ void kvmppc_error_append_smt_possible_hint(Error *const *errp);
++>>>>>>> remotes/armbru/tags/pull-error-2019-12-16
  int kvmppc_set_smt_threads(int smt);
  int kvmppc_clear_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits);
  int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits);
@@@ -164,7 -164,7 +168,11 @@@ static inline int kvmppc_smt_threads(vo
      return 1;
  }

++<<<<<<< HEAD
+static inline void kvmppc_error_append_smt_possible_hint(Error **errp_in)
++=======
+ static inline void kvmppc_error_append_smt_possible_hint(Error *const *errp) ++>>>>>>> remotes/armbru/tags/pull-error-2019-12-16

  {
      return;

}

Furthermore, it turns out that the conflicts are due to different patches from the same author to the same function ("ppc: well form kvmppc_hint_smt_possible error hint helper" and "ppc: make Error **errp const where it is appropriate") which both seem to be addressing broadly the same thing but conflict with each other and arrived via different pull requests.

So I'm just bouncing this one back for you to fix and figure out which version you want...

thanks
-- PMM

#39 lore raw
Quoted 73 lines · Peter Maydell
Quoted 9 lines · Markus Armbruster

The following changes since commit cb88904a54903ef6ba21a68a61d9cd51e2166304:

Merge remote-tracking branch 'remotes/amarkovic/tags/mips-queue-dec-16-2019' into staging (2019-12-16 14:07:56 +0000)

are available in the Git repository at:

git://repo.or.cz/qemu/armbru.git tags/pull-error-2019-12-16

Quoted 8 lines

for you to fetch changes up to 0e7f83bab6559775cd71e418b12a49145e59faa7:

nbd: assert that Error** is not NULL in nbd_iter_channel_error (2019-12-16 20:50:16 +0100)

----------------------------------------------------------------
Error reporting patches for 2019-12-16

----------------------------------------------------------------

This gets conflicts:

target/ppc/kvm.c +4 -0
diff --cc target/ppc/kvm.c
index 7406d18945,27ea3ce535..0000000000
@@@ -2076,7 -2076,7 +2076,11 @@@ int kvmppc_set_smt_threads(int smt
      return ret;
  }
 
++<<<<<<< HEAD
 +void kvmppc_error_append_smt_possible_hint(Error **errp_in)
++=======
+ void kvmppc_error_append_smt_possible_hint(Error *const *errp)
++>>>>>>> remotes/armbru/tags/pull-error-2019-12-16
  {
      int i;
      GString *g;
target/ppc/kvm_ppc.h +8 -0
diff --cc target/ppc/kvm_ppc.h
index 47b08a4030,f22daabf51..0000000000
@@@ -28,7 -28,7 +28,11 @@@ void kvmppc_set_papr(PowerPCCPU *cpu)
  int kvmppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr);
  void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy);
  int kvmppc_smt_threads(void);
++<<<<<<< HEAD
 +void kvmppc_error_append_smt_possible_hint(Error **errp_in);
++=======
+ void kvmppc_error_append_smt_possible_hint(Error *const *errp);
++>>>>>>> remotes/armbru/tags/pull-error-2019-12-16
  int kvmppc_set_smt_threads(int smt);
  int kvmppc_clear_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits);
  int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits);
@@@ -164,7 -164,7 +168,11 @@@ static inline int kvmppc_smt_threads(vo
      return 1;
  }
 
++<<<<<<< HEAD
 +static inline void kvmppc_error_append_smt_possible_hint(Error **errp_in)
++=======
+ static inline void kvmppc_error_append_smt_possible_hint(Error *const *errp)
++>>>>>>> remotes/armbru/tags/pull-error-2019-12-16
  {
      return;
  }

Furthermore, it turns out that the conflicts are due to different patches from the same author to the same function ("ppc: well form kvmppc_hint_smt_possible error hint helper" and "ppc: make Error **errp const where it is appropriate") which both seem to be addressing broadly the same thing but conflict with each other and arrived via different pull requests.

Quoted 2 lines

So I'm just bouncing this one back for you to fix and figure out which version you want...

You got an outdated version of the patch via David's pull request. Happens. I'll fix things up and repost.