From nobody Fri May 3 03:43:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1562947584; cv=none; d=zoho.com; s=zohoarc; b=P+AXT58L0hz0A7NZ1yQxoVNuQH12aO4EumWGNHn9AI5GRiyzT0hquGJkQxCGlGis46UszAsaEwvpGGKVnzYpmjFZDio05DtS33j+SysZdnpZvNqB/gnQ8/VJ5I3zl5MeKWmVRPrtdgm/fry46l+aOmte8Q1uPmXyEOoNxBwm0cE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562947584; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=9rifqNR8MUDlujKfjvNbF1IAdRzIxpKX+9ZV02MFf0c=; b=NChE7HlUdosO1CBU/NKFqGK+dxU2i33qcrNY8Su3obRU9T6bGXifyK93hC/Lh+4YT46OFy5uDd12SCddYBIWcLr8ZpFM/VWB+pn2AUnDuuV4BrfHKSDrWJ0p0p7VIowdouDVZV/s9/8itMC7l0Mun6vUjId95jodjXU5PwEMeuI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562947584396487.6187242779504; Fri, 12 Jul 2019 09:06:24 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C60013092666; Fri, 12 Jul 2019 16:06:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A007760C70; Fri, 12 Jul 2019 16:06:22 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 64DE21833008; Fri, 12 Jul 2019 16:06:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6CG6C90016296 for ; Fri, 12 Jul 2019 12:06:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id B18BB60C70; Fri, 12 Jul 2019 16:06:12 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 16CA760C05; Fri, 12 Jul 2019 16:06:11 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 12 Jul 2019 18:05:42 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 01/25] qemu: domain: Repurpose and export helper for saving domain status XML X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Fri, 12 Jul 2019 16:06:23 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Rename qemuDomainObjSaveJob and create a wrapper for it which does not require 'driver' to be passed and export it so that other palces can easily save the status XML without having to invoke virDomainSaveStatus which has unpleasing parameters. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 23 ++++++++++++++++------- src/qemu/qemu_domain.h | 2 ++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 0f1fda2384..2c0096d2ac 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7198,7 +7198,8 @@ virDomainDefParserConfig virQEMUDriverDomainDefParser= Config =3D { static void -qemuDomainObjSaveJob(virQEMUDriverPtr driver, virDomainObjPtr obj) +qemuDomainObjSaveStatus(virQEMUDriverPtr driver, + virDomainObjPtr obj) { virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); @@ -7210,6 +7211,14 @@ qemuDomainObjSaveJob(virQEMUDriverPtr driver, virDom= ainObjPtr obj) virObjectUnref(cfg); } + +void +qemuDomainSaveStatus(virDomainObjPtr obj) +{ + qemuDomainObjSaveStatus(QEMU_DOMAIN_PRIVATE(obj)->driver, obj); +} + + void qemuDomainObjSetJobPhase(virQEMUDriverPtr driver, virDomainObjPtr obj, @@ -7233,7 +7242,7 @@ qemuDomainObjSetJobPhase(virQEMUDriverPtr driver, priv->job.phase =3D phase; priv->job.asyncOwner =3D me; - qemuDomainObjSaveJob(driver, obj); + qemuDomainObjSaveStatus(driver, obj); } void @@ -7256,7 +7265,7 @@ qemuDomainObjDiscardAsyncJob(virQEMUDriverPtr driver,= virDomainObjPtr obj) if (priv->job.active =3D=3D QEMU_JOB_ASYNC_NESTED) qemuDomainObjResetJob(priv); qemuDomainObjResetAsyncJob(priv); - qemuDomainObjSaveJob(driver, obj); + qemuDomainObjSaveStatus(driver, obj); } void @@ -7439,7 +7448,7 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver, } if (qemuDomainTrackJob(job)) - qemuDomainObjSaveJob(driver, obj); + qemuDomainObjSaveStatus(driver, obj); virObjectUnref(cfg); return 0; @@ -7683,7 +7692,7 @@ qemuDomainObjEndJob(virQEMUDriverPtr driver, virDomai= nObjPtr obj) qemuDomainObjResetJob(priv); if (qemuDomainTrackJob(job)) - qemuDomainObjSaveJob(driver, obj); + qemuDomainObjSaveStatus(driver, obj); /* We indeed need to wake up ALL threads waiting because * grabbing a job requires checking more variables. */ virCondBroadcast(&priv->job.cond); @@ -7727,7 +7736,7 @@ qemuDomainObjEndJobWithAgent(virQEMUDriverPtr driver, qemuDomainObjResetJob(priv); qemuDomainObjResetAgentJob(priv); if (qemuDomainTrackJob(job)) - qemuDomainObjSaveJob(driver, obj); + qemuDomainObjSaveStatus(driver, obj); /* We indeed need to wake up ALL threads waiting because * grabbing a job requires checking more variables. */ virCondBroadcast(&priv->job.cond); @@ -7745,7 +7754,7 @@ qemuDomainObjEndAsyncJob(virQEMUDriverPtr driver, vir= DomainObjPtr obj) obj, obj->def->name); qemuDomainObjResetAsyncJob(priv); - qemuDomainObjSaveJob(driver, obj); + qemuDomainObjSaveStatus(driver, obj); virCondBroadcast(&priv->job.asyncCond); } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 3eea8b0f96..5853852880 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -206,6 +206,8 @@ typedef void (*qemuDomainCleanupCallback)(virQEMUDriver= Ptr driver, #define QEMU_DOMAIN_MASTER_KEY_LEN 32 /* 32 bytes for 256 bit random key = */ +void qemuDomainSaveStatus(virDomainObjPtr obj); + /* helper data types for async device unplug */ typedef enum { --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 03:43:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1562947577; cv=none; d=zoho.com; s=zohoarc; b=KsajsrwsgP9v2etvAiIgEHsH7aACmJX6aAhNY6Chn6U5Z55AXZ/2ZBgihO67bSO2C8VqqT9ElwWqexdN6tryfc1/jDiQy9RU/JMwLiFXfvhLhOspDsFTvWn2kCn143pf71ZkKfuMHcO1BjlICeCi2Wb3Zf9LBHkNDBQ6/+xCvJw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562947577; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Z3eusVr+ueo+i+XdaYg8q/GnrrGRBjhRWuCmWtB6R4A=; b=bLqhjs/q0ZayDYgw7XwwVwohaBTveTcvTuvhVAo6BGpH7zEU5ex1gTYToA2bFIixBln17lQEBfbNyCL1d0Q9sVVoBETs++sO2ykT1jzP71tu9XEn/kBOnJ3XEso8jf+66Q4JA/bj2tEzSa7a9zAohgZknjvGY3o0qWj5euafdh8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562947577858847.0459499511412; Fri, 12 Jul 2019 09:06:17 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0A5C9309265B; Fri, 12 Jul 2019 16:06:16 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CCA6B5DE64; Fri, 12 Jul 2019 16:06:15 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 575FA1833004; Fri, 12 Jul 2019 16:06:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6CG6D2p016305 for ; Fri, 12 Jul 2019 12:06:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id A61F760C64; Fri, 12 Jul 2019 16:06:13 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A30460C05; Fri, 12 Jul 2019 16:06:12 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 12 Jul 2019 18:05:43 +0200 Message-Id: <08b04c16656dcee7cc5692b9a70eae556f0af550.1562947284.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 02/25] qemu: domain: Add helper for saving config XML X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Fri, 12 Jul 2019 16:06:16 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Similarly to qemuDomainSaveStatus add a helper to save the config XML named qemuDomainSaveConfig. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 22 ++++++++++++++++++++++ src/qemu/qemu_domain.h | 1 + 2 files changed, 23 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 2c0096d2ac..073c9744d3 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7219,6 +7219,28 @@ qemuDomainSaveStatus(virDomainObjPtr obj) } +void +qemuDomainSaveConfig(virDomainObjPtr obj) +{ + virQEMUDriverPtr driver =3D QEMU_DOMAIN_PRIVATE(obj)->driver; + VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg =3D NULL; + virDomainDefPtr def =3D NULL; + + if (virDomainObjIsActive(obj)) + def =3D obj->newDef; + else + def =3D obj->def; + + if (!def) + return; + + cfg =3D virQEMUDriverGetConfig(driver); + + if (virDomainSaveConfig(cfg->configDir, driver->caps, def) < 0) + VIR_WARN("Failed to save config of vm %s", obj->def->name); +} + + void qemuDomainObjSetJobPhase(virQEMUDriverPtr driver, virDomainObjPtr obj, diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 5853852880..12882d5b91 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -207,6 +207,7 @@ typedef void (*qemuDomainCleanupCallback)(virQEMUDriver= Ptr driver, #define QEMU_DOMAIN_MASTER_KEY_LEN 32 /* 32 bytes for 256 bit random key = */ void qemuDomainSaveStatus(virDomainObjPtr obj); +void qemuDomainSaveConfig(virDomainObjPtr obj); /* helper data types for async device unplug */ --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 03:43:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1562947587; cv=none; d=zoho.com; s=zohoarc; b=gH3bYqc8Xcuia+oSG7M9ii8uX5UX9ynwdDvMC6NR+tu03jOHWNz/SGGKXief+1ecMztzG8wrsycVkX2c21+0B8eWBc8spPN4npLLQLSQ0OGyiCZTq2KsmCB4gE/k0R0g+u7aDTO0zlc+SosvX7Qu5IrjGLfbxcxFmIJmZHeLMQk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562947587; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=TVyrcXHrsrUyZXzpq5vAPsZyW9fers3H6VPqFjNX4nM=; b=Q3Hlt8WcpTj3TZWd2KkjH8JvqrWzqdtv5/yT5pEUFNLEDKlmXvsCPaVZ+kkTWSg8u7nFsiDA3h1bQ60ZhUwGravUW/7+gPurNBXW/UsxYs7avMFgt3k+H20+b+ebbcQgY1FGgW3wZwtlzu+7R+HAPQmhN5ib1mBbVhNDh+JfR+w= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562947587889309.2733679102497; Fri, 12 Jul 2019 09:06:27 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 469BF308FC4E; Fri, 12 Jul 2019 16:06:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1D063196B4; Fri, 12 Jul 2019 16:06:26 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id CE8EB183300A; Fri, 12 Jul 2019 16:06:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6CG6E2g016310 for ; Fri, 12 Jul 2019 12:06:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 97E8460C70; Fri, 12 Jul 2019 16:06:14 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0BAE60C05; Fri, 12 Jul 2019 16:06:13 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 12 Jul 2019 18:05:44 +0200 Message-Id: <2af9a01627243c11313459e635fbbb49a0300f5f.1562947284.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 03/25] qemu: blockjob: Use VIR_AUTOUNREF in qemuBlockJobDataNew X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Fri, 12 Jul 2019 16:06:26 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Simplify error paths. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_blockjob.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index b3bdbeb990..b45103f2f3 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -73,8 +73,7 @@ static qemuBlockJobDataPtr qemuBlockJobDataNew(qemuBlockJobType type, const char *name) { - qemuBlockJobDataPtr job =3D NULL; - qemuBlockJobDataPtr ret =3D NULL; + VIR_AUTOUNREF(qemuBlockJobDataPtr) job =3D NULL; if (qemuBlockJobDataInitialize() < 0) return NULL; @@ -83,17 +82,13 @@ qemuBlockJobDataNew(qemuBlockJobType type, return NULL; if (VIR_STRDUP(job->name, name) < 0) - goto cleanup; + return NULL; job->state =3D QEMU_BLOCKJOB_STATE_NEW; job->newstate =3D -1; job->type =3D type; - VIR_STEAL_PTR(ret, job); - - cleanup: - virObjectUnref(job); - return ret; + VIR_RETURN_PTR(job); } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 03:43:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1562947580; cv=none; d=zoho.com; s=zohoarc; b=hT9fMXIUIAcemlw87jNaxVXpKv22EGb6EoFGgHaIuWXS9wysUsYw/67k4Ad4/iwjTo7uya0ullDdl3IwXGFNqGLqhbFsfypH7NgGucLHMebkjU6PKe7Zkq9cYrpuf7B147hUVCzIAo7Al/Db+fZsuuuRJy0kEOn+MMp0zPsMptk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562947580; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=e9Eea/M3zrRc+TVi5ro2cgelDOFaJZJFQEpgM8DvryQ=; b=npdJg/haCZOp0K572LXsUHn+c8ZHg/oOfwKb70BtADMVCQTj+auVoq+XzcaDfbl3igOpZmR9LVggyffwqkczX5kEi5lLAN2fq11h2g8UC6V9PQO6lzuSEQvIs4dS9u76je/Rs8j1FVBIpkKrAcOyIq1BOq7ZsYfDQojofQf2Cu0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562947580702859.4165877854008; Fri, 12 Jul 2019 09:06:20 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E476E307D986; Fri, 12 Jul 2019 16:06:18 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B5BDC5D756; Fri, 12 Jul 2019 16:06:18 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 79CEE41F53; Fri, 12 Jul 2019 16:06:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6CG6FfT016318 for ; Fri, 12 Jul 2019 12:06:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8CF1B60C70; Fri, 12 Jul 2019 16:06:15 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id E319060C05; Fri, 12 Jul 2019 16:06:14 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 12 Jul 2019 18:05:45 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 04/25] qemu: blockjob: Separate and unify block job (un)registration X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Fri, 12 Jul 2019 16:06:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Rename and move qemuBlockJobTerminate to qemuBlockJobUnregister and separate bits from qemuBlockJobDiskNew which register the job with the disk. This creates an unified interface for other APIs to use. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_blockjob.c | 62 ++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index b45103f2f3..c102417e43 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -92,6 +92,37 @@ qemuBlockJobDataNew(qemuBlockJobType type, } +static int +qemuBlockJobRegister(qemuBlockJobDataPtr job, + virDomainDiskDefPtr disk) +{ + if (disk) { + job->disk =3D disk; + QEMU_DOMAIN_DISK_PRIVATE(disk)->blockjob =3D virObjectRef(job); + } + + return 0; +} + + +static void +qemuBlockJobUnregister(qemuBlockJobDataPtr job) +{ + qemuDomainDiskPrivatePtr diskPriv; + + if (job->disk) { + diskPriv =3D QEMU_DOMAIN_DISK_PRIVATE(job->disk); + + if (job =3D=3D diskPriv->blockjob) { + virObjectUnref(diskPriv->blockjob); + diskPriv->blockjob =3D NULL; + } + + job->disk =3D NULL; + } +} + + /** * qemuBlockJobDiskNew: * @disk: disk definition @@ -105,16 +136,15 @@ qemuBlockJobDiskNew(virDomainDiskDefPtr disk, qemuBlockJobType type, const char *jobname) { - qemuBlockJobDataPtr job =3D NULL; + VIR_AUTOUNREF(qemuBlockJobDataPtr) job =3D NULL; if (!(job =3D qemuBlockJobDataNew(type, jobname))) return NULL; - job->disk =3D disk; - if (disk) - QEMU_DOMAIN_DISK_PRIVATE(disk)->blockjob =3D virObjectRef(job); + if (qemuBlockJobRegister(job, disk) < 0) + return NULL; - return job; + VIR_RETURN_PTR(job); } @@ -150,22 +180,6 @@ qemuBlockJobStarted(qemuBlockJobDataPtr job) } -static void -qemuBlockJobTerminate(qemuBlockJobDataPtr job) -{ - qemuDomainDiskPrivatePtr diskPriv; - - if (job->disk) { - diskPriv =3D QEMU_DOMAIN_DISK_PRIVATE(job->disk); - - if (job =3D=3D diskPriv->blockjob) { - virObjectUnref(diskPriv->blockjob); - diskPriv->blockjob =3D NULL; - } - } -} - - /** * qemuBlockJobStartupFinalize: * @job: job being started @@ -181,7 +195,7 @@ qemuBlockJobStartupFinalize(qemuBlockJobDataPtr job) return; if (job->state =3D=3D QEMU_BLOCKJOB_STATE_NEW) - qemuBlockJobTerminate(job); + qemuBlockJobUnregister(job); virObjectUnref(job); } @@ -300,7 +314,7 @@ qemuBlockJobEventProcessLegacyCompleted(virQEMUDriverPt= r driver, virStorageSourceBackingStoreClear(disk->src); ignore_value(qemuDomainDetermineDiskChain(driver, vm, disk, NULL, true= )); ignore_value(qemuBlockNodeNamesDetect(driver, vm, asyncJob)); - qemuBlockJobTerminate(job); + qemuBlockJobUnregister(job); } @@ -355,7 +369,7 @@ qemuBlockJobEventProcessLegacy(virQEMUDriverPtr driver, } disk->mirrorState =3D VIR_DOMAIN_DISK_MIRROR_STATE_NONE; disk->mirrorJob =3D VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN; - qemuBlockJobTerminate(job); + qemuBlockJobUnregister(job); break; case VIR_DOMAIN_BLOCK_JOB_LAST: --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 03:43:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1562947584; cv=none; d=zoho.com; s=zohoarc; b=RJQDs4l2RaSR/81RIb7K6xsDTamZ+Y85T0zPQW1Y0qa8g/k+aNabHzz2QkKuXOMLOIqRaIksl/puN1QVzC7yaLrle1fKzUerfGyZLlU/dOIgSK2fizSjz+AviRHE1oUkr5g8785EdnbVwXWWJc1iJhjBgj7nq1D/FhzTUv5OnXg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562947584; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=lh4GDcBg9ov8BdwtoFyECOHnoCBhAUrPESqSPESSBZM=; b=FxmA1XTXOrjXjeNvUQH2RaHmVekjAHLvxgaPgUhtq+mbAKh3qvVkHnqO0OjVF4jg4V46BRw8pJcVeEdwisMsx+vGeDOwJr9uus1hnAcmMyoyKVOmJ0L95DIF8TapdxoW8EehZXUc0XArNPSdGTZ+bc+KFVPyKjvNoWvySM6RC6Q= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 156294758438294.4930520459261; Fri, 12 Jul 2019 09:06:24 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BAE2B308C380; Fri, 12 Jul 2019 16:06:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 94B9F60142; Fri, 12 Jul 2019 16:06:22 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5AFE4C596; Fri, 12 Jul 2019 16:06:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6CG6GYc016328 for ; Fri, 12 Jul 2019 12:06:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7CCE360C70; Fri, 12 Jul 2019 16:06:16 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5F9860C05; Fri, 12 Jul 2019 16:06:15 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 12 Jul 2019 18:05:46 +0200 Message-Id: <9ee90fc0839836522cf60382e9d2070f15ce915d.1562947284.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 05/25] qemu: domain: Add global table of blockjobs X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Fri, 12 Jul 2019 16:06:23 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Block jobs currently belong to disks only so we can look up the block job data for them in the corresponding disks. This won't be the case when using blockdev as certain jobs don't even correspond to a disk and most of them can run on a part of the backing chain. Add a global table of blockjobs which can be used to look up the data for the blockjobs when the job events need to be processed. The table is a hash table organized by job name and has a reference to the job. New and running jobs will later be added to this table. Reference counting will allow to reap job state for synchronous callers. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 7 +++++++ src/qemu/qemu_domain.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 073c9744d3..5af8f3b30c 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1982,6 +1982,9 @@ qemuDomainObjPrivateAlloc(void *opaque) if (!(priv->devs =3D virChrdevAlloc())) goto error; + if (!(priv->blockjobs =3D virHashCreate(5, virObjectFreeHashData))) + goto error; + priv->migMaxBandwidth =3D QEMU_DOMAIN_MIG_BANDWIDTH_MAX; priv->driver =3D opaque; @@ -2051,6 +2054,8 @@ qemuDomainObjPrivateDataClear(qemuDomainObjPrivatePtr= priv) qemuDomainObjResetJob(priv); qemuDomainObjResetAsyncJob(priv); + + virHashRemoveAll(priv->blockjobs); } @@ -2082,6 +2087,8 @@ qemuDomainObjPrivateFree(void *data) qemuDomainSecretInfoFree(&priv->migSecinfo); qemuDomainMasterKeyFree(priv); + virHashFree(priv->blockjobs); + VIR_FREE(priv); } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 12882d5b91..b42b205398 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -389,6 +389,9 @@ struct _qemuDomainObjPrivate { /* true if global -mem-prealloc appears on cmd line */ bool memPrealloc; + + /* running block jobs */ + virHashTablePtr blockjobs; }; #define QEMU_DOMAIN_PRIVATE(vm) \ --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 03:43:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1562947587; cv=none; d=zoho.com; s=zohoarc; b=ENB6OLIZR66Mwj+Mueh/yYNUD+Xx9EnUpiMO1PddOILipQ0VNINyUNJRiZCQaP6GpmzZoMrbUx8K5Dlrq8K2mkSyUL2zu0zqeJb9OGHGcm+SXEsgNuLU+E93Muqc1n4dyLtMyQnJhGHvHgqifjwFnSGB28IJUS1yeMsAkg9nZPo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562947587; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=mWT5FjbbCzAiDxt8fC6tTpWPulYKm++EhxqLZrcX+GE=; b=hpGEjX4YtZHc1MU+PYZP2uMZkqaRWKOvXQImmprfWqVSsa//ua6JwlmN5wrdZyMxFzQtPNQsV9x8MK4IUYrTyY/gFAt5d1MeTbwp/Ger4xrAJ9oQbfHNo/1CWwKMNUhOUjpWF8rOilb299CtauiJFfa/jmXSGWbhhD3sadYfMdA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562947587800552.4011289029955; Fri, 12 Jul 2019 09:06:27 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 21C95C0586D8; Fri, 12 Jul 2019 16:06:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EA65960A9A; Fri, 12 Jul 2019 16:06:25 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B0CDC3D3F3; Fri, 12 Jul 2019 16:06:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6CG6LeU016355 for ; Fri, 12 Jul 2019 12:06:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5E9EB60C70; Fri, 12 Jul 2019 16:06:21 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 95DBF60C05; Fri, 12 Jul 2019 16:06:16 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 12 Jul 2019 18:05:47 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 06/25] qemu: blockjob: Register new and running blockjobs in the global table X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 12 Jul 2019 16:06:26 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add the job structure to the table when instantiating a new job and remove it when it terminates/fails. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_blockjob.c | 29 ++++++++++++++++++++++------- src/qemu/qemu_blockjob.h | 6 ++++-- src/qemu/qemu_driver.c | 16 ++++++++-------- src/qemu/qemu_migration.c | 4 ++-- src/qemu/qemu_process.c | 6 +++--- 5 files changed, 39 insertions(+), 22 deletions(-) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index c102417e43..8cbfc556b3 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -94,8 +94,16 @@ qemuBlockJobDataNew(qemuBlockJobType type, static int qemuBlockJobRegister(qemuBlockJobDataPtr job, + virDomainObjPtr vm, virDomainDiskDefPtr disk) { + qemuDomainObjPrivatePtr priv =3D vm->privateData; + + if (virHashAddEntry(priv->blockjobs, job->name, virObjectRef(job)) < 0= ) { + virObjectUnref(job); + return -1; + } + if (disk) { job->disk =3D disk; QEMU_DOMAIN_DISK_PRIVATE(disk)->blockjob =3D virObjectRef(job); @@ -106,8 +114,10 @@ qemuBlockJobRegister(qemuBlockJobDataPtr job, static void -qemuBlockJobUnregister(qemuBlockJobDataPtr job) +qemuBlockJobUnregister(qemuBlockJobDataPtr job, + virDomainObjPtr vm) { + qemuDomainObjPrivatePtr priv =3D vm->privateData; qemuDomainDiskPrivatePtr diskPriv; if (job->disk) { @@ -120,6 +130,9 @@ qemuBlockJobUnregister(qemuBlockJobDataPtr job) job->disk =3D NULL; } + + /* this may remove the last reference of 'job' */ + virHashRemoveEntry(priv->blockjobs, job->name); } @@ -132,7 +145,8 @@ qemuBlockJobUnregister(qemuBlockJobDataPtr job) * Returns 0 on success and -1 on failure. */ qemuBlockJobDataPtr -qemuBlockJobDiskNew(virDomainDiskDefPtr disk, +qemuBlockJobDiskNew(virDomainObjPtr vm, + virDomainDiskDefPtr disk, qemuBlockJobType type, const char *jobname) { @@ -141,7 +155,7 @@ qemuBlockJobDiskNew(virDomainDiskDefPtr disk, if (!(job =3D qemuBlockJobDataNew(type, jobname))) return NULL; - if (qemuBlockJobRegister(job, disk) < 0) + if (qemuBlockJobRegister(job, vm, disk) < 0) return NULL; VIR_RETURN_PTR(job); @@ -189,13 +203,14 @@ qemuBlockJobStarted(qemuBlockJobDataPtr job) * to @job if it was started. */ void -qemuBlockJobStartupFinalize(qemuBlockJobDataPtr job) +qemuBlockJobStartupFinalize(virDomainObjPtr vm, + qemuBlockJobDataPtr job) { if (!job) return; if (job->state =3D=3D QEMU_BLOCKJOB_STATE_NEW) - qemuBlockJobUnregister(job); + qemuBlockJobUnregister(job, vm); virObjectUnref(job); } @@ -314,7 +329,7 @@ qemuBlockJobEventProcessLegacyCompleted(virQEMUDriverPt= r driver, virStorageSourceBackingStoreClear(disk->src); ignore_value(qemuDomainDetermineDiskChain(driver, vm, disk, NULL, true= )); ignore_value(qemuBlockNodeNamesDetect(driver, vm, asyncJob)); - qemuBlockJobUnregister(job); + qemuBlockJobUnregister(job, vm); } @@ -369,7 +384,7 @@ qemuBlockJobEventProcessLegacy(virQEMUDriverPtr driver, } disk->mirrorState =3D VIR_DOMAIN_DISK_MIRROR_STATE_NONE; disk->mirrorJob =3D VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN; - qemuBlockJobUnregister(job); + qemuBlockJobUnregister(job, vm); break; case VIR_DOMAIN_BLOCK_JOB_LAST: diff --git a/src/qemu/qemu_blockjob.h b/src/qemu/qemu_blockjob.h index da529090ad..b7aaa86f4d 100644 --- a/src/qemu/qemu_blockjob.h +++ b/src/qemu/qemu_blockjob.h @@ -80,7 +80,8 @@ struct _qemuBlockJobData { qemuBlockJobDataPtr -qemuBlockJobDiskNew(virDomainDiskDefPtr disk, +qemuBlockJobDiskNew(virDomainObjPtr vm, + virDomainDiskDefPtr disk, qemuBlockJobType type, const char *jobname) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3); @@ -98,7 +99,8 @@ qemuBlockJobIsRunning(qemuBlockJobDataPtr job) ATTRIBUTE_NONNULL(1); void -qemuBlockJobStartupFinalize(qemuBlockJobDataPtr job); +qemuBlockJobStartupFinalize(virDomainObjPtr vm, + qemuBlockJobDataPtr job); int qemuBlockJobUpdate(virDomainObjPtr vm, qemuBlockJobDataPtr job, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index e41a3001ae..879a78858b 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4702,7 +4702,7 @@ processBlockJobEvent(virQEMUDriverPtr driver, } if (!(job =3D qemuBlockJobDiskGetJob(disk))) { - if (!(job =3D qemuBlockJobDiskNew(disk, type, diskAlias))) + if (!(job =3D qemuBlockJobDiskNew(vm, disk, type, diskAlias))) goto endjob; qemuBlockJobStarted(job); } @@ -4712,7 +4712,7 @@ processBlockJobEvent(virQEMUDriverPtr driver, qemuBlockJobUpdate(vm, job, QEMU_ASYNC_JOB_NONE); endjob: - qemuBlockJobStartupFinalize(job); + qemuBlockJobStartupFinalize(vm, job); qemuDomainObjEndJob(driver, vm); } @@ -17084,7 +17084,7 @@ qemuDomainBlockPullCommon(virQEMUDriverPtr driver, speed <<=3D 20; } - if (!(job =3D qemuBlockJobDiskNew(disk, QEMU_BLOCKJOB_TYPE_PULL, devic= e))) + if (!(job =3D qemuBlockJobDiskNew(vm, disk, QEMU_BLOCKJOB_TYPE_PULL, d= evice))) goto endjob; qemuDomainObjEnterMonitor(driver, vm); @@ -17110,7 +17110,7 @@ qemuDomainBlockPullCommon(virQEMUDriverPtr driver, qemuDomainObjEndJob(driver, vm); cleanup: - qemuBlockJobStartupFinalize(job); + qemuBlockJobStartupFinalize(vm, job); virDomainObjEndAPI(&vm); return ret; } @@ -17655,7 +17655,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, if (qemuDomainStorageSourceChainAccessAllow(driver, vm, mirror) < 0) goto endjob; - if (!(job =3D qemuBlockJobDiskNew(disk, QEMU_BLOCKJOB_TYPE_COPY, devic= e))) + if (!(job =3D qemuBlockJobDiskNew(vm, disk, QEMU_BLOCKJOB_TYPE_COPY, d= evice))) goto endjob; disk->mirrorState =3D VIR_DOMAIN_DISK_MIRROR_STATE_NONE; @@ -17691,7 +17691,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, VIR_WARN("%s", _("unable to remove just-created copy target")); virStorageFileDeinit(mirror); qemuDomainObjEndJob(driver, vm); - qemuBlockJobStartupFinalize(job); + qemuBlockJobStartupFinalize(vm, job); return ret; } @@ -18042,7 +18042,7 @@ qemuDomainBlockCommit(virDomainPtr dom, qemuDomainStorageSourceAccessAllow(driver, vm, top_parent, false,= false) < 0)) goto endjob; - if (!(job =3D qemuBlockJobDiskNew(disk, jobtype, device))) + if (!(job =3D qemuBlockJobDiskNew(vm, disk, jobtype, device))) goto endjob; disk->mirrorState =3D VIR_DOMAIN_DISK_MIRROR_STATE_NONE; @@ -18089,7 +18089,7 @@ qemuDomainBlockCommit(virDomainPtr dom, virFreeError(orig_err); } } - qemuBlockJobStartupFinalize(job); + qemuBlockJobStartupFinalize(vm, job); qemuDomainObjEndJob(driver, vm); cleanup: diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 1fb88c11b6..e72553befc 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -921,7 +921,7 @@ qemuMigrationSrcNBDStorageCopyOne(virQEMUDriverPtr driv= er, if (!(diskAlias =3D qemuAliasDiskDriveFromDisk(disk))) goto cleanup; - if (!(job =3D qemuBlockJobDiskNew(disk, QEMU_BLOCKJOB_TYPE_COPY, diskA= lias))) + if (!(job =3D qemuBlockJobDiskNew(vm, disk, QEMU_BLOCKJOB_TYPE_COPY, d= iskAlias))) goto cleanup; qemuBlockJobSyncBegin(job); @@ -949,7 +949,7 @@ qemuMigrationSrcNBDStorageCopyOne(virQEMUDriverPtr driv= er, ret =3D 0; cleanup: - qemuBlockJobStartupFinalize(job); + qemuBlockJobStartupFinalize(vm, job); VIR_FREE(diskAlias); return ret; } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index aa09ef175a..29124ae184 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -976,7 +976,7 @@ qemuProcessHandleBlockJob(qemuMonitorPtr mon ATTRIBUTE_= UNUSED, } cleanup: - qemuBlockJobStartupFinalize(job); + qemuBlockJobStartupFinalize(vm, job); qemuProcessEventFree(processEvent); virObjectUnlock(vm); return 0; @@ -7816,7 +7816,7 @@ qemuProcessRefreshLegacyBlockjob(void *payload, disk->mirrorJob =3D=3D VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT) jobtype =3D disk->mirrorJob; - if (!(job =3D qemuBlockJobDiskNew(disk, jobtype, jobname))) + if (!(job =3D qemuBlockJobDiskNew(vm, disk, jobtype, jobname))) return -1; qemuBlockJobStarted(job); @@ -7850,7 +7850,7 @@ qemuProcessRefreshLegacyBlockjob(void *payload, } cleanup: - qemuBlockJobStartupFinalize(job); + qemuBlockJobStartupFinalize(vm, job); return 0; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 03:43:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1562947589; cv=none; d=zoho.com; s=zohoarc; b=Bea3vj/JAFd6DnQK7az4p6LHZAvA9gQWDQdqCb3/8ktoC7cBC47ydBHB/sozEYf9jMOc/aOdTVqtGfJ76qI8SdR6HHHHoUHixQNLFySzHwhbEPk9+I9ESiv9G00/K3dE4+wTmCnLk1S+Y6qAIVLqENwuCrA3ipEK6gAI3Zy1rGg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562947589; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=3ZGMAUxxz5shpX65QxCOp/WzVZ+REjdBwLB9xGfVDeI=; b=aUkl1UnvGBeMbNKFwQXEhYlFP8hGlKKyLte3jn45WNftS9XWFWkwUXVSWidsLrGwUcO3XkZfzGAcesUvMUXfs40fVKovnIPxIFUHlQ5OvdKFil4JzR/wf1AZlcqkQ3hnLP6yOchMx07lzABuirENmCxA5sZjgy/b5TWL7wjUp/k= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562947589713133.5296506238368; Fri, 12 Jul 2019 09:06:29 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0F8A886679; Fri, 12 Jul 2019 16:06:28 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DFD421001B02; Fri, 12 Jul 2019 16:06:27 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A93A024B25; Fri, 12 Jul 2019 16:06:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6CG6PP8016365 for ; Fri, 12 Jul 2019 12:06:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id CCB6660C78; Fri, 12 Jul 2019 16:06:25 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 21C6D60BFB; Fri, 12 Jul 2019 16:06:21 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 12 Jul 2019 18:05:48 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 07/25] qemu: blockjob: Add string convertors for blockjob type and state enums X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 12 Jul 2019 16:06:28 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Later on we'll format these values into the status XML so the from/to string functions will come handy. The implementation also notes that these will be used in the status XML to avoid somebody changing the values. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_blockjob.c | 9 +++++++++ src/qemu/qemu_blockjob.h | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index 8cbfc556b3..bba1b9d656 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -43,6 +43,15 @@ VIR_LOG_INIT("qemu.qemu_blockjob"); +/* Note that qemuBlockjobState and qemuBlockjobType values are formatted i= nto + * the status XML */ +VIR_ENUM_IMPL(qemuBlockjobState, + QEMU_BLOCKJOB_STATE_LAST, + "completed", "failed", "cancelled", "ready", "new", "running= "); + +VIR_ENUM_IMPL(qemuBlockjob, + QEMU_BLOCKJOB_TYPE_LAST, + "", "pull", "copy", "commit", "active-commit", ""); static virClassPtr qemuBlockJobDataClass; diff --git a/src/qemu/qemu_blockjob.h b/src/qemu/qemu_blockjob.h index b7aaa86f4d..77298a4bea 100644 --- a/src/qemu/qemu_blockjob.h +++ b/src/qemu/qemu_blockjob.h @@ -42,6 +42,8 @@ typedef enum { } qemuBlockjobState; verify((int)QEMU_BLOCKJOB_STATE_NEW =3D=3D VIR_DOMAIN_BLOCK_JOB_LAST); +VIR_ENUM_DECL(qemuBlockjobState); + /** * This enum has to map all known block job types from enum virDomainBlock= JobType * to the same values. All internal blockjobs can be mapped after and don't @@ -60,6 +62,8 @@ typedef enum { } qemuBlockJobType; verify((int)QEMU_BLOCKJOB_TYPE_INTERNAL =3D=3D VIR_DOMAIN_BLOCK_JOB_TYPE_L= AST); +VIR_ENUM_DECL(qemuBlockjob); + typedef struct _qemuBlockJobData qemuBlockJobData; typedef qemuBlockJobData *qemuBlockJobDataPtr; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 03:43:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1562947596; cv=none; d=zoho.com; s=zohoarc; b=jTKk/qj7midz7o/KFdEwrJ2nR8GEy3iLGDIYrOl3FPZ9xiVwJZUAUFIiOPvUM2ErHMEat6cny3OdvIM9UefMyoNN6GxaAZE/Iu6j1lpDsmbnkLvh60uUBlNfYKCiXWXA1TT+qATAeluKhBOI5oUI8oOtwXQZpG3WbzGfk2F2T3M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562947596; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=JyjfGfw3kcbOXWUjuRtK0tCebG6QSJAoFkfufGlLGvY=; b=JEvz9wQEjUjjl9R1zjE793cC/Rl4qUtNXcXAzpcrA1TzhTRxNn3NnWKa3wG16NSjZMM8+FnKzghRWxLj/EtThGL/ZEss9MzGYE1WEDNfCgAZ7Ek34ZW0VU+9L3yX8W+DIR8e8zm3zKgkiNsjc4BCpXW3AvDZ3PxenWFVibpR0I4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562947596269502.388766932276; Fri, 12 Jul 2019 09:06:36 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9597730BC58A; Fri, 12 Jul 2019 16:06:34 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6FF4960A9A; Fri, 12 Jul 2019 16:06:34 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 368271833002; Fri, 12 Jul 2019 16:06:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6CG6Wkr016385 for ; Fri, 12 Jul 2019 12:06:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id B3FC260C05; Fri, 12 Jul 2019 16:06:32 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id EAFD060BFB; Fri, 12 Jul 2019 16:06:25 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 12 Jul 2019 18:05:49 +0200 Message-Id: <25c728cc82b1673afc8ad923ff5b01ee8538f068.1562947284.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 08/25] qemu: blockjob: Export functions for allocating and registering job data X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 12 Jul 2019 16:06:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" When parsing the status XML we need to register all existing jobs. Export the functions so that they are usable in other modules. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_blockjob.c | 4 ++-- src/qemu/qemu_blockjob.h | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index bba1b9d656..78d4938684 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -78,7 +78,7 @@ qemuBlockJobDataOnceInit(void) VIR_ONCE_GLOBAL_INIT(qemuBlockJobData); -static qemuBlockJobDataPtr +qemuBlockJobDataPtr qemuBlockJobDataNew(qemuBlockJobType type, const char *name) { @@ -101,7 +101,7 @@ qemuBlockJobDataNew(qemuBlockJobType type, } -static int +int qemuBlockJobRegister(qemuBlockJobDataPtr job, virDomainObjPtr vm, virDomainDiskDefPtr disk) diff --git a/src/qemu/qemu_blockjob.h b/src/qemu/qemu_blockjob.h index 77298a4bea..fe16badbc8 100644 --- a/src/qemu/qemu_blockjob.h +++ b/src/qemu/qemu_blockjob.h @@ -82,6 +82,16 @@ struct _qemuBlockJobData { int newstate; /* qemuBlockjobState, subset of events emitted by qemu */ }; +int +qemuBlockJobRegister(qemuBlockJobDataPtr job, + virDomainObjPtr vm, + virDomainDiskDefPtr disk) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); + +qemuBlockJobDataPtr +qemuBlockJobDataNew(qemuBlockJobType type, + const char *name) + ATTRIBUTE_NONNULL(2); qemuBlockJobDataPtr qemuBlockJobDiskNew(virDomainObjPtr vm, --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 03:43:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1562947600; cv=none; d=zoho.com; s=zohoarc; b=UPBEpp9j2UNgRsr1xB75A/q0+0QkipNNC5gp1YcEnuPYpBgV3Au0odUSeqJfuEO+du9AUNL0rvVHHiJaFht2PGETUlTYueckKP2adKQlMLKsGGvhzlFOOu8+USd0g69KvfhEfM/XnLOdMNXOMzo61UkhM14zr03Uf9IPDdOUsQI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562947600; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=9I6gQooN4lZr6rric4FQAeXHdir1euhHhc01aOB9gh8=; b=oVbs3bIUFTG8Ks6hkV0Lwe5ZESuc62MCuFIwtA7dvoo66HGklpKGNlRAym3YrNkUoJ8wfOMxD1S7MxkZvDL8OJ4NHWCXu9wryC3IprqBYcTSrbaDLUogtUJ73pkrX2u4/RuQLh5lJpSxUhFqFBytoF61QP1t+0C9df5LZVpxmug= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562947600385970.0320351760967; Fri, 12 Jul 2019 09:06:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B5AA081F0C; Fri, 12 Jul 2019 16:06:38 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 884055C207; Fri, 12 Jul 2019 16:06:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 46C7B183300A; Fri, 12 Jul 2019 16:06:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6CG6boQ016407 for ; Fri, 12 Jul 2019 12:06:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5760460C73; Fri, 12 Jul 2019 16:06:37 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8712960BFB; Fri, 12 Jul 2019 16:06:32 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 12 Jul 2019 18:05:50 +0200 Message-Id: <2206a4755db3576e861fc0dbac3728b14af104d7.1562947284.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 09/25] qemu: blockjob: Add flag for invalid block job data X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 12 Jul 2019 16:06:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The job data saved in the XML may be partially invalid e.g. if something is missing. To prevent losing a domain with such a job add a flag to the job data so that job APIs can ignore such a job and we can just cancel it. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_blockjob.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/qemu/qemu_blockjob.h b/src/qemu/qemu_blockjob.h index fe16badbc8..5b3af69d89 100644 --- a/src/qemu/qemu_blockjob.h +++ b/src/qemu/qemu_blockjob.h @@ -80,6 +80,8 @@ struct _qemuBlockJobData { bool synchronous; /* API call is waiting for this job */ int newstate; /* qemuBlockjobState, subset of events emitted by qemu */ + + bool invalidData; /* the job data (except name) is not valid */ }; int --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 03:43:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1562947603; cv=none; d=zoho.com; s=zohoarc; b=XQmDFvl8AaCSsgqFNkh/PD/aeq7qhJGquYqYKYdRoR6cABsCUj9D6O+6MgUuSboumawGNEevGsM4NypoCPA+dWQ+xH3yEeWjS9C8H0Hz/C2zNKy5qyea7Th7pQYMuGnCiYnWdod5NzlXtZ+KF1B9vAltaBokIujZ4PkLih6jYTI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562947603; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=r86Xl1BQdWkwQpK8T2LclczErs6op+af9gN2HJMxq1E=; b=nDR6JaNwT8gglJ7AzmLx1pVdzp7rv6l2jrJeEk+MKnsmmhT4sUZtOEDUPMFUlC7rapp1OtiyDUWHr/o1WP82sO05ZYOe6Gab+yX8qUiGc9rm3CTIVUCvJNMSFKg2EhUfhTw5AOL5sx5NFEdxurGwYTP/TMqJKk9l+I1gq8t+gSU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562947603426227.24765661789615; Fri, 12 Jul 2019 09:06:43 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E169388313; Fri, 12 Jul 2019 16:06:41 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BC48F60142; Fri, 12 Jul 2019 16:06:41 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6D93D183300F; Fri, 12 Jul 2019 16:06:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6CG6e1F016571 for ; Fri, 12 Jul 2019 12:06:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0D97B60C73; Fri, 12 Jul 2019 16:06:40 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 666B360C70; Fri, 12 Jul 2019 16:06:37 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 12 Jul 2019 18:05:51 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 10/25] qemu: domain: Store blockjob data in the status XML X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 12 Jul 2019 16:06:42 +0000 (UTC) Content-Type: text/plain; charset="utf-8" We need to store the block job state in the status XML so that we can properly recover any data when reconnecting after startup and also in the end to be able to do any transition of the backing chain that happened while libvirt was not connected to the monitor. First step is to note the name, type, state and corresponding disk into the status XML. We also need to make sure that a broken blockjob does not make libvirt to lose the VM, thus many of the errors are just mark the job as invalid. Later on we'll cancel all invalid jobs. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 123 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 119 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 5af8f3b30c..59225c3ca9 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -32,6 +32,7 @@ #include "qemu_migration_params.h" #include "qemu_security.h" #include "qemu_extdevice.h" +#include "qemu_blockjob.h" #include "viralloc.h" #include "virlog.h" #include "virerror.h" @@ -2312,17 +2313,57 @@ qemuDomainObjPrivateXMLFormatAutomaticPlacement(vir= BufferPtr buf, } +static int +qemuDomainObjPrivateXMLFormatBlockjobIterator(void *payload, + const void *name ATTRIBUTE_U= NUSED, + void *data) +{ + VIR_AUTOCLEAN(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; + VIR_AUTOCLEAN(virBuffer) childBuf =3D VIR_BUFFER_INITIALIZER; + qemuBlockJobDataPtr job =3D payload; + virBufferPtr buf =3D data; + const char *state =3D qemuBlockjobStateTypeToString(job->state); + const char *newstate =3D NULL; + + if (job->newstate !=3D -1) + newstate =3D qemuBlockjobStateTypeToString(job->newstate); + + virBufferSetChildIndent(&childBuf, buf); + + virBufferEscapeString(&attrBuf, " name=3D'%s'", job->name); + virBufferEscapeString(&attrBuf, " type=3D'%s'", qemuBlockjobTypeToStri= ng(job->type)); + virBufferEscapeString(&attrBuf, " state=3D'%s'", state); + virBufferEscapeString(&attrBuf, " newstate=3D'%s'", newstate); + virBufferEscapeString(&childBuf, "%s", job->errmsg); + + if (job->disk) + virBufferEscapeString(&childBuf, "\n", job->disk= ->dst); + + return virXMLFormatElement(buf, "blockjob", &attrBuf, &childBuf); +} + + static int qemuDomainObjPrivateXMLFormatBlockjobs(virBufferPtr buf, virDomainObjPtr vm) { - virBuffer attrBuf =3D VIR_BUFFER_INITIALIZER; + qemuDomainObjPrivatePtr priv =3D vm->privateData; + VIR_AUTOCLEAN(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; + VIR_AUTOCLEAN(virBuffer) childBuf =3D VIR_BUFFER_INITIALIZER; bool bj =3D qemuDomainHasBlockjob(vm, false); virBufferAsprintf(&attrBuf, " active=3D'%s'", virTristateBoolTypeToString(virTristateBoolFromBool(= bj))); - return virXMLFormatElement(buf, "blockjobs", &attrBuf, NULL); + virBufferSetChildIndent(&childBuf, buf); + + if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV) && + virHashForEach(priv->blockjobs, + qemuDomainObjPrivateXMLFormatBlockjobIterator, + &childBuf) < 0) + return -1; + + return virXMLFormatElement(buf, "blockjobs", &attrBuf, &childBuf); } @@ -2662,16 +2703,90 @@ qemuDomainObjPrivateXMLParseAutomaticPlacement(xmlX= PathContextPtr ctxt, static int -qemuDomainObjPrivateXMLParseBlockjobs(qemuDomainObjPrivatePtr priv, +qemuDomainObjPrivateXMLParseBlockjobData(virDomainObjPtr vm, + xmlNodePtr node, + xmlXPathContextPtr ctxt) +{ + VIR_XPATH_NODE_AUTORESTORE(ctxt); + virDomainDiskDefPtr disk =3D NULL; + VIR_AUTOUNREF(qemuBlockJobDataPtr) job =3D NULL; + VIR_AUTOFREE(char *) name =3D NULL; + VIR_AUTOFREE(char *) typestr =3D NULL; + int type; + VIR_AUTOFREE(char *) statestr =3D NULL; + int state =3D QEMU_BLOCKJOB_STATE_FAILED; + VIR_AUTOFREE(char *) diskdst =3D NULL; + VIR_AUTOFREE(char *) newstatestr =3D NULL; + int newstate =3D -1; + bool invalidData =3D false; + + ctxt->node =3D node; + + if (!(name =3D virXPathString("string(./@name)", ctxt))) { + VIR_WARN("malformed block job data for vm '%s'", vm->def->name); + return 0; + } + + /* if the job name is known we need to register such a job so that we = can + * clean it up */ + if (!(typestr =3D virXPathString("string(./@type)", ctxt)) || + (type =3D qemuBlockjobTypeFromString(typestr)) < 0) { + type =3D QEMU_BLOCKJOB_TYPE_NONE; + invalidData =3D true; + } + + if (!(job =3D qemuBlockJobDataNew(type, name))) + return -1; + + if (!(statestr =3D virXPathString("string(./@state)", ctxt)) || + (state =3D qemuBlockjobStateTypeFromString(statestr)) < 0) + invalidData =3D true; + + if ((newstatestr =3D virXPathString("string(./@newstate)", ctxt)) && + (newstate =3D qemuBlockjobStateTypeFromString(newstatestr)) < 0) + invalidData =3D true; + + if ((diskdst =3D virXPathString("string(./disk/@dst)", ctxt)) && + !(disk =3D virDomainDiskByName(vm->def, diskdst, false))) + invalidData =3D true; + + job->state =3D state; + job->newstate =3D newstate; + job->errmsg =3D virXPathString("string(./errmsg)", ctxt); + job->invalidData =3D invalidData; + + if (qemuBlockJobRegister(job, vm, disk) < 0) + return -1; + + return 0; +} + + +static int +qemuDomainObjPrivateXMLParseBlockjobs(virDomainObjPtr vm, + qemuDomainObjPrivatePtr priv, xmlXPathContextPtr ctxt) { + VIR_AUTOFREE(xmlNodePtr *) nodes =3D NULL; + ssize_t nnodes =3D 0; VIR_AUTOFREE(char *) active =3D NULL; int tmp; + size_t i; if ((active =3D virXPathString("string(./blockjobs/@active)", ctxt)) && (tmp =3D virTristateBoolTypeFromString(active)) > 0) priv->reconnectBlockjobs =3D tmp; + if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) { + if ((nnodes =3D virXPathNodeSet("./blockjobs/blockjob", ctxt, &nod= es)) < 0) + return -1; + + for (i =3D 0; i < nnodes; i++) { + if (qemuDomainObjPrivateXMLParseBlockjobData(vm, nodes[i], ctx= t) < 0) + return -1; + } + } + return 0; } @@ -3029,7 +3144,7 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, qemuDomainObjPrivateXMLParsePR(ctxt, &priv->prDaemonRunning); - if (qemuDomainObjPrivateXMLParseBlockjobs(priv, ctxt) < 0) + if (qemuDomainObjPrivateXMLParseBlockjobs(vm, priv, ctxt) < 0) goto error; qemuDomainStorageIdReset(priv); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 03:43:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1562947605; cv=none; d=zoho.com; s=zohoarc; b=GBFcPeR0fi3tbbeBVW4Co8N+dJyYoRAvPlGO4ZCby8eElJJNbYPX76PF5kHdlZ13ZDUwMtnShzTwJPFakMy1LRFQjaCJgtxixWZ/UY2FkLBYSSjzUizLES89E4Nqo+ibUf7+AnvhT4yiIluZ/VIUein/ZPoKh8UJXnJp2n/Et6U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562947605; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=dHRT2thcpHa1sWnPeK5xVQYSf2KSQ+zVn9OhPwPaNjE=; b=Q35dJD6dYy1T8kEktfMMjRPnjzJexrpNCrLBrv70S9WU5MNxWdyHcNEilLOWYHWe+AxTBVtEAJhPMkujYKjRcQg9xVtVf2KJhbUrQBecdAiOksGk2Wrn95ZgFLRoM5P2QTyYAJtA32zY1IudE7Gc/isAVunQ/Jbxo7/8kdEL1b0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562947605491589.4242039109178; Fri, 12 Jul 2019 09:06:45 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5DE618110A; Fri, 12 Jul 2019 16:06:43 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3449F1001B23; Fri, 12 Jul 2019 16:06:43 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id EAF72206D3; Fri, 12 Jul 2019 16:06:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6CG6fh7016712 for ; Fri, 12 Jul 2019 12:06:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 008D560C70; Fri, 12 Jul 2019 16:06:41 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5979060C64; Fri, 12 Jul 2019 16:06:40 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 12 Jul 2019 18:05:52 +0200 Message-Id: <19f63484792cf396740f4256335f1bbfb0e0b0f8.1562947284.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 11/25] qemu: blockjob: Save status XML when modifying job state X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 12 Jul 2019 16:06:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Now that block job data is stored in the status XML portion we need to make sure that everything which changes the state also saves the status XML. The job registering function is used while parsing the status XML so in that case we need to skip the XML saving. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_blockjob.c | 15 ++++++++++++--- src/qemu/qemu_blockjob.h | 8 +++++--- src/qemu/qemu_domain.c | 2 +- src/qemu/qemu_driver.c | 8 ++++---- src/qemu/qemu_migration.c | 2 +- src/qemu/qemu_process.c | 4 ++-- 6 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index 78d4938684..3211230811 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -104,7 +104,8 @@ qemuBlockJobDataNew(qemuBlockJobType type, int qemuBlockJobRegister(qemuBlockJobDataPtr job, virDomainObjPtr vm, - virDomainDiskDefPtr disk) + virDomainDiskDefPtr disk, + bool savestatus) { qemuDomainObjPrivatePtr priv =3D vm->privateData; @@ -118,6 +119,9 @@ qemuBlockJobRegister(qemuBlockJobDataPtr job, QEMU_DOMAIN_DISK_PRIVATE(disk)->blockjob =3D virObjectRef(job); } + if (savestatus) + qemuDomainSaveStatus(vm); + return 0; } @@ -142,6 +146,8 @@ qemuBlockJobUnregister(qemuBlockJobDataPtr job, /* this may remove the last reference of 'job' */ virHashRemoveEntry(priv->blockjobs, job->name); + + qemuDomainSaveStatus(vm); } @@ -164,7 +170,7 @@ qemuBlockJobDiskNew(virDomainObjPtr vm, if (!(job =3D qemuBlockJobDataNew(type, jobname))) return NULL; - if (qemuBlockJobRegister(job, vm, disk) < 0) + if (qemuBlockJobRegister(job, vm, disk, true) < 0) return NULL; VIR_RETURN_PTR(job); @@ -196,10 +202,13 @@ qemuBlockJobDiskGetJob(virDomainDiskDefPtr disk) * Mark @job as started in qemu. */ void -qemuBlockJobStarted(qemuBlockJobDataPtr job) +qemuBlockJobStarted(qemuBlockJobDataPtr job, + virDomainObjPtr vm) { if (job->state =3D=3D QEMU_BLOCKJOB_STATE_NEW) job->state =3D QEMU_BLOCKJOB_STATE_RUNNING; + + qemuDomainSaveStatus(vm); } diff --git a/src/qemu/qemu_blockjob.h b/src/qemu/qemu_blockjob.h index 5b3af69d89..c5fd636340 100644 --- a/src/qemu/qemu_blockjob.h +++ b/src/qemu/qemu_blockjob.h @@ -87,7 +87,8 @@ struct _qemuBlockJobData { int qemuBlockJobRegister(qemuBlockJobDataPtr job, virDomainObjPtr vm, - virDomainDiskDefPtr disk) + virDomainDiskDefPtr disk, + bool savestatus) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); qemuBlockJobDataPtr @@ -107,8 +108,9 @@ qemuBlockJobDiskGetJob(virDomainDiskDefPtr disk) ATTRIBUTE_NONNULL(1); void -qemuBlockJobStarted(qemuBlockJobDataPtr job) - ATTRIBUTE_NONNULL(1); +qemuBlockJobStarted(qemuBlockJobDataPtr job, + virDomainObjPtr vm) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); bool qemuBlockJobIsRunning(qemuBlockJobDataPtr job) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 59225c3ca9..7162fca71b 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2755,7 +2755,7 @@ qemuDomainObjPrivateXMLParseBlockjobData(virDomainObj= Ptr vm, job->errmsg =3D virXPathString("string(./errmsg)", ctxt); job->invalidData =3D invalidData; - if (qemuBlockJobRegister(job, vm, disk) < 0) + if (qemuBlockJobRegister(job, vm, disk, false) < 0) return -1; return 0; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 879a78858b..a0c246a416 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4704,7 +4704,7 @@ processBlockJobEvent(virQEMUDriverPtr driver, if (!(job =3D qemuBlockJobDiskGetJob(disk))) { if (!(job =3D qemuBlockJobDiskNew(vm, disk, type, diskAlias))) goto endjob; - qemuBlockJobStarted(job); + job->state =3D QEMU_BLOCKJOB_STATE_RUNNING; } job->newstate =3D status; @@ -17100,7 +17100,7 @@ qemuDomainBlockPullCommon(virQEMUDriverPtr driver, if (ret < 0) goto endjob; - qemuBlockJobStarted(job); + qemuBlockJobStarted(job, vm); if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) VIR_WARN("Unable to save status on vm %s after state change", @@ -17676,11 +17676,11 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, } /* Update vm in place to match changes. */ - qemuBlockJobStarted(job); need_unlink =3D false; virStorageFileDeinit(mirror); VIR_STEAL_PTR(disk->mirror, mirror); disk->mirrorJob =3D VIR_DOMAIN_BLOCK_JOB_TYPE_COPY; + qemuBlockJobStarted(job, vm); if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) VIR_WARN("Unable to save status on vm %s after state change", @@ -18066,11 +18066,11 @@ qemuDomainBlockCommit(virDomainPtr dom, goto endjob; } - qemuBlockJobStarted(job); if (mirror) { VIR_STEAL_PTR(disk->mirror, mirror); disk->mirrorJob =3D VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT; } + qemuBlockJobStarted(job, vm); if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) VIR_WARN("Unable to save status on vm %s after block job", diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index e72553befc..cbacb886f8 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -944,7 +944,7 @@ qemuMigrationSrcNBDStorageCopyOne(virQEMUDriverPtr driv= er, goto cleanup; diskPriv->migrating =3D true; - qemuBlockJobStarted(job); + qemuBlockJobStarted(job, vm); ret =3D 0; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 29124ae184..f39143d499 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7819,8 +7819,6 @@ qemuProcessRefreshLegacyBlockjob(void *payload, if (!(job =3D qemuBlockJobDiskNew(vm, disk, jobtype, jobname))) return -1; - qemuBlockJobStarted(job); - if (disk->mirror) { if (info->ready =3D=3D 1 || (info->ready =3D=3D -1 && info->end =3D=3D info->cur)) { @@ -7849,6 +7847,8 @@ qemuProcessRefreshLegacyBlockjob(void *payload, } } + qemuBlockJobStarted(job, vm); + cleanup: qemuBlockJobStartupFinalize(vm, job); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 03:43:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1562947607; cv=none; d=zoho.com; s=zohoarc; b=Cv6NfTYG44LgW+AgifB1UR3RICsO/J4ykVCRjrAsGpVVOxE/3rnCkHh5eIwybXjwLr2/2RJh2TuAm0AppP4JRlKV/YcETL21CnCKpLIcWsU1XLObiyFU85WAkpCM8lqG2STF/QHYTfeLPl90FrtF66E/yFbzpsGiMJLnOTUzje0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562947607; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=WBQMhtKgTnGgDy8pxhb1XcMi9WiCvZ7vQ6dK9Uc02j4=; b=QU8CbyciXH734SizfneMvZb50U0Q13YjXtODujbM9+IBxpwKNgaR/oT8J5suwEtyrMbbxI3novbqXRfPTvAZuMQKzlXmLWOHnVvm54QjkdmFCzeAzD8G2ntoFeoSGXDf8+jha9je3VNrSlTO7hpK9oRRRQLm4YNDFcgcWG1PYNE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562947607057141.87151236141005; Fri, 12 Jul 2019 09:06:47 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 52A4730C0DDD; Fri, 12 Jul 2019 16:06:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 293EF1967F; Fri, 12 Jul 2019 16:06:45 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D97C9206D6; Fri, 12 Jul 2019 16:06:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6CG6fwd016749 for ; Fri, 12 Jul 2019 12:06:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id E746B60C79; Fri, 12 Jul 2019 16:06:41 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C15C60C64; Fri, 12 Jul 2019 16:06:41 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 12 Jul 2019 18:05:53 +0200 Message-Id: <8f50bec14239178156f8366f28b0706ede6b4080.1562947284.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 12/25] qemu: driver: Remove unnecessary saving of status XML X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Fri, 12 Jul 2019 16:06:45 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Now that the blockjob handling code deals with the status XML we don't need to save it explicitly when starting blockjobs. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a0c246a416..a1dc2634ca 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17012,7 +17012,6 @@ qemuDomainBlockPullCommon(virQEMUDriverPtr driver, unsigned int flags) { qemuDomainObjPrivatePtr priv =3D vm->privateData; - VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg =3D virQEMUDriverGetConfig(d= river); VIR_AUTOFREE(char *) device =3D NULL; virDomainDiskDefPtr disk; virStorageSourcePtr baseSource =3D NULL; @@ -17102,10 +17101,6 @@ qemuDomainBlockPullCommon(virQEMUDriverPtr driver, qemuBlockJobStarted(job, vm); - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) - VIR_WARN("Unable to save status on vm %s after state change", - vm->def->name); - endjob: qemuDomainObjEndJob(driver, vm); @@ -17682,10 +17677,6 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, disk->mirrorJob =3D VIR_DOMAIN_BLOCK_JOB_TYPE_COPY; qemuBlockJobStarted(job, vm); - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) - VIR_WARN("Unable to save status on vm %s after state change", - vm->def->name); - endjob: if (need_unlink && virStorageFileUnlink(mirror) < 0) VIR_WARN("%s", _("unable to remove just-created copy target")); @@ -17880,7 +17871,6 @@ qemuDomainBlockCommit(virDomainPtr dom, unsigned int flags) { virQEMUDriverPtr driver =3D dom->conn->privateData; - VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg =3D NULL; qemuDomainObjPrivatePtr priv; virDomainObjPtr vm =3D NULL; VIR_AUTOFREE(char *) device =3D NULL; @@ -17909,7 +17899,6 @@ qemuDomainBlockCommit(virDomainPtr dom, if (!(vm =3D qemuDomObjFromDomain(dom))) goto cleanup; priv =3D vm->privateData; - cfg =3D virQEMUDriverGetConfig(driver); if (virDomainBlockCommitEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -18072,10 +18061,6 @@ qemuDomainBlockCommit(virDomainPtr dom, } qemuBlockJobStarted(job, vm); - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) - VIR_WARN("Unable to save status on vm %s after block job", - vm->def->name); - endjob: if (ret < 0 && clean_access) { virErrorPtr orig_err =3D virSaveLastError(); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 03:43:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1562947611; cv=none; d=zoho.com; s=zohoarc; b=ZflHniusGlNCfv3MPCsnueVO6IRkv380lbTF/nSAE+5aJGVktxbJXVKgn9DE0eTqW0GhYDBHEOky+ZJhJrQ/KVID+PqX1AtPVQGr8PYlQKeymbtZMNctZaHQ+pOmnUn2FjZBcHh37BVrRizaVr269XyFoc20Oy3kuj1qzhYCqiM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562947611; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=app+Xo7BS3ql4oMNPEDcwaCmqoAR6sczTVAPpRB4RQc=; b=E1QZSdbCXK29ZBn6l7YgDj9Bw+L8jXu23vRYiPVr+XZp2cm6ArKokhFaq8y3nYsowXCL9DyGmHZjDF79j4IBTaa8lHhI4rz2hOSne3vbYH1vm+lyfPB1ZiVpY3LXdvPgMWQXFaMmdjuqLP1KSXir4J5PRHQRVoHddF6fV37W6Hg= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562947611109452.70490946242137; Fri, 12 Jul 2019 09:06:51 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C47683079B8D; Fri, 12 Jul 2019 16:06:48 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 987A91F8; Fri, 12 Jul 2019 16:06:48 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 56CA4206D8; Fri, 12 Jul 2019 16:06:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6CG6kug016823 for ; Fri, 12 Jul 2019 12:06:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id EB4B560C79; Fri, 12 Jul 2019 16:06:46 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1ADF060C64; Fri, 12 Jul 2019 16:06:42 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 12 Jul 2019 18:05:54 +0200 Message-Id: <9b02dc26f66a15a2da957e39f4bca7791d848750.1562947284.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 13/25] tests: qemustatusxml2xml: Add test case for block job tracking X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Fri, 12 Jul 2019 16:06:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- .../blockjob-blockdev-in.xml | 366 ++++++++++++++++++ .../blockjob-blockdev-out.xml | 1 + tests/qemuxml2xmltest.c | 2 + 3 files changed, 369 insertions(+) create mode 100644 tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml create mode 120000 tests/qemustatusxml2xmldata/blockjob-blockdev-out.xml diff --git a/tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml b/tests/q= emustatusxml2xmldata/blockjob-blockdev-in.xml new file mode 100644 index 0000000000..115eaa4887 --- /dev/null +++ b/tests/qemustatusxml2xmldata/blockjob-blockdev-in.xml @@ -0,0 +1,366 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + copy + 0439a4a8-db56-4933-9183-d8681d7b0746 + 1024000 + 1024000 + 8 + + + + + /machine + + + hvm + + + + + + + + + + + + + + + + + + + + destroy + restart + restart + + + + + + /home/pipo/git/qemu.git/x86_64-softmmu/qemu-system-x86_64<= /emulator> + + + + + + + + + + +
+ + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + + + + + + + + +
+ +