Skip to content

Commit

Permalink
ch: Handle resize events
Browse files Browse the repository at this point in the history
When resize events are found in the monitor, try to update the thread
id mapping (if a change is detected the domain.xml will also be
updated).

On vm resizes removing vcpus, the event will be triggered but because
cloud-hypervisor does not kill the associated thread right away, the
thread of the removed vcpu is going to still be detected and so
validating the event was processed successfully is skipped for now.
  • Loading branch information
bryteise committed Mar 16, 2021
1 parent 90d9dac commit a7f2659
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/ch/ch_monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,20 @@ static int virCHMonitorProcessEvent(virCHMonitorPtr mon,
case virCHMonitorVmEventSnapshotted:
case virCHMonitorVmEventRestoring:
case virCHMonitorVmEventResizing:
break;
case virCHMonitorVmEventResized:
virObjectLock(vm);
if (virDomainObjIsActive(vm) &&
virCHDomainObjBeginJob(vm, CH_JOB_MODIFY) == 0) {
virCHProcessSetupThreads(vm);
/* currently cloud hypervisor lazy offlines cpus so
* the offline cpus may still have an active thread id
* making virCHDomainValidateVcpuInfo fail. For now
* don't validate the result of resizing. */
virCHDomainObjEndJob(vm);
}
virObjectUnlock(vm);
break;
case virCHMonitorVmEventDeleted:
case virCHMonitorVmmEventStarting:
case virCHMonitorCpuCreateVcpu:
Expand Down
6 changes: 6 additions & 0 deletions src/ch/ch_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,8 @@ virCHProcessSetupVcpus(virDomainObjPtr vm)

int virCHProcessSetupThreads(virDomainObjPtr vm)
{
virCHDriverPtr driver = CH_DOMAIN_PRIVATE(vm)->driver;
g_autoptr(virCHDriverConfig) cfg = virCHDriverGetConfig(driver);
virCHDomainObjPrivatePtr priv = vm->privateData;
int ret;

Expand All @@ -523,6 +525,10 @@ int virCHProcessSetupThreads(virDomainObjPtr vm)
ret = virCHProcessSetupVcpus(vm);
}

if (!ret) {
ret = virDomainObjSave(vm, driver->xmlopt, cfg->stateDir);
}

return ret;
}

Expand Down

0 comments on commit a7f2659

Please sign in to comment.