Skip to content

Commit a7f2659

Browse files
committed
ch: Handle resize events
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.
1 parent 90d9dac commit a7f2659

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/ch/ch_monitor.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,20 @@ static int virCHMonitorProcessEvent(virCHMonitorPtr mon,
771771
case virCHMonitorVmEventSnapshotted:
772772
case virCHMonitorVmEventRestoring:
773773
case virCHMonitorVmEventResizing:
774+
break;
774775
case virCHMonitorVmEventResized:
776+
virObjectLock(vm);
777+
if (virDomainObjIsActive(vm) &&
778+
virCHDomainObjBeginJob(vm, CH_JOB_MODIFY) == 0) {
779+
virCHProcessSetupThreads(vm);
780+
/* currently cloud hypervisor lazy offlines cpus so
781+
* the offline cpus may still have an active thread id
782+
* making virCHDomainValidateVcpuInfo fail. For now
783+
* don't validate the result of resizing. */
784+
virCHDomainObjEndJob(vm);
785+
}
786+
virObjectUnlock(vm);
787+
break;
775788
case virCHMonitorVmEventDeleted:
776789
case virCHMonitorVmmEventStarting:
777790
case virCHMonitorCpuCreateVcpu:

src/ch/ch_process.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,8 @@ virCHProcessSetupVcpus(virDomainObjPtr vm)
503503

504504
int virCHProcessSetupThreads(virDomainObjPtr vm)
505505
{
506+
virCHDriverPtr driver = CH_DOMAIN_PRIVATE(vm)->driver;
507+
g_autoptr(virCHDriverConfig) cfg = virCHDriverGetConfig(driver);
506508
virCHDomainObjPrivatePtr priv = vm->privateData;
507509
int ret;
508510

@@ -523,6 +525,10 @@ int virCHProcessSetupThreads(virDomainObjPtr vm)
523525
ret = virCHProcessSetupVcpus(vm);
524526
}
525527

528+
if (!ret) {
529+
ret = virDomainObjSave(vm, driver->xmlopt, cfg->stateDir);
530+
}
531+
526532
return ret;
527533
}
528534

0 commit comments

Comments
 (0)