Use the helper added earlier to implement this new API. --- src/qemu/qemu_driver.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ba3a6e1..19a86bf 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15377,6 +15377,70 @@ cleanup: } #undef MATCH + +static int +qemuDomainSetGuestVcpu(virDomainPtr dom, + unsigned int id, + unsigned int online, + unsigned int flags) +{ + virQEMUDriverPtr driver = dom->conn->privateData; + virDomainObjPtr vm; + qemuDomainObjPrivatePtr priv; + int ret = -1; + + qemuAgentCPUInfo agentinfo = { .id = id, + .online = !!online }; + + virCheckFlags(0, -1); + + if (!(vm = qemuDomObjFromDomain(dom))) + return -1; + + priv = vm->privateData; + + /* request data from the guest */ + if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) + goto cleanup; + + if (!virDomainObjIsActive(vm)) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("domain is not running")); + goto endjob; + } + + if (!priv->agent) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("guest agent is not configured")); + goto endjob; + } + + qemuDomainObjEnterAgent(vm); + ret = qemuAgentSetVCPUs(priv->agent, &agentinfo, 1); + qemuDomainObjExitAgent(vm); + +endjob: + if (qemuDomainObjEndJob(driver, vm) == 0) + vm = NULL; + + if (ret < 0) + goto cleanup; + + if (ret != 0) { + virReportError(VIR_ERR_OPERATION_FAILED, + _("failed to set state of vCPU '%u'"), id); + goto cleanup; + } + + ret = 0; + +cleanup: + if (vm) + virObjectUnlock(vm); + return ret; +} + + static virDriver qemuDriver = { .no = VIR_DRV_QEMU, .name = QEMU_DRIVER_NAME, @@ -15557,6 +15621,7 @@ static virDriver qemuDriver = { .domainFSTrim = qemuDomainFSTrim, /* 1.0.1 */ .domainOpenChannel = qemuDomainOpenChannel, /* 1.0.2 */ .domainGetVCPUMap = qemuDomainGetVCPUMap, /* 1.0.7 */ + .domainSetGuestVcpu = qemuDomainSetGuestVcpu, /* 1.0.7 */ }; -- 1.8.2.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list