mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-24 05:25:18 +00:00
qemu: Alter qemuDomainChgIOThread to take enum instead of bool
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 <phrdina@redhat.com>, but placed into a separate patch. Signed-off-by: John Ferlan <jferlan@redhat.com> ACKed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
3083bf18da
commit
315e1105b6
@ -6016,11 +6016,16 @@ qemuDomainDelIOThreadCheck(virDomainDefPtr def,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
VIR_DOMAIN_IOTHREAD_ACTION_ADD,
|
||||||
|
VIR_DOMAIN_IOTHREAD_ACTION_DEL,
|
||||||
|
} virDomainIOThreadAction;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainChgIOThread(virQEMUDriverPtr driver,
|
qemuDomainChgIOThread(virQEMUDriverPtr driver,
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
unsigned int iothread_id,
|
unsigned int iothread_id,
|
||||||
bool add,
|
virDomainIOThreadAction action,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
virQEMUDriverConfigPtr cfg = NULL;
|
virQEMUDriverConfigPtr cfg = NULL;
|
||||||
@ -6046,18 +6051,24 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver,
|
|||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (add) {
|
switch (action) {
|
||||||
|
case VIR_DOMAIN_IOTHREAD_ACTION_ADD:
|
||||||
if (qemuDomainAddIOThreadCheck(def, iothread_id) < 0)
|
if (qemuDomainAddIOThreadCheck(def, iothread_id) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if (qemuDomainHotplugAddIOThread(driver, vm, iothread_id) < 0)
|
if (qemuDomainHotplugAddIOThread(driver, vm, iothread_id) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
} else {
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_IOTHREAD_ACTION_DEL:
|
||||||
if (qemuDomainDelIOThreadCheck(def, iothread_id) < 0)
|
if (qemuDomainDelIOThreadCheck(def, iothread_id) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if (qemuDomainHotplugDelIOThread(driver, vm, iothread_id) < 0)
|
if (qemuDomainHotplugDelIOThread(driver, vm, iothread_id) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0)
|
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0)
|
||||||
@ -6065,18 +6076,23 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (persistentDef) {
|
if (persistentDef) {
|
||||||
if (add) {
|
switch (action) {
|
||||||
|
case VIR_DOMAIN_IOTHREAD_ACTION_ADD:
|
||||||
if (qemuDomainAddIOThreadCheck(persistentDef, iothread_id) < 0)
|
if (qemuDomainAddIOThreadCheck(persistentDef, iothread_id) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if (!virDomainIOThreadIDAdd(persistentDef, iothread_id))
|
if (!virDomainIOThreadIDAdd(persistentDef, iothread_id))
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
} else {
|
break;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_IOTHREAD_ACTION_DEL:
|
||||||
if (qemuDomainDelIOThreadCheck(persistentDef, iothread_id) < 0)
|
if (qemuDomainDelIOThreadCheck(persistentDef, iothread_id) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
virDomainIOThreadIDDel(persistentDef, iothread_id);
|
virDomainIOThreadIDDel(persistentDef, iothread_id);
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virDomainSaveConfig(cfg->configDir, driver->caps,
|
if (virDomainSaveConfig(cfg->configDir, driver->caps,
|
||||||
@ -6118,7 +6134,8 @@ qemuDomainAddIOThread(virDomainPtr dom,
|
|||||||
if (virDomainAddIOThreadEnsureACL(dom->conn, vm->def, flags) < 0)
|
if (virDomainAddIOThreadEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
ret = qemuDomainChgIOThread(driver, vm, iothread_id, true, flags);
|
ret = qemuDomainChgIOThread(driver, vm, iothread_id,
|
||||||
|
VIR_DOMAIN_IOTHREAD_ACTION_ADD, flags);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virDomainObjEndAPI(&vm);
|
virDomainObjEndAPI(&vm);
|
||||||
@ -6150,7 +6167,8 @@ qemuDomainDelIOThread(virDomainPtr dom,
|
|||||||
if (virDomainDelIOThreadEnsureACL(dom->conn, vm->def, flags) < 0)
|
if (virDomainDelIOThreadEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
ret = qemuDomainChgIOThread(driver, vm, iothread_id, false, flags);
|
ret = qemuDomainChgIOThread(driver, vm, iothread_id,
|
||||||
|
VIR_DOMAIN_IOTHREAD_ACTION_DEL, flags);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virDomainObjEndAPI(&vm);
|
virDomainObjEndAPI(&vm);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user