From nobody Tue May 13 12:24:17 2025 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1539963764512246.10748868774522; Fri, 19 Oct 2018 08:42:44 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id DBA84307D913; Fri, 19 Oct 2018 15:42:42 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A6B0D2D027; Fri, 19 Oct 2018 15:42:42 +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 4EACE4BB79; Fri, 19 Oct 2018 15:42:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9JFDaGI007240 for ; Fri, 19 Oct 2018 11:13:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 335AB6AE90; Fri, 19 Oct 2018 15:13:36 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-156.phx2.redhat.com [10.3.116.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF8296AEB2 for ; Fri, 19 Oct 2018 15:13:35 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Fri, 19 Oct 2018 11:13:21 -0400 Message-Id: <20181019151326.16793-8-jferlan@redhat.com> In-Reply-To: <20181019151326.16793-1-jferlan@redhat.com> References: <20181019151326.16793-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 07/12] qemu: Alter qemuDomainChgIOThread to take enum instead of bool 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Fri, 19 Oct 2018 15:42:43 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We're about to add a new state "modify" and thus the function goes from just Add/Del. Use an enum to manage. Extracted from code originally posted by Pavel Hrdina , but placed into a separate patch. Signed-off-by: John Ferlan ACKed-by: Michal Privoznik --- src/qemu/qemu_driver.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b50d805bf1..6835d3e875 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6018,11 +6018,16 @@ qemuDomainDelIOThreadCheck(virDomainDefPtr def, return 0; } =20 +typedef enum { + VIR_DOMAIN_IOTHREAD_ACTION_ADD, + VIR_DOMAIN_IOTHREAD_ACTION_DEL, +} virDomainIOThreadAction; + static int qemuDomainChgIOThread(virQEMUDriverPtr driver, virDomainObjPtr vm, unsigned int iothread_id, - bool add, + virDomainIOThreadAction action, unsigned int flags) { virQEMUDriverConfigPtr cfg =3D NULL; @@ -6048,18 +6053,24 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver, goto endjob; } =20 - if (add) { + switch (action) { + case VIR_DOMAIN_IOTHREAD_ACTION_ADD: if (qemuDomainAddIOThreadCheck(def, iothread_id) < 0) goto endjob; =20 if (qemuDomainHotplugAddIOThread(driver, vm, iothread_id) < 0) goto endjob; - } else { + + break; + + case VIR_DOMAIN_IOTHREAD_ACTION_DEL: if (qemuDomainDelIOThreadCheck(def, iothread_id) < 0) goto endjob; =20 if (qemuDomainHotplugDelIOThread(driver, vm, iothread_id) < 0) goto endjob; + + break; } =20 if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver-= >caps) < 0) @@ -6067,18 +6078,23 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver, } =20 if (persistentDef) { - if (add) { + switch (action) { + case VIR_DOMAIN_IOTHREAD_ACTION_ADD: if (qemuDomainAddIOThreadCheck(persistentDef, iothread_id) < 0) goto endjob; =20 if (!virDomainIOThreadIDAdd(persistentDef, iothread_id)) goto endjob; =20 - } else { + break; + + case VIR_DOMAIN_IOTHREAD_ACTION_DEL: if (qemuDomainDelIOThreadCheck(persistentDef, iothread_id) < 0) goto endjob; =20 virDomainIOThreadIDDel(persistentDef, iothread_id); + + break; } =20 if (virDomainSaveConfig(cfg->configDir, driver->caps, @@ -6120,7 +6136,8 @@ qemuDomainAddIOThread(virDomainPtr dom, if (virDomainAddIOThreadEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; =20 - ret =3D qemuDomainChgIOThread(driver, vm, iothread_id, true, flags); + ret =3D qemuDomainChgIOThread(driver, vm, iothread_id, + VIR_DOMAIN_IOTHREAD_ACTION_ADD, flags); =20 cleanup: virDomainObjEndAPI(&vm); @@ -6152,7 +6169,8 @@ qemuDomainDelIOThread(virDomainPtr dom, if (virDomainDelIOThreadEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; =20 - ret =3D qemuDomainChgIOThread(driver, vm, iothread_id, false, flags); + ret =3D qemuDomainChgIOThread(driver, vm, iothread_id, + VIR_DOMAIN_IOTHREAD_ACTION_DEL, flags); =20 cleanup: virDomainObjEndAPI(&vm); --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list