From nobody Thu May 2 09:36:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1515066127624997.6554423414593; Thu, 4 Jan 2018 03:42:07 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id F196A4A6FF; Thu, 4 Jan 2018 11:42:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4053B5DA60; Thu, 4 Jan 2018 11:42:03 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id AD4A118033D9; Thu, 4 Jan 2018 11:42:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w04BfxC4013221 for ; Thu, 4 Jan 2018 06:41:59 -0500 Received: by smtp.corp.redhat.com (Postfix) id 292EB5DD9C; Thu, 4 Jan 2018 11:41:59 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1CFEB5DA60 for ; Thu, 4 Jan 2018 11:41:57 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 476E2780D8 for ; Thu, 4 Jan 2018 11:41:55 +0000 (UTC) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w04BeQJY081517 for ; Thu, 4 Jan 2018 06:41:54 -0500 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2f9hvvcjub-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 04 Jan 2018 06:41:54 -0500 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 4 Jan 2018 11:41:51 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 4 Jan 2018 11:41:49 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w04Bfmt848431104; Thu, 4 Jan 2018 11:41:48 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EB3FFAE055; Thu, 4 Jan 2018 11:33:57 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E4968AE04D; Thu, 4 Jan 2018 11:33:56 +0000 (GMT) Received: from marc-ibm.emea.ibm.com (unknown [9.145.1.5]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 4 Jan 2018 11:33:56 +0000 (GMT) From: Marc Hartmayer To: Libvirt Mailing List , John Ferlan Date: Thu, 4 Jan 2018 12:41:29 +0100 In-Reply-To: <20171212150708.7563-1-jferlan@redhat.com> References: <20171212150708.7563-1-jferlan@redhat.com> X-TM-AS-GCONF: 00 x-cbid: 18010411-0012-0000-0000-0000059F90B2 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18010411-0013-0000-0000-0000191ADECF Message-Id: <20180104114129.7816-1-mhartmay@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-01-04_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1801040161 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 04 Jan 2018 11:41:55 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 04 Jan 2018 11:41:55 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'mhartmay@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.701 (RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] qemu: Use switch statement for address types in qemuBuildControllerDevStr X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 04 Jan 2018 11:42:05 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Use a switch statement instead of if-else-if statements. Move the command line building of the iothread attribute into the common path as the SCSI controller attributes are already validated. Signed-off-by: Marc Hartmayer --- This patch fits well to this series as it was created during the review :) The default cases in the switch statements should be replaced by the appropriate types. --- src/qemu/qemu_command.c | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 1c9a802de73d..c82497860eb4 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2612,6 +2612,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainD= ef, { virBuffer buf =3D VIR_BUFFER_INITIALIZER; int model =3D def->model; + int address_type =3D def->info.type; const virDomainPCIControllerOpts *pciopts; const char *modelName =3D NULL; =20 @@ -2624,23 +2625,25 @@ qemuBuildControllerDevStr(const virDomainDef *domai= nDef, =20 switch ((virDomainControllerModelSCSI) model) { case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI: - if (def->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { + switch ((virDomainDeviceAddressType) address_type) { + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW: virBufferAddLit(&buf, "virtio-scsi-ccw"); - if (def->iothread) - virBufferAsprintf(&buf, ",iothread=3Diothread%u", - def->iothread); - } else if (def->info.type =3D=3D - VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390) { + break; + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390: virBufferAddLit(&buf, "virtio-scsi-s390"); - } else if (def->info.type =3D=3D - VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO) { + break; + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO: virBufferAddLit(&buf, "virtio-scsi-device"); - } else { + break; + default: virBufferAddLit(&buf, "virtio-scsi-pci"); - if (def->iothread) - virBufferAsprintf(&buf, ",iothread=3Diothread%u", - def->iothread); } + + if (def->iothread) { + virBufferAsprintf(&buf, ",iothread=3Diothread%u", + def->iothread); + } + if (qemuBuildVirtioOptionsStr(&buf, def->virtio, qemuCaps) < 0) goto error; break; @@ -2668,18 +2671,20 @@ qemuBuildControllerDevStr(const virDomainDef *domai= nDef, break; =20 case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: - if (def->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { + switch ((virDomainDeviceAddressType) address_type) { + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: virBufferAddLit(&buf, "virtio-serial-pci"); - } else if (def->info.type =3D=3D - VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { + break; + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW: virBufferAddLit(&buf, "virtio-serial-ccw"); - } else if (def->info.type =3D=3D - VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390) { + break; + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390: virBufferAddLit(&buf, "virtio-serial-s390"); - } else if (def->info.type =3D=3D - VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO) { + break; + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO: virBufferAddLit(&buf, "virtio-serial-device"); - } else { + break; + default: virBufferAddLit(&buf, "virtio-serial"); } virBufferAsprintf(&buf, ",id=3D%s", def->info.alias); --=20 2.13.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list