Port to RHEL 6.3 early backport naming of __com.redhat_drive-mirror and __com.redhat_drive-reopen (with more arguments than block-job-complete). Thankfully, the rest of our code is nicely isolated from the difference in JSON code. * src/qemu/qemu_capabilities.c (qemuCapsProbeQMPCommands): Probe alternate name. * src/qemu/qemu_monitor_json.c (qemuMonitorJSONDriveMirror) (qemuMonitorJSONDrivePivot): Add RHEL fallbacks. --- v9.5: Don't require caller to pass 'bool reopen' argument, but instead try both spellings - that way, a single downstream libvirt build with this patch applied will support both RHEL and upstream qemu. This is for reference only, and not proposed for upstream. src/qemu/qemu_capabilities.c | 3 ++- src/qemu/qemu_monitor_json.c | 38 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 6194310..4caac06 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1891,7 +1891,8 @@ qemuCapsProbeQMPCommands(qemuCapsPtr caps, qemuCapsSet(caps, QEMU_CAPS_BLOCK_COMMIT); else if (STREQ(name, "query-vnc")) qemuCapsSet(caps, QEMU_CAPS_VNC); - else if (STREQ(name, "drive-mirror")) + else if (STREQ(name, "drive-mirror") || + STREQ(name, "__com.redhat_drive-mirror")) qemuCapsSet(caps, QEMU_CAPS_DRIVE_MIRROR); VIR_FREE(name); } diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 8f207b1..1f43d8b 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -3276,6 +3276,25 @@ qemuMonitorJSONDriveMirror(qemuMonitorPtr mon, if ((ret = qemuMonitorJSONCommand(mon, cmd, &reply)) < 0) goto cleanup; + if (qemuMonitorJSONHasError(reply, "CommandNotFound")) { + VIR_DEBUG("block-job-complete command not found, trying RHEL version"); + virJSONValueFree(cmd); + virJSONValueFree(reply); + reply = NULL; + cmd = qemuMonitorJSONMakeCommand("__com.redhat_drive-mirror", + "s:device", device, + "s:target", file, + "U:speed", speed, + "b:full", !shallow, + "s:mode", + reuse ? "existing" : "absolute-paths", + format ? "s:format" : NULL, format, + NULL); + if (!cmd) + goto cleanup; + if ((ret = qemuMonitorJSONCommand(mon, cmd, &reply)) < 0) + goto cleanup; + } ret = qemuMonitorJSONCheckError(cmd, reply); cleanup: @@ -3343,8 +3362,7 @@ cleanup: int qemuMonitorJSONDrivePivot(qemuMonitorPtr mon, const char *device, - const char *file ATTRIBUTE_UNUSED, - const char *format ATTRIBUTE_UNUSED) + const char *file, const char *format) { int ret; virJSONValuePtr cmd; @@ -3358,6 +3376,22 @@ qemuMonitorJSONDrivePivot(qemuMonitorPtr mon, const char *device, if ((ret = qemuMonitorJSONCommand(mon, cmd, &reply)) < 0) goto cleanup; + if (qemuMonitorJSONHasError(reply, "CommandNotFound")) { + VIR_DEBUG("block-job-complete command not found, trying RHEL version"); + virJSONValueFree(cmd); + virJSONValueFree(reply); + reply = NULL; + cmd = qemuMonitorJSONMakeCommand("__com.redhat_drive-reopen", + "s:device", device, + "s:new-image-file", file, + format ? "s:format" : NULL, format, + NULL); + if (!cmd) + goto cleanup; + if ((ret = qemuMonitorJSONCommand(mon, cmd, &reply)) < 0) + goto cleanup; + } + ret = qemuMonitorJSONCheckError(cmd, reply); cleanup: -- 1.7.11.7 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list