From nobody Fri Sep 20 22:14:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588145445; cv=none; d=zohomail.com; s=zohoarc; b=H2jNeHcYGoH1n4Wb0AYYiApDxiQI0Cn0wA9cFChHEii+r6kW777NIXhDoCg/wTKY/jwtpv/ynuAiNG1bEzipLro7/p6V9nBjcJ38TYZjorcHVVyyoUP1YCTl8H0rhYXzZqUvO1FfWPCDabLBmqHIZrVXHTgbnCIz4oxEOz3YXs8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588145445; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/q+oXi50GMupSm+7rXcjLmCi9r2gW1+YWdw23q5lev8=; b=UmyDeD/nkPWWSbqq4SOXP/piIjY23k0kS6zPNyiPpIfi7zn9N3htM8UAYSCmt68pXQi59JeEjcPj/tQQ3IcrMsjQpQHvun4X9uBpoVumxLHXEYGb76DSMtIJEQNGnk+nsoTPxyocmOjFSLM2/BunyxG9ULRrjdYqsvwEkRizB4M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158814544517164.71249678794004; Wed, 29 Apr 2020 00:30:45 -0700 (PDT) Received: from localhost ([::1]:56714 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jThB5-00077C-P3 for importer@patchew.org; Wed, 29 Apr 2020 03:30:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46216) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh22-0007u4-PT for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh1i-0003yY-Pm for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:22 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:32700 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh1h-0003uj-J3 for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:01 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-288-iGq9NqIBOYK9QgIkksfa-w-1; Wed, 29 Apr 2020 03:20:54 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8BFAE8014D9; Wed, 29 Apr 2020 07:20:53 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5B7A260BF4; Wed, 29 Apr 2020 07:20:50 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C33DA11358BD; Wed, 29 Apr 2020 09:20:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144857; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/q+oXi50GMupSm+7rXcjLmCi9r2gW1+YWdw23q5lev8=; b=JQPrT58I8/n8dWvUAYlUxTcGEsOzgX/q3YTCO18uEy5SdzlKx9LaJJLR5uIUCl++SjQrIL Gzu0Bp8fabBaMcw/IVhoLJBYYVfnUvsXNiwqQlclDaV1CIVUFWA7EQZUOnwMWFWKxAUdnD V3jA7vq87eJEGaQ+4YLIf82nPu3etqI= X-MC-Unique: iGq9NqIBOYK9QgIkksfa-w-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 01/32] various: Remove suspicious '\' character outside of #define in C code Date: Wed, 29 Apr 2020 09:20:17 +0200 Message-Id: <20200429072048.29963-2-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=205.139.110.120; envelope-from=armbru@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 01:42:37 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Philippe Mathieu-Daud=C3=A9 Fixes the following coccinelle warnings: $ spatch --sp-file --verbose-parsing ... \ scripts/coccinelle/remove_local_err.cocci ... SUSPICIOUS: a \ character appears outside of a #define at ./target/ppc/tr= anslate_init.inc.c:5213 SUSPICIOUS: a \ character appears outside of a #define at ./target/ppc/tr= anslate_init.inc.c:5261 SUSPICIOUS: a \ character appears outside of a #define at ./target/microb= laze/cpu.c:166 SUSPICIOUS: a \ character appears outside of a #define at ./target/microb= laze/cpu.c:167 SUSPICIOUS: a \ character appears outside of a #define at ./target/microb= laze/cpu.c:169 SUSPICIOUS: a \ character appears outside of a #define at ./target/microb= laze/cpu.c:170 SUSPICIOUS: a \ character appears outside of a #define at ./target/microb= laze/cpu.c:171 SUSPICIOUS: a \ character appears outside of a #define at ./target/microb= laze/cpu.c:172 SUSPICIOUS: a \ character appears outside of a #define at ./target/microb= laze/cpu.c:173 SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/c= pu.c:5787 SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/c= pu.c:5789 SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/c= pu.c:5800 SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/c= pu.c:5801 SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/c= pu.c:5802 SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/c= pu.c:5804 SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/c= pu.c:5805 SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/c= pu.c:5806 SUSPICIOUS: a \ character appears outside of a #define at ./target/i386/c= pu.c:6329 SUSPICIOUS: a \ character appears outside of a #define at ./hw/sd/sdhci.c= :1133 SUSPICIOUS: a \ character appears outside of a #define at ./hw/scsi/scsi-= disk.c:3081 SUSPICIOUS: a \ character appears outside of a #define at ./hw/net/virtio= -net.c:1529 SUSPICIOUS: a \ character appears outside of a #define at ./hw/riscv/sifi= ve_u.c:468 SUSPICIOUS: a \ character appears outside of a #define at ./dump/dump.c:1= 895 SUSPICIOUS: a \ character appears outside of a #define at ./block/vhdx.c:= 2209 SUSPICIOUS: a \ character appears outside of a #define at ./block/vhdx.c:= 2215 SUSPICIOUS: a \ character appears outside of a #define at ./block/vhdx.c:= 2221 SUSPICIOUS: a \ character appears outside of a #define at ./block/vhdx.c:= 2222 SUSPICIOUS: a \ character appears outside of a #define at ./block/replica= tion.c:172 SUSPICIOUS: a \ character appears outside of a #define at ./block/replica= tion.c:173 Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200412223619.11284-2-f4bug@amsat.org> Reviewed-by: Alistair Francis Acked-by: David Gibson Signed-off-by: Markus Armbruster --- block/replication.c | 4 ++-- block/vhdx.c | 8 ++++---- dump/dump.c | 2 +- hw/net/virtio-net.c | 2 +- hw/riscv/sifive_u.c | 2 +- hw/scsi/scsi-disk.c | 2 +- hw/sd/sdhci.c | 2 +- target/i386/cpu.c | 18 +++++++++--------- target/microblaze/cpu.c | 14 +++++++------- target/ppc/translate_init.inc.c | 4 ++-- 10 files changed, 29 insertions(+), 29 deletions(-) diff --git a/block/replication.c b/block/replication.c index da013c2041..971f0fe266 100644 --- a/block/replication.c +++ b/block/replication.c @@ -172,8 +172,8 @@ static void replication_child_perm(BlockDriverState *bs= , BdrvChild *c, if ((bs->open_flags & (BDRV_O_INACTIVE | BDRV_O_RDWR)) =3D=3D BDRV_O_R= DWR) { *nperm |=3D BLK_PERM_WRITE; } - *nshared =3D BLK_PERM_CONSISTENT_READ \ - | BLK_PERM_WRITE \ + *nshared =3D BLK_PERM_CONSISTENT_READ + | BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED; return; } diff --git a/block/vhdx.c b/block/vhdx.c index 33e57cd656..e16fdc2f2d 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -2206,20 +2206,20 @@ static QemuOptsList vhdx_create_opts =3D { .name =3D VHDX_BLOCK_OPT_BLOCK_SIZE, .type =3D QEMU_OPT_SIZE, .def_value_str =3D stringify(0), - .help =3D "Block Size; min 1MB, max 256MB. " \ + .help =3D "Block Size; min 1MB, max 256MB. " "0 means auto-calculate based on image size." }, { .name =3D BLOCK_OPT_SUBFMT, .type =3D QEMU_OPT_STRING, - .help =3D "VHDX format type, can be either 'dynamic' or 'fixed'= . "\ + .help =3D "VHDX format type, can be either 'dynamic' or 'fixed'= . " "Default is 'dynamic'." }, { .name =3D VHDX_BLOCK_OPT_ZERO, .type =3D QEMU_OPT_BOOL, - .help =3D "Force use of payload blocks of type 'ZERO'. "\ - "Non-standard, but default. Do not set to 'off' when "\ + .help =3D "Force use of payload blocks of type 'ZERO'. " + "Non-standard, but default. Do not set to 'off' when " "using 'qemu-img convert' with subformat=3Ddynamic." }, { NULL } diff --git a/dump/dump.c b/dump/dump.c index 22ed1d3b0d..248ea06370 100644 --- a/dump/dump.c +++ b/dump/dump.c @@ -1892,7 +1892,7 @@ static void dump_process(DumpState *s, Error **errp) result =3D qmp_query_dump(NULL); /* should never fail */ assert(result); - qapi_event_send_dump_completed(result, !!local_err, (local_err ? \ + qapi_event_send_dump_completed(result, !!local_err, (local_err ? error_get_pretty(local_err) : NULL)); qapi_free_DumpQueryResult(result); =20 diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index a46e3b37a7..eddfa7f923 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1526,7 +1526,7 @@ static void virtio_net_rsc_extract_unit6(VirtioNetRsc= Chain *chain, + sizeof(struct eth_header)); unit->ip =3D ip6; unit->ip_plen =3D &(ip6->ip6_ctlun.ip6_un1.ip6_un1_plen); - unit->tcp =3D (struct tcp_header *)(((uint8_t *)unit->ip)\ + unit->tcp =3D (struct tcp_header *)(((uint8_t *)unit->ip) + sizeof(struct ip6_header)); unit->tcp_hdrlen =3D (htons(unit->tcp->th_offset_flags) & 0xF000) >> 1= 0; =20 diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index 56351c4faa..998666c91f 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -465,7 +465,7 @@ static void riscv_sifive_u_machine_instance_init(Object= *obj) object_property_add_bool(obj, "start-in-flash", sifive_u_get_start_in_= flash, sifive_u_set_start_in_flash, NULL); object_property_set_description(obj, "start-in-flash", - "Set on to tell QEMU's ROM to jump to = " \ + "Set on to tell QEMU's ROM to jump to " "flash. Otherwise QEMU will jump to DR= AM", NULL); } diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 1c0cb63a6f..e5bcd0baf8 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -3078,7 +3078,7 @@ static const TypeInfo scsi_cd_info =3D { =20 #ifdef __linux__ static Property scsi_block_properties[] =3D { - DEFINE_BLOCK_ERROR_PROPERTIES(SCSIDiskState, qdev.conf), \ + DEFINE_BLOCK_ERROR_PROPERTIES(SCSIDiskState, qdev.conf), DEFINE_PROP_DRIVE("drive", SCSIDiskState, qdev.conf.blk), DEFINE_PROP_BOOL("share-rw", SCSIDiskState, qdev.conf.share_rw, false), DEFINE_PROP_UINT16("rotation_rate", SCSIDiskState, rotation_rate, 0), diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index de63ffb037..70531ad360 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -1130,7 +1130,7 @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val= , unsigned size) =20 /* Limit block size to the maximum buffer size */ if (extract32(s->blksize, 0, 12) > s->buf_maxsz) { - qemu_log_mask(LOG_GUEST_ERROR, "%s: Size 0x%x is larger than "= \ + qemu_log_mask(LOG_GUEST_ERROR, "%s: Size 0x%x is larger than " "the maximum buffer 0x%x", __func__, s->blksize, s->buf_maxsz); =20 diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 90ffc5f3b1..9c256ab159 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5784,9 +5784,9 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, = uint32_t count, host_cpuid(index, 0, eax, ebx, ecx, edx); break; } - *eax =3D (L1_DTLB_2M_ASSOC << 24) | (L1_DTLB_2M_ENTRIES << 16) | \ + *eax =3D (L1_DTLB_2M_ASSOC << 24) | (L1_DTLB_2M_ENTRIES << 16) | (L1_ITLB_2M_ASSOC << 8) | (L1_ITLB_2M_ENTRIES); - *ebx =3D (L1_DTLB_4K_ASSOC << 24) | (L1_DTLB_4K_ENTRIES << 16) | \ + *ebx =3D (L1_DTLB_4K_ASSOC << 24) | (L1_DTLB_4K_ENTRIES << 16) | (L1_ITLB_4K_ASSOC << 8) | (L1_ITLB_4K_ENTRIES); *ecx =3D encode_cache_cpuid80000005(env->cache_info_amd.l1d_cache); *edx =3D encode_cache_cpuid80000005(env->cache_info_amd.l1i_cache); @@ -5797,13 +5797,13 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index= , uint32_t count, host_cpuid(index, 0, eax, ebx, ecx, edx); break; } - *eax =3D (AMD_ENC_ASSOC(L2_DTLB_2M_ASSOC) << 28) | \ - (L2_DTLB_2M_ENTRIES << 16) | \ - (AMD_ENC_ASSOC(L2_ITLB_2M_ASSOC) << 12) | \ + *eax =3D (AMD_ENC_ASSOC(L2_DTLB_2M_ASSOC) << 28) | + (L2_DTLB_2M_ENTRIES << 16) | + (AMD_ENC_ASSOC(L2_ITLB_2M_ASSOC) << 12) | (L2_ITLB_2M_ENTRIES); - *ebx =3D (AMD_ENC_ASSOC(L2_DTLB_4K_ASSOC) << 28) | \ - (L2_DTLB_4K_ENTRIES << 16) | \ - (AMD_ENC_ASSOC(L2_ITLB_4K_ASSOC) << 12) | \ + *ebx =3D (AMD_ENC_ASSOC(L2_DTLB_4K_ASSOC) << 28) | + (L2_DTLB_4K_ENTRIES << 16) | + (AMD_ENC_ASSOC(L2_ITLB_4K_ASSOC) << 12) | (L2_ITLB_4K_ENTRIES); encode_cache_cpuid80000006(env->cache_info_amd.l2_cache, cpu->enable_l3_cache ? @@ -6326,7 +6326,7 @@ static void x86_cpu_expand_features(X86CPU *cpu, Erro= r **errp) */ env->features[w] |=3D x86_cpu_get_supported_feature_word(w, cpu->migratable) & - ~env->user_features[w] & \ + ~env->user_features[w] & ~feature_word_info[w].no_autoenable_flags; } } diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index a2c2f271df..c9cf2364ca 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -163,14 +163,14 @@ static void mb_cpu_realizefn(DeviceState *dev, Error = **errp) =20 qemu_init_vcpu(cs); =20 - env->pvr.regs[0] =3D PVR0_USE_EXC_MASK \ - | PVR0_USE_ICACHE_MASK \ + env->pvr.regs[0] =3D PVR0_USE_EXC_MASK + | PVR0_USE_ICACHE_MASK | PVR0_USE_DCACHE_MASK; - env->pvr.regs[2] =3D PVR2_D_OPB_MASK \ - | PVR2_D_LMB_MASK \ - | PVR2_I_OPB_MASK \ - | PVR2_I_LMB_MASK \ - | PVR2_FPU_EXC_MASK \ + env->pvr.regs[2] =3D PVR2_D_OPB_MASK + | PVR2_D_LMB_MASK + | PVR2_I_OPB_MASK + | PVR2_I_LMB_MASK + | PVR2_FPU_EXC_MASK | 0; =20 version =3D cpu->cfg.version ? cpu->cfg.version : DEFAULT_CPU_VERSION; diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.in= c.c index e853164a86..fd763e588e 100644 --- a/target/ppc/translate_init.inc.c +++ b/target/ppc/translate_init.inc.c @@ -5210,7 +5210,7 @@ POWERPC_FAMILY(e5500)(ObjectClass *oc, void *data) PPC_FLOAT_STFIWX | PPC_WAIT | PPC_MEM_TLBSYNC | PPC_TLBIVAX | PPC_MEM_SYNC | PPC_64B | PPC_POPCNTB | PPC_POPCNTWD; - pcc->insns_flags2 =3D PPC2_BOOKE206 | PPC2_PRCNTL | PPC2_PERM_ISA206 |= \ + pcc->insns_flags2 =3D PPC2_BOOKE206 | PPC2_PRCNTL | PPC2_PERM_ISA206 | PPC2_FP_CVT_S64; pcc->msr_mask =3D (1ull << MSR_CM) | (1ull << MSR_GS) | @@ -5258,7 +5258,7 @@ POWERPC_FAMILY(e6500)(ObjectClass *oc, void *data) PPC_FLOAT_STFIWX | PPC_WAIT | PPC_MEM_TLBSYNC | PPC_TLBIVAX | PPC_MEM_SYNC | PPC_64B | PPC_POPCNTB | PPC_POPCNTWD | PPC_ALTIVEC; - pcc->insns_flags2 =3D PPC2_BOOKE206 | PPC2_PRCNTL | PPC2_PERM_ISA206 |= \ + pcc->insns_flags2 =3D PPC2_BOOKE206 | PPC2_PRCNTL | PPC2_PERM_ISA206 | PPC2_FP_CVT_S64 | PPC2_ATOMIC_ISA206; pcc->msr_mask =3D (1ull << MSR_CM) | (1ull << MSR_GS) | --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588145195; cv=none; d=zohomail.com; s=zohoarc; b=Sd5HEHd4CjwWNwABN1Lh7pxPWE1cQsmmMkt2QHdaQg7V/3JjexK9x9DuwY4BgPgWr7BPyEeWP9kzg46wjPYiln5JQi3MsX0A+Kyi7pzUqtoIWSAXpX7dcMd8+bgOfyqGO6ybJx8K2oXkNWiPdaYATp3lJbDr7e0cPxzU3jue1YU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588145195; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pJdX+A1mES63QPyAbifOauLBYN0jMpBgWHmzfmjgvzc=; b=bOfabWc50NhDF3nA+BU3j+mcDLvE4yd6FMcDp30uJUyTKaXkpEIVmCl2ba9QqGj7XHpFIP0+8DJwI1kN5fv7R3g8EaQVj6+2BAy9kiHnUgJ3vJp33FzpqMjZqCFWUpTTWKUIqEUXNPr961DpsWrYeXauZtkXqrrVzAMkL7dic/Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588145195626166.3776757753675; Wed, 29 Apr 2020 00:26:35 -0700 (PDT) Received: from localhost ([::1]:39920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh74-00008H-CG for importer@patchew.org; Wed, 29 Apr 2020 03:26:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46112) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh1n-0007tN-In for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh1c-0003tS-03 for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:07 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:26660 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh1b-0003q8-C6 for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:20:55 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-368-FpGMlk_RMvyJXONHIULWQg-1; Wed, 29 Apr 2020 03:20:51 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9BFAA1895A28 for ; Wed, 29 Apr 2020 07:20:50 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6A87127CC4; Wed, 29 Apr 2020 07:20:50 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C5FF811358BE; Wed, 29 Apr 2020 09:20:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144853; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pJdX+A1mES63QPyAbifOauLBYN0jMpBgWHmzfmjgvzc=; b=ORR6jnQkDRqREJ7xbm6bc1QGrDAHOgxo4PRUisoFckRTYrXya7B2uiYZjd4F1cHg1PstiZ l6QHeHlnW9jEo1jWKDg/uq9E/FuFb84n7ObBgKFnCRrhhOATnExVNXNJHBEMgbq0Ikg4GU lEXUtn7uRPQbwriFi23g5Zw1RQ/XTh4= X-MC-Unique: FpGMlk_RMvyJXONHIULWQg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 02/32] tests-qemu-opts: Cover has_help_option(), qemu_opt_has_help_opt() Date: Wed, 29 Apr 2020 09:20:18 +0200 Message-Id: <20200429072048.29963-3-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=205.139.110.120; envelope-from=armbru@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 01:42:37 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The two turn out to be inconsistent for "a,b,,help". Test case marked /* BUG */. Signed-off-by: Markus Armbruster Message-Id: <20200415074927.19897-2-armbru@redhat.com> Reviewed-by: Eric Blake --- tests/test-qemu-opts.c | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/tests/test-qemu-opts.c b/tests/test-qemu-opts.c index ef96e84aed..88a3e7bdf4 100644 --- a/tests/test-qemu-opts.c +++ b/tests/test-qemu-opts.c @@ -728,6 +728,49 @@ static void test_opts_parse_size(void) qemu_opts_reset(&opts_list_02); } =20 +static void test_has_help_option(void) +{ + static const struct { + const char *params; + /* expected value of has_help_option() */ + bool expect_has_help_option; + /* expected value of qemu_opt_has_help_opt() with implied=3Dfalse = */ + bool expect_opt_has_help_opt; + /* expected value of qemu_opt_has_help_opt() with implied=3Dtrue */ + bool expect_opt_has_help_opt_implied; + } test[] =3D { + { "help", true, true, false }, + { "?", true, true, false }, + { "helpme", false, false, false }, + { "?me", false, false, false }, + { "a,help", true, true, true }, + { "a,?", true, true, true }, + { "a=3D0,help,b", true, true, true }, + { "a=3D0,?,b", true, true, true }, + { "help,b=3D1", true, true, false }, + { "?,b=3D1", true, true, false }, + { "a,b,,help", false /* BUG */, true, true }, + { "a,b,,?", false /* BUG */, true, true }, + }; + int i; + QemuOpts *opts; + + for (i =3D 0; i < ARRAY_SIZE(test); i++) { + g_assert_cmpint(has_help_option(test[i].params), + =3D=3D, test[i].expect_has_help_option); + opts =3D qemu_opts_parse(&opts_list_03, test[i].params, false, + &error_abort); + g_assert_cmpint(qemu_opt_has_help_opt(opts), + =3D=3D, test[i].expect_opt_has_help_opt); + qemu_opts_del(opts); + opts =3D qemu_opts_parse(&opts_list_03, test[i].params, true, + &error_abort); + g_assert_cmpint(qemu_opt_has_help_opt(opts), + =3D=3D, test[i].expect_opt_has_help_opt_implied); + qemu_opts_del(opts); + } +} + static void append_verify_list_01(QemuOptDesc *desc, bool with_overlapping) { int i =3D 0; @@ -990,6 +1033,7 @@ int main(int argc, char *argv[]) g_test_add_func("/qemu-opts/opts_parse/bool", test_opts_parse_bool); g_test_add_func("/qemu-opts/opts_parse/number", test_opts_parse_number= ); g_test_add_func("/qemu-opts/opts_parse/size", test_opts_parse_size); + g_test_add_func("/qemu-opts/has_help_option", test_has_help_option); g_test_add_func("/qemu-opts/append_to_null", test_opts_append_to_null); g_test_add_func("/qemu-opts/append", test_opts_append); g_test_add_func("/qemu-opts/to_qdict/basic", test_opts_to_qdict_basic); --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588144999; cv=none; d=zohomail.com; s=zohoarc; b=H4h/OXWR08TDWEj5RWmF4IXbH/wqbrqkgscI7MSKN6adUefK3xDXFwcvSnB6MKJrjuDVL2dmzVgsd+RCOM5m0GxW6xysGsPjaWyJ55LLnwGq4sfSAh1McaCXZQ0QAmPxdnWtbf0bF852KHal8F4Dc1is09ETdSZfHJQaa+FtAUQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588144999; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eT+R0I/VElMw3JWqlTxOEPXFaLiuh2Ap2kR+8RrELrE=; b=imk176tqn9+KAWB6fIYOiZVxdR6N/XFGNmzijwKp3owGNxf04Dk7QHt2Lkm6/CGPBn0y/epB/y7F9o0ELzVcOPMu3Y+Hr+ngXz3cXQG/hrOMKD31XGiSFmr3tyZImQzweWmjD93QEOXsLWZYKNLCfJYqM5XVXjR5h8BXA8S6zUc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588144999800796.1232974897599; Wed, 29 Apr 2020 00:23:19 -0700 (PDT) Received: from localhost ([::1]:51104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh3u-0001G4-2L for importer@patchew.org; Wed, 29 Apr 2020 03:23:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46130) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh1p-0007tQ-3i for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh1c-0003tb-0V for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:08 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:30876 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh1b-0003qF-Bg for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:20:55 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-428-JI5jaD9AOxuCaPvbR1R_jw-1; Wed, 29 Apr 2020 03:20:51 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9BD79107ACCD for ; Wed, 29 Apr 2020 07:20:50 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6A7B95D715; Wed, 29 Apr 2020 07:20:50 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C8E4C11358BF; Wed, 29 Apr 2020 09:20:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144853; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eT+R0I/VElMw3JWqlTxOEPXFaLiuh2Ap2kR+8RrELrE=; b=OCB9f5+3EOOctKAlC283MpCKDmGimcUCMD4ATv95Vc/NBkTWb7ZgrUpeeNbYuYnRW1wjD4 tUDwNj36rhG/g4z1HmK1TFys3IIjWxFZ6zyTi7NxqJlS1lblftowiZ4dt1qfjYX5Tcfupw sn/vKZxkzJ4+El5IebMbqdn2j6K90ck= X-MC-Unique: JI5jaD9AOxuCaPvbR1R_jw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 03/32] qemu-options: Factor out get_opt_name_value() helper Date: Wed, 29 Apr 2020 09:20:19 +0200 Message-Id: <20200429072048.29963-4-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=205.139.110.120; envelope-from=armbru@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 01:42:37 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The next commits will put it to use. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Kevin Wolf Message-Id: <20200415074927.19897-3-armbru@redhat.com> --- util/qemu-option.c | 102 +++++++++++++++++++++++++-------------------- 1 file changed, 56 insertions(+), 46 deletions(-) diff --git a/util/qemu-option.c b/util/qemu-option.c index 97172b5eaa..f08f4bc458 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -805,61 +805,71 @@ void qemu_opts_print(QemuOpts *opts, const char *sepa= rator) } } =20 +static const char *get_opt_name_value(const char *params, + const char *firstname, + char **name, char **value) +{ + const char *p, *pe, *pc; + + pe =3D strchr(params, '=3D'); + pc =3D strchr(params, ','); + + if (!pe || (pc && pc < pe)) { + /* found "foo,more" */ + if (firstname) { + /* implicitly named first option */ + *name =3D g_strdup(firstname); + p =3D get_opt_value(params, value); + } else { + /* option without value, must be a flag */ + p =3D get_opt_name(params, name, ','); + if (strncmp(*name, "no", 2) =3D=3D 0) { + memmove(*name, *name + 2, strlen(*name + 2) + 1); + *value =3D g_strdup("off"); + } else { + *value =3D g_strdup("on"); + } + } + } else { + /* found "foo=3Dbar,more" */ + p =3D get_opt_name(params, name, '=3D'); + assert(*p =3D=3D '=3D'); + p++; + p =3D get_opt_value(p, value); + } + + assert(!*p || *p =3D=3D ','); + if (*p =3D=3D ',') { + p++; + } + return p; +} + static void opts_do_parse(QemuOpts *opts, const char *params, const char *firstname, bool prepend, bool *invalidp, Error **errp) { - char *option =3D NULL; - char *value =3D NULL; - const char *p,*pe,*pc; Error *local_err =3D NULL; + char *option, *value; + const char *p; =20 - for (p =3D params; *p !=3D '\0'; p++) { - pe =3D strchr(p, '=3D'); - pc =3D strchr(p, ','); - if (!pe || (pc && pc < pe)) { - /* found "foo,more" */ - if (p =3D=3D params && firstname) { - /* implicitly named first option */ - option =3D g_strdup(firstname); - p =3D get_opt_value(p, &value); - } else { - /* option without value, probably a flag */ - p =3D get_opt_name(p, &option, ','); - if (strncmp(option, "no", 2) =3D=3D 0) { - memmove(option, option+2, strlen(option+2)+1); - value =3D g_strdup("off"); - } else { - value =3D g_strdup("on"); - } - } - } else { - /* found "foo=3Dbar,more" */ - p =3D get_opt_name(p, &option, '=3D'); - assert(*p =3D=3D '=3D'); - p++; - p =3D get_opt_value(p, &value); - } - if (strcmp(option, "id") !=3D 0) { - /* store and parse */ - opt_set(opts, option, value, prepend, invalidp, &local_err); - value =3D NULL; - if (local_err) { - error_propagate(errp, local_err); - goto cleanup; - } - } - if (*p !=3D ',') { - break; + for (p =3D params; *p;) { + p =3D get_opt_name_value(p, firstname, &option, &value); + firstname =3D NULL; + + if (!strcmp(option, "id")) { + g_free(option); + g_free(value); + continue; } + + opt_set(opts, option, value, prepend, invalidp, &local_err); g_free(option); - g_free(value); - option =3D value =3D NULL; + if (local_err) { + error_propagate(errp, local_err); + return; + } } - - cleanup: - g_free(option); - g_free(value); } =20 /** --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588145093; cv=none; d=zohomail.com; s=zohoarc; b=mdb0DkXKK02EhvSt4xTKNi46VYi2LzaYucuqsEvMgmhKxCPRrP2WrTft9gNdGvHqdgWVAwAYznEel+svMwgkwphqKbrzZ0dSaYTANasfKBo6hkyxy5/rhtlxDZKwTSmgyrHl0277io09t+DMxmv7tDsuJM52DR0Nb6FdG2sFrFM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588145093; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PPD7lNvI/SDnbRnovak9k9THltlmpEMwSUgo+tpzTEw=; b=JI/ck1OOw4dLDDTwuIbnLphbbgtfnsrlrXYx7PPxgelUUsBbTMiXL/a8NfFuKouXJ80fOYtS5Uw8mbA1NX8Qnmq7Wnl7+D3pLMBYZfz+B5xD9fDKPipzM5QSGJktx1h7yb6A8O2PZ0j6RZsaP8aXZpnYK2xboWM+eSsZllQKEdU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588145093400391.1663884277792; Wed, 29 Apr 2020 00:24:53 -0700 (PDT) Received: from localhost ([::1]:59688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh5Q-0004kd-5I for importer@patchew.org; Wed, 29 Apr 2020 03:24:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46094) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh1k-0007tE-O7 for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh1b-0003t3-Vj for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:04 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:27377 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh1b-0003qB-Bn for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:20:55 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-337-sI8aPHUuNEK7ZjoV4yiFtg-1; Wed, 29 Apr 2020 03:20:51 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A120680058A for ; Wed, 29 Apr 2020 07:20:50 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6B15D648C8; Wed, 29 Apr 2020 07:20:50 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id CD95C11358C0; Wed, 29 Apr 2020 09:20:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144853; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PPD7lNvI/SDnbRnovak9k9THltlmpEMwSUgo+tpzTEw=; b=gLtccPIVPvustBe3mR3/FT8ZTIIZke7tr/1RxEfsgPw4Lb4fFZHs11mFem3h33tvxtsReI 7POzoiS8qVF4y07F3xCOSMIiHQaCw6ncxRDlluWSFVikOOckqF+5KQso8FoYPotSMOws1h UM0ABWzoC4EIyWBQ7WsIZoriQTyK4O0= X-MC-Unique: sI8aPHUuNEK7ZjoV4yiFtg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 04/32] qemu-option: Fix sloppy recognition of "id=..." after ", , " Date: Wed, 29 Apr 2020 09:20:20 +0200 Message-Id: <20200429072048.29963-5-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=207.211.31.120; envelope-from=armbru@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 01:18:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Kevin Wolf Message-Id: <20200415074927.19897-4-armbru@redhat.com> --- tests/test-qemu-opts.c | 4 ++-- util/qemu-option.c | 27 +++++++++++++++++++-------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/tests/test-qemu-opts.c b/tests/test-qemu-opts.c index 88a3e7bdf4..8ff97268d8 100644 --- a/tests/test-qemu-opts.c +++ b/tests/test-qemu-opts.c @@ -500,10 +500,10 @@ static void test_opts_parse(void) g_assert(!opts); /* TODO Cover .merge_lists =3D true */ =20 - /* Buggy ID recognition */ + /* Buggy ID recognition (fixed) */ opts =3D qemu_opts_parse(&opts_list_03, "x=3D,,id=3Dbar", false, &erro= r_abort); g_assert_cmpuint(opts_count(opts), =3D=3D, 1); - g_assert_cmpstr(qemu_opts_id(opts), =3D=3D, "bar"); /* BUG */ + g_assert(!qemu_opts_id(opts)); g_assert_cmpstr(qemu_opt_get(opts, "x"), =3D=3D, ",id=3Dbar"); =20 /* Anti-social ID */ diff --git a/util/qemu-option.c b/util/qemu-option.c index f08f4bc458..d2956082bd 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -872,6 +872,24 @@ static void opts_do_parse(QemuOpts *opts, const char *= params, } } =20 +static char *opts_parse_id(const char *params) +{ + const char *p; + char *name, *value; + + for (p =3D params; *p;) { + p =3D get_opt_name_value(p, NULL, &name, &value); + if (!strcmp(name, "id")) { + g_free(name); + return value; + } + g_free(name); + g_free(value); + } + + return NULL; +} + /** * Store options parsed from @params into @opts. * If @firstname is non-null, the first key=3Dvalue in @params may omit @@ -889,20 +907,13 @@ static QemuOpts *opts_parse(QemuOptsList *list, const= char *params, bool *invalidp, Error **errp) { const char *firstname; - char *id =3D NULL; - const char *p; + char *id =3D opts_parse_id(params); QemuOpts *opts; Error *local_err =3D NULL; =20 assert(!permit_abbrev || list->implied_opt_name); firstname =3D permit_abbrev ? list->implied_opt_name : NULL; =20 - if (strncmp(params, "id=3D", 3) =3D=3D 0) { - get_opt_value(params + 3, &id); - } else if ((p =3D strstr(params, ",id=3D")) !=3D NULL) { - get_opt_value(p + 4, &id); - } - /* * This code doesn't work for defaults && !list->merge_lists: when * params has no id=3D, and list has an element with !opts->id, it --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588145092; cv=none; d=zohomail.com; s=zohoarc; b=hllRUSePM9m+no058wFKgcNZWzrE93pzeI31LOMOHxXZ/7Z1M02RazJ6HqQa9fkLXMZcjgPmiHaAdroQC1CIw7mEFCRR4M20mGUMhmWRpABO6m2eB8P4GeppKRn/DSy0vjvycGsCWQr11du7n0cvdr4IxQE4qN5yGA8heackiSM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588145092; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gvZkIdBVh8QKF8y067AWLV4BFTfiAafKj00YpLmPNpA=; b=j2tKn+fzdflUYqqjeg5wbPUfz2cmKBMzieCwgdLfN6PLrhmpWJo9u48Rhx9l/hrIbpLw2A1T+2dDr9NTgEdwWVEgMmJ9nON20g4ZQIywgM/NHkF4uWWKfTZg3T/MTEbzxD59aDBR4aZmRVDs6aKmUokZsEF1ivE0JF9cpOUXfKg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588145092728577.702532358355; Wed, 29 Apr 2020 00:24:52 -0700 (PDT) Received: from localhost ([::1]:59604 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh5P-0004iZ-Cm for importer@patchew.org; Wed, 29 Apr 2020 03:24:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46124) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh1o-0007tP-3H for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh1c-0003tM-0d for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:07 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:55655 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh1b-0003qR-FV for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:20:55 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-378-BAMPB_m9PR2xfeAZaX-GFQ-1; Wed, 29 Apr 2020 03:20:52 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 213971009444 for ; Wed, 29 Apr 2020 07:20:52 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E4FC060C18; Wed, 29 Apr 2020 07:20:51 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id D26AF11358C1; Wed, 29 Apr 2020 09:20:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144854; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gvZkIdBVh8QKF8y067AWLV4BFTfiAafKj00YpLmPNpA=; b=W3xxClDRRGefy8O2IDJIvpei1PTMtBwQqqgedzM0Uh4106jFANB8XTt47PRcC7osbdUyfa b56qer52PgAbTU7PifI9hiX+zJ8Yg50Wdwj+J7rImv14RHkfQjQdb7qpZkPJbsW6YKLlrk T67obI9phIRAAofVbXIbDlf3FhHL91U= X-MC-Unique: BAMPB_m9PR2xfeAZaX-GFQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 05/32] qemu-option: Fix has_help_option()'s sloppy parsing Date: Wed, 29 Apr 2020 09:20:21 +0200 Message-Id: <20200429072048.29963-6-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=205.139.110.120; envelope-from=armbru@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 01:42:37 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" has_help_option() uses its own parser. It's inconsistent with qemu_opts_parse(), as demonstrated by test-qemu-opts case /qemu-opts/has_help_option. Fix by reusing the common parser. Signed-off-by: Markus Armbruster Message-Id: <20200415074927.19897-5-armbru@redhat.com> Reviewed-by: Eric Blake --- tests/test-qemu-opts.c | 4 ++-- util/qemu-option.c | 39 +++++++++++++++++++-------------------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/tests/test-qemu-opts.c b/tests/test-qemu-opts.c index 8ff97268d8..77c944c4aa 100644 --- a/tests/test-qemu-opts.c +++ b/tests/test-qemu-opts.c @@ -749,8 +749,8 @@ static void test_has_help_option(void) { "a=3D0,?,b", true, true, true }, { "help,b=3D1", true, true, false }, { "?,b=3D1", true, true, false }, - { "a,b,,help", false /* BUG */, true, true }, - { "a,b,,?", false /* BUG */, true, true }, + { "a,b,,help", true, true, true }, + { "a,b,,?", true, true, true }, }; int i; QemuOpts *opts; diff --git a/util/qemu-option.c b/util/qemu-option.c index d2956082bd..0abf26b61f 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -165,26 +165,6 @@ void parse_option_size(const char *name, const char *v= alue, *ret =3D size; } =20 -bool has_help_option(const char *param) -{ - const char *p =3D param; - bool result =3D false; - - while (*p && !result) { - char *value; - - p =3D get_opt_value(p, &value); - if (*p) { - p++; - } - - result =3D is_help_option(value); - g_free(value); - } - - return result; -} - bool is_valid_option_list(const char *p) { char *value =3D NULL; @@ -890,6 +870,25 @@ static char *opts_parse_id(const char *params) return NULL; } =20 +bool has_help_option(const char *params) +{ + const char *p; + char *name, *value; + bool ret; + + for (p =3D params; *p;) { + p =3D get_opt_name_value(p, NULL, &name, &value); + ret =3D is_help_option(name); + g_free(name); + g_free(value); + if (ret) { + return true; + } + } + + return false; +} + /** * Store options parsed from @params into @opts. * If @firstname is non-null, the first key=3Dvalue in @params may omit --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588145197; cv=none; d=zohomail.com; s=zohoarc; b=e3QY4ZfuR+E+KNmovU1ODOYVYG6J8uEik1PP0DAwlTc5OcYdC9gJzLyxBkUjoha7AbFHFfKlW6yd83zLsx+U23EJ0q5462gw8jM5hwVGD/zy1IbhB9uDCm2mCyuWv9iaRam1NS6Jsy1CrkhbsQN+9wxjBoDfoUYN35FBWXiyeuw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588145197; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vopO6icJU9oW0OXatkyCDGGFzRbzqNq0XdIne6fEN/A=; b=OEJjLOPtzNSiD1Fmo0YWpqtSqi5Ikh5iyRidKGzVpup7SSQbstILCGG4BUOIfBxpIeRfvru4r884pm/hoh9JV66SWGhoiw5s9lUiVFXGEKTsFMjwPjV7gWMPt2GAAUpK7aFYP40pfeGzN0En7BBOpqxzk5HMT9INYQfdWkTYbI0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588145197985273.09930777267834; Wed, 29 Apr 2020 00:26:37 -0700 (PDT) Received: from localhost ([::1]:40034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh76-0000BO-PH for importer@patchew.org; Wed, 29 Apr 2020 03:26:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46156) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh1u-0007td-Vh for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh1g-0003wA-8E for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:14 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:43451 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh1f-0003sS-PC for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:20:59 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-36-UGhf8HR7N0-yILQXflHapQ-1; Wed, 29 Apr 2020 03:20:52 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 24894801503 for ; Wed, 29 Apr 2020 07:20:52 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E6E115D9E8; Wed, 29 Apr 2020 07:20:51 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id D588C11358C2; Wed, 29 Apr 2020 09:20:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144855; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vopO6icJU9oW0OXatkyCDGGFzRbzqNq0XdIne6fEN/A=; b=Q9T1yIIL8B0/qnjAi64X9SQyQ8qv5rElJ9xw70/rJC4ulw4YY+6jKJnkTkp7hftcC+2arI 9Dkgw0EZbIE9VVsHQSOoAtXZMoqTbqcVFl7OfMPbBuKJliYnKUAIoDHAhAq8HHl1XwMGx4 7m436YrVgHu44KR60k3cmMzKB0T03Gs= X-MC-Unique: UGhf8HR7N0-yILQXflHapQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 06/32] test-qemu-opts: Simplify test_has_help_option() after bug fix Date: Wed, 29 Apr 2020 09:20:22 +0200 Message-Id: <20200429072048.29963-7-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=205.139.110.61; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 00:53:13 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Kevin Wolf Message-Id: <20200415074927.19897-6-armbru@redhat.com> --- tests/test-qemu-opts.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/tests/test-qemu-opts.c b/tests/test-qemu-opts.c index 77c944c4aa..2a0f42a09b 100644 --- a/tests/test-qemu-opts.c +++ b/tests/test-qemu-opts.c @@ -732,41 +732,39 @@ static void test_has_help_option(void) { static const struct { const char *params; - /* expected value of has_help_option() */ - bool expect_has_help_option; /* expected value of qemu_opt_has_help_opt() with implied=3Dfalse = */ - bool expect_opt_has_help_opt; + bool expect; /* expected value of qemu_opt_has_help_opt() with implied=3Dtrue */ - bool expect_opt_has_help_opt_implied; + bool expect_implied; } test[] =3D { - { "help", true, true, false }, - { "?", true, true, false }, - { "helpme", false, false, false }, - { "?me", false, false, false }, - { "a,help", true, true, true }, - { "a,?", true, true, true }, - { "a=3D0,help,b", true, true, true }, - { "a=3D0,?,b", true, true, true }, - { "help,b=3D1", true, true, false }, - { "?,b=3D1", true, true, false }, - { "a,b,,help", true, true, true }, - { "a,b,,?", true, true, true }, + { "help", true, false }, + { "?", true, false }, + { "helpme", false, false }, + { "?me", false, false }, + { "a,help", true, true }, + { "a,?", true, true }, + { "a=3D0,help,b", true, true }, + { "a=3D0,?,b", true, true }, + { "help,b=3D1", true, false }, + { "?,b=3D1", true, false }, + { "a,b,,help", true, true }, + { "a,b,,?", true, true }, }; int i; QemuOpts *opts; =20 for (i =3D 0; i < ARRAY_SIZE(test); i++) { g_assert_cmpint(has_help_option(test[i].params), - =3D=3D, test[i].expect_has_help_option); + =3D=3D, test[i].expect); opts =3D qemu_opts_parse(&opts_list_03, test[i].params, false, &error_abort); g_assert_cmpint(qemu_opt_has_help_opt(opts), - =3D=3D, test[i].expect_opt_has_help_opt); + =3D=3D, test[i].expect); qemu_opts_del(opts); opts =3D qemu_opts_parse(&opts_list_03, test[i].params, true, &error_abort); g_assert_cmpint(qemu_opt_has_help_opt(opts), - =3D=3D, test[i].expect_opt_has_help_opt_implied); + =3D=3D, test[i].expect_implied); qemu_opts_del(opts); } } --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588145003; cv=none; d=zohomail.com; s=zohoarc; b=HQ/f7Vw/LUDEbKzzDwPUpD+7qlZO7pE/PrxNM9LCrNoDZuPjMSAX25Vp6Fp7vgFBm+NGucHaflhEQ+3tAyKJ2pReHtCHe4HLJQaDzThAL5scMqIeONtFwpFvsOfPFjywb6EjnshlxBSM8jpfJJ2s/yrXO3Oav0tdGVmOdSZH6Iw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588145003; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WFwTmY5izH7vt1PFzmbOpOPKretwC0f3JKTKzMM1H/Y=; b=g4EM5VwaMVJwY/nBJwSzPq1nmNUoKIC6wigIAKVYN+YQolU0fE76MlH8dBRIEKn5ZdhaikS9qyiXHPtuR8AE+AdxBWaqClu4iPEvIVzHB2R/ZavgwtPsXzt6haADlVffXY38pBluxG3P1lzRo48g/WgsApRzxEH7bz3U1A8/dXc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588145003301159.72615096405855; Wed, 29 Apr 2020 00:23:23 -0700 (PDT) Received: from localhost ([::1]:51548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh3x-0001Qv-VJ for importer@patchew.org; Wed, 29 Apr 2020 03:23:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46146) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh1t-0007ta-Kr for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh1c-0003uA-DR for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:13 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:41392 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh1b-0003qV-Vn for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:20:56 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-36-zpFDKbq9PCyPSXJHuJBrhg-1; Wed, 29 Apr 2020 03:20:52 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 265A3BFC3 for ; Wed, 29 Apr 2020 07:20:52 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E9EC9648C8; Wed, 29 Apr 2020 07:20:51 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id D984B11358C3; Wed, 29 Apr 2020 09:20:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144854; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WFwTmY5izH7vt1PFzmbOpOPKretwC0f3JKTKzMM1H/Y=; b=MUt1L/rKGkcWmajys6VCZRuDnc6KHk+RB5MU1qo0QACmFkg/0BV9gQalf8jd4sFz12BXAD FtMm+B1ASp+3M1TSyxAXKSsxU8fuKy56ssVae/GkvVAlGkGFGLPR0g4E5T+tVRSXobLzXo MfImfLN1CIatsBnHGKOn5ewRhWqLaGU= X-MC-Unique: zpFDKbq9PCyPSXJHuJBrhg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 07/32] qemu-option: Avoid has_help_option() in qemu_opts_parse_noisily() Date: Wed, 29 Apr 2020 09:20:23 +0200 Message-Id: <20200429072048.29963-8-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=205.139.110.61; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 00:53:13 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" When opts_parse() sets @invalidp to true, qemu_opts_parse_noisily() uses has_help_option() to decide whether to print help. This parses the input string a second time. Easy to avoid: replace @invalidp by @help_wanted. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <20200415074927.19897-7-armbru@redhat.com> --- util/qemu-option.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/util/qemu-option.c b/util/qemu-option.c index 0abf26b61f..2d0d24ee27 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -519,7 +519,7 @@ int qemu_opt_unset(QemuOpts *opts, const char *name) } =20 static void opt_set(QemuOpts *opts, const char *name, char *value, - bool prepend, bool *invalidp, Error **errp) + bool prepend, bool *help_wanted, Error **errp) { QemuOpt *opt; const QemuOptDesc *desc; @@ -529,8 +529,8 @@ static void opt_set(QemuOpts *opts, const char *name, c= har *value, if (!desc && !opts_accepts_any(opts)) { g_free(value); error_setg(errp, QERR_INVALID_PARAMETER, name); - if (invalidp) { - *invalidp =3D true; + if (help_wanted && is_help_option(name)) { + *help_wanted =3D true; } return; } @@ -827,7 +827,7 @@ static const char *get_opt_name_value(const char *param= s, =20 static void opts_do_parse(QemuOpts *opts, const char *params, const char *firstname, bool prepend, - bool *invalidp, Error **errp) + bool *help_wanted, Error **errp) { Error *local_err =3D NULL; char *option, *value; @@ -843,7 +843,7 @@ static void opts_do_parse(QemuOpts *opts, const char *p= arams, continue; } =20 - opt_set(opts, option, value, prepend, invalidp, &local_err); + opt_set(opts, option, value, prepend, help_wanted, &local_err); g_free(option); if (local_err) { error_propagate(errp, local_err); @@ -903,7 +903,7 @@ void qemu_opts_do_parse(QemuOpts *opts, const char *par= ams, =20 static QemuOpts *opts_parse(QemuOptsList *list, const char *params, bool permit_abbrev, bool defaults, - bool *invalidp, Error **errp) + bool *help_wanted, Error **errp) { const char *firstname; char *id =3D opts_parse_id(params); @@ -928,7 +928,7 @@ static QemuOpts *opts_parse(QemuOptsList *list, const c= har *params, return NULL; } =20 - opts_do_parse(opts, params, firstname, defaults, invalidp, &local_err); + opts_do_parse(opts, params, firstname, defaults, help_wanted, &local_e= rr); if (local_err) { error_propagate(errp, local_err); qemu_opts_del(opts); @@ -964,11 +964,11 @@ QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list,= const char *params, { Error *err =3D NULL; QemuOpts *opts; - bool invalidp =3D false; + bool help_wanted =3D false; =20 - opts =3D opts_parse(list, params, permit_abbrev, false, &invalidp, &er= r); + opts =3D opts_parse(list, params, permit_abbrev, false, &help_wanted, = &err); if (err) { - if (invalidp && has_help_option(params)) { + if (help_wanted) { qemu_opts_print_help(list, true); error_free(err); } else { --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588145096; cv=none; d=zohomail.com; s=zohoarc; b=kWY6W+Quc1La+QGOAgcnv7whoy+9ygQtJ2cZ/zU5W3IIvhxfP8Wd/zuvBn8LHw1rgh7QYoGO3yEXOPdQhn18VZfaw/AsgbBTzzMVbjhrWn8/3xoYrdOsHB5pJ4Md+mpWJWyE7eU/X680435Y1+Zdl/wZUGvqSNEAXDfMTyk48Ys= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588145096; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=B+HhnvMEuvaOsq1YhwdQ7CSRL41BxavMcvoSsGvfs2k=; b=W4LKdGT73TD55wDnb4QW6HeTUC0hQxXW1DiMRJ1XP2mXpw8sw+X5przbdLSlr8TsPNWWn/3lChI9ce58RyIjNN1EhVkipS2sbtfpUqUaiu7knKOLPIGdl8Or/fEa3J/gXoO7L72PzYglQwvTryKq4IPpv38V1ivQMCaPvaQIC90= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588145096398862.7617969846732; Wed, 29 Apr 2020 00:24:56 -0700 (PDT) Received: from localhost ([::1]:59932 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh5T-0004sM-4T for importer@patchew.org; Wed, 29 Apr 2020 03:24:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46152) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh1u-0007tc-7t for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh1g-0003w5-8V for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:14 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:26558 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh1f-0003uE-Oo for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:20:59 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-408-4jAWjpLrPN2LsWXgFFhgMg-1; Wed, 29 Apr 2020 03:20:54 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9B657BFC1 for ; Wed, 29 Apr 2020 07:20:53 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E7E34282CA; Wed, 29 Apr 2020 07:20:51 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id DE41311358C4; Wed, 29 Apr 2020 09:20:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144856; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B+HhnvMEuvaOsq1YhwdQ7CSRL41BxavMcvoSsGvfs2k=; b=Di+wzTtipDW83KPt50PuFSDCMCMIHgLCNTawj+PdmyDXqynpnJSSf5g3UKCo5ZeYF5DtSQ cVmCA4Ou1KLYHAih3d0MtovOe2Q7eA2BpNd3RSZkY+BOxO64P8DayhyfV29i6fQB4N9EH7 5bpgn8gl23OlVptzQEYlbU0Nojv0Lac= X-MC-Unique: 4jAWjpLrPN2LsWXgFFhgMg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 08/32] qemu-img: Factor out accumulate_options() helper Date: Wed, 29 Apr 2020 09:20:24 +0200 Message-Id: <20200429072048.29963-9-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=205.139.110.61; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 00:53:13 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Kevin Wolf Message-Id: <20200415074927.19897-8-armbru@redhat.com> --- qemu-img.c | 59 +++++++++++++++++++++--------------------------------- 1 file changed, 23 insertions(+), 36 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 821cbf610e..d36b21b758 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -223,6 +223,25 @@ static bool qemu_img_object_print_help(const char *typ= e, QemuOpts *opts) return true; } =20 +static int accumulate_options(char **options, char *optarg) +{ + char *new_options; + + if (!is_valid_option_list(optarg)) { + error_report("Invalid option list: %s", optarg); + return -1; + } + + if (!*options) { + *options =3D g_strdup(optarg); + } else { + new_options =3D g_strdup_printf("%s,%s", *options, optarg); + g_free(*options); + *options =3D new_options; + } + return 0; +} + static QemuOptsList qemu_source_opts =3D { .name =3D "source", .implied_opt_name =3D "file", @@ -482,17 +501,9 @@ static int img_create(int argc, char **argv) fmt =3D optarg; break; case 'o': - if (!is_valid_option_list(optarg)) { - error_report("Invalid option list: %s", optarg); + if (accumulate_options(&options, optarg) < 0) { goto fail; } - if (!options) { - options =3D g_strdup(optarg); - } else { - char *old_options =3D options; - options =3D g_strdup_printf("%s,%s", options, optarg); - g_free(old_options); - } break; case 'q': quiet =3D true; @@ -2127,17 +2138,9 @@ static int img_convert(int argc, char **argv) s.compressed =3D true; break; case 'o': - if (!is_valid_option_list(optarg)) { - error_report("Invalid option list: %s", optarg); + if (accumulate_options(&options, optarg) < 0) { goto fail_getopt; } - if (!options) { - options =3D g_strdup(optarg); - } else { - char *old_options =3D options; - options =3D g_strdup_printf("%s,%s", options, optarg); - g_free(old_options); - } break; case 'l': if (strstart(optarg, SNAPSHOT_OPT_BASE, NULL)) { @@ -3953,18 +3956,10 @@ static int img_amend(int argc, char **argv) help(); break; case 'o': - if (!is_valid_option_list(optarg)) { - error_report("Invalid option list: %s", optarg); + if (accumulate_options(&options, optarg) < 0) { ret =3D -1; goto out_no_progress; } - if (!options) { - options =3D g_strdup(optarg); - } else { - char *old_options =3D options; - options =3D g_strdup_printf("%s,%s", options, optarg); - g_free(old_options); - } break; case 'f': fmt =3D optarg; @@ -4855,17 +4850,9 @@ static int img_measure(int argc, char **argv) out_fmt =3D optarg; break; case 'o': - if (!is_valid_option_list(optarg)) { - error_report("Invalid option list: %s", optarg); + if (accumulate_options(&options, optarg) < 0) { goto out; } - if (!options) { - options =3D g_strdup(optarg); - } else { - char *old_options =3D options; - options =3D g_strdup_printf("%s,%s", options, optarg); - g_free(old_options); - } break; case 'l': if (strstart(optarg, SNAPSHOT_OPT_BASE, NULL)) { --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588145316; cv=none; d=zohomail.com; s=zohoarc; b=IIMxVlYAx8ysI5VRywbcLGRb+tU1BUmpXKCOGl0ns6yZrIzGMJpxtODGR4Uso3diyBeaVPbnYhCwBRU60z3K1muXehFhaHdzgofknskx60XcJDJjKGrBXcQ3LvqA3L2tSCXYJi1weCK47SONQ9dIHSIKq8+KQq+hajj9dAsnHmQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588145316; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RRERRyG7fjjzAR2u6+g0KLtZHvTM2XC2r+BKiMNxEbM=; b=U9KUdMWf9Xk3Ca8IdPbM8EDusR+qk0o0WiNamWkZXCH5MVj1ByE2e6x8vp+iqs6ITcvSbuK5fenGVwCiGA+2vh3Ojnv/EPptS7VC5zuDOv4CL+u63Jp3CzG3IlBN/SSyOPbjT+RXSuGlRHutM55dit0qAjsZNTlxrQdJjYKXUVc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588145316784699.4635170081204; Wed, 29 Apr 2020 00:28:36 -0700 (PDT) Received: from localhost ([::1]:48540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh90-0003fr-Pa for importer@patchew.org; Wed, 29 Apr 2020 03:28:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46140) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh1q-0007tU-R5 for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh1c-0003u0-8R for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:10 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:49903 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh1b-0003qe-Mh for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:20:55 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-148-yw2oXDZHOnObayMQd6kKkg-1; Wed, 29 Apr 2020 03:20:53 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 268CE1009445 for ; Wed, 29 Apr 2020 07:20:52 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EA1635C1BE; Wed, 29 Apr 2020 07:20:51 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E2FC911358C5; Wed, 29 Apr 2020 09:20:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144854; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RRERRyG7fjjzAR2u6+g0KLtZHvTM2XC2r+BKiMNxEbM=; b=X42Bi01hNDOYzl+//DTq5vRnNjB7sOI5kDOwvbnJLXps0WlhuL9R5J4KMCwsgikkmziJ3Y xDIVKkRPe/f6iUNpmpHjAslga+OrJKgBvKoBpZks9N8YVtnX/Vuzo+Ma3yoRHvsjUbKbwE BBf6ESG/tb7NbMYIpSYvlQ8G/D5yPns= X-MC-Unique: yw2oXDZHOnObayMQd6kKkg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 09/32] qemu-img: Move is_valid_option_list() to qemu-img.c and rewrite Date: Wed, 29 Apr 2020 09:20:25 +0200 Message-Id: <20200429072048.29963-10-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=205.139.110.120; envelope-from=armbru@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 01:42:37 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" is_valid_option_list()'s purpose is ensuring qemu-img.c's can safely join multiple parameter strings separated by ',' like this: g_strdup_printf("%s,%s", params1, params2); How it does that is anything but obvious. A close reading of the code reveals that it fails exactly when its argument starts with ',' or ends with an odd number of ','. Makes sense, actually, because when the argument starts with ',', a separating ',' preceding it would get escaped, and when it ends with an odd number of ',', a separating ',' following it would get escaped. Move it to qemu-img.c and rewrite it the obvious way. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <20200415074927.19897-9-armbru@redhat.com> --- include/qemu/option.h | 1 - qemu-img.c | 26 ++++++++++++++++++++++++++ util/qemu-option.c | 22 ---------------------- 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/include/qemu/option.h b/include/qemu/option.h index 844587cab3..eb4097889d 100644 --- a/include/qemu/option.h +++ b/include/qemu/option.h @@ -33,7 +33,6 @@ const char *get_opt_value(const char *p, char **value); void parse_option_size(const char *name, const char *value, uint64_t *ret, Error **errp); bool has_help_option(const char *param); -bool is_valid_option_list(const char *param); =20 enum QemuOptType { QEMU_OPT_STRING =3D 0, /* no parsing (use string as-is) = */ diff --git a/qemu-img.c b/qemu-img.c index d36b21b758..cc51db7ed4 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -223,6 +223,32 @@ static bool qemu_img_object_print_help(const char *typ= e, QemuOpts *opts) return true; } =20 +/* + * Is @optarg safe for accumulate_options()? + * It is when multiple of them can be joined together separated by ','. + * To make that work, @optarg must not start with ',' (or else a + * separating ',' preceding it gets escaped), and it must not end with + * an odd number of ',' (or else a separating ',' following it gets + * escaped). + */ +static bool is_valid_option_list(const char *optarg) +{ + size_t len =3D strlen(optarg); + size_t i; + + if (optarg[0] =3D=3D ',') { + return false; + } + + for (i =3D len; i > 0 && optarg[i - 1] =3D=3D ','; i--) { + } + if ((len - i) % 2) { + return false; + } + + return true; +} + static int accumulate_options(char **options, char *optarg) { char *new_options; diff --git a/util/qemu-option.c b/util/qemu-option.c index 2d0d24ee27..9542988183 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -165,28 +165,6 @@ void parse_option_size(const char *name, const char *v= alue, *ret =3D size; } =20 -bool is_valid_option_list(const char *p) -{ - char *value =3D NULL; - bool result =3D false; - - while (*p) { - p =3D get_opt_value(p, &value); - if ((*p && !*++p) || - (!*value || *value =3D=3D ',')) { - goto out; - } - - g_free(value); - value =3D NULL; - } - - result =3D true; -out: - g_free(value); - return result; -} - static const char *opt_type_to_string(enum QemuOptType type) { switch (type) { --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588144999; cv=none; d=zohomail.com; s=zohoarc; b=kOcQd6zDCO99sMR5qpFn1pVjLOZF8zRWpF8rwwPHloCsHQ/9b6xwAigjhcSSCM8Y0oIopC/Dkt+hVCTGtyIkAMq3THeT+l4+CEcASMZnMs4i/D+bhUraF39D+tjsZLwPteIoV62vJAyqSAkFoo4Fvj2bAnKDPM+EnzmTE4kkngI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588144999; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JUehSluyCfYKVpllec9HGLDt3XECTdSIT8Fz2eXmjrM=; b=LQOcBBQOeajEOBfqf/AsSEoz3Y1foUPYazUnuJWOOxNNt+ZqwFdJSGCplhwudE3XvNid1BBjwkWsUdEdeYG0cCjy99kr839ipCc1jYFDNRiZNhEPaipt3b0hMARUtWrKayOt6r00mcYDbIeYBZ0nlR7WUa1oDu2FgpgfZrKV2lU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588144999021172.32242800469044; Wed, 29 Apr 2020 00:23:19 -0700 (PDT) Received: from localhost ([::1]:51022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh3t-0001E5-7o for importer@patchew.org; Wed, 29 Apr 2020 03:23:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46106) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh1m-0007tK-QL for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh1b-0003tD-W5 for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:06 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:51483 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh1b-0003qO-Bc for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:20:55 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-85-C1Vv83YfNUagfZNF-Z8baQ-1; Wed, 29 Apr 2020 03:20:53 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 24A5B1895A2E for ; Wed, 29 Apr 2020 07:20:52 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E9FBD5D9F1; Wed, 29 Apr 2020 07:20:51 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id EE3CB11358C6; Wed, 29 Apr 2020 09:20:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144854; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JUehSluyCfYKVpllec9HGLDt3XECTdSIT8Fz2eXmjrM=; b=ekRl+AdR8Yj0Qec4hYp0vNNLHnC2VIUe+vU1aLnkV2wSi1tsG8Pt+OVJWJ4yARu2UEKrrL 36Pc6M+TOfSW6aDGq1WFMYwijfOTfntplexT0wzDCAFk9NEKpsmFDTNqwreoM5v/cLQTFm mNXMYERZKIg9vnG/RCOY4Fli7uz3WmM= X-MC-Unique: C1Vv83YfNUagfZNF-Z8baQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 10/32] qemu-img: Reject broken -o "" Date: Wed, 29 Apr 2020 09:20:26 +0200 Message-Id: <20200429072048.29963-11-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=207.211.31.120; envelope-from=armbru@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 01:18:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" qemu-img create, convert, amend, and measure use accumulate_options() to merge multiple -o options. This is broken for -o "": $ qemu-img create -f qcow2 -o backing_file=3Da -o "" -o backing_fmt=3Dr= aw,size=3D1M new.qcow2 qemu-img: warning: Could not verify backing image. This may become an e= rror in future versions. Could not open 'a,backing_fmt=3Draw': No such file or directory Formatting 'new.qcow2', fmt=3Dqcow2 size=3D1048576 backing_file=3Da,,ba= cking_fmt=3Draw cluster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 $ qemu-img info new.qcow2 image: new.qcow2 file format: qcow2 virtual size: 1 MiB (1048576 bytes) disk size: 196 KiB cluster_size: 65536 --> backing file: a,backing_fmt=3Draw Format specific information: compat: 1.1 lazy refcounts: false refcount bits: 16 corrupt: false Merging these three -o the obvious way is wrong, because it results in an unwanted ',' escape: backing_file=3Da,,backing_fmt=3Draw,size=3D1M ~~ We could silently drop -o "", but Kevin asked me to reject it instead. Signed-off-by: Markus Armbruster Message-Id: <20200415074927.19897-10-armbru@redhat.com> Reviewed-by: Eric Blake --- qemu-img.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index cc51db7ed4..a2369766f0 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -229,14 +229,16 @@ static bool qemu_img_object_print_help(const char *ty= pe, QemuOpts *opts) * To make that work, @optarg must not start with ',' (or else a * separating ',' preceding it gets escaped), and it must not end with * an odd number of ',' (or else a separating ',' following it gets - * escaped). + * escaped), or be empty (or else a separating ',' preceding it can + * escape a separating ',' following it). + *=20 */ static bool is_valid_option_list(const char *optarg) { size_t len =3D strlen(optarg); size_t i; =20 - if (optarg[0] =3D=3D ',') { + if (!optarg[0] || optarg[0] =3D=3D ',') { return false; } =20 --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588145616; cv=none; d=zohomail.com; s=zohoarc; b=RilIS0cMdTc4WF7/+xpAIx4byTjDfAlbSiG6smEoPgTPBjTqwuSJdnhs7AGVBRZ4Q52espornfEXKMGS3S0q6OBGUjb8EkiPlRxcfhA4ZXj02XboJMacWEbPUBIvhv5kzieyTKpaUT8x6O5EpLZyWBDLvThw1iCwZyiy4/mlLJc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588145616; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IE0ACh06lsV4xdUtL6CVvp7fPI2t78e9W1N+YfzHsbY=; b=VbE5tb81vsSvDHE8dsI0WbaLxVHiUWS+etsYmSRkT4xMsjslBgJweerG0QyK+yns+PirYGXreFZ/H1Nx5ytQlAso7oMCJCF9K4MabYp68wrz9fmWHz7a3m3pCo4+gnaL1FAzW10E7xlWkEoNBLs2RTkZQHxRX2wKlSUqGOM9Oq4= 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=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588145616829318.52251563007576; Wed, 29 Apr 2020 00:33:36 -0700 (PDT) Received: from localhost ([::1]:37978 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jThDr-0002ke-J1 for importer@patchew.org; Wed, 29 Apr 2020 03:33:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46206) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh21-0007u1-Gu for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh1i-0003yS-R2 for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:21 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:60951 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh1h-0003wu-KY for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:01 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-325-cU81mEKMNLq05zJK78rA3w-1; Wed, 29 Apr 2020 03:20:58 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 410041009446; Wed, 29 Apr 2020 07:20:52 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0E8C21000329; Wed, 29 Apr 2020 07:20:52 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 054CF11358C7; Wed, 29 Apr 2020 09:20:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144860; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IE0ACh06lsV4xdUtL6CVvp7fPI2t78e9W1N+YfzHsbY=; b=PnJuEAWpeS0SJLRgl/RA1KPxqALaVh1GBwec2Xs8CHT+ThMK+SiJ7g0VzHDyXWhWTZcrVO 4VQB17k47SMcOtEHsjH3cpljMAFOUvZzgA+OQjaKDUgkmX6NL7oqOq/Bd04EMnWA3HpxsK p7C+GDJBj6Y/LUzQ+/+gcNAZxRfBwI0= X-MC-Unique: cU81mEKMNLq05zJK78rA3w-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 11/32] cryptodev: Fix cryptodev_builtin_cleanup() error API violation Date: Wed, 29 Apr 2020 09:20:27 +0200 Message-Id: <20200429072048.29963-12-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=207.211.31.120; envelope-from=armbru@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 01:18:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gonglei Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The Error ** argument must be NULL, &error_abort, &error_fatal, or a pointer to a variable containing NULL. Passing an argument of the latter kind twice without clearing it in between is wrong: if the first call sets an error, it no longer points to NULL for the second call. cryptodev_builtin_cleanup() passes @errp to cryptodev_builtin_sym_close_session() in a loop. Harmless, because cryptodev_builtin_sym_close_session() can't actually fail. Fix it anyway. Cc: Gonglei Signed-off-by: Markus Armbruster Message-Id: <20200422130719.28225-2-armbru@redhat.com> --- backends/cryptodev-builtin.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c index c8ae3b9742..14316333fe 100644 --- a/backends/cryptodev-builtin.c +++ b/backends/cryptodev-builtin.c @@ -282,12 +282,7 @@ static int cryptodev_builtin_sym_close_session( CryptoDevBackendBuiltin *builtin =3D CRYPTODEV_BACKEND_BUILTIN(backend); =20 - if (session_id >=3D MAX_NUM_SESSIONS || - builtin->sessions[session_id] =3D=3D NULL) { - error_setg(errp, "Cannot find a valid session id: %" PRIu64 "", - session_id); - return -1; - } + assert(session_id < MAX_NUM_SESSIONS && builtin->sessions[session_id]); =20 qcrypto_cipher_free(builtin->sessions[session_id]->cipher); g_free(builtin->sessions[session_id]); @@ -356,8 +351,7 @@ static void cryptodev_builtin_cleanup( =20 for (i =3D 0; i < MAX_NUM_SESSIONS; i++) { if (builtin->sessions[i] !=3D NULL) { - cryptodev_builtin_sym_close_session( - backend, i, 0, errp); + cryptodev_builtin_sym_close_session(backend, i, 0, &error_abor= t); } } =20 --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588146194; cv=none; d=zohomail.com; s=zohoarc; b=XHGrkJrG6J113on0UkOhQbZnKzu3JqknSsdZS7pjL3wamOQMnjEMWqiiq3nndfkpGZqHFft0+/AjjSDPFDuNdI+8O2Zdsoc0J1MVR8mCti/0gUr58qI3MNv4LSiLBc/Utbqr6ZZmG5BXJvdivO1nzANonMpnQCM5lbSzaQTMBy0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588146194; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wH9qFb1vz2F+UQwonoBfny/s8QXIKAguywZ3WwtIZ4Y=; b=Hsjp2omXsQMe04LmXNs5uAxjWe/VptXVrLtRvMlnO8CAgfdP7uSY6xmnWdin5uFZxMIGmyvnt2iO5j/g9i+nLTEL7trWIQ2+4uzIOe35l9JB2l45A0BXrL4rus0gosYFDFeeCIwOFdWTPi0PaHyYTxR2ZDDzgectDeop1qs4RmE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588146194913156.10682411133587; Wed, 29 Apr 2020 00:43:14 -0700 (PDT) Received: from localhost ([::1]:43924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jThNB-0001Qs-OC for importer@patchew.org; Wed, 29 Apr 2020 03:43:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46264) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh28-0007uN-R4 for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh1i-0003zp-Sf for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:28 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:21136 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh1h-0003v5-NG for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:01 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-208-csiLGFbeOgWZNSc8JbmkmA-1; Wed, 29 Apr 2020 03:20:56 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 453AA1009447 for ; Wed, 29 Apr 2020 07:20:55 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 169E910021B3; Wed, 29 Apr 2020 07:20:52 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1016E11358C8; Wed, 29 Apr 2020 09:20:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144857; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wH9qFb1vz2F+UQwonoBfny/s8QXIKAguywZ3WwtIZ4Y=; b=R+7mlO5pNB5eIc4L8qxat0S6o7S+XHa6FnsM38HM38+KRBG3cz5f4qjBPdEQxJI4e2ISzj WFdmcfohUwB6l8yo+SVZzbkpuMf5wlf+gox79LqNMrn6ye1wbrh3DFTU2rOvoAZeSKc0vE gXELUAtI8+weZxi1fjhlKjXxLeJyAik= X-MC-Unique: csiLGFbeOgWZNSc8JbmkmA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 12/32] block/file-posix: Fix check_cache_dropped() error handling Date: Wed, 29 Apr 2020 09:20:28 +0200 Message-Id: <20200429072048.29963-13-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=205.139.110.61; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 00:53:13 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The Error ** argument must be NULL, &error_abort, &error_fatal, or a pointer to a variable containing NULL. Passing an argument of the latter kind twice without clearing it in between is wrong: if the first call sets an error, it no longer points to NULL for the second call. check_cache_dropped() calls error_setg() in a loop. It fails to break the loop in one instance. If a subsequent iteration error_setg()s again, it trips error_setv()'s assertion. Fix it to break the loop. Fixes: 31be8a2a97ecba7d31a82932286489cac318e9e9 Cc: Stefan Hajnoczi Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <20200422130719.28225-3-armbru@redhat.com> Reviewed-by: Stefan Hajnoczi --- block/file-posix.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/block/file-posix.c b/block/file-posix.c index 7e19bbff5f..094e3b0212 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2691,10 +2691,13 @@ static void check_cache_dropped(BlockDriverState *b= s, Error **errp) vec_end =3D DIV_ROUND_UP(length, page_size); for (i =3D 0; i < vec_end; i++) { if (vec[i] & 0x1) { - error_setg(errp, "page cache still in use!"); break; } } + if (i < vec_end) { + error_setg(errp, "page cache still in use!"); + break; + } } =20 if (window) { --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588145685; cv=none; d=zohomail.com; s=zohoarc; b=CVWTF0B9VKiM+Pm6YotEO6bM5ZB4eZt7bVeYHkxOpGNptmPQZwuYDDCJmFutA4xSVJIqvxIUJSfviWdvv+Eu+SctBHOSW38/lqd1cH8stG1xCP2On+ukXF4fCjb+eLuuQ/J+hr+/uB+tcJEXRuFBi5S7cs7IrNVf9rcDnbdY+qc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588145685; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OZQTbK0EklUs/kywoqWzaWvRrmI9x3y1VmDM0uS/gYQ=; b=nZDSuMkO/f/Z0LYLQ6F9DP8MyElGHj+jF6AFDq4rEJhL2uss0oPNugXpl2pTETR5YOoRm5YiyCiEVf8zsZjvdNC8bkm7ByHAR9n1wQenGDzcP8e+Tb1R+MQBDBWGqu5xdgzqteTjXabx9Hnkraeg+napRSrKQCb/dOHk0eWCvHU= 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=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588145685264711.4176929604092; Wed, 29 Apr 2020 00:34:45 -0700 (PDT) Received: from localhost ([::1]:42160 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jThEx-0004Sn-VZ for importer@patchew.org; Wed, 29 Apr 2020 03:34:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46260) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh28-0007uL-BJ for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh1i-0003ze-UJ for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:28 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:39708 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh1h-0003uJ-MX for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:02 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-168-3T06aCjjMx2djsl4_YbWaA-1; Wed, 29 Apr 2020 03:20:54 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 977D91895A2B for ; Wed, 29 Apr 2020 07:20:53 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 663505D76A; Wed, 29 Apr 2020 07:20:53 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 16E0211358CA; Wed, 29 Apr 2020 09:20:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144856; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OZQTbK0EklUs/kywoqWzaWvRrmI9x3y1VmDM0uS/gYQ=; b=OCbzE7ZIIU2E/Z80+lxKytTnKi2s8iZeP5DunW5Nm8W9xgy3KLX0hzYG+K51agM0AjdQzu qc1b+R0UT0hdco19Ymvvv4etoX4u1o+gNvlN6g0eYW2vzUV19waWqSL3Flv2hBclVJUpYo MhutWrwKPhU6GGcAbFdAPuWs5HczGl0= X-MC-Unique: 3T06aCjjMx2djsl4_YbWaA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 13/32] cpus: Fix configure_icount() error API violation Date: Wed, 29 Apr 2020 09:20:29 +0200 Message-Id: <20200429072048.29963-14-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=205.139.110.61; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 00:53:13 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The Error ** argument must be NULL, &error_abort, &error_fatal, or a pointer to a variable containing NULL. Passing an argument of the latter kind twice without clearing it in between is wrong: if the first call sets an error, it no longer points to NULL for the second call. configure_icount() is wrong that way. Harmless, because its @errp is always &error_abort or &error_fatal. Just as wrong (and just as harmless): when it fails, it can still update global state. Fix all that. Cc: Paolo Bonzini Signed-off-by: Markus Armbruster Message-Id: <20200422130719.28225-4-armbru@redhat.com> --- cpus.c | 51 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/cpus.c b/cpus.c index ef441bdf62..1b542b37f9 100644 --- a/cpus.c +++ b/cpus.c @@ -797,40 +797,49 @@ void cpu_ticks_init(void) =20 void configure_icount(QemuOpts *opts, Error **errp) { - const char *option; + const char *option =3D qemu_opt_get(opts, "shift"); + bool sleep =3D qemu_opt_get_bool(opts, "sleep", true); + bool align =3D qemu_opt_get_bool(opts, "align", false); + long time_shift =3D -1; char *rem_str =3D NULL; =20 - option =3D qemu_opt_get(opts, "shift"); - if (!option) { - if (qemu_opt_get(opts, "align") !=3D NULL) { - error_setg(errp, "Please specify shift option when using align= "); - } + if (!option && qemu_opt_get(opts, "align")) { + error_setg(errp, "Please specify shift option when using align"); return; } =20 - icount_sleep =3D qemu_opt_get_bool(opts, "sleep", true); + if (align && !sleep) { + error_setg(errp, "align=3Don and sleep=3Doff are incompatible"); + return; + } + + if (strcmp(option, "auto") !=3D 0) { + errno =3D 0; + time_shift =3D strtol(option, &rem_str, 0); + if (errno !=3D 0 || *rem_str !=3D '\0' || !strlen(option)) { + error_setg(errp, "icount: Invalid shift value"); + return; + } + } else if (icount_align_option) { + error_setg(errp, "shift=3Dauto and align=3Don are incompatible"); + return; + } else if (!icount_sleep) { + error_setg(errp, "shift=3Dauto and sleep=3Doff are incompatible"); + return; + } + + icount_sleep =3D sleep; if (icount_sleep) { timers_state.icount_warp_timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL= _RT, icount_timer_cb, NULL); } =20 - icount_align_option =3D qemu_opt_get_bool(opts, "align", false); + icount_align_option =3D align; =20 - if (icount_align_option && !icount_sleep) { - error_setg(errp, "align=3Don and sleep=3Doff are incompatible"); - } - if (strcmp(option, "auto") !=3D 0) { - errno =3D 0; - timers_state.icount_time_shift =3D strtol(option, &rem_str, 0); - if (errno !=3D 0 || *rem_str !=3D '\0' || !strlen(option)) { - error_setg(errp, "icount: Invalid shift value"); - } + if (time_shift >=3D 0) { + timers_state.icount_time_shift =3D time_shift; use_icount =3D 1; return; - } else if (icount_align_option) { - error_setg(errp, "shift=3Dauto and align=3Don are incompatible"); - } else if (!icount_sleep) { - error_setg(errp, "shift=3Dauto and sleep=3Doff are incompatible"); } =20 use_icount =3D 2; --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588146122; cv=none; d=zohomail.com; s=zohoarc; b=RWNk2ftaHwH+mHSd39kR4tsKqLggMVU1LMBzgfrefra8syEOVLBRtYqiLDBVD9B3/xfO1oESJ4++RgM8iKl7vwghN8lp40IZQUamnUAIFR+3299ivr0HlEtKXgKkJIN3COaKrijzC0zBeqYGXGOTSTYOdA3Cw8AI7yRzCJVQw6E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588146122; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/7bpX1iXJErQuyCFTBQ9FX3q8b7UtGzaD9CWLu+A9OI=; b=IgFIn4+DQ8Sm1k8fLrt3p/9bVK/sxIsgTziqbN2bl2VLbKPnIK2gBJk2UtjdmUrD9ma0/BSLMgQjCfeiH6cp+IF120kxplyHcFEmnsrBCKEkXbF/odcv8bMrJGKGj+Er9OiyfNSE13iRcrJD0CMDKSvMNPthaCQDARqZfwW/YzM= 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=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588146122068300.95231619986146; Wed, 29 Apr 2020 00:42:02 -0700 (PDT) Received: from localhost ([::1]:39854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jThM0-0007tm-SO for importer@patchew.org; Wed, 29 Apr 2020 03:42:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46256) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh27-0007uJ-Pd for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh1j-0003zZ-05 for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:27 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:34005 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh1h-0003uW-KD for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:01 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-417-cQx5e_4rOpOVt9j_fDD6zA-1; Wed, 29 Apr 2020 03:20:54 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9B0E21895A2C for ; Wed, 29 Apr 2020 07:20:53 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 697BB5D9F3; Wed, 29 Apr 2020 07:20:53 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1CBE311358CB; Wed, 29 Apr 2020 09:20:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144856; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/7bpX1iXJErQuyCFTBQ9FX3q8b7UtGzaD9CWLu+A9OI=; b=L0qOlvY9K1Qg52INXkYpab4P2I5pOTNfh/vGeby96fCIsRev9JvKsEeARnEWI39bzKE3aS J3nyPx3RENiv/MqgabAW+qqRjnOck/sXlqOB9wVHCgvwJsUWC0iAMcilp2JU/BiYKyR4rV VkPrYreciCYzAvLjcAXHBJrKUULUfUg= X-MC-Unique: cQx5e_4rOpOVt9j_fDD6zA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 14/32] cpus: Proper range-checking for -icount shift=N Date: Wed, 29 Apr 2020 09:20:30 +0200 Message-Id: <20200429072048.29963-15-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=207.211.31.120; envelope-from=armbru@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 01:18:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" timers_state.icount_time_shift must be in [0,63] to avoid undefined behavior when shifting by it, e.g. in cpu_icount_to_ns(). icount_adjust() clamps it to [0,MAX_ICOUNT_SHIFT], with MAX_ICOUNT_SHIFT =3D 10. configure_icount() doesn't. Fix that. Fixes: a8bfac37085c3372366d722f131a7e18d664ee4d Cc: Paolo Bonzini Signed-off-by: Markus Armbruster Message-Id: <20200422130719.28225-5-armbru@redhat.com> --- cpus.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cpus.c b/cpus.c index 1b542b37f9..5670c96bcf 100644 --- a/cpus.c +++ b/cpus.c @@ -25,6 +25,7 @@ #include "qemu/osdep.h" #include "qemu-common.h" #include "qemu/config-file.h" +#include "qemu/cutils.h" #include "migration/vmstate.h" #include "monitor/monitor.h" #include "qapi/error.h" @@ -801,7 +802,6 @@ void configure_icount(QemuOpts *opts, Error **errp) bool sleep =3D qemu_opt_get_bool(opts, "sleep", true); bool align =3D qemu_opt_get_bool(opts, "align", false); long time_shift =3D -1; - char *rem_str =3D NULL; =20 if (!option && qemu_opt_get(opts, "align")) { error_setg(errp, "Please specify shift option when using align"); @@ -814,9 +814,8 @@ void configure_icount(QemuOpts *opts, Error **errp) } =20 if (strcmp(option, "auto") !=3D 0) { - errno =3D 0; - time_shift =3D strtol(option, &rem_str, 0); - if (errno !=3D 0 || *rem_str !=3D '\0' || !strlen(option)) { + if (qemu_strtol(option, NULL, 0, &time_shift) < 0 + || time_shift < 0 || time_shift > MAX_ICOUNT_SHIFT) { error_setg(errp, "icount: Invalid shift value"); return; } --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588145574; cv=none; d=zohomail.com; s=zohoarc; b=Ky3HlDu+w8IkzDJeu48NTlFz+lMEjKp3WvfO57uLTE+OzxxSULsDLCousyMEpwIklsFMXrhDO2XU2X4QS2Vl8aXXPsvMuBj2tj3FOfFwYgcgBxz7oGp0CM2jOFBS8LFyCXbL45yISjdprnolgjl8zXgErh+cUBXZCJBQvhDq4VM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588145574; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NL0nRywYZ6Azb/iX369tYfd6PROrKxWJQJJ1mV6HfmM=; b=eFG7O9B7lk1VfG5bxXSlF/dvtsg1Q+P8f212cJkomQVZkV6PHmxNqBLo/7wLDSAf6OGV3Qa53M08gLOH1XnzlS3/pYpnRzJcNW+B41IOiTv7UEdGVqzPQWz9jY2Nas+iYQvQZXszJ8eW9LkXa60sy3MSm1B+W3if4DU/3wSIEsE= 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=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588145574874115.52565550682971; Wed, 29 Apr 2020 00:32:54 -0700 (PDT) Received: from localhost ([::1]:35646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jThDB-0001nQ-MH for importer@patchew.org; Wed, 29 Apr 2020 03:32:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46242) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh26-0007uE-1w for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh1i-0003z6-Q7 for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:25 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:45506 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh1h-0003uZ-KZ for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:01 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-408-H6ho_SUwN4uT4YihlYU5gA-1; Wed, 29 Apr 2020 03:20:54 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9B054835B42; Wed, 29 Apr 2020 07:20:53 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6975A600DB; Wed, 29 Apr 2020 07:20:53 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 22A8111358CC; Wed, 29 Apr 2020 09:20:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144856; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NL0nRywYZ6Azb/iX369tYfd6PROrKxWJQJJ1mV6HfmM=; b=DMmpVe+sCAm6PmwToe7gvrTsf1PN3NzMfrcPmcKWyMBUmX4ADbsI/in7brIn/628RFqfCd Ug1m0M9LYjIXONxy/rO9CcntYOYHaqc5n9fhJUMc2fm69NJVJg/JSrdjlbhsSZzJgb1R+P eVvKihsvT3/TParSEhGNni0VbiMfeMw= X-MC-Unique: H6ho_SUwN4uT4YihlYU5gA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 15/32] arm/virt: Fix virt_machine_device_plug_cb() error API violation Date: Wed, 29 Apr 2020 09:20:31 +0200 Message-Id: <20200429072048.29963-16-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=205.139.110.61; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 00:53:13 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The Error ** argument must be NULL, &error_abort, &error_fatal, or a pointer to a variable containing NULL. Passing an argument of the latter kind twice without clearing it in between is wrong: if the first call sets an error, it no longer points to NULL for the second call. virt_machine_device_plug_cb() passes @errp to cryptodev_builtin_sym_close_session() in a loop. Harmless, because cryptodev_builtin_sym_close_session() can't actually fail. Fix by dropping its Error ** parameter. Cc: Peter Maydell Cc: qemu-arm@nongnu.org Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200422130719.28225-6-armbru@redhat.com> --- hw/arm/virt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 7dc96abf72..cca5316256 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1186,7 +1186,7 @@ static void create_smmu(const VirtMachineState *vms, g_free(node); } =20 -static void create_virtio_iommu_dt_bindings(VirtMachineState *vms, Error *= *errp) +static void create_virtio_iommu_dt_bindings(VirtMachineState *vms) { const char compat[] =3D "virtio,pci-iommu"; uint16_t bdf =3D vms->virtio_iommu_bdf; @@ -2118,7 +2118,7 @@ static void virt_machine_device_plug_cb(HotplugHandle= r *hotplug_dev, =20 vms->iommu =3D VIRT_IOMMU_VIRTIO; vms->virtio_iommu_bdf =3D pci_get_bdf(pdev); - create_virtio_iommu_dt_bindings(vms, errp); + create_virtio_iommu_dt_bindings(vms); } } =20 --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588145320; cv=none; d=zohomail.com; s=zohoarc; b=E5G0m6ZNHk8n+ejDvNY65PLf1clnT1v7XJ5lHJ79Y8DvCjUexo1amO+cRvJ/FsAVI8yIno9gHBRApKj05SQnhdqDCO+Y8Hrf1ZNmrPeZbc0/i05TvFf522cITAoRqUJR4Unk+Su/OQ+bKSXyBDy0KeI0ZUgwlzHVrOmDkIM9gr4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588145320; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dveDF7i19YrBFtpGujUfYTE4uhIXGRPm1+3EZMRFKqo=; b=B4/CMX++ob82lqsK0vXYYSOZbtbPSua9etmiaEu4WzRu01d+ILMg9zymr5DgNJ30j/YwqL3wHxuR6w17Iq25U+wN/4r6jAX2WUf9/R9w8Is0U0KnXeEqZWGgXw+y/N9QaS6T1laJIRknVRaQWY6vC5TWwQlLAbz/rIk7JmYrv2s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158814532006479.51038103767746; Wed, 29 Apr 2020 00:28:40 -0700 (PDT) Received: from localhost ([::1]:48914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh94-0003qV-MK for importer@patchew.org; Wed, 29 Apr 2020 03:28:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46170) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh1w-0007tk-Fh for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh1g-0003wb-Kw for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:16 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:38121 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh1f-0003uO-QS for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:20:59 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-186-SRw8G0QAObC_u2r8A5UiVw-1; Wed, 29 Apr 2020 03:20:54 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9DF6EBFC2 for ; Wed, 29 Apr 2020 07:20:53 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6C75F5D771; Wed, 29 Apr 2020 07:20:53 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2878011358CD; Wed, 29 Apr 2020 09:20:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144856; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dveDF7i19YrBFtpGujUfYTE4uhIXGRPm1+3EZMRFKqo=; b=EFGQuzTIyWns3hl3ZcKuQI9DbYdkHxbB3l1d6A7YLsieI70kv3OxdJ8vY39rYalsZq5CT9 oMcmeZMMRQ/4NVibxkCZrXQUh0QvTZcjkUbCnnrfPD1tTv/dcbqICJ6o1TWdxY6P5vC7mF E1wo/HGwNGu6SkHONEE5rMziPtjMryQ= X-MC-Unique: SRw8G0QAObC_u2r8A5UiVw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 16/32] fdc: Fix fallback=auto error handling Date: Wed, 29 Apr 2020 09:20:32 +0200 Message-Id: <20200429072048.29963-17-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=205.139.110.61; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 00:53:13 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" fdctrl_realize_common() rejects fallback=3Dauto. Used by devices "isa-fdc", "sysbus-fdc", "SUNW,fdtwo". The error handling is broken: $ qemu-system-x86_64 -nodefaults -device isa-fdc,fallback=3Dauto,driveA= =3Dfd0 -drive if=3Dnone,id=3Dfd0 ** ERROR:/work/armbru/qemu/hw/block/fdc.c:434:pick_drive_type: assertion f= ailed: (drv->drive !=3D FLOPPY_DRIVE_TYPE_AUTO) Aborted (core dumped) Cause: fdctrl_realize_common() neglects to bail out after setting the error. Fix that. Fixes: a73275dd6fc3bfda33165bebc28e0c33c20cb0a0 Cc: John Snow Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200422130719.28225-7-armbru@redhat.com> --- hw/block/fdc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/block/fdc.c b/hw/block/fdc.c index 33bc9e2f92..9628cc171e 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -2615,6 +2615,7 @@ static void fdctrl_realize_common(DeviceState *dev, F= DCtrl *fdctrl, =20 if (fdctrl->fallback =3D=3D FLOPPY_DRIVE_TYPE_AUTO) { error_setg(errp, "Cannot choose a fallback FDrive type of 'auto'"); + return; } =20 /* Fill 'command_to_handler' lookup table */ --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588145826; cv=none; d=zohomail.com; s=zohoarc; b=jzMmEIMNhyA9zlBxQG6XwD39ZU6jVAUmPlENdEJ82b6j7qPZakFEAxaXBubXyg/kqWM4GNhoD8cVXKbWNVK0yWv0N5U7cjlozZ77Uo0/HCAv40Pt6YwfbD3C544LgWUspnJqq6xcoq5PMVPYSSM3yf6WdrKbw23cOPZhCkuTIcI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588145826; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=I0CwfPL0bHAmIgroIO9vlkMhNJh/UfpvjW50OODwJ/U=; b=RMAKYXUE/ofTqe5M5hgga1pVpqh9u7wFhY6b3rD0PaH2jU4UKxggaX8hmH8y0BhVQTpKSF5BiFmd24wQlM4eHGdd4pHQ+nwJII4NDUfkDiNGqnDHxexPEsizWXBuvUBT+ZxfRL/qa78EzME5Legk6IXgoMy5yG2kczQh1xx1wto= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588145826342179.3519662990359; Wed, 29 Apr 2020 00:37:06 -0700 (PDT) Received: from localhost ([::1]:50802 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jThHF-0008F1-3P for importer@patchew.org; Wed, 29 Apr 2020 03:37:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46224) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh24-0007u8-0Q for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh1i-0003ym-M9 for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:23 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:28506 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh1h-0003vh-IG for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:01 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-174-T2-mIlrQP5229-5Zlmi-CQ-1; Wed, 29 Apr 2020 03:20:57 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 55FC68015CB for ; Wed, 29 Apr 2020 07:20:56 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6FC02282D8; Wed, 29 Apr 2020 07:20:53 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2F41911358CE; Wed, 29 Apr 2020 09:20:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144859; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I0CwfPL0bHAmIgroIO9vlkMhNJh/UfpvjW50OODwJ/U=; b=acr/hxcOHKYI0yrWnytTpc5dlzCa6L/2cpc3VhOBRc6jr+vD9/Eos7UiQH8nMK/7rUTrb7 zfXGojYa+ThE2ITPyZu9+ZP7cZOv9cnZEbZqZfdbuDgxlgRFfHBgfncP37KyiQyuoUhoUZ Zysm2UtvSAN0t6YqaDhtBXBFYIEzFI4= X-MC-Unique: T2-mIlrQP5229-5Zlmi-CQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 17/32] bochs-display: Fix vgamem=SIZE error handling Date: Wed, 29 Apr 2020 09:20:33 +0200 Message-Id: <20200429072048.29963-18-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=205.139.110.61; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 00:53:13 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" bochs_display_realize() rejects out-of-range vgamem. The error handling is broken: $ qemu-system-x86_64 -S -display none -monitor stdio QEMU 4.2.93 monitor - type 'help' for more information (qemu) device_add bochs-display,vgamem=3D1 Error: bochs-display: video memory too small (qemu) device_add bochs-display,vgamem=3D1 RAMBlock "0000:00:04.0/bochs-display-vram" already registered, abort! Aborted (core dumped) Cause: bochs_display_realize() neglects to bail out after setting the error. Fix that. Fixes: 765c94290863eef1fc4a67819d452cc13b7854a1 Cc: Gerd Hoffmann Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200422130719.28225-8-armbru@redhat.com> Reviewed-by: Gerd Hoffmann --- hw/display/bochs-display.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/display/bochs-display.c b/hw/display/bochs-display.c index 70eb619ef4..e763a0a72d 100644 --- a/hw/display/bochs-display.c +++ b/hw/display/bochs-display.c @@ -267,16 +267,18 @@ static void bochs_display_realize(PCIDevice *dev, Err= or **errp) Object *obj =3D OBJECT(dev); int ret; =20 - s->con =3D graphic_console_init(DEVICE(dev), 0, &bochs_display_gfx_ops= , s); - if (s->vgamem < 4 * MiB) { error_setg(errp, "bochs-display: video memory too small"); + return; } if (s->vgamem > 256 * MiB) { error_setg(errp, "bochs-display: video memory too big"); + return; } s->vgamem =3D pow2ceil(s->vgamem); =20 + s->con =3D graphic_console_init(DEVICE(dev), 0, &bochs_display_gfx_ops= , s); + memory_region_init_ram(&s->vram, obj, "bochs-display-vram", s->vgamem, &error_fatal); memory_region_init_io(&s->vbe, obj, &bochs_display_vbe_ops, s, --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588145905; cv=none; d=zohomail.com; s=zohoarc; b=ZWMmYrioFac36p41v4P8mFE0/DkxkDhFfujCSmRB8H2Z0VY/S+mgVLX16YW411akMlWUBFGs7LGPoHXXsIIHbJ8KvNSLs/UlfCR84FjfO7BLhmtWHEK19MA6s1grth21HAfXxC21IKIryLIrD+9TiEwxBPgfmt6n6h2y6/axUKk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588145905; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SMMno6mGoMsRZKU4ACociZdb2h0cUGFhg3LPyjD+Xt8=; b=GmXIVav+JhxizEzWNXP9mJ2m+SevJ/7Ai/0W31DOAIVsctOeeBuCqo1xdYMRansIIzuTb4iwCMqiA4D3cNc5EAat80s/PB3tWHrO4Rte10d1RqWP/876B43YiWI1I6GNhtkZyZAcHwZj0TjazOyT3JUFppXvZBlkn7lp5UoiY8U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588145905912240.20728923310492; Wed, 29 Apr 2020 00:38:25 -0700 (PDT) Received: from localhost ([::1]:55004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jThIV-0001bK-Lp for importer@patchew.org; Wed, 29 Apr 2020 03:38:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46290) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh2o-0007wn-Oz for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh1j-00041j-QM for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:10 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:49637 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh1j-0003xL-CM for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:03 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-465-e1FnSLJTNOSNebFtnqjQsw-1; Wed, 29 Apr 2020 03:20:59 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0AE64801503 for ; Wed, 29 Apr 2020 07:20:59 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 71178282E2; Wed, 29 Apr 2020 07:20:53 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 35C6A11358CF; Wed, 29 Apr 2020 09:20:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144861; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SMMno6mGoMsRZKU4ACociZdb2h0cUGFhg3LPyjD+Xt8=; b=Rgy/oeFvB45qiAWxkVP2oKbGojs9R9iQQduKoaXC4B7JQH58CkIwaAcDAXQa5rXRwKhTTC XbVFUkgRV8FNlHBC83P4lWVwibjqF2So7Bt3FOXOZIzfnK1JWWHB58hOSrM6gmMz1149MV blf/mNydYh25jJT814gSOgdY0tfyoZ4= X-MC-Unique: e1FnSLJTNOSNebFtnqjQsw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 18/32] virtio-net: Fix duplex=... and speed=... error handling Date: Wed, 29 Apr 2020 09:20:34 +0200 Message-Id: <20200429072048.29963-19-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=207.211.31.120; envelope-from=armbru@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 01:18:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" virtio_net_device_realize() rejects invalid duplex and speed values. The error handling is broken: $ ../qemu/bld-sani/x86_64-softmmu/qemu-system-x86_64 -S -display none -= monitor stdio QEMU 4.2.93 monitor - type 'help' for more information (qemu) device_add virtio-net,duplex=3Dx Error: 'duplex' must be 'half' or 'full' (qemu) c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D15654=3D=3DERROR: AddressSanitizer: heap-use-after-free on addres= s 0x62e000014590 at pc 0x560b75c8dc13 bp 0x7fffdf1a6950 sp 0x7fffdf1a6940 READ of size 8 at 0x62e000014590 thread T0 #0 0x560b75c8dc12 in object_dynamic_cast_assert /work/armbru/qemu/qom/obje= ct.c:826 #1 0x560b74c38ac0 in virtio_vmstate_change /work/armbru/qemu/hw/virtio/vir= tio.c:3210 #2 0x560b74d9765e in vm_state_notify /work/armbru/qemu/softmmu/vl.c:1271 #3 0x560b7494ba72 in vm_prepare_start /work/armbru/qemu/cpus.c:2156 #4 0x560b7494bacd in vm_start /work/armbru/qemu/cpus.c:2162 #5 0x560b75a7d890 in qmp_cont /work/armbru/qemu/monitor/qmp-cmds.c:160 #6 0x560b75a8d70a in hmp_cont /work/armbru/qemu/monitor/hmp-cmds.c:1043 #7 0x560b75a799f2 in handle_hmp_command /work/armbru/qemu/monitor/hmp.c:10= 82 [...] 0x62e000014590 is located 33168 bytes inside of 42288-byte region [0x62= e00000c400,0x62e000016930) freed by thread T1 here: #0 0x7feadd39491f in __interceptor_free (/lib64/libasan.so.5+0x10d91f) #1 0x7feadcebcd7c in g_free (/lib64/libglib-2.0.so.0+0x55d7c) #2 0x560b75c8fd40 in object_unref /work/armbru/qemu/qom/object.c:1128 #3 0x560b7498a625 in memory_region_unref /work/armbru/qemu/memory.c:1762 #4 0x560b74999fa4 in do_address_space_destroy /work/armbru/qemu/memory.c:2= 788 #5 0x560b762362fc in call_rcu_thread /work/armbru/qemu/util/rcu.c:283 #6 0x560b761c8884 in qemu_thread_start /work/armbru/qemu/util/qemu-thread-= posix.c:519 #7 0x7fead9be34bf in start_thread (/lib64/libpthread.so.0+0x84bf) previously allocated by thread T0 here: #0 0x7feadd394d18 in __interceptor_malloc (/lib64/libasan.so.5+0x10dd18) #1 0x7feadcebcc88 in g_malloc (/lib64/libglib-2.0.so.0+0x55c88) #2 0x560b75c8cf8a in object_new /work/armbru/qemu/qom/object.c:699 #3 0x560b75010ad9 in qdev_device_add /work/armbru/qemu/qdev-monitor.c:654 #4 0x560b750120c2 in qmp_device_add /work/armbru/qemu/qdev-monitor.c:805 #5 0x560b75012c1b in hmp_device_add /work/armbru/qemu/qdev-monitor.c:905 [...] =3D=3D15654=3D=3DABORTING Cause: virtio_net_device_realize() neglects to bail out after setting the error. Fix that. Fixes: 9473939ed7addcaaeb8fde5c093918fb7fa0919c Cc: "Michael S. Tsirkin" Cc: Jason Wang Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200422130719.28225-9-armbru@redhat.com> Acked-by: Michael S. Tsirkin --- hw/net/virtio-net.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index eddfa7f923..65bb6886c7 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -2947,6 +2947,7 @@ static void virtio_net_device_realize(DeviceState *de= v, Error **errp) n->net_conf.duplex =3D DUPLEX_FULL; } else { error_setg(errp, "'duplex' must be 'half' or 'full'"); + return; } n->host_features |=3D (1ULL << VIRTIO_NET_F_SPEED_DUPLEX); } else { @@ -2955,7 +2956,9 @@ static void virtio_net_device_realize(DeviceState *de= v, Error **errp) =20 if (n->net_conf.speed < SPEED_UNKNOWN) { error_setg(errp, "'speed' must be between 0 and INT_MAX"); - } else if (n->net_conf.speed >=3D 0) { + return; + } + if (n->net_conf.speed >=3D 0) { n->host_features |=3D (1ULL << VIRTIO_NET_F_SPEED_DUPLEX); } =20 --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588144898; cv=none; d=zohomail.com; s=zohoarc; b=W3582yF8ogO9I1BgvrLTdGG1VQaA6asSmLeO72u1rR9jSwmPxUg9eoQ4GJXmQ67CbyzHC0qKqd4iQ7fOEHvd61sI9vlo3mL2ByVmyubO0wq44aG49k0c75oGuJnwhwz0UmshEbqsqbapzIUI2UY/RUaCrV7H/8Le5yBeK8PJrJ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588144898; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LuKMz2cunkuyvgsHrtA6mHRQurhlf+Q6ZpdMc5OyeVA=; b=mAHpFI/JNBWiNLLcAhz0WQjeZUsRaoP7m2cl5zjDynY9TjwBuRtv+wgNY/xpJ2p8zpDkr1hSBhNysmcq9jEJCoL3ILoNWthtKjLl81DBT59rHzW9cqZAk2B4aGDkR5yZ4ezoGOWyV7T05ThPK8gC49YfeEcKzYz/+Mhzc5YxoNk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1588144898433735.8138150787606; Wed, 29 Apr 2020 00:21:38 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jTh1f-0003q1-L1; Wed, 29 Apr 2020 07:20:59 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jTh1e-0003pw-8B for xen-devel@lists.xenproject.org; Wed, 29 Apr 2020 07:20:58 +0000 Received: from us-smtp-1.mimecast.com (unknown [205.139.110.61]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id f8675ac2-89e9-11ea-b07b-bc764e2007e4; Wed, 29 Apr 2020 07:20:57 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-212-PhhyA91fOTm_1kO8hKGi9g-1; Wed, 29 Apr 2020 03:20:55 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CB9DFBFC5; Wed, 29 Apr 2020 07:20:53 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 75ED25D779; Wed, 29 Apr 2020 07:20:53 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 3BA1911358D0; Wed, 29 Apr 2020 09:20:49 +0200 (CEST) X-Inumbo-ID: f8675ac2-89e9-11ea-b07b-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144857; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LuKMz2cunkuyvgsHrtA6mHRQurhlf+Q6ZpdMc5OyeVA=; b=YPBuMTW12EnWYveR326vcqxkUUOw4frNJbAtyhAipiuA0hgFz5JL6whaTMw2e4O+Mnfxbt 9gurWbor2RBwrMN0b2Sq0sbQH2yv2DuyF1tAnNRAHqhKp6IUTJyzEvcYv19xLPoYOp81kT 0wqxC3oboz2YgAv5ig0GfGr4fNLkklE= X-MC-Unique: PhhyA91fOTm_1kO8hKGi9g-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 19/32] xen/pt: Fix flawed conversion to realize() Date: Wed, 29 Apr 2020 09:20:35 +0200 Message-Id: <20200429072048.29963-20-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony Perard , xen-devel@lists.xenproject.org, Stefano Stabellini , Paul Durrant Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The conversion of xen_pt_initfn() to xen_pt_realize() blindly replaced XEN_PT_ERR() by error_setg(). Several error conditions that did not fail xen_pt_initfn() now fail xen_pt_realize(). Unsurprisingly, the cleanup on these errors looks highly suspicious. Revert the inappropriate replacements. Fixes: 5a11d0f7549e24a10e178a9dc8ff5e698031d9a6 Cc: Stefano Stabellini Cc: Anthony Perard Cc: Paul Durrant Cc: xen-devel@lists.xenproject.org Signed-off-by: Markus Armbruster Reviewed-by: Paul Durrant Message-Id: <20200422130719.28225-10-armbru@redhat.com> --- hw/xen/xen_pt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c index b91082cb8b..81d5ad8da7 100644 --- a/hw/xen/xen_pt.c +++ b/hw/xen/xen_pt.c @@ -858,8 +858,8 @@ static void xen_pt_realize(PCIDevice *d, Error **errp) =20 rc =3D xc_physdev_map_pirq(xen_xc, xen_domid, machine_irq, &pirq); if (rc < 0) { - error_setg_errno(errp, errno, "Mapping machine irq %u to" - " pirq %i failed", machine_irq, pirq); + XEN_PT_ERR(d, "Mapping machine irq %u to pirq %i failed, (err: %d)= \n", + machine_irq, pirq, errno); =20 /* Disable PCI intx assertion (turn on bit10 of devctl) */ cmd |=3D PCI_COMMAND_INTX_DISABLE; @@ -880,8 +880,8 @@ static void xen_pt_realize(PCIDevice *d, Error **errp) PCI_SLOT(d->devfn), e_intx); if (rc < 0) { - error_setg_errno(errp, errno, "Binding of interrupt %u failed", - e_intx); + XEN_PT_ERR(d, "Binding of interrupt %i failed! (err: %d)\n", + e_intx, errno); =20 /* Disable PCI intx assertion (turn on bit10 of devctl) */ cmd |=3D PCI_COMMAND_INTX_DISABLE; @@ -889,8 +889,8 @@ static void xen_pt_realize(PCIDevice *d, Error **errp) =20 if (xen_pt_mapped_machine_irq[machine_irq] =3D=3D 0) { if (xc_physdev_unmap_pirq(xen_xc, xen_domid, machine_irq))= { - error_setg_errno(errp, errno, "Unmapping of machine" - " interrupt %u failed", machine_irq); + XEN_PT_ERR(d, "Unmapping of machine interrupt %i faile= d!" + " (err: %d)\n", machine_irq, errno); } } s->machine_irq =3D 0; --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588145316; cv=none; d=zohomail.com; s=zohoarc; b=aFo9qju5ifGrwEO1GyCADqNsavzoI1OeMsqBzen++5sb9oxwozWnL+xfFrMY0RAFNC94R00ngbTcX2w3pUDZA6QvPUqgz7DYm7VmbndelRJpvbyixPiqaB3mCxU1gDQmZg+OBfHQThQizmrf0k6/OPjbZWappUKshSbE7l0a+Bk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588145316; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PhhhUudLUbRStHxYbTEaO9gPqZJVt40K2eleSR+HyVE=; b=XoW/yXiBdIdplYume06sKrhZj8NFttsu0AVEa+Ay5rVKPU3+h05BO1ujGHc6Vm2SBUvUUUHxBNf66LF02n6RPUMzRcYr+FkOc1ukpwo2Mt+81z8z2rSrY2j2IKe/zs4o4bmfb1QSE6aKsd7DArHG5UhDjPus6D183pefOMtZMZ8= 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=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588145316615577.3161255357478; Wed, 29 Apr 2020 00:28:36 -0700 (PDT) Received: from localhost ([::1]:48608 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh91-0003hS-1z for importer@patchew.org; Wed, 29 Apr 2020 03:28:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46164) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh1v-0007ti-Vk for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh1g-0003wW-Iu for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:15 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:38445 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh1f-0003u4-Ps for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:20:59 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-506-UV-j63ukPdaHtcS_9EJg1g-1; Wed, 29 Apr 2020 03:20:54 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A9FED801504 for ; Wed, 29 Apr 2020 07:20:53 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 794EA648DF; Wed, 29 Apr 2020 07:20:53 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 41F8411358D1; Wed, 29 Apr 2020 09:20:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144856; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PhhhUudLUbRStHxYbTEaO9gPqZJVt40K2eleSR+HyVE=; b=MgQPxevOY2zlrL6xKxk3njT7KuJ0ZL2nQBndXvsbpEqs6pW67RkBJ0Wvv0Mg46k61jWzAj GtdrVKC33vW9ocnb2mmTlf7xB5N34Ra4WG7ccvUzWNscKG71s69lhGvv9YX0RJIFUpfoCl CpFyrj2oQTcGm7rFLbIfAFZ0HLyV1Bc= X-MC-Unique: UV-j63ukPdaHtcS_9EJg1g-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 20/32] io: Fix qio_channel_socket_close() error handling Date: Wed, 29 Apr 2020 09:20:36 +0200 Message-Id: <20200429072048.29963-21-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=205.139.110.120; envelope-from=armbru@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 01:42:37 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The Error ** argument must be NULL, &error_abort, &error_fatal, or a pointer to a variable containing NULL. Passing an argument of the latter kind twice without clearing it in between is wrong: if the first call sets an error, it no longer points to NULL for the second call. qio_channel_socket_close() passes @errp first to socket_listen_cleanup(), and then, if closesocket() fails, to error_setg_errno(). If socket_listen_cleanup() failed, this will trip the assertion in error_setv(). Fix by ignoring a second error. Fixes: 73564c407caedf992a1c688b5fea776a8b56ba2a Cc: Daniel P. Berrang=C3=A9 Signed-off-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: <20200422130719.28225-11-armbru@redhat.com> --- io/channel-socket.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/io/channel-socket.c b/io/channel-socket.c index b74f5b92a0..e1b4667087 100644 --- a/io/channel-socket.c +++ b/io/channel-socket.c @@ -704,6 +704,7 @@ qio_channel_socket_close(QIOChannel *ioc, { QIOChannelSocket *sioc =3D QIO_CHANNEL_SOCKET(ioc); int rc =3D 0; + Error *err =3D NULL; =20 if (sioc->fd !=3D -1) { #ifdef WIN32 @@ -715,8 +716,8 @@ qio_channel_socket_close(QIOChannel *ioc, =20 if (closesocket(sioc->fd) < 0) { sioc->fd =3D -1; - error_setg_errno(errp, errno, - "Unable to close socket"); + error_setg_errno(&err, errno, "Unable to close socket"); + error_propagate(errp, err); return -1; } sioc->fd =3D -1; --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588146012; cv=none; d=zohomail.com; s=zohoarc; b=RL91Lm18ac9+SEe1aCHQj23PllPu83Db4uHbe6j9DXnCmCvAJIDCKmNYoPBxla1nv/M2IwMo2YCZr+RXhw2ggYsmqC3MIvqEk1LxmVAmCkbQJhf1QytRGHKzBOOWaFUt8Acuhisi4pMR1ZC+HvHSGJ1Q4IdFnURpX1sFiXeBllk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588146012; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ARsxO36GYr/5NC74E6ItLer6/hyG11wa9m/wl3IdRbI=; b=n6QGLtfCvJmopngd4PV8A8R0jqMZ/52N9pe6RxLcLYM/P346rh/yIm7jKoVFiVmzjYndHRKk8bEcVWk5J9d03W8x17PDe0hu6i37DyW69arrGsh0pY/OkuXfLQ7rUClbQr03RhuppSpMlPQEWRzWn6nSmnKLYYLz3QW0smpuVOE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588146012522298.51433988269514; Wed, 29 Apr 2020 00:40:12 -0700 (PDT) Received: from localhost ([::1]:34574 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jThKF-0004ta-5o for importer@patchew.org; Wed, 29 Apr 2020 03:40:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46252) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh27-0007uG-8H for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh1i-0003zN-MI for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:27 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:31206 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh1h-0003uf-IT for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:01 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-288-0a0jWyUZOZ2y_NQq2XFQHw-1; Wed, 29 Apr 2020 03:20:54 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BD69C8015CE; Wed, 29 Apr 2020 07:20:53 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 815721000329; Wed, 29 Apr 2020 07:20:53 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 47D3311358D2; Wed, 29 Apr 2020 09:20:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144857; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ARsxO36GYr/5NC74E6ItLer6/hyG11wa9m/wl3IdRbI=; b=FLm0doXrB3X2HO92y8Kwl0zTgccp+/hHd8ZrWQK8PXIb4ifY/IH1UC1HJKPtNFlgAdD8+F ztw+Gb9aml48074+9LLOgIh2kvLZCQHXVTrCUKmCXrtvtCqq8VKW39H4bN7+FDYxgHwTJE AMHPyZgMX9c5uFWpUU5x6vlXdNyxRTY= X-MC-Unique: 0a0jWyUZOZ2y_NQq2XFQHw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 21/32] migration/colo: Fix qmp_xen_colo_do_checkpoint() error handling Date: Wed, 29 Apr 2020 09:20:37 +0200 Message-Id: <20200429072048.29963-22-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=205.139.110.120; envelope-from=armbru@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 01:42:37 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhang Chen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , zhanghailiang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The Error ** argument must be NULL, &error_abort, &error_fatal, or a pointer to a variable containing NULL. Passing an argument of the latter kind twice without clearing it in between is wrong: if the first call sets an error, it no longer points to NULL for the second call. qmp_xen_colo_do_checkpoint() passes @errp first to replication_do_checkpoint_all(), and then to colo_notify_filters_event(). If both fail, this will trip the assertion in error_setv(). Similar code in secondary_vm_do_failover() calls colo_notify_filters_event() only after replication_do_checkpoint_all() succeeded. Do the same here. Fixes: 0e8818f023616677416840d6ddc880db8de3c967 Cc: Zhang Chen Cc: zhanghailiang Signed-off-by: Markus Armbruster Reviewed-by: zhanghailiang Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Zhang Chen Message-Id: <20200422130719.28225-12-armbru@redhat.com> --- migration/colo.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/migration/colo.c b/migration/colo.c index a54ac84f41..1b3493729b 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -263,7 +263,13 @@ ReplicationStatus *qmp_query_xen_replication_status(Er= ror **errp) =20 void qmp_xen_colo_do_checkpoint(Error **errp) { - replication_do_checkpoint_all(errp); + Error *err =3D NULL; + + replication_do_checkpoint_all(&err); + if (err) { + error_propagate(errp, err); + return; + } /* Notify all filters of all NIC to do checkpoint */ colo_notify_filters_event(COLO_EVENT_CHECKPOINT, errp); } --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588145986; cv=none; d=zohomail.com; s=zohoarc; b=iZVXJIk9QASzfwyklpfa0B32pc2XwMP+hVF6/zclnpOnjswvxyPkkstXxByPFT18/j54IkgxrH4bGwqExSSCRCGtSqmaH7xstb9eL9JULL/K2YTj8cAcrgOd0kSvDCim19J96vvbODuR0s3O2YNpQ4ycj5SgLagHej6U0RBERR8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588145986; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cD8zki1D1EIAJAynicB/92D9YP+ssmVx79XfEZUiT4M=; b=iEiXK5oGzD5yURcJ9EAVHHR5t8G3K5LatUFNhDq7Lz63zLoPkqblQ45Fy3L0FoPSycQ7BrK6zcRlDgEjV/1DKp+gRezQ8A8vT1MJSX6+DSE9VQiKHFuwu1Ok3b2Gshw59x2aS9kevX2ccJrG2wzjbmD0GbTfh/n6wOS0Jl/VXGY= 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=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588145986806407.36072370212014; Wed, 29 Apr 2020 00:39:46 -0700 (PDT) Received: from localhost ([::1]:60708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jThJp-0003zS-Cn for importer@patchew.org; Wed, 29 Apr 2020 03:39:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46342) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh3H-0000WC-2f for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh2I-0004MF-IV for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:38 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:46346 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh2I-0004M5-5s for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:38 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-134--_6VvPBLMkOUdryorqLXhg-1; Wed, 29 Apr 2020 03:20:54 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B71C11009454 for ; Wed, 29 Apr 2020 07:20:53 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8760566060; Wed, 29 Apr 2020 07:20:53 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4E69111358D3; Wed, 29 Apr 2020 09:20:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144897; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cD8zki1D1EIAJAynicB/92D9YP+ssmVx79XfEZUiT4M=; b=UWDd9Lu7LSGeBsDAqFIKmTQDGj6/NTEkNtsL7ZqHOLAMkKoy5JjA2NoZUqxgi5scNFx0ip pCwibgDUGiu7omtQLxYmlpc3x7JNp5XPYKF/jHRtTrIEYlkYKGpJkka6STsUrymCAIVYap pu99VyjbzTu1JqW7y9lcyWWUeonVrSU= X-MC-Unique: -_6VvPBLMkOUdryorqLXhg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 22/32] tests/test-logging: Fix test for -dfilter 0..0xffffffffffffffff Date: Wed, 29 Apr 2020 09:20:38 +0200 Message-Id: <20200429072048.29963-23-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=205.139.110.120; envelope-from=armbru@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 01:42:37 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Fixes: 58e19e6e7914354242a67442d0006f9e31684d1a Signed-off-by: Markus Armbruster Message-Id: <20200422130719.28225-13-armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tests/test-logging.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test-logging.c b/tests/test-logging.c index 6387e4933f..8580b82420 100644 --- a/tests/test-logging.c +++ b/tests/test-logging.c @@ -73,10 +73,10 @@ static void test_parse_range(void) g_assert(qemu_log_in_addr_range(UINT64_MAX)); g_assert_false(qemu_log_in_addr_range(UINT64_MAX - 1)); =20 - qemu_set_dfilter_ranges("0..0xffffffffffffffff", &err); + qemu_set_dfilter_ranges("0..0xffffffffffffffff", &error_abort); g_assert(qemu_log_in_addr_range(0)); g_assert(qemu_log_in_addr_range(UINT64_MAX)); -=20 + qemu_set_dfilter_ranges("2..1", &err); error_free_or_abort(&err); =20 --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588145681; cv=none; d=zohomail.com; s=zohoarc; b=WqdKpEy/Jlm+upxLS3XCE9vwKQ80WDUJT/c+VH4DDRTESU5plNWxo2ZIHrQOpUd1PxYFiGnTlceJlLZl19hYntS/yxdSQtfesyYoklasokn3G44hoqVWt2TU0Xfd8MB7JhD4LWFmrwVRscVbeaAS5ntqHQrHuaXZY1z+m4vVhao= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588145681; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5n34gq+3RmHjy+dXJz5n6EkI7iwJ+vPmZrsqkO05GB4=; b=j1P0pf770YyZtcGfvCV4sjZvB4MZe+e8d+UE8fD8Yd263EPDbl5qywP8dwnPFjq7+Y5SEkK4L72HcgQ9Lb2M37H/+fPJArG53K2MLznH7clCIToZuRvHF1vglrPb0EhgLul8NwULMw60TbXRniGkdQui88vfsm3udiMAKFK9d3g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588145681615705.9635940016775; Wed, 29 Apr 2020 00:34:41 -0700 (PDT) Received: from localhost ([::1]:41858 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jThEt-0004LO-9q for importer@patchew.org; Wed, 29 Apr 2020 03:34:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46234) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh24-0007u9-Hz for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh1i-0003ys-Eh for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:24 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:28536 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh1h-0003uw-2o for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:01 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-168-obsKFwb1NdOtZcsdgx2o2Q-1; Wed, 29 Apr 2020 03:20:54 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BBB55835B44; Wed, 29 Apr 2020 07:20:53 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 87DD95C1BE; Wed, 29 Apr 2020 07:20:53 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5424311358D4; Wed, 29 Apr 2020 09:20:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144857; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5n34gq+3RmHjy+dXJz5n6EkI7iwJ+vPmZrsqkO05GB4=; b=TvTxkeT5i6g2F9gtC/YiWu3gOHezvVm6AfJFFefSdKAf3NUY0tFtUCdjcEYeu3+dTcYOoj gNn2rLFMIo7m4F5GWIaxfguKqOIYX56YJHfogXzhpIaJOJ4fGtDULxNLxuNT61t9zvp/M5 hxl9YHk54B9bXybCKrj2dXWt0ZNmps4= X-MC-Unique: obsKFwb1NdOtZcsdgx2o2Q-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 23/32] qga: Fix qmp_guest_get_memory_blocks() error handling Date: Wed, 29 Apr 2020 09:20:39 +0200 Message-Id: <20200429072048.29963-24-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=205.139.110.120; envelope-from=armbru@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 01:42:37 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Roth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The Error ** argument must be NULL, &error_abort, &error_fatal, or a pointer to a variable containing NULL. Passing an argument of the latter kind twice without clearing it in between is wrong: if the first call sets an error, it no longer points to NULL for the second call. qmp_guest_get_memory_blocks() passes &local_err to transfer_memory_block() in a loop. If this fails in more than one iteration, it can trip error_setv()'s assertion. Fix it to break the loop. Cc: Michael Roth Signed-off-by: Markus Armbruster Message-Id: <20200422130719.28225-14-armbru@redhat.com> Reviewed-by: Eric Blake --- qga/commands-posix.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index a52af0315f..ae1348dc8f 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -2518,6 +2518,9 @@ GuestMemoryBlockList *qmp_guest_get_memory_blocks(Err= or **errp) mem_blk->phys_index =3D strtoul(&de->d_name[6], NULL, 10); mem_blk->has_can_offline =3D true; /* lolspeak ftw */ transfer_memory_block(mem_blk, true, NULL, &local_err); + if (local_err) { + break; + } =20 entry =3D g_malloc0(sizeof *entry); entry->value =3D mem_blk; --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588145097; cv=none; d=zohomail.com; s=zohoarc; b=aaqEmQFUu99s1E/YqZkQy2L3xjgJ3LwG08cUxMDoTidwHVvrYr4OWYvU/xxY1XFg+5l4SurxVm+bJ+WgtkUoIBai4cOW4pJj2uxfReDX501Fn5R6R3Ck1QIjgcmYC5KXIr3XvY1YOgclJP3HrR/EojAsI6euqo/StW3+9flgVl8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588145097; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5nz3jWVyp59t6okYH7nE69b5YZrpl0FIWVQOMM5Ns0Y=; b=Z4GIuQn4yvu7kMrE3AH2r89p/LB5Mj8B74ZW274bivYYyJp0Tx7etfiHD9tv4xeb4pd4aGOwCcqLMJmeNvND+240w5CykYJ63g3KwE6ChgBmb1Za2gP1VHzgagcDRoJdv44IdCKZOPwEOkbFU2eCIjNgY0QNqa9dobkFIeW/HtM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588145097799822.9850474628448; Wed, 29 Apr 2020 00:24:57 -0700 (PDT) Received: from localhost ([::1]:60090 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh5U-0004wR-Fw for importer@patchew.org; Wed, 29 Apr 2020 03:24:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46182) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh1y-0007tq-CB for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh1i-0003y3-H5 for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:18 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:56417 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh1g-0003ub-KB for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:01 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-417-0V47d_TFMaCGA4yZTIVm4A-1; Wed, 29 Apr 2020 03:20:54 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C324EBFC4; Wed, 29 Apr 2020 07:20:53 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8D65D5C221; Wed, 29 Apr 2020 07:20:53 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5B20E11358D5; Wed, 29 Apr 2020 09:20:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144856; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5nz3jWVyp59t6okYH7nE69b5YZrpl0FIWVQOMM5Ns0Y=; b=i0TN+dpMM/R56BcRyzjXD9XZI1r6NrxPvfV04yLzfLxNynYiLopF3/ibsBYYWirz/CFyMF evsoCVwFG/QRRSJ4sTka7J/fRebx9aWwKzu+LsmD1YuxDgyx0EYwTVjmoRGGAKgnXMUFxP M11sMT6dtTK6zBb/IHBJsNxicVBuBLk= X-MC-Unique: 0V47d_TFMaCGA4yZTIVm4A-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 24/32] qga: Fix qmp_guest_suspend_{disk, ram}() error handling Date: Wed, 29 Apr 2020 09:20:40 +0200 Message-Id: <20200429072048.29963-25-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=207.211.31.81; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 01:28:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Michael Roth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The Error ** argument must be NULL, &error_abort, &error_fatal, or a pointer to a variable containing NULL. Passing an argument of the latter kind twice without clearing it in between is wrong: if the first call sets an error, it no longer points to NULL for the second qmp_guest_suspend_disk() and qmp_guest_suspend_ram() pass @local_err first to check_suspend_mode(), then to acquire_privilege(), then to execute_async(). Continuing after errors here can only end in tears. For instance, we risk tripping error_setv()'s assertion. Fixes: aa59637ea1c6a4c83430933f9c44c43e6c3f1b69 Fixes: f54603b6aa765514b2519e74114a2f417759d727 Cc: Michael Roth Signed-off-by: Markus Armbruster Message-Id: <20200422130719.28225-15-armbru@redhat.com> Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- qga/commands-win32.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 9717a8d52d..5ba56327dd 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -1322,9 +1322,16 @@ void qmp_guest_suspend_disk(Error **errp) =20 *mode =3D GUEST_SUSPEND_MODE_DISK; check_suspend_mode(*mode, &local_err); + if (local_err) { + goto out; + } acquire_privilege(SE_SHUTDOWN_NAME, &local_err); + if (local_err) { + goto out; + } execute_async(do_suspend, mode, &local_err); =20 +out: if (local_err) { error_propagate(errp, local_err); g_free(mode); @@ -1338,9 +1345,16 @@ void qmp_guest_suspend_ram(Error **errp) =20 *mode =3D GUEST_SUSPEND_MODE_RAM; check_suspend_mode(*mode, &local_err); + if (local_err) { + goto out; + } acquire_privilege(SE_SHUTDOWN_NAME, &local_err); + if (local_err) { + goto out; + } execute_async(do_suspend, mode, &local_err); =20 +out: if (local_err) { error_propagate(errp, local_err); g_free(mode); --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588145220; cv=none; d=zohomail.com; s=zohoarc; b=IepRY0orjaut/lOmecYaRAd+B4a9IUDUjePec4vQZ9hNScqasHk7DC9oncGAaP11M7bBcrieIEQlP/CpGc4f98TeZSsF2FYN1nlBK5vAB3nydrKPlRoPi2vrhVojo1rgjqau8SqYr3DBS/SHNux2ssqYtzXSpwtWWJb9pzZ3sks= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588145220; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ohrMlQSDYve0v0icgLJtlOnRxnFckFAJJHmPNmaC5mg=; b=V3ts7Qt/+XummDfvb/wPZkT/zSkh5Ppb9M2Ps7qetz6Inev0F7SRCwRYSsk8cWzNVf8cn6tKwnGXfZeHdY5uOUVQ8kfh5qLQ1kFisgsZQvAl4D0KJQkZKSdLPG1BX/RlYef0EP+CQcnt1CWI7iwtnvukA7vCAMoL0NMjOp7dvas= 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=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588145220029127.76809858371087; Wed, 29 Apr 2020 00:27:00 -0700 (PDT) Received: from localhost ([::1]:40496 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh7P-0000NL-5K for importer@patchew.org; Wed, 29 Apr 2020 03:26:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46196) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh20-0007tx-5i for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh1i-0003yO-P4 for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:19 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:39127 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh1g-0003v1-Ih for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:01 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-289-j-bjr4kxPu2lXHGk3_CWBA-1; Wed, 29 Apr 2020 03:20:55 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0B2081895A28 for ; Wed, 29 Apr 2020 07:20:55 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D04AD600DB; Wed, 29 Apr 2020 07:20:54 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 60E9211358D6; Wed, 29 Apr 2020 09:20:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144857; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ohrMlQSDYve0v0icgLJtlOnRxnFckFAJJHmPNmaC5mg=; b=FnQXsSqBcgXmyW5GtwAh+L3jfJRg5fvuFjVp3leP+NzneLHg5XMTJP0zs7rPFbA8CSFvlW 0U4u/Oif+mLMQ/iQ+2XRtMoenBC19Dc0RocMt4COXrvWJbzOeUpLYOkw3+JTgjIiqWciHL amKA7kUX237b4EdUVeAte5Kz0TltdMg= X-MC-Unique: j-bjr4kxPu2lXHGk3_CWBA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 25/32] sam460ex: Suppress useless warning on -m 32 and -m 64 Date: Wed, 29 Apr 2020 09:20:41 +0200 Message-Id: <20200429072048.29963-26-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=207.211.31.81; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 01:28:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Requesting 32 or 64 MiB of RAM with the sam460ex machine type produces a useless warning: qemu-system-ppc: warning: Memory size is too small for SDRAM type, adju= sting type This is because sam460ex_init() asks spd_data_generate() for DDR2, which is impossible, so spd_data_generate() corrects it to DDR. The warning goes back to commit 08fd99179a "sam460ex: Clean up SPD EEPROM creation". Make sam460ex_init() pass the correct SDRAM type to get rid of the warning. Signed-off-by: Markus Armbruster Message-Id: <20200422134815.1584-2-armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/ppc/sam460ex.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c index 898453cf30..1e3eaac0db 100644 --- a/hw/ppc/sam460ex.c +++ b/hw/ppc/sam460ex.c @@ -335,7 +335,8 @@ static void sam460ex_init(MachineState *machine) dev =3D sysbus_create_simple(TYPE_PPC4xx_I2C, 0x4ef600700, uic[0][2]); i2c =3D PPC4xx_I2C(dev)->bus; /* SPD EEPROM on RAM module */ - spd_data =3D spd_data_generate(DDR2, ram_sizes[0], &err); + spd_data =3D spd_data_generate(ram_sizes[0] < 128 * MiB ? DDR : DDR2, + ram_sizes[0], &err); if (err) { warn_report_err(err); } --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588145726; cv=none; d=zohomail.com; s=zohoarc; b=WVJWgyS2c9pq4bRq8IDK1vdZobpY5nH7m5IO7Jbg+1wwlmJCKEkqUg82TRsdURpaLVWE9DGEah8u7xMFtCr6w5nYrETkPWFuyZWoUCSG1EHUhYjLbGjgirYbbk5DCMED+DMrCBX5aNs0O/F77MCC01+eUKiGHpIC6vhF6YJjPtM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588145726; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XUbi8y5cbN7Fl8el7ItnKryZ4y2K06/Omj/+3XAoE7g=; b=JZ8de4XyfVeHG5DlWPuw8lGdi5Ijn0ykjPBwionsdC3SY8C2ou8sM+x1cxTRcpCU1cLO8LKhIzx24xQIS1H6pxBF5Yw733DPdg/V4NhM46VzH36LLD12oHZMeNqtOGujztCo6pArH8rRjVNuqKhXDxKnZJPYALPd6WPnG9Ap6O0= 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=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588145726462833.6560884744116; Wed, 29 Apr 2020 00:35:26 -0700 (PDT) Received: from localhost ([::1]:44402 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jThFd-0005Q8-2V for importer@patchew.org; Wed, 29 Apr 2020 03:35:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46220) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh23-0007u7-FS for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh1i-0003ye-T8 for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:23 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:48215 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh1h-0003v8-M7 for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:01 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-323--pw2r-BJM9-SVOzZMqy3ZA-1; Wed, 29 Apr 2020 03:20:56 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3ED41107AFB2 for ; Wed, 29 Apr 2020 07:20:55 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DB42760300 for ; Wed, 29 Apr 2020 07:20:54 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6723E11358D7; Wed, 29 Apr 2020 09:20:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144857; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XUbi8y5cbN7Fl8el7ItnKryZ4y2K06/Omj/+3XAoE7g=; b=XE5P/Qf6rVN1dlgMwu2VGU1brsjFDZkBdD0hk9JfF3LvVC8Iw1nAa7SzrfrOPNRzZyNThz PJnAakd/+DqcV1OeMjL33XLakkkAZSZNXvNsscjr7pEMIvJ56ibBgwVIJG3q0115EenjYK rabWjQBJV95BKzNHtx+hkb2t9Z8xABg= X-MC-Unique: -pw2r-BJM9-SVOzZMqy3ZA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 26/32] smbus: Fix spd_data_generate() error API violation Date: Wed, 29 Apr 2020 09:20:42 +0200 Message-Id: <20200429072048.29963-27-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=207.211.31.81; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 01:28:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The Error ** argument must be NULL, &error_abort, &error_fatal, or a pointer to a variable containing NULL. Passing an argument of the latter kind twice without clearing it in between is wrong: if the first call sets an error, it no longer points to NULL for the second call. spd_data_generate() can pass @errp to error_setg() more than once when it adjusts both memory size and type. Harmless, because no caller passes anything that needs adjusting. Until the previous commit, sam460ex passed types that needed adjusting, but not sizes. spd_data_generate()'s contract is rather awkward: If everything's fine, return non-null and don't set an error. Else, if memory size or type need adjusting, return non-null and set an error describing the adjustment. Else, return null and set an error reporting why no data can be generated. Its callers treat the error as a warning even when null is returned. They don't create the "smbus-eeprom" device then. Suspicious. Since the previous commit, only "everything's fine" can actually happen. Drop the unused code and simplify the callers. This gets rid of the error API violation. Signed-off-by: Markus Armbruster Message-Id: <20200422134815.1584-3-armbru@redhat.com> --- include/hw/i2c/smbus_eeprom.h | 2 +- hw/i2c/smbus_eeprom.c | 30 ++++-------------------------- hw/mips/mips_fulong2e.c | 10 ++-------- hw/ppc/sam460ex.c | 12 +++--------- 4 files changed, 10 insertions(+), 44 deletions(-) diff --git a/include/hw/i2c/smbus_eeprom.h b/include/hw/i2c/smbus_eeprom.h index 15e2151b50..68b0063ab6 100644 --- a/include/hw/i2c/smbus_eeprom.h +++ b/include/hw/i2c/smbus_eeprom.h @@ -31,6 +31,6 @@ void smbus_eeprom_init(I2CBus *bus, int nb_eeprom, const uint8_t *eeprom_spd, int size); =20 enum sdram_type { SDR =3D 0x4, DDR =3D 0x7, DDR2 =3D 0x8 }; -uint8_t *spd_data_generate(enum sdram_type type, ram_addr_t size, Error **= errp); +uint8_t *spd_data_generate(enum sdram_type type, ram_addr_t size); =20 #endif diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c index 5adf3b15b5..07fbbf87f1 100644 --- a/hw/i2c/smbus_eeprom.c +++ b/hw/i2c/smbus_eeprom.c @@ -195,8 +195,7 @@ void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom, } =20 /* Generate SDRAM SPD EEPROM data describing a module of type and size */ -uint8_t *spd_data_generate(enum sdram_type type, ram_addr_t ram_size, - Error **errp) +uint8_t *spd_data_generate(enum sdram_type type, ram_addr_t ram_size) { uint8_t *spd; uint8_t nbanks; @@ -222,29 +221,10 @@ uint8_t *spd_data_generate(enum sdram_type type, ram_= addr_t ram_size, g_assert_not_reached(); } size =3D ram_size >> 20; /* work in terms of megabytes */ - if (size < 4) { - error_setg(errp, "SDRAM size is too small"); - return NULL; - } sz_log2 =3D 31 - clz32(size); size =3D 1U << sz_log2; - if (ram_size > size * MiB) { - error_setg(errp, "SDRAM size 0x"RAM_ADDR_FMT" is not a power of 2,= " - "truncating to %u MB", ram_size, size); - } - if (sz_log2 < min_log2) { - error_setg(errp, - "Memory size is too small for SDRAM type, adjusting typ= e"); - if (size >=3D 32) { - type =3D DDR; - min_log2 =3D 5; - max_log2 =3D 12; - } else { - type =3D SDR; - min_log2 =3D 2; - max_log2 =3D 9; - } - } + assert(ram_size =3D=3D size * MiB); + assert(sz_log2 >=3D min_log2); =20 nbanks =3D 1; while (sz_log2 > max_log2 && nbanks < 8) { @@ -252,9 +232,7 @@ uint8_t *spd_data_generate(enum sdram_type type, ram_ad= dr_t ram_size, nbanks++; } =20 - if (size > (1ULL << sz_log2) * nbanks) { - error_setg(errp, "Memory size is too big for SDRAM, truncating"); - } + assert(size =3D=3D (1ULL << sz_log2) * nbanks); =20 /* split to 2 banks if possible to avoid a bug in MIPS Malta firmware = */ if (nbanks =3D=3D 1 && sz_log2 > min_log2) { diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c index 5040afd581..ef02d54b33 100644 --- a/hw/mips/mips_fulong2e.c +++ b/hw/mips/mips_fulong2e.c @@ -297,7 +297,6 @@ static void mips_fulong2e_init(MachineState *machine) MemoryRegion *bios =3D g_new(MemoryRegion, 1); long bios_size; uint8_t *spd_data; - Error *err =3D NULL; int64_t kernel_entry; PCIBus *pci_bus; ISABus *isa_bus; @@ -377,13 +376,8 @@ static void mips_fulong2e_init(MachineState *machine) } =20 /* Populate SPD eeprom data */ - spd_data =3D spd_data_generate(DDR, machine->ram_size, &err); - if (err) { - warn_report_err(err); - } - if (spd_data) { - smbus_eeprom_init_one(smbus, 0x50, spd_data); - } + spd_data =3D spd_data_generate(DDR, machine->ram_size); + smbus_eeprom_init_one(smbus, 0x50, spd_data); =20 mc146818_rtc_init(isa_bus, 2000, NULL); =20 diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c index 1e3eaac0db..42a8c9fb7f 100644 --- a/hw/ppc/sam460ex.c +++ b/hw/ppc/sam460ex.c @@ -292,7 +292,6 @@ static void sam460ex_init(MachineState *machine) SysBusDevice *sbdev; struct boot_info *boot_info; uint8_t *spd_data; - Error *err =3D NULL; int success; =20 cpu =3D POWERPC_CPU(cpu_create(machine->cpu_type)); @@ -336,14 +335,9 @@ static void sam460ex_init(MachineState *machine) i2c =3D PPC4xx_I2C(dev)->bus; /* SPD EEPROM on RAM module */ spd_data =3D spd_data_generate(ram_sizes[0] < 128 * MiB ? DDR : DDR2, - ram_sizes[0], &err); - if (err) { - warn_report_err(err); - } - if (spd_data) { - spd_data[20] =3D 4; /* SO-DIMM module */ - smbus_eeprom_init_one(i2c, 0x50, spd_data); - } + ram_sizes[0]); + spd_data[20] =3D 4; /* SO-DIMM module */ + smbus_eeprom_init_one(i2c, 0x50, spd_data); /* RTC */ i2c_create_slave(i2c, "m41t80", 0x68); =20 --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588145321; cv=none; d=zohomail.com; s=zohoarc; b=HHft/mHX/Iu17WCiaJ4iv0N4XGRsMHNQ4uPX/NZKnhEhAB/i9ocu8g/vPxKAoca656tFYwS2NwLrhup9t/ehxRNLIGpt3SUHtzmdmsrJgidwTx70d6ZcKwb72BDdi5TRhEW9PJ2smCQcVSt62n0OH2gNqjzMyYatQ107cjKXy7M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588145321; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JOczfZRQoEV4DEKIyen7wvPpHOzlScKV32qYKsGaAFQ=; b=C+Z1B4SBJqTU2wTFEor9Sv+LsvG+yIVeWX9jJOzDP0QEanGycoXHEIAJUTMl7yajzTJ5I9Dv/G+ZmhVOMxhTxAPUGIZeD9Do0yXSQRCOUG7fuNaKyo4QYYUG8KtK/X84XmQSju5oNV36wzCuARnKeFE6GRxDLyaOMly9+QQ2nYE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588145321245777.0026907500597; Wed, 29 Apr 2020 00:28:41 -0700 (PDT) Received: from localhost ([::1]:49038 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh95-0003tg-RB for importer@patchew.org; Wed, 29 Apr 2020 03:28:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46200) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh20-0007ty-VR for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh1i-0003yJ-N9 for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:20 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:35628 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh1h-0003wj-IH for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:01 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-411-r6cIbYhMPkOst_SuAnYTFA-1; Wed, 29 Apr 2020 03:20:56 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1A3BC835B48; Wed, 29 Apr 2020 07:20:55 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DD7E55D9E5; Wed, 29 Apr 2020 07:20:54 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6DC5811358D8; Wed, 29 Apr 2020 09:20:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144860; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JOczfZRQoEV4DEKIyen7wvPpHOzlScKV32qYKsGaAFQ=; b=KBRW/GrckDo6KFOuHcb+W1q20bhZsYk19UWwFr+2EwSTBAMGMa9H9BVRMBEHwEh+RzbJej l82cMqblFcqPPu8+E9wy9gNSZuqhccQh3HBO8ec4CHojZThySGwVmz1pzAIdXjkesHPRnA b86xfrTUbae7Ti3aY9QnTmyKnztTBEg= X-MC-Unique: r6cIbYhMPkOst_SuAnYTFA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 27/32] bamboo, sam460ex: Tidy up error message for unsupported RAM size Date: Wed, 29 Apr 2020 09:20:43 +0200 Message-Id: <20200429072048.29963-28-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=207.211.31.81; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 01:28:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Improve $ ppc-softmmu/qemu-system-ppc -M sam460ex -m 4096 qemu-system-ppc: Max 1 banks of 2048 ,1024 ,512 ,256 ,128 ,64 ,32 MB DI= MM/bank supported qemu-system-ppc: Possible valid RAM size: 2048 to qemu-system-ppc: at most 1 bank of 2048, 1024, 512, 256, 128, 64, 32 Mi= B each supported Possible valid RAM size: 1024 MiB Signed-off-by: Markus Armbruster Message-Id: <20200422134815.1584-4-armbru@redhat.com> Reviewed-by: BALATON Zoltan Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/ppc/ppc4xx_devs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/ppc/ppc4xx_devs.c b/hw/ppc/ppc4xx_devs.c index 3376c43ff5..f1651e04d9 100644 --- a/hw/ppc/ppc4xx_devs.c +++ b/hw/ppc/ppc4xx_devs.c @@ -716,11 +716,11 @@ void ppc4xx_sdram_banks(MemoryRegion *ram, int nr_ban= ks, for (i =3D 0; sdram_bank_sizes[i]; i++) { g_string_append_printf(s, "%" PRIi64 "%s", sdram_bank_sizes[i] / MiB, - sdram_bank_sizes[i + 1] ? " ," : ""); + sdram_bank_sizes[i + 1] ? ", " : ""); } - error_report("Max %d banks of %s MB DIMM/bank supported", - nr_banks, s->str); - error_report("Possible valid RAM size: %" PRIi64, + error_report("at most %d bank%s of %s MiB each supported", + nr_banks, nr_banks =3D=3D 1 ? "" : "s", s->str); + error_printf("Possible valid RAM size: %" PRIi64 " MiB \n", used_size ? used_size / MiB : sdram_bank_sizes[i - 1] / MiB); =20 g_string_free(s, true); --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588145571; cv=none; d=zohomail.com; s=zohoarc; b=VRfdlQ4AwN/dTjjmR2I/CaaL9wGnj5UtcLs/7vqpkgECHsIEVZlJ4mDCvAOzjIvhXbWVD8l7lc1e057JQ/3cvbWsDGPrOq7qg5OpDS31MBhvbhFW4nIfvvBkACvSz0mv9kLGlQ4D8jh3h4p/w8XcmutJLzOdQxiKjpdE3G1XtLw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588145571; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yF+PmgERbTWXmJQUaeokDtWDsSNx4xCM1rtQqZprl0M=; b=PeJcw9qfy2XDRq9o9W4P7L9we8qZeCFkGmahhIDNBYRQa5oV0dUaAhDFSkKVn1i+j0ED46hCQoqYZOM20DO6N+8NsFKovJkOH/MWUOhkILXZICMfgUIlkhpgA1NU/BJv+3j3QGxVaKA+af9qxe6rg7qsRtK7BA8E2kA3cLbeeTs= 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=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588145571795757.7541443983063; Wed, 29 Apr 2020 00:32:51 -0700 (PDT) Received: from localhost ([::1]:35426 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jThD8-0001i4-HI for importer@patchew.org; Wed, 29 Apr 2020 03:32:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46188) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh1y-0007tt-S9 for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh1i-0003xv-Gv for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:18 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:56736 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh1g-0003v2-HQ for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:00 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-289-ZhFa8XY5PACWZ3LIDjQ3Ug-1; Wed, 29 Apr 2020 03:20:55 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1BBFC80058A for ; Wed, 29 Apr 2020 07:20:55 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DF4EE5D9F1 for ; Wed, 29 Apr 2020 07:20:54 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 7388811358D9; Wed, 29 Apr 2020 09:20:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144857; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yF+PmgERbTWXmJQUaeokDtWDsSNx4xCM1rtQqZprl0M=; b=ehSyKLh+otWHgMR4Rpx2MN/UQkucbt9XrVLIPTCWHGMJXQOJQPdZuhjz88nEecBlgcOI6b kmQ4iRe/2OwT2cQiED407GDyE60/kSC9jz8VMyJ9I1RuwmbHk7meFshRuL/NSHch6oU/mE RknktOpjr6tmGy/P6FcIzi4HNWeQKy8= X-MC-Unique: ZhFa8XY5PACWZ3LIDjQ3Ug-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 28/32] smbus: Fix spd_data_generate() for number of banks > 2 Date: Wed, 29 Apr 2020 09:20:44 +0200 Message-Id: <20200429072048.29963-29-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=207.211.31.81; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 01:28:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" spd_data_generate() splits @ram_size bytes into @nbanks RAM banks of 1 << sz_log2 MiB each, like this: size =3D ram_size >> 20; /* work in terms of megabytes */ [...] nbanks =3D 1; while (sz_log2 > max_log2 && nbanks < 8) { sz_log2--; nbanks++; } Each iteration halves the size of a bank, and increments the number of banks. Wrong: it should double the number of banks. The bug goes back all the way to commit b296b664ab "smbus: Add a helper to generate SPD EEPROM data". It can't bite because spd_data_generate()'s current users pass only @ram_size that result in *zero* iterations: machine RAM size #banks type bank size fulong2e 256 MiB 1 DDR 256 MiB sam460ex 2048 MiB 1 DDR2 2048 MiB 1024 MiB 1 DDR2 1024 MiB 512 MiB 1 DDR2 512 MiB 256 MiB 1 DDR2 256 MiB 128 MiB 1 SDR 128 MiB 64 MiB 1 SDR 64 MiB 32 MiB 1 SDR 32 MiB Apply the obvious, minimal fix. I admit I'm tempted to rip out the unused (and obviously untested) feature instead, because YAGNI. Note that this is not the final result, as spd_data_generate() next increases #banks from 1 to 2 if possible. This is done "to avoid a bug in MIPS Malta firmware". We don't even use this function with machine type malta. *Shrug* Signed-off-by: Markus Armbruster Message-Id: <20200422134815.1584-5-armbru@redhat.com> --- hw/i2c/smbus_eeprom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c index 07fbbf87f1..e199fc8678 100644 --- a/hw/i2c/smbus_eeprom.c +++ b/hw/i2c/smbus_eeprom.c @@ -229,7 +229,7 @@ uint8_t *spd_data_generate(enum sdram_type type, ram_ad= dr_t ram_size) nbanks =3D 1; while (sz_log2 > max_log2 && nbanks < 8) { sz_log2--; - nbanks++; + nbanks *=3D 2; } =20 assert(size =3D=3D (1ULL << sz_log2) * nbanks); --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588145786; cv=none; d=zohomail.com; s=zohoarc; b=YML0zZLJHs8NnchvgtjJoE/K+8a/+dqN9z3wvEkXcQmHOX2dil/RKDH1ahp++cH3TxL1/KiZErm9PcvKELZQc79gEAT7lxszaAAjCNNmklAaKAphaqBWYfMpbeMwQElV+stbyiX/RTkwSrabVE6KcRbs2WxAD/LNdEpm+SnOEH8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588145786; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YgQMi/VIlokV4j21xg1xPA3aAdLq5fqh3fzpQ3W4hWU=; b=YdsJos962cOlcBiDB6f0Gn3H3d1oAwMogQZDNdUpDL0RqHAULsgWnJehiufrDpjkPI0gMjUohjEGYmu+qSBT42zPLOWtdga4sHWLBOJeLm2CNT3jVd8/Zt6r/Kpu9WDRkDCFU0vx7UUvUPm2ASTLxm1eC9ZfP1GJxoA3AP1WZP0= 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=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588145786125122.74915160786361; Wed, 29 Apr 2020 00:36:26 -0700 (PDT) Received: from localhost ([::1]:48326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jThGa-000799-NR for importer@patchew.org; Wed, 29 Apr 2020 03:36:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46246) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh26-0007uF-IQ for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh1i-0003zD-S3 for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:26 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:36409 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh1h-0003vb-Lc for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:01 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-451-zZhjivkOPg-lQfk8Q4DQ8g-1; Wed, 29 Apr 2020 03:20:56 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2B7CEBFC6; Wed, 29 Apr 2020 07:20:55 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F096A60C18; Wed, 29 Apr 2020 07:20:54 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 79D1711358DA; Wed, 29 Apr 2020 09:20:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144858; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YgQMi/VIlokV4j21xg1xPA3aAdLq5fqh3fzpQ3W4hWU=; b=GrWqg5rfVTiNzWFk/dW1LDGJAuzdidt58i694kUBsVi+s4qKlbwkbhABUsD7iqTtHcbpa7 fy5ODTDkYsuprIPaMcAHgZD9eL4HS+KRTlL9dEmdVUub1G1j+iE/x98VVCPONYiQiZiZR7 NxF4JcgdiQCsXxduJPK8Txc3zS0rPI8= X-MC-Unique: zZhjivkOPg-lQfk8Q4DQ8g-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 29/32] Makefile: Drop unused, broken target recurse-fuzz Date: Wed, 29 Apr 2020 09:20:45 +0200 Message-Id: <20200429072048.29963-30-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=207.211.31.81; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 01:28:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexander Bulekov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Target recurse-fuzz depends on pc-bios/optionrom/fuzz, which can't be made. It's not used anywhere. Added in commit c621dc3e01c, looks like cargo cult. Delete. Signed-off-by: Markus Armbruster Message-Id: <20200424071142.3525-2-armbru@redhat.com> Reviewed-by: Alexander Bulekov --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 8a9113e666..34275f57c9 100644 --- a/Makefile +++ b/Makefile @@ -582,7 +582,6 @@ $(ROM_DIRS_RULES): =20 .PHONY: recurse-all recurse-clean recurse-install recurse-all: $(addsuffix /all, $(TARGET_DIRS) $(ROM_DIRS)) -recurse-fuzz: $(addsuffix /fuzz, $(TARGET_DIRS) $(ROM_DIRS)) recurse-clean: $(addsuffix /clean, $(TARGET_DIRS) $(ROM_DIRS)) recurse-install: $(addsuffix /install, $(TARGET_DIRS)) $(addsuffix /install, $(TARGET_DIRS)): all --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588145925; cv=none; d=zohomail.com; s=zohoarc; b=U0PEen9f6Ua320F6axL3c8iSiWaoZGZgOJXpaCpyTNaiNRc6KVeGNe4fvBZ+8bi4a2ZEqfty/VTv1UiVJQpCiq76DF0ImJ+F5Uayk6R889JwWbJGNIztZ64q+B9zIQpx0PEoLfe0sDnLoxaAvokDqJmGY2ddsAgd/Am9nfeMomw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588145925; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=stLAzBapgXwNnV94BzcEBwLvTMWzLIGo8fDX7N3683c=; b=auDbeEsjGMDI48xschgUdUY/fH+6sS+QvLlf3JcUWUOPZZ3l4WiepKFWFDHyDqrGK2Wu8UhBGsVWREFtoabSrljfYtJbtfJ0M+y+rps7tt1zNyfeGgJU5tsHqd5E6jfw/B5qUHOGrBKhzT6GXiZJa6tuQcZOUmagp+gYceQ0IiA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588145925865430.6896515544205; Wed, 29 Apr 2020 00:38:45 -0700 (PDT) Received: from localhost ([::1]:56610 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jThIq-0002FM-Iz for importer@patchew.org; Wed, 29 Apr 2020 03:38:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46238) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh25-0007uC-EY for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh1i-0003yx-RH for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:25 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:23700 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh1h-0003vP-MQ for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:01 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-290-qiJ3GMpDMiuST-s1NrR-_A-1; Wed, 29 Apr 2020 03:20:56 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5602D1895A33; Wed, 29 Apr 2020 07:20:55 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F05135D9F3; Wed, 29 Apr 2020 07:20:54 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8054111358DB; Wed, 29 Apr 2020 09:20:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144858; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=stLAzBapgXwNnV94BzcEBwLvTMWzLIGo8fDX7N3683c=; b=SW2iM6P3VfQElpFm+v3z0PXPjr3IwzkgKCIFdc3ZeRTUfxPsEL8fgTYOSSWG9h3/J/+V48 y6Lj+eBx71MSnAHiXQOiet/L7TbQNTMsNZ/nY+LtnYcmCQO7SrpimFaauNN4C/p4zDPSE6 ZYgaZSVNKktzNPFP2f6/JlAy/NUXLMM= X-MC-Unique: qiJ3GMpDMiuST-s1NrR-_A-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 30/32] fuzz: Simplify how we compute available machines and types Date: Wed, 29 Apr 2020 09:20:46 +0200 Message-Id: <20200429072048.29963-31-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=205.139.110.61; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 00:53:13 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexander Bulekov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" apply_to_qlist(), apply_to_node() work with QObjects. This is designed for use by tests/qtest/qos-test.c, which gets the data in that form via QMP. Goes back to commit fc281c8020 "tests: qgraph API for the qtest driver framework". Commit 275ab39d86 "fuzz: add support for qos-assisted fuzz targets" added another user: qtest/fuzz/qos_fuzz.c. To get the data as QObjects, it uses qmp_marshal_query_machines() and qmp_marshal_qom_list_types(). All this code is rather cumbersome. Switch to working with generated QAPI types instead: * Replace apply_to_qlist() & friends by machines_apply_to_node() and types_apply_to_node(). * Have qos_fuzz.c use qmp_query_machines() and qmp_qom_list_types() instead. * Have qos_test.c convert from QObject to the QAPI types. Signed-off-by: Markus Armbruster Message-Id: <20200424071142.3525-3-armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alexander Bulekov --- tests/qtest/libqos/qos_external.h | 8 +++- tests/qtest/fuzz/qos_fuzz.c | 34 ++++----------- tests/qtest/libqos/qos_external.c | 70 +++++++++++-------------------- tests/qtest/qos-test.c | 29 +++++++++---- 4 files changed, 59 insertions(+), 82 deletions(-) diff --git a/tests/qtest/libqos/qos_external.h b/tests/qtest/libqos/qos_ext= ernal.h index 7b44930c55..f63388cb30 100644 --- a/tests/qtest/libqos/qos_external.h +++ b/tests/qtest/libqos/qos_external.h @@ -20,8 +20,12 @@ #define QOS_EXTERNAL_H #include "libqos/qgraph.h" =20 -void apply_to_node(const char *name, bool is_machine, bool is_abstract); -void apply_to_qlist(QList *list, bool is_machine); +#include "libqos/malloc.h" +#include "qapi/qapi-types-machine.h" +#include "qapi/qapi-types-qom.h" + +void machines_apply_to_node(MachineInfoList *mach_info); +void types_apply_to_node(ObjectTypeInfoList *type_info); QGuestAllocator *get_machine_allocator(QOSGraphObject *obj); void *allocate_objects(QTestState *qts, char **path, QGuestAllocator **p_a= lloc); =20 diff --git a/tests/qtest/fuzz/qos_fuzz.c b/tests/qtest/fuzz/qos_fuzz.c index af28c92866..87eadb0889 100644 --- a/tests/qtest/fuzz/qos_fuzz.c +++ b/tests/qtest/fuzz/qos_fuzz.c @@ -36,7 +36,6 @@ =20 #include "qapi/qapi-commands-machine.h" #include "qapi/qapi-commands-qom.h" -#include "qapi/qmp/qlist.h" =20 =20 void *fuzz_qos_obj; @@ -45,34 +44,19 @@ QGuestAllocator *fuzz_qos_alloc; static const char *fuzz_target_name; static char **fuzz_path_vec; =20 -/* - * Replaced the qmp commands with direct qmp_marshal calls. - * Probably there is a better way to do this - */ static void qos_set_machines_devices_available(void) { - QDict *req =3D qdict_new(); - QObject *response; - QDict *args =3D qdict_new(); - QList *lst; + MachineInfoList *mach_info; + ObjectTypeInfoList *type_info; =20 - qmp_marshal_query_machines(NULL, &response, &error_abort); - lst =3D qobject_to(QList, response); - apply_to_qlist(lst, true); + mach_info =3D qmp_query_machines(&error_abort); + machines_apply_to_node(mach_info); + qapi_free_MachineInfoList(mach_info); =20 - qobject_unref(response); - - - qdict_put_str(req, "execute", "qom-list-types"); - qdict_put_str(args, "implements", "device"); - qdict_put_bool(args, "abstract", true); - qdict_put_obj(req, "arguments", (QObject *) args); - - qmp_marshal_qom_list_types(args, &response, &error_abort); - lst =3D qobject_to(QList, response); - apply_to_qlist(lst, false); - qobject_unref(response); - qobject_unref(req); + type_info =3D qmp_qom_list_types(true, "device", true, true, + &error_abort); + types_apply_to_node(type_info); + qapi_free_ObjectTypeInfoList(type_info); } =20 static char **current_path; diff --git a/tests/qtest/libqos/qos_external.c b/tests/qtest/libqos/qos_ext= ernal.c index 398556dde0..c707dac3b9 100644 --- a/tests/qtest/libqos/qos_external.c +++ b/tests/qtest/libqos/qos_external.c @@ -29,62 +29,40 @@ #include "libqos/qgraph_internal.h" #include "libqos/qos_external.h" =20 - - -void apply_to_node(const char *name, bool is_machine, bool is_abstract) +static void machine_apply_to_node(const char *name) { - char *machine_name =3D NULL; - if (is_machine) { - const char *arch =3D qtest_get_arch(); - machine_name =3D g_strconcat(arch, "/", name, NULL); - name =3D machine_name; + char *machine_name =3D g_strconcat(qtest_get_arch(), "/", name, NULL); + + qos_graph_node_set_availability(machine_name, true); + g_free(machine_name); +} + +void machines_apply_to_node(MachineInfoList *mach_info) +{ + MachineInfoList *tail; + + for (tail =3D mach_info; tail; tail =3D tail->next) { + machine_apply_to_node(tail->value->name); + if (tail->value->alias) { + machine_apply_to_node(tail->value->alias); + } } +} + +static void type_apply_to_node(const char *name, bool is_abstract) +{ qos_graph_node_set_availability(name, true); if (is_abstract) { qos_delete_cmd_line(name); } - g_free(machine_name); } =20 -/** - * apply_to_qlist(): using QMP queries QEMU for a list of - * machines and devices available, and sets the respective node - * as true. If a node is found, also all its produced and contained - * child are marked available. - * - * See qos_graph_node_set_availability() for more info - */ -void apply_to_qlist(QList *list, bool is_machine) +void types_apply_to_node(ObjectTypeInfoList *type_info) { - const QListEntry *p; - const char *name; - bool abstract; - QDict *minfo; - QObject *qobj; - QString *qstr; - QBool *qbool; + ObjectTypeInfoList *tail; =20 - for (p =3D qlist_first(list); p; p =3D qlist_next(p)) { - minfo =3D qobject_to(QDict, qlist_entry_obj(p)); - qobj =3D qdict_get(minfo, "name"); - qstr =3D qobject_to(QString, qobj); - name =3D qstring_get_str(qstr); - - qobj =3D qdict_get(minfo, "abstract"); - if (qobj) { - qbool =3D qobject_to(QBool, qobj); - abstract =3D qbool_get_bool(qbool); - } else { - abstract =3D false; - } - - apply_to_node(name, is_machine, abstract); - qobj =3D qdict_get(minfo, "alias"); - if (qobj) { - qstr =3D qobject_to(QString, qobj); - name =3D qstring_get_str(qstr); - apply_to_node(name, is_machine, abstract); - } + for (tail =3D type_info; tail; tail =3D tail->next) { + type_apply_to_node(tail->value->name, tail->value->abstract); } } =20 diff --git a/tests/qtest/qos-test.c b/tests/qtest/qos-test.c index ad193f43a5..3062a13557 100644 --- a/tests/qtest/qos-test.c +++ b/tests/qtest/qos-test.c @@ -19,11 +19,12 @@ #include "qemu/osdep.h" #include #include "libqtest-single.h" +#include "qapi/error.h" #include "qapi/qmp/qdict.h" -#include "qapi/qmp/qbool.h" -#include "qapi/qmp/qstring.h" #include "qemu/module.h" -#include "qapi/qmp/qlist.h" +#include "qapi/qobject-input-visitor.h" +#include "qapi/qapi-visit-machine.h" +#include "qapi/qapi-visit-qom.h" #include "libqos/malloc.h" #include "libqos/qgraph.h" #include "libqos/qgraph_internal.h" @@ -51,13 +52,20 @@ static void qos_set_machines_devices_available(void) { QDict *response; QDict *args =3D qdict_new(); - QList *list; + QObject *ret; + Visitor *v; + MachineInfoList *mach_info; + ObjectTypeInfoList *type_info; =20 qtest_start("-machine none"); response =3D qmp("{ 'execute': 'query-machines' }"); - list =3D qdict_get_qlist(response, "return"); + ret =3D qdict_get(response, "return"); =20 - apply_to_qlist(list, true); + v =3D qobject_input_visitor_new(ret); + visit_type_MachineInfoList(v, NULL, &mach_info, &error_abort); + visit_free(v); + machines_apply_to_node(mach_info); + qapi_free_MachineInfoList(mach_info); =20 qobject_unref(response); =20 @@ -66,10 +74,13 @@ static void qos_set_machines_devices_available(void) =20 response =3D qmp("{'execute': 'qom-list-types'," " 'arguments': %p }", args); - g_assert(qdict_haskey(response, "return")); - list =3D qdict_get_qlist(response, "return"); + ret =3D qdict_get(response, "return"); =20 - apply_to_qlist(list, false); + v =3D qobject_input_visitor_new(ret); + visit_type_ObjectTypeInfoList(v, NULL, &type_info, &error_abort); + visit_free(v); + types_apply_to_node(type_info); + qapi_free_ObjectTypeInfoList(type_info); =20 qtest_end(); qobject_unref(response); --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588145210; cv=none; d=zohomail.com; s=zohoarc; b=YCTEcr4nUPOI7jYqT5hnw4oYq8NWAhFadjvTlSIxbQovA6Qo8Pb/w7ZiiO0eD8TFnuyy5kYMhdczuU6/+TjU6PS7gGJRq5b1i11nu0Sp/Pd3Ml1r2jwk4mkoTGtB3RXrdnspp1ty55AD6WBGPnFhuWJwZ9DKmN5mTYuwSOi3Spk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588145210; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XTNLZDAPrsEg/QHVKC3akB2bs2mhWsm2Z3bgdrOIoXw=; b=JGAToNlo4d/OqIPhRsJMpfcC/ePU7kf8ozzU5cqaeMSmkuKiRO+mP8aq8y/CwlCmXJV6oTrq7WR5MuNGTFETaeDTjwIbSjIqpDhQvsyT7dzV4IQeghsNWuUEE41RA6N8aNrlSUPBcW5ENdQB6+QeGVSidnQ/KmBdpbj1vQIBKnw= 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=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588145210946554.4823746350747; Wed, 29 Apr 2020 00:26:50 -0700 (PDT) Received: from localhost ([::1]:40322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh7J-0000It-DD for importer@patchew.org; Wed, 29 Apr 2020 03:26:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46160) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh1v-0007tg-FK for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh1g-0003wR-If for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:15 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:43714 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh1f-0003vB-Pz for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:20:59 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-154-06XNxqNMNnGwtSlOFCtcGA-1; Wed, 29 Apr 2020 03:20:56 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1E8F4107AFB1 for ; Wed, 29 Apr 2020 07:20:55 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E02B327CC4; Wed, 29 Apr 2020 07:20:54 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8875111358DC; Wed, 29 Apr 2020 09:20:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144857; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XTNLZDAPrsEg/QHVKC3akB2bs2mhWsm2Z3bgdrOIoXw=; b=ivXfOpYfvhb6gcrvrAkxCwaRkRLhs/x9W1mQy8/mpwewVtcnJ2XauVku8fBK1dMl/n3Vly dx1hgxqLDB9zPf4t2BZDlLBXPHbUCcEe85hqe7GiRpaLNyXlWGuE024WbmOTY61M6cPEY3 AHi9V/raE/c3WoCdqLtU8ft71CR4U7Y= X-MC-Unique: 06XNxqNMNnGwtSlOFCtcGA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 31/32] libqos: Give get_machine_allocator() internal linkage Date: Wed, 29 Apr 2020 09:20:47 +0200 Message-Id: <20200429072048.29963-32-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=205.139.110.61; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 00:53:13 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Message-Id: <20200424071142.3525-4-armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tests/qtest/libqos/qos_external.h | 2 -- tests/qtest/libqos/qos_external.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/qtest/libqos/qos_external.h b/tests/qtest/libqos/qos_ext= ernal.h index f63388cb30..72d7f91707 100644 --- a/tests/qtest/libqos/qos_external.h +++ b/tests/qtest/libqos/qos_external.h @@ -18,7 +18,6 @@ =20 #ifndef QOS_EXTERNAL_H #define QOS_EXTERNAL_H -#include "libqos/qgraph.h" =20 #include "libqos/malloc.h" #include "qapi/qapi-types-machine.h" @@ -26,7 +25,6 @@ =20 void machines_apply_to_node(MachineInfoList *mach_info); void types_apply_to_node(ObjectTypeInfoList *type_info); -QGuestAllocator *get_machine_allocator(QOSGraphObject *obj); void *allocate_objects(QTestState *qts, char **path, QGuestAllocator **p_a= lloc); =20 #endif diff --git a/tests/qtest/libqos/qos_external.c b/tests/qtest/libqos/qos_ext= ernal.c index c707dac3b9..9f5180e18d 100644 --- a/tests/qtest/libqos/qos_external.c +++ b/tests/qtest/libqos/qos_external.c @@ -66,7 +66,7 @@ void types_apply_to_node(ObjectTypeInfoList *type_info) } } =20 -QGuestAllocator *get_machine_allocator(QOSGraphObject *obj) +static QGuestAllocator *get_machine_allocator(QOSGraphObject *obj) { return obj->get_driver(obj, "memory"); } --=20 2.21.1 From nobody Fri Sep 20 22:14:56 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1588145447; cv=none; d=zohomail.com; s=zohoarc; b=W/jkwFw8X2cgNYWe9829wnIxqce0W5pW9xGMhHdOUTdnxeuiSHr9IKEX9L4SseIR/DBRoBG5MFEs3yJRlliVO2UEtxMxH9hl0mL5NyA5QrpTwKt5hgfRlTEOQnlmC3Opg4l/WGGasSnQTE+Csetb2t3IZ8pDopryrhtQCqI0rSU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588145447; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8Nr3g64N1ZbytavTEHUIn3pBRY3200wKKl65xH32qj8=; b=n+gwBgi4i466Z0juYlJ5G63XAkhkCZW2bCVMXkz1OVBZlHWl6Mj+hz7tswZWUrjYfu9f8DNDRiBhH+j/MXDIzp9IL5zVFLfab6IcnzmlIDepioQQzQTiHE39+GkdHDgImixWGYc5WVYRGXzcg2DFEvD/XKvC7pRSruji6wz0dbY= 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=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588145447639970.8143440833027; Wed, 29 Apr 2020 00:30:47 -0700 (PDT) Received: from localhost ([::1]:56910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jThB8-0007C7-BP for importer@patchew.org; Wed, 29 Apr 2020 03:30:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46174) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTh1x-0007tn-7i for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:22:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTh1g-0003wp-T3 for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:17 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:26506 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jTh1f-0003vR-TS for qemu-devel@nongnu.org; Wed, 29 Apr 2020 03:21:00 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-161-njkdIEKSNHuXjEG2PHpVDQ-1; Wed, 29 Apr 2020 03:20:56 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 203771009445; Wed, 29 Apr 2020 07:20:55 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E40AD60BF4; Wed, 29 Apr 2020 07:20:54 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8E4F711358DD; Wed, 29 Apr 2020 09:20:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588144858; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8Nr3g64N1ZbytavTEHUIn3pBRY3200wKKl65xH32qj8=; b=bChIX4gSpg57Nax+9+Uaie5KVxTnJF8qjT4vkkDnfUz4cs/oJFxjNVlmdCLuGfurVXugWF 6mHe3rBDrQ5SbmPzizcn7FZ8nr+CHF6cMVTQYpn7LXbteMOSqf3AIzu1dFIHhx7qcqKBYn YcRmP3B1QIlMw3c2yzeJFq/KkTLk1UA= X-MC-Unique: njkdIEKSNHuXjEG2PHpVDQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 32/32] qemu-option: pass NULL rather than 0 to the id of qemu_opts_set() Date: Wed, 29 Apr 2020 09:20:48 +0200 Message-Id: <20200429072048.29963-33-armbru@redhat.com> In-Reply-To: <20200429072048.29963-1-armbru@redhat.com> References: <20200429072048.29963-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=207.211.31.81; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 01:28:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Masahiro Yamada Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Masahiro Yamada The second argument 'id' is a pointer. Pass NULL rather than 0. Signed-off-by: Masahiro Yamada Message-Id: <20200427005704.2475782-1-masahiroy@kernel.org> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- softmmu/vl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index 32c0047889..afd2615fb3 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -3059,19 +3059,19 @@ void qemu_init(int argc, char **argv, char **envp) } break; case QEMU_OPTION_kernel: - qemu_opts_set(qemu_find_opts("machine"), 0, "kernel", opta= rg, + qemu_opts_set(qemu_find_opts("machine"), NULL, "kernel", o= ptarg, &error_abort); break; case QEMU_OPTION_initrd: - qemu_opts_set(qemu_find_opts("machine"), 0, "initrd", opta= rg, + qemu_opts_set(qemu_find_opts("machine"), NULL, "initrd", o= ptarg, &error_abort); break; case QEMU_OPTION_append: - qemu_opts_set(qemu_find_opts("machine"), 0, "append", opta= rg, + qemu_opts_set(qemu_find_opts("machine"), NULL, "append", o= ptarg, &error_abort); break; case QEMU_OPTION_dtb: - qemu_opts_set(qemu_find_opts("machine"), 0, "dtb", optarg, + qemu_opts_set(qemu_find_opts("machine"), NULL, "dtb", opta= rg, &error_abort); break; case QEMU_OPTION_cdrom: @@ -3182,7 +3182,7 @@ void qemu_init(int argc, char **argv, char **envp) } break; case QEMU_OPTION_bios: - qemu_opts_set(qemu_find_opts("machine"), 0, "firmware", op= targ, + qemu_opts_set(qemu_find_opts("machine"), NULL, "firmware",= optarg, &error_abort); break; case QEMU_OPTION_singlestep: --=20 2.21.1