From nobody Mon Sep 16 19:22:06 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; 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 1541423145249282.51471667740293; Mon, 5 Nov 2018 05:05:45 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id 505E881DE3; Mon, 5 Nov 2018 13:05:43 +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 130B2608E7; Mon, 5 Nov 2018 13:05:43 +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 777123D380; Mon, 5 Nov 2018 13:05:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wA5CwXoC004334 for ; Mon, 5 Nov 2018 07:58:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id AA88716D45; Mon, 5 Nov 2018 12:58:33 +0000 (UTC) Received: from unknown4CEB42C824F4.redhat.com (ovpn-116-143.phx2.redhat.com [10.3.116.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id 69E27450D for ; Mon, 5 Nov 2018 12:58:33 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Mon, 5 Nov 2018 07:58:11 -0500 Message-Id: <20181105125816.20385-8-jferlan@redhat.com> In-Reply-To: <20181105125816.20385-1-jferlan@redhat.com> References: <20181105125816.20385-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [REPOST 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 05 Nov 2018 13:05:44 +0000 (UTC) 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