Skip to content

Commit

Permalink
acrn_driver: offline CPUs in Service VM first
Browse files Browse the repository at this point in the history
Offline CPUs in Service VM before offlining them in ACRN Hypervisor.

Tracked-On: #26
Signed-off-by: Fei Li <fei1.li@intel.com>
  • Loading branch information
lifeix authored and liuhang-bit committed Aug 18, 2022
1 parent 3cc935e commit 666d8e6
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/acrn/acrn_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -2649,9 +2649,9 @@ acrnOfflineCpus(int nprocs)
int fd;
char path[128], chr, online, cpu_id[4];
ssize_t rc;
virBitmapPtr cpus;
virBitmapPtr cpus, cpus_bak;

cpus = virHostCPUGetOnlineBitmap();
cpus_bak = cpus = virHostCPUGetOnlineBitmap();
while ((i = virBitmapNextSetBit(cpus, i)) >= 0 && i < nprocs) {
/* cpu0 can't be offlined */
if (i == 0)
Expand Down Expand Up @@ -2682,21 +2682,28 @@ acrnOfflineCpus(int nprocs)
virReportError(VIR_ERR_READ_FAILED, _("%s"), path);
return -1;
}
}

if ((fd = open(ACRN_OFFLINE_PATH, O_WRONLY)) < 0) {
virReportError(VIR_ERR_OPEN_FAILED, _(ACRN_OFFLINE_PATH));
return -1;
}
if ((fd = open(ACRN_OFFLINE_PATH, O_WRONLY)) < 0) {
virReportError(VIR_ERR_OPEN_FAILED, _(ACRN_OFFLINE_PATH));
return -1;
}

while ((i = virBitmapNextSetBit(cpus_bak, i)) >= 0 && i < nprocs) {
/* cpu0 can't be offlined */
if (i == 0)
continue;

snprintf(cpu_id, sizeof(cpu_id), "%ld", i);
if (write(fd, cpu_id, strlen(cpu_id)) < strlen(cpu_id)) {
close(fd);
virReportError(VIR_ERR_WRITE_FAILED, _(ACRN_OFFLINE_PATH));
return -1;
}

close(fd);
}

close(fd);

return 0;
}

Expand Down

0 comments on commit 666d8e6

Please sign in to comment.