[libvirt] [PATCH 4/7] qemu: Add qemuProcessUpdateLiveGuestCPU
Pavel Hrdina
phrdina at redhat.com
Wed Jul 12 13:18:58 UTC 2017
On Wed, Jul 12, 2017 at 02:56:50PM +0200, Jiri Denemark wrote:
> Separated from qemuProcessUpdateAndVerifyCPU to handle updating of an
> active guest CPU definition according to live data from QEMU.
>
> Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
> ---
> src/qemu/qemu_process.c | 70 +++++++++++++++++++++++++++++--------------------
> 1 file changed, 42 insertions(+), 28 deletions(-)
>
> diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
> index ebd13057b..926c64197 100644
> --- a/src/qemu/qemu_process.c
> +++ b/src/qemu/qemu_process.c
> @@ -4011,17 +4011,53 @@ qemuProcessVerifyCPU(virDomainObjPtr vm,
>
>
> static int
> +qemuProcessUpdateLiveGuestCPU(virDomainObjPtr vm,
> + virCPUDataPtr enabled,
> + virCPUDataPtr disabled)
> +{
> + virDomainDefPtr def = vm->def;
> + qemuDomainObjPrivatePtr priv = vm->privateData;
> + virCPUDefPtr orig = NULL;
> + int rc;
> + int ret = -1;
> +
> + if (!enabled ||
> + !def->cpu ||
> + (def->cpu->mode == VIR_CPU_MODE_CUSTOM &&
> + !def->cpu->model))
Now the condition is extended by another check, this makes the code
fragile. I would prefer separating the "!enabled".
> + return 0;
> +
> + if (!(orig = virCPUDefCopy(def->cpu)))
> + goto cleanup;
> +
> + if ((rc = virCPUUpdateLive(def->os.arch, def->cpu, enabled, disabled)) < 0) {
> + goto cleanup;
> + } else if (rc == 0) {
> + /* Store the original CPU in priv if QEMU changed it and we didn't
> + * get the original CPU via migration, restore, or snapshot revert.
> + */
> + if (!priv->origCPU && !virCPUDefIsEqual(def->cpu, orig, false))
> + VIR_STEAL_PTR(priv->origCPU, orig);
> +
> + def->cpu->check = VIR_CPU_CHECK_FULL;
> + }
> +
> + ret = 0;
> +
> + cleanup:
> + virCPUDefFree(orig);
> + return ret;
> +}
Reviewed-by: Pavel Hrdina <phrdina at redhat.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170712/01e65f1f/attachment-0001.sig>
More information about the libvir-list
mailing list