From nobody Mon Feb 9 05:40:51 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1767792362; cv=none; d=zohomail.com; s=zohoarc; b=S835hqD4xOYkaMZwsSruckPNkjYdD7uVsqzfHV6Dmc4TpkykvQQqWb1myQOZy4SFjKSSqFaUKnY6654D/POhQdXUcsTXH4oJl9DLunSogSSDRl5jESDIix+le6tmY+y0jCI1onESzpfS67epGefrpKw+j0fwr9NMPblA4jmsguM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767792362; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Resent-Date:Resent-To:References:Resent-Message-ID:Resent-From:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lfrf2Vh7y/59XVqNRaeDs87uvCGai5ZnCtsqsvw3gto=; b=nGQA1hqsmU1EkyNjj15AnjzP9kfueWRToDaoEUtyyqpIXAbZ68aSfLqlhg/NzkpgZCtTmFML44A1kgjTEqHAVzuKTr/XtaqTI/CMsxg4QD+gd55NFg+LTbnkIGkeffgK3KMCl5vvLFu8UCt4/FBItKSKw6/RVneXjciyKuclR4g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1767792362815861.2253690624714; Wed, 7 Jan 2026 05:26:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vdTXi-0001Cb-1P; Wed, 07 Jan 2026 08:25:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vdTX7-0000y1-NQ for qemu-devel@nongnu.org; Wed, 07 Jan 2026 08:25:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vdTX5-0005g4-7m for qemu-devel@nongnu.org; Wed, 07 Jan 2026 08:25:05 -0500 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-296-LZHONa8fO1eFec2UWvzQwg-1; Wed, 07 Jan 2026 08:24:57 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0D9511956058; Wed, 7 Jan 2026 13:24:56 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.45.242.32]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8544C1800285; Wed, 7 Jan 2026 13:24:55 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5CF5821E6934; Wed, 07 Jan 2026 14:24:53 +0100 (CET) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6B5C321E61BF; Wed, 07 Jan 2026 13:43:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1767792302; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-to: resent-from:resent-message-id:in-reply-to:in-reply-to: references:references; bh=lfrf2Vh7y/59XVqNRaeDs87uvCGai5ZnCtsqsvw3gto=; b=O/KKKlOeutjDGh8xRpJk/feGduVI+kypz/bwJx3rW/qub5GG4mF7OceTbyFAlEOPdJqfzQ 7pjv13j+oIV/u9hXte+/IIlqjfJ+wgbxt3nJzXR5hzZBBl9tgRPyJDQpp7X+m27C4MtI2H lTYfG7jh3rrkVm0EcCVllzu0PjcDAmE= X-MC-Unique: LZHONa8fO1eFec2UWvzQwg-1 X-Mimecast-MFC-AGG-ID: LZHONa8fO1eFec2UWvzQwg_1767792296 Resent-To: philmd@linaro.org, richard.henderson@linaro.org, qemu-devel@nongnu.org, jag.raman@oracle.com Resent-From: Markus Armbruster Resent-Date: Wed, 07 Jan 2026 14:24:53 +0100 Resent-Message-ID: <87pl7lh7x6.fsf@pond.sub.org> X-From-Line: armbru@redhat.com Wed Jan 7 13:43:41 2026 X-Original-To: armbru From: Markus Armbruster To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, Jagannathan Raman , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 15/17] error: Use error_setg_errno() for simplicity and consistency Date: Wed, 7 Jan 2026 13:43:39 +0100 Message-ID: <20260107124341.1093312-16-armbru@redhat.com> In-Reply-To: <20260107124341.1093312-1-armbru@redhat.com> References: <20260107124341.1093312-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Lines: 428 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1767792363588158500 Use error_setg_errno() instead of passing the value of strerror() or g_strerror() to error_setg(). The separator between the error message proper and the value of strerror() changes from " : ", "", " - ", "- " to ": " in places. Signed-off-by: Markus Armbruster Message-ID: <20251121121438.1249498-14-armbru@redhat.com> Acked-by: Jagannathan Raman Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- backends/spdm-socket.c | 4 ++-- backends/tpm/tpm_emulator.c | 13 +++++-------- hw/9pfs/9p.c | 3 +-- hw/acpi/core.c | 3 +-- hw/intc/openpic_kvm.c | 3 +-- hw/intc/xics_kvm.c | 5 +++-- hw/remote/vfio-user-obj.c | 18 +++++++++--------- hw/sensor/emc141x.c | 4 ++-- hw/sensor/tmp421.c | 4 ++-- hw/smbios/smbios.c | 4 ++-- hw/virtio/vdpa-dev.c | 4 ++-- migration/postcopy-ram.c | 10 +++++----- net/slirp.c | 5 +++-- qga/commands-posix-ssh.c | 23 +++++++++++++---------- system/vl.c | 2 +- target/ppc/kvm.c | 5 ++--- 16 files changed, 54 insertions(+), 56 deletions(-) diff --git a/backends/spdm-socket.c b/backends/spdm-socket.c index bc5c7afb3c..b625a65d28 100644 --- a/backends/spdm-socket.c +++ b/backends/spdm-socket.c @@ -167,7 +167,7 @@ int spdm_socket_connect(uint16_t port, Error **errp) =20 client_socket =3D socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (client_socket < 0) { - error_setg(errp, "cannot create socket: %s", strerror(errno)); + error_setg_errno(errp, errno, "cannot create socket"); return -1; } =20 @@ -179,7 +179,7 @@ int spdm_socket_connect(uint16_t port, Error **errp) =20 if (connect(client_socket, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) { - error_setg(errp, "cannot connect: %s", strerror(errno)); + error_setg_errno(errp, errno, "cannot connect"); close(client_socket); return -1; } diff --git a/backends/tpm/tpm_emulator.c b/backends/tpm/tpm_emulator.c index f10b9074fb..f52cb4d435 100644 --- a/backends/tpm/tpm_emulator.c +++ b/backends/tpm/tpm_emulator.c @@ -225,8 +225,7 @@ static int tpm_emulator_set_locality(TPMEmulator *tpm_e= mu, uint8_t locty_number, if (tpm_emulator_ctrlcmd(tpm_emu, CMD_SET_LOCALITY, &loc, sizeof(loc), sizeof(loc.u.resp.tpm_result), sizeof(loc)) < 0) { - error_setg(errp, "tpm-emulator: could not set locality : %s", - strerror(errno)); + error_setg_errno(errp, errno, "tpm-emulator: could not set localit= y"); return -1; } =20 @@ -315,8 +314,7 @@ static int tpm_emulator_stop_tpm(TPMBackend *tb, Error = **errp) =20 if (tpm_emulator_ctrlcmd(tpm_emu, CMD_STOP, &res, 0, sizeof(ptm_res), sizeof(res)) < 0) { - error_setg(errp, "tpm-emulator: Could not stop TPM: %s", - strerror(errno)); + error_setg_errno(errp, errno, "tpm-emulator: Could not stop TPM"); return -1; } =20 @@ -377,8 +375,8 @@ static int tpm_emulator_set_buffer_size(TPMBackend *tb, if (tpm_emulator_ctrlcmd(tpm_emu, CMD_SET_BUFFERSIZE, &psbs, sizeof(psbs.u.req), sizeof(psbs.u.resp.tpm_re= sult), sizeof(psbs.u.resp)) < 0) { - error_setg(errp, "tpm-emulator: Could not set buffer size: %s", - strerror(errno)); + error_setg_errno(errp, errno, + "tpm-emulator: Could not set buffer size"); return -1; } =20 @@ -426,8 +424,7 @@ static int tpm_emulator_startup_tpm_resume(TPMBackend *= tb, size_t buffersize, if (tpm_emulator_ctrlcmd(tpm_emu, CMD_INIT, &init, sizeof(init), sizeof(init.u.resp.tpm_result), sizeof(init)) < 0) { - error_setg(errp, "tpm-emulator: could not send INIT: %s", - strerror(errno)); + error_setg_errno(errp, errno, "tpm-emulator: could not send INIT"); goto err_exit; } =20 diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index bc4a016ee3..6fbe604ce8 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -4345,8 +4345,7 @@ int v9fs_device_realize_common(V9fsState *s, const V9= fsTransport *t, * use co-routines here. */ if (s->ops->name_to_path(&s->ctx, NULL, "/", &path) < 0) { - error_setg(errp, - "error in converting name to path %s", strerror(errno)); + error_setg_errno(errp, errno, "error in converting name to path"); goto out; } if (s->ops->lstat(&s->ctx, &path, &stat)) { diff --git a/hw/acpi/core.c b/hw/acpi/core.c index 4e030d8e3b..d9979b0da9 100644 --- a/hw/acpi/core.c +++ b/hw/acpi/core.c @@ -293,8 +293,7 @@ void acpi_table_add(const QemuOpts *opts, Error **errp) memcpy(blob + bloblen, data, r); bloblen +=3D r; } else if (errno !=3D EINTR) { - error_setg(errp, "can't read file %s: %s", *cur, - strerror(errno)); + error_setg_errno(errp, errno, "can't read file %s", *cur); close(fd); goto out; } diff --git a/hw/intc/openpic_kvm.c b/hw/intc/openpic_kvm.c index 9aafef5d9e..fbf0bdbe07 100644 --- a/hw/intc/openpic_kvm.c +++ b/hw/intc/openpic_kvm.c @@ -223,8 +223,7 @@ static void kvm_openpic_realize(DeviceState *dev, Error= **errp) cd.type =3D kvm_openpic_model; ret =3D kvm_vm_ioctl(s, KVM_CREATE_DEVICE, &cd); if (ret < 0) { - error_setg(errp, "Can't create device %d: %s", - cd.type, strerror(errno)); + error_setg_errno(errp, errno, "Can't create device %d", cd.type); return; } opp->fd =3D cd.fd; diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c index ee72969f5f..61f66d1019 100644 --- a/hw/intc/xics_kvm.c +++ b/hw/intc/xics_kvm.c @@ -165,8 +165,9 @@ void icp_kvm_realize(DeviceState *dev, Error **errp) if (ret < 0) { Error *local_err =3D NULL; =20 - error_setg(&local_err, "Unable to connect CPU%ld to kernel XICS: %= s", - vcpu_id, strerror(errno)); + error_setg_errno(&local_err, errno, + "Unable to connect CPU%ld to kernel XICS", + vcpu_id); if (errno =3D=3D ENOSPC) { error_append_hint(&local_err, "Try -smp maxcpus=3DN with N < %= u\n", MACHINE(qdev_get_machine())->smp.max_cpus); diff --git a/hw/remote/vfio-user-obj.c b/hw/remote/vfio-user-obj.c index 4eb036a546..12ecdab6de 100644 --- a/hw/remote/vfio-user-obj.c +++ b/hw/remote/vfio-user-obj.c @@ -751,7 +751,7 @@ static void vfu_object_init_ctx(VfuObject *o, Error **e= rrp) LIBVFIO_USER_FLAG_ATTACH_NB, o, VFU_DEV_TYPE_PCI); if (o->vfu_ctx =3D=3D NULL) { - error_setg(errp, "vfu: Failed to create context - %s", strerror(er= rno)); + error_setg_errno(errp, errno, "vfu: Failed to create context"); return; } =20 @@ -776,9 +776,9 @@ static void vfu_object_init_ctx(VfuObject *o, Error **e= rrp) =20 ret =3D vfu_pci_init(o->vfu_ctx, pci_type, PCI_HEADER_TYPE_NORMAL, 0); if (ret < 0) { - error_setg(errp, - "vfu: Failed to attach PCI device %s to context - %s", - o->device, strerror(errno)); + error_setg_errno(errp, errno, + "vfu: Failed to attach PCI device %s to context", + o->device); goto fail; } =20 @@ -792,9 +792,9 @@ static void vfu_object_init_ctx(VfuObject *o, Error **e= rrp) VFU_REGION_FLAG_RW | VFU_REGION_FLAG_ALWAYS_CB, NULL, 0, -1, 0); if (ret < 0) { - error_setg(errp, - "vfu: Failed to setup config space handlers for %s- %s", - o->device, strerror(errno)); + error_setg_errno(errp, errno, + "vfu: Failed to setup config space handlers for %= s", + o->device); goto fail; } =20 @@ -822,8 +822,8 @@ static void vfu_object_init_ctx(VfuObject *o, Error **e= rrp) =20 ret =3D vfu_realize_ctx(o->vfu_ctx); if (ret < 0) { - error_setg(errp, "vfu: Failed to realize device %s- %s", - o->device, strerror(errno)); + error_setg_errno(errp, errno, "vfu: Failed to realize device %s", + o->device); goto fail; } =20 diff --git a/hw/sensor/emc141x.c b/hw/sensor/emc141x.c index 7b2ce383a1..a51fc44395 100644 --- a/hw/sensor/emc141x.c +++ b/hw/sensor/emc141x.c @@ -59,7 +59,7 @@ static void emc141x_get_temperature(Object *obj, Visitor = *v, const char *name, unsigned tempid; =20 if (sscanf(name, "temperature%u", &tempid) !=3D 1) { - error_setg(errp, "error reading %s: %s", name, g_strerror(errno)); + error_setg_errno(errp, errno, "error reading %s", name); return; } =20 @@ -86,7 +86,7 @@ static void emc141x_set_temperature(Object *obj, Visitor = *v, const char *name, } =20 if (sscanf(name, "temperature%u", &tempid) !=3D 1) { - error_setg(errp, "error reading %s: %s", name, g_strerror(errno)); + error_setg_errno(errp, errno, "error reading %s", name); return; } =20 diff --git a/hw/sensor/tmp421.c b/hw/sensor/tmp421.c index 3421c44086..127edd0ba5 100644 --- a/hw/sensor/tmp421.c +++ b/hw/sensor/tmp421.c @@ -117,7 +117,7 @@ static void tmp421_get_temperature(Object *obj, Visitor= *v, const char *name, int tempid; =20 if (sscanf(name, "temperature%d", &tempid) !=3D 1) { - error_setg(errp, "error reading %s: %s", name, g_strerror(errno)); + error_setg_errno(errp, errno, "error reading %s", name); return; } =20 @@ -154,7 +154,7 @@ static void tmp421_set_temperature(Object *obj, Visitor= *v, const char *name, } =20 if (sscanf(name, "temperature%d", &tempid) !=3D 1) { - error_setg(errp, "error reading %s: %s", name, g_strerror(errno)); + error_setg_errno(errp, errno, "error reading %s", name); return; } =20 diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index be97a5effc..7d7141851b 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -1281,8 +1281,8 @@ static int save_opt_one(void *opaque, break; } if (ret < 0) { - error_setg(errp, "Unable to read from %s: %s", - value, strerror(errno)); + error_setg_errno(errp, errno, "Unable to read from %s", + value); qemu_close(fd); return -1; } diff --git a/hw/virtio/vdpa-dev.c b/hw/virtio/vdpa-dev.c index f2377d2d50..4532d63653 100644 --- a/hw/virtio/vdpa-dev.c +++ b/hw/virtio/vdpa-dev.c @@ -41,8 +41,8 @@ vhost_vdpa_device_get_u32(int fd, unsigned long int cmd, = Error **errp) uint32_t val =3D (uint32_t)-1; =20 if (ioctl(fd, cmd, &val) < 0) { - error_setg(errp, "vhost-vdpa-device: cmd 0x%lx failed: %s", - cmd, strerror(errno)); + error_setg_errno(errp, errno, "vhost-vdpa-device: cmd 0x%lx failed= ", + cmd); } =20 return val; diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 98a98138be..ac410676ef 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -582,7 +582,7 @@ bool postcopy_ram_supported_by_host(MigrationIncomingSt= ate *mis, Error **errp) =20 ufd =3D uffd_open(O_CLOEXEC); if (ufd =3D=3D -1) { - error_setg(errp, "Userfaultfd not available: %s", strerror(errno)); + error_setg_errno(errp, errno, "Userfaultfd not available"); goto out; } =20 @@ -620,7 +620,7 @@ bool postcopy_ram_supported_by_host(MigrationIncomingSt= ate *mis, Error **errp) * it was enabled. */ if (munlockall()) { - error_setg(errp, "munlockall() failed: %s", strerror(errno)); + error_setg_errno(errp, errno, "munlockall() failed"); goto out; } =20 @@ -632,7 +632,7 @@ bool postcopy_ram_supported_by_host(MigrationIncomingSt= ate *mis, Error **errp) testarea =3D mmap(NULL, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (testarea =3D=3D MAP_FAILED) { - error_setg(errp, "Failed to map test area: %s", strerror(errno)); + error_setg_errno(errp, errno, "Failed to map test area"); goto out; } g_assert(QEMU_PTR_IS_ALIGNED(testarea, pagesize)); @@ -642,14 +642,14 @@ bool postcopy_ram_supported_by_host(MigrationIncoming= State *mis, Error **errp) reg_struct.mode =3D UFFDIO_REGISTER_MODE_MISSING; =20 if (ioctl(ufd, UFFDIO_REGISTER, ®_struct)) { - error_setg(errp, "UFFDIO_REGISTER failed: %s", strerror(errno)); + error_setg_errno(errp, errno, "UFFDIO_REGISTER failed"); goto out; } =20 range_struct.start =3D (uintptr_t)testarea; range_struct.len =3D pagesize; if (ioctl(ufd, UFFDIO_UNREGISTER, &range_struct)) { - error_setg(errp, "UFFDIO_UNREGISTER failed: %s", strerror(errno)); + error_setg_errno(errp, errno, "UFFDIO_UNREGISTER failed"); goto out; } =20 diff --git a/net/slirp.c b/net/slirp.c index 5996fec512..04925f3318 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -1020,8 +1020,9 @@ static int slirp_smb(SlirpState* s, const char *expor= ted_dir, } =20 if (access(exported_dir, R_OK | X_OK)) { - error_setg(errp, "Error accessing shared directory '%s': %s", - exported_dir, strerror(errno)); + error_setg_errno(errp, errno, + "Error accessing shared directory '%s'", + exported_dir); return -1; } =20 diff --git a/qga/commands-posix-ssh.c b/qga/commands-posix-ssh.c index 246171d323..661972e34e 100644 --- a/qga/commands-posix-ssh.c +++ b/qga/commands-posix-ssh.c @@ -61,20 +61,22 @@ mkdir_for_user(const char *path, const struct passwd *p, mode_t mode, Error **errp) { if (g_mkdir(path, mode) =3D=3D -1) { - error_setg(errp, "failed to create directory '%s': %s", - path, g_strerror(errno)); + error_setg_errno(errp, errno, "failed to create directory '%s'", + path); return false; } =20 if (chown(path, p->pw_uid, p->pw_gid) =3D=3D -1) { - error_setg(errp, "failed to set ownership of directory '%s': %s", - path, g_strerror(errno)); + error_setg_errno(errp, errno, + "failed to set ownership of directory '%s'", + path); return false; } =20 if (chmod(path, mode) =3D=3D -1) { - error_setg(errp, "failed to set permissions of directory '%s': %s", - path, g_strerror(errno)); + error_setg_errno(errp, errno, + "failed to set permissions of directory '%s'", + path); return false; } =20 @@ -95,14 +97,15 @@ write_authkeys(const char *path, const GStrv keys, } =20 if (chown(path, p->pw_uid, p->pw_gid) =3D=3D -1) { - error_setg(errp, "failed to set ownership of directory '%s': %s", - path, g_strerror(errno)); + error_setg_errno(errp, errno, + "failed to set ownership of directory '%s'", + path); return false; } =20 if (chmod(path, 0600) =3D=3D -1) { - error_setg(errp, "failed to set permissions of '%s': %s", - path, g_strerror(errno)); + error_setg_errno(errp, errno, "failed to set permissions of '%s'", + path); return false; } =20 diff --git a/system/vl.c b/system/vl.c index b60b883050..aa9a155041 100644 --- a/system/vl.c +++ b/system/vl.c @@ -618,7 +618,7 @@ static int parse_add_fd(void *opaque, QemuOpts *opts, E= rror **errp) } #endif if (dupfd =3D=3D -1) { - error_setg(errp, "error duplicating fd: %s", strerror(errno)); + error_setg_errno(errp, errno, "error duplicating fd"); return -1; } =20 diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 3b2f1077da..1521787b3f 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -2699,9 +2699,8 @@ int kvmppc_get_htab_fd(bool write, uint64_t index, Er= ror **errp) =20 ret =3D kvm_vm_ioctl(kvm_state, KVM_PPC_GET_HTAB_FD, &s); if (ret < 0) { - error_setg(errp, "Unable to open fd for %s HPT %s KVM: %s", - write ? "writing" : "reading", write ? "to" : "from", - strerror(errno)); + error_setg_errno(errp, errno, "Unable to open fd for %s HPT %s KVM= ", + write ? "writing" : "reading", write ? "to" : "from"); return -errno; } =20 --=20 2.52.0