Skip to content

Commit

Permalink
fix job cancellation after changing block job_id parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
abbbi committed Dec 17, 2024
1 parent 5b79cc6 commit 3a5e43c
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions qmpbackup
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 3a5e43c

Please sign in to comment.