[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] qemu: Start domain on a node without cpu affinity



libvirt affinity wrappers don't support macOS Thread Affinity API:
https://developer.apple.com/library/archive/releasenotes/Performance/RN-AffinityAPI/index.html

virProcessSetAffinity stub prevents libvirt from starting a qemu domain
on macOS:

$ virsh start vm
error: Failed to start domain vm
error: Process CPU affinity is not supported on this platform: Function not implemented

With the patch a VM can be started on macOS but some affinity-related
commands will return errors:

$ virsh vcpuinfo vm
error: Requested operation is not valid: cpu affinity is not supported

$ virsh vcpupin vm
VCPU: CPU Affinity
----------------------------------
   0: 0-7

$ virsh vcpupin vm --live --vcpu 0 --cpulist 7
error: operation failed: Virt type 'qemu' does not support vCPU pinning

$ virsh emulatorpin vm
emulator: CPU Affinity
----------------------------------
       *: 0-7

$ virsh emulatorpin vm --live --cpulist 7
error: Requested operation is not valid: cpu affinity is not supported

The patch also fixes virmacmaptest on macOS

Signed-off-by: Roman Bolshakov <r bolshakov yadro com>
---
 src/qemu/qemu_driver.c | 6 ++++++
 src/util/virprocess.c  | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 21e9e87ddd..2e225b1ede 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5245,6 +5245,12 @@ qemuDomainPinEmulator(virDomainPtr dom,
     if (virDomainPinEmulatorEnsureACL(dom->conn, vm->def, flags) < 0)
         goto cleanup;
 
+    if (!qemuDomainHasVcpuPids(vm)) {
+        virReportError(VIR_ERR_OPERATION_INVALID,
+                       "%s", _("cpu affinity is not supported"));
+        goto cleanup;
+    }
+
     if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
         goto cleanup;
 
diff --git a/src/util/virprocess.c b/src/util/virprocess.c
index 3988f5546c..7eaafd29f2 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -598,7 +598,7 @@ int virProcessSetAffinity(pid_t pid ATTRIBUTE_UNUSED,
 {
     virReportSystemError(ENOSYS, "%s",
                          _("Process CPU affinity is not supported on this platform"));
-    return -1;
+    return 0;
 }
 
 virBitmapPtr
-- 
2.15.2 (Apple Git-101.1)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]