From 3a5e43c59d41ea6f306323142e1b97bdffcc0d0a Mon Sep 17 00:00:00 2001 From: ma Date: Tue, 17 Dec 2024 14:55:38 +0100 Subject: [PATCH] fix job cancellation after changing block job_id parameter --- qmpbackup | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/qmpbackup b/qmpbackup index 0ffa5d0..b009ae9 100755 --- a/qmpbackup +++ b/qmpbackup @@ -43,18 +43,22 @@ async def stop_jobs(blockdev, log, qmp, signal): log.error("Stopping backup jobs") SIGNAL_CATCHED = True jobs = await qmp.execute("query-block-jobs") - if not jobs: + if len(jobs) == 0: log.info("No running jobs found") for job in jobs: + if job["type"] != "backup": + continue for dev in blockdev: - if job["device"] == dev.node and job["type"] == "backup": - try: - await qmp.execute( - "block-job-cancel", - arguments={"device": dev.node, "force": True}, - ) - except qmp_client.ExecuteError as err: - log.info(err) + try: + await qmp.execute( + "block-job-cancel", + arguments={ + "device": f"qmpbackup.{dev.node}.{os.path.basename(dev.filename)}", + "force": True, + }, + ) + except qmp_client.ExecuteError as err: + log.info(err) async def main():