From nobody Mon May 6 21:21:54 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=1571415095; cv=none; d=zoho.com; s=zohoarc; b=b3v+JA5ewG4S3cyey8cZvIYzRFnjzTE9e6LFsBp2Bl6jmTwIMBloTyas+ynXJtrN8WZHxtWGqOUOSYafTC63TTCkuER5DFKomYS2jICfh/w3CORdLZ58ROr4kFp3Sho5EYx/tVDUl6f1GFeB+KLBpzBBDgjri/GR1+e9Pbo8vEI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415095; h=Content-Type:Content-Transfer-Encoding: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; bh=b4oD466FMOh7yKZ6bVmMCAcStHLaPBH6xXaWXbn9Lag=; b=SP/nZCRe2G+Xjy7s1XzLOgCtlgBfURWUGejsSuAa7qfv31BAP3IIS0nl0qTqWBgvx26JudRI6Lgc9cP5sjiEkn1CQwZrLtWgWEaWqtzPcwXkZisDvNIfnglx0+rqmDVP7/SFmVKG+daN9nzIiMIqLFcAczNhvrXgHabgr/E2/kw= 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 1571415095834171.90440940463543; Fri, 18 Oct 2019 09:11:35 -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 EF8272B87; Fri, 18 Oct 2019 16:11:33 +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 C11B460C4E; Fri, 18 Oct 2019 16:11:33 +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 56AAB4EE68; Fri, 18 Oct 2019 16:11:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGBU21004533 for ; Fri, 18 Oct 2019 12:11:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 83AA4601B3; Fri, 18 Oct 2019 16:11:30 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7850600C8; Fri, 18 Oct 2019 16:11:29 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:10:46 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 01/40] util: hash: Add possibility to use simpler data free function in virHash 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.6.2 (mx1.redhat.com [10.5.110.71]); Fri, 18 Oct 2019 16:11:34 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Introduce a new type virHashDataFreeSimple which has only a void * as argument for cases when knowing the name of the entry when freeing the hash entry is not required. Signed-off-by: Peter Krempa --- src/conf/domain_addr.c | 4 ++-- src/util/vircgroup.c | 2 +- src/util/virhash.c | 15 ++++++++++++++- src/util/virhash.h | 10 ++++++++++ 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index d0026942aa..dd8e04576a 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -1037,14 +1037,14 @@ virDomainPCIAddressSetExtensionAlloc(virDomainPCIAd= dressSetPtr addrs, if (VIR_ALLOC(addrs->zpciIds) < 0) return -1; - if (!(addrs->zpciIds->uids =3D virHashCreateFull(10, NULL, + if (!(addrs->zpciIds->uids =3D virHashCreateFull(10, NULL, NULL, virZPCIAddrKeyCode, virZPCIAddrKeyEqual, virZPCIAddrKeyCopy, virZPCIAddrKeyFree)= )) goto error; - if (!(addrs->zpciIds->fids =3D virHashCreateFull(10, NULL, + if (!(addrs->zpciIds->fids =3D virHashCreateFull(10, NULL, NULL, virZPCIAddrKeyCode, virZPCIAddrKeyEqual, virZPCIAddrKeyCopy, diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index d824aee86d..21c0fe67e3 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -2600,7 +2600,7 @@ virCgroupKillRecursive(virCgroupPtr group, int signum) bool backendAvailable =3D false; virCgroupBackendPtr *backends =3D virCgroupBackendGetAll(); virHashTablePtr pids =3D virHashCreateFull(100, - NULL, + NULL, NULL, virCgroupPidCode, virCgroupPidEqual, virCgroupPidCopy, diff --git a/src/util/virhash.c b/src/util/virhash.c index a7fc620567..4d90fa5333 100644 --- a/src/util/virhash.c +++ b/src/util/virhash.c @@ -56,6 +56,7 @@ struct _virHashTable { size_t size; size_t nbElems; virHashDataFree dataFree; + virHashDataFreeSimple dataFreeSimple; virHashKeyCode keyCode; virHashKeyEqual keyEqual; virHashKeyCopy keyCopy; @@ -133,6 +134,7 @@ virHashComputeKey(const virHashTable *table, const void= *name) */ virHashTablePtr virHashCreateFull(ssize_t size, virHashDataFree dataFree, + virHashDataFreeSimple dataFreeSimple, virHashKeyCode keyCode, virHashKeyEqual keyEqual, virHashKeyCopy keyCopy, @@ -149,7 +151,10 @@ virHashTablePtr virHashCreateFull(ssize_t size, table->seed =3D virRandomBits(32); table->size =3D size; table->nbElems =3D 0; - table->dataFree =3D dataFree; + if (dataFree) + table->dataFree =3D dataFree; + else + table->dataFreeSimple =3D dataFreeSimple; table->keyCode =3D keyCode; table->keyEqual =3D keyEqual; table->keyCopy =3D keyCopy; @@ -177,6 +182,7 @@ virHashTablePtr virHashCreate(ssize_t size, virHashData= Free dataFree) { return virHashCreateFull(size, dataFree, + NULL, virHashStrCode, virHashStrEqual, virHashStrCopy, @@ -298,6 +304,8 @@ virHashFree(virHashTablePtr table) if (table->dataFree) table->dataFree(iter->payload, iter->name); + if (table->dataFreeSimple) + table->dataFreeSimple(iter->payload); if (table->keyFree) table->keyFree(iter->name); VIR_FREE(iter); @@ -330,6 +338,8 @@ virHashAddOrUpdateEntry(virHashTablePtr table, const vo= id *name, if (is_update) { if (table->dataFree) table->dataFree(entry->payload, entry->name); + if (table->dataFreeSimple) + table->dataFreeSimple(entry->payload); entry->payload =3D userdata; return 0; } else { @@ -456,9 +466,12 @@ void *virHashSteal(virHashTablePtr table, const void *= name) void *data =3D virHashLookup(table, name); if (data) { virHashDataFree dataFree =3D table->dataFree; + virHashDataFreeSimple dataFreeSimple =3D table->dataFreeSimple; table->dataFree =3D NULL; + table->dataFreeSimple =3D NULL; virHashRemoveEntry(table, name); table->dataFree =3D dataFree; + table->dataFreeSimple =3D dataFreeSimple; } return data; } diff --git a/src/util/virhash.h b/src/util/virhash.h index b5e7c79260..94fe8e23e4 100644 --- a/src/util/virhash.h +++ b/src/util/virhash.h @@ -30,6 +30,15 @@ typedef virHashAtomic *virHashAtomicPtr; * Callback to free data from a hash. */ typedef void (*virHashDataFree) (void *payload, const void *name); +/** + * virHashDataFreeSimple: + * @payload: the data in the hash + * @name: the name associated + * + * Callback to free data from a hash. + */ +typedef void (*virHashDataFreeSimple) (void *payload); + /** * virHashIterator: * @payload: the data in the hash @@ -104,6 +113,7 @@ virHashAtomicPtr virHashAtomicNew(ssize_t size, virHashDataFree dataFree); virHashTablePtr virHashCreateFull(ssize_t size, virHashDataFree dataFree, + virHashDataFreeSimple dataFreeSimple, virHashKeyCode keyCode, virHashKeyEqual keyEqual, virHashKeyCopy keyCopy, --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415104; cv=none; d=zoho.com; s=zohoarc; b=fV93gOhG4aFGmTIdB/XTcXlYdpNv/kPEub19tj2uGwqvqjB0i7BXy12nAfcWmMbRglAln6MAiKMaN15Kfe1AkXuwNmwT/0jNREiUurMl1lj6MjTh1DDi3tJxhJ7snPNGHbnCD0vJvmhwBp3p/njY/PWnZa5seUuAGvrX4b5zn18= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415104; h=Content-Type:Content-Transfer-Encoding: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; bh=FNR8mF/NTQMeoWEF6twXc5FnH/p2keB7pKtnepmkzuQ=; b=HGlmTZnW/7uw7mpnepkBOkvQKGov/MOWSCa0xGS4x8SZOMV80daAJOUuaqYpdfXZnIbBSz8R1/RkuatGgUv7NYnZAlbkpSDv5sRjFCWGBagalRhUYtobXKrpGbVd7MjD2lGdqqVvqPhkD5aKChfePCYHiakz4xPZz7lfStzcbFA= 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 1571415104592532.179123004914; Fri, 18 Oct 2019 09:11:44 -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 97C078A218D; Fri, 18 Oct 2019 16:11:42 +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 733195DA8C; Fri, 18 Oct 2019 16:11:42 +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 2E360180BA99; Fri, 18 Oct 2019 16:11:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGBVSd004540 for ; Fri, 18 Oct 2019 12:11:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id 700E3600C8; Fri, 18 Oct 2019 16:11:31 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id C61D7600C1; Fri, 18 Oct 2019 16:11:30 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:10:47 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 02/40] util: hash: Add new constructor 'virHashNew' 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.6.2 (mx1.redhat.com [10.5.110.69]); Fri, 18 Oct 2019 16:11:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add a simpler constructor for hash tables which specifically does not require specifying the initial hash size and uses simpler freeing function. The initial hash table size usually is not important as the hash table is growing when it reaches certain number of entries in one bucket. Additionally many callers pass in a random small number for ad-hoc table use so using a central one will simplify things. Signed-off-by: Peter Krempa --- src/libvirt_private.syms | 1 + src/util/virhash.c | 21 +++++++++++++++++++++ src/util/virhash.h | 1 + 3 files changed, 23 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 0da02bb8bd..c155f51174 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2066,6 +2066,7 @@ virHashForEach; virHashFree; virHashGetItems; virHashLookup; +virHashNew; virHashRemoveAll; virHashRemoveEntry; virHashRemoveSet; diff --git a/src/util/virhash.c b/src/util/virhash.c index 4d90fa5333..de03032bf1 100644 --- a/src/util/virhash.c +++ b/src/util/virhash.c @@ -169,6 +169,27 @@ virHashTablePtr virHashCreateFull(ssize_t size, } +/** + * virHashNew: + * @dataFree: callback to free data + * + * Create a new virHashTablePtr. + * + * Returns the newly created object, or NULL if an error occurred. + */ +virHashTablePtr +virHashNew(virHashDataFreeSimple dataFree) +{ + return virHashCreateFull(32, + NULL, + dataFree, + virHashStrCode, + virHashStrEqual, + virHashStrCopy, + virHashStrFree); +} + + /** * virHashCreate: * @size: the size of the hash table diff --git a/src/util/virhash.h b/src/util/virhash.h index 94fe8e23e4..d7de0618cb 100644 --- a/src/util/virhash.h +++ b/src/util/virhash.h @@ -107,6 +107,7 @@ typedef void (*virHashKeyFree)(void *name); /* * Constructor and destructor. */ +virHashTablePtr virHashNew(virHashDataFreeSimple dataFree); virHashTablePtr virHashCreate(ssize_t size, virHashDataFree dataFree); virHashAtomicPtr virHashAtomicNew(ssize_t size, --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415096; cv=none; d=zoho.com; s=zohoarc; b=e9pmTVlV6SafF3vcZH0LBJI8TFSymNPK6PxHmeny57D/rcBUaiSbPF7A3E4eXYDVGSyN0+TDaRJmv9iKR8J52itswnNswWRLQIr9TfMSFSGcjtpZ5bOa6boGOw1sKpLbwEjlWdrqmrnjSUaYiePOI4UF2r89wZdVryktICk9qEw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415096; h=Content-Type:Content-Transfer-Encoding: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; bh=4F6m3Z8D/7QFh+EwMy31vwA4vNoZ12zfHxVSpwcqgoU=; b=PDmOJM5grXpNsvC/BuBPDtIt66oZ1EF+HH7aNpLDgcdrH5f3JS+7RBiuUJ+SSuDQOK4WEXv+l4+FfSWBk0chc3TthSH37gOfVxKMJqePL1aP3NzneZUzeP373OrBqnB5jmTH6xUJ1Crka7iwwfAhAswaS8bCJUka4Djd2dm2ABE= 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 1571415096004639.8753687128981; Fri, 18 Oct 2019 09:11:36 -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 27306ED3C1; Fri, 18 Oct 2019 16:11: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 ED02E5D9DC; Fri, 18 Oct 2019 16:11:33 +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 9CE4B180B761; Fri, 18 Oct 2019 16:11:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGBWor004548 for ; Fri, 18 Oct 2019 12:11:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id 67632600C8; Fri, 18 Oct 2019 16:11:32 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id BDF01600C1; Fri, 18 Oct 2019 16:11:31 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:10:48 +0200 Message-Id: <52b1e82d0a004dd031dc7fc072ff7fdde2640b09.1571414890.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 03/40] util: hash: Introduce virHashHasEntry 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.28]); Fri, 18 Oct 2019 16:11:34 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add a helper that checks whether an entry with given name exists but does not touch the userdata. Signed-off-by: Peter Krempa --- src/libvirt_private.syms | 1 + src/util/virhash.c | 49 ++++++++++++++++++++++++++++++++-------- src/util/virhash.h | 1 + 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index c155f51174..588f0a4356 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2065,6 +2065,7 @@ virHashEqual; virHashForEach; virHashFree; virHashGetItems; +virHashHasEntry; virHashLookup; virHashNew; virHashRemoveAll; diff --git a/src/util/virhash.c b/src/util/virhash.c index de03032bf1..df07e37e42 100644 --- a/src/util/virhash.c +++ b/src/util/virhash.c @@ -445,6 +445,26 @@ virHashAtomicUpdate(virHashAtomicPtr table, } +static virHashEntryPtr +virHashGetEntry(const virHashTable *table, + const void *name) +{ + size_t key; + virHashEntryPtr entry; + + if (!table || !name) + return NULL; + + key =3D virHashComputeKey(table, name); + for (entry =3D table->table[key]; entry; entry =3D entry->next) { + if (table->keyEqual(entry->name, name)) + return entry; + } + + return NULL; +} + + /** * virHashLookup: * @table: the hash table @@ -457,18 +477,29 @@ virHashAtomicUpdate(virHashAtomicPtr table, void * virHashLookup(const virHashTable *table, const void *name) { - size_t key; - virHashEntryPtr entry; + virHashEntryPtr entry =3D virHashGetEntry(table, name); - if (!table || !name) + if (!entry) return NULL; - key =3D virHashComputeKey(table, name); - for (entry =3D table->table[key]; entry; entry =3D entry->next) { - if (table->keyEqual(entry->name, name)) - return entry->payload; - } - return NULL; + return entry->payload; +} + + +/** + * virHashHasEntry: + * @table: the hash table + * @name: the name of the userdata + * + * Find whether entry specified by @name exists. + * + * Returns true if the entry exists and false otherwise + */ +bool +virHashHasEntry(const virHashTable *table, + const void *name) +{ + return !!virHashGetEntry(table, name); } diff --git a/src/util/virhash.h b/src/util/virhash.h index d7de0618cb..8087965ee9 100644 --- a/src/util/virhash.h +++ b/src/util/virhash.h @@ -150,6 +150,7 @@ ssize_t virHashRemoveAll(virHashTablePtr table); * Retrieve the userdata. */ void *virHashLookup(const virHashTable *table, const void *name); +bool virHashHasEntry(const virHashTable *table, const void *name); /* * Retrieve & remove the userdata. --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415108; cv=none; d=zoho.com; s=zohoarc; b=jf9R985UXkXT5w7JOSp0KADYMw+90DMnpAeC8hu8rt1PCfQntHAXMTMkjhbrOXpPM0WvhP1gUCVAlmn/ZzKvjRO4sJOS//NQDHgLiqECxUXDt7duiugHeAjzLanl+mfG9XUf51zgZsv1pGoXDDmlPI25Tv53Rmu7DIjNpSsJ0pM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415108; h=Content-Type:Content-Transfer-Encoding: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; bh=NkobUpTOpQuYsTx38k8vIQ+YpCWOmWuX9uA1pCcA1vU=; b=NOZs8l0WZ2iWPcYKvi8UGgNlN4b3GLrKU39As51E9UCSWtXJLGu+ouC93cCFt9nx5WI7d9gZNn5u1aaXtkuzcvecRThSyIvdleu5jRPB5k21d4NPt6+23k3pP6DOxrMmW3VF8iVWNwokv0fxdmyDseFBjnnljkIttnC3uzWvgaQ= 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 1571415108095792.3652903486612; Fri, 18 Oct 2019 09:11:48 -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 80E8246671; Fri, 18 Oct 2019 16:11:46 +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 56D365C21E; Fri, 18 Oct 2019 16:11:46 +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 0CBC14EE70; Fri, 18 Oct 2019 16:11:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGBXgT004555 for ; Fri, 18 Oct 2019 12:11:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5C703600C4; Fri, 18 Oct 2019 16:11:33 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id B3CA0600C1; Fri, 18 Oct 2019 16:11:32 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:10:49 +0200 Message-Id: <9d926b1109df55ca23b345ee0314f2d8ceec6ce9.1571414890.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 04/40] qemu: domain: Split out setup of virStorageSource from qemu driver config 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.30]); Fri, 18 Oct 2019 16:11:47 +0000 (UTC) Content-Type: text/plain; charset="utf-8" qemuDomainPrepareDiskSourceData historically prepared everything but we'we split out the majority of the functionality so that it sets up predominantely only according to the configuration of the disk. There was one leftover bit of setting the gluster debug level from the config. Split this out into a separate function so that qemuDomainPrepareDiskSourceData only perpares based on the disk. Signed-off-by: Peter Krempa Reviewed-by: Daniel Henrique Barboza --- src/qemu/qemu_domain.c | 51 +++++++++++++++++++++++++++++------------- src/qemu/qemu_domain.h | 4 +--- tests/qemublocktest.c | 2 +- 3 files changed, 38 insertions(+), 19 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index a97bf65e7f..6a93dd5293 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -10251,6 +10251,32 @@ qemuDomainStorageSourceValidateDepth(virStorageSou= rcePtr src, } +/** + * qemuDomainPrepareStorageSourceConfig: + * @src: storage source to configure + * @cfg: qemu driver config object + * @qemuCaps: capabilities of qemu + * + * Set properties of @src based on the qemu driver config @cfg. + * + */ +static void +qemuDomainPrepareStorageSourceConfig(virStorageSourcePtr src, + virQEMUDriverConfigPtr cfg, + virQEMUCapsPtr qemuCaps) +{ + if (!cfg) + return; + + if (src->type =3D=3D VIR_STORAGE_TYPE_NETWORK && + src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_GLUSTER && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_GLUSTER_DEBUG_LEVEL)) { + src->debug =3D true; + src->debugLevel =3D cfg->glusterDebugLevel; + } +} + + /** * qemuDomainDetermineDiskChain: * @driver: qemu driver object @@ -10356,7 +10382,9 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr drive= r, if (qemuDomainValidateStorageSource(n, priv->qemuCaps) < 0) return -1; - if (qemuDomainPrepareDiskSourceData(disk, n, cfg, priv->qemuCaps) = < 0) + qemuDomainPrepareStorageSourceConfig(n, cfg, priv->qemuCaps); + + if (qemuDomainPrepareDiskSourceData(disk, n) < 0) return -1; if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV) && @@ -15060,7 +15088,6 @@ qemuDomainCheckCCWS390AddressSupport(const virDomai= nDef *def, * * @disk: Disk config object * @src: source to start from - * @cfg: qemu driver config object * * Prepares various aspects of a storage source belonging to a disk backing * chain. This function should be also called for detected backing chain @@ -15068,22 +15095,12 @@ qemuDomainCheckCCWS390AddressSupport(const virDom= ainDef *def, */ int qemuDomainPrepareDiskSourceData(virDomainDiskDefPtr disk, - virStorageSourcePtr src, - virQEMUDriverConfigPtr cfg, - virQEMUCapsPtr qemuCaps) + virStorageSourcePtr src) { /* transfer properties valid only for the top level image */ if (src =3D=3D disk->src) src->detect_zeroes =3D disk->detect_zeroes; - if (cfg && - src->type =3D=3D VIR_STORAGE_TYPE_NETWORK && - src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_GLUSTER && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_GLUSTER_DEBUG_LEVEL)) { - src->debug =3D true; - src->debugLevel =3D cfg->glusterDebugLevel; - } - /* transfer properties valid for the full chain */ src->iomode =3D disk->iomode; src->cachemode =3D disk->cachemode; @@ -15144,7 +15161,9 @@ qemuDomainPrepareDiskSourceLegacy(virDomainDiskDefP= tr disk, if (qemuDomainValidateStorageSource(disk->src, priv->qemuCaps) < 0) return -1; - if (qemuDomainPrepareDiskSourceData(disk, disk->src, cfg, priv->qemuCa= ps) < 0) + qemuDomainPrepareStorageSourceConfig(disk->src, cfg, priv->qemuCaps); + + if (qemuDomainPrepareDiskSourceData(disk, disk->src) < 0) return -1; if (qemuDomainSecretStorageSourcePrepare(priv, disk->src, @@ -15178,7 +15197,9 @@ qemuDomainPrepareStorageSourceBlockdev(virDomainDis= kDefPtr disk, if (qemuDomainValidateStorageSource(src, priv->qemuCaps) < 0) return -1; - if (qemuDomainPrepareDiskSourceData(disk, src, cfg, priv->qemuCaps) < = 0) + qemuDomainPrepareStorageSourceConfig(src, cfg, priv->qemuCaps); + + if (qemuDomainPrepareDiskSourceData(disk, src) < 0) return -1; if (qemuDomainSecretStorageSourcePrepare(priv, src, diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index d703417862..14367f7320 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -1169,9 +1169,7 @@ qemuDomainCheckCCWS390AddressSupport(const virDomainD= ef *def, int qemuDomainPrepareDiskSourceData(virDomainDiskDefPtr disk, - virStorageSourcePtr src, - virQEMUDriverConfigPtr cfg, - virQEMUCapsPtr qemuCaps) + virStorageSourcePtr src) G_GNUC_WARN_UNUSED_RESULT; diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 0f073682ca..9b7abceb40 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -223,7 +223,7 @@ testQemuDiskXMLToProps(const void *opaque) if (qemuDomainValidateStorageSource(n, data->qemuCaps) < 0) goto cleanup; - if (qemuDomainPrepareDiskSourceData(disk, n, NULL, data->qemuCaps)= < 0) + if (qemuDomainPrepareDiskSourceData(disk, n) < 0) goto cleanup; if (!(formatProps =3D qemuBlockStorageSourceGetBlockdevProps(n, n-= >backingStore)) || --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415103; cv=none; d=zoho.com; s=zohoarc; b=EyJmQeVuADIi+ehntvRUBR0rQHavBJIV0yzAnoaoQN06OaiOsLctNv9LTwrfbhnLqw+qbfWTjX8BFGhwa4v/R/i93szc09su7ZlxP7drlIONftmUhpwB1xXNVI2KmS70cs18hnbMo7H5krvlmdFqdh+1sQbLMCQlL8p6zwtpgYU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415103; h=Content-Type:Content-Transfer-Encoding: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; bh=qzxXU+dyCHar1Byp8aV1lkAhLMIn7hO4vSuNaoUfcUg=; b=npAsJ5YMGA90IsXvvdl+1x3sPyAvnoTflWV7PRfRGKy0gUjwMYjQYpSIwdN0ulojfMaQnycDBmdhcY0jhcIiE0wFHc6pnptOPDFoRyF5EHH6FtYCsC4lvEPpc255NDhZQXQZMLKPeM695SDQMsVVf+8BzZYT2jArnCwzabHA4Mo= 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 1571415103718495.13420174139833; Fri, 18 Oct 2019 09:11:43 -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 17577A96E9; Fri, 18 Oct 2019 16:11:42 +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 E71365C290; Fri, 18 Oct 2019 16:11: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 ACC144EE6D; Fri, 18 Oct 2019 16:11:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGBYXG004564 for ; Fri, 18 Oct 2019 12:11:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 53D0B6012A; Fri, 18 Oct 2019 16:11:34 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA710600D1; Fri, 18 Oct 2019 16:11:33 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:10:50 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 05/40] qemu: domain: Remove pointless return value in qemuDomainPrepareDiskSourceData 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.38]); Fri, 18 Oct 2019 16:11:42 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The function does not do anything that could fail. Remove the return value. Signed-off-by: Peter Krempa Reviewed-by: Daniel Henrique Barboza --- src/qemu/qemu_domain.c | 16 ++++------------ src/qemu/qemu_domain.h | 5 ++--- tests/qemublocktest.c | 3 +-- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6a93dd5293..29212eaa10 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -10383,9 +10383,7 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr drive= r, return -1; qemuDomainPrepareStorageSourceConfig(n, cfg, priv->qemuCaps); - - if (qemuDomainPrepareDiskSourceData(disk, n) < 0) - return -1; + qemuDomainPrepareDiskSourceData(disk, n); if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV) && qemuDomainPrepareStorageSourceBlockdev(disk, n, priv, cfg) < 0) @@ -15093,7 +15091,7 @@ qemuDomainCheckCCWS390AddressSupport(const virDomai= nDef *def, * chain. This function should be also called for detected backing chain * members. */ -int +void qemuDomainPrepareDiskSourceData(virDomainDiskDefPtr disk, virStorageSourcePtr src) { @@ -15108,8 +15106,6 @@ qemuDomainPrepareDiskSourceData(virDomainDiskDefPtr= disk, if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY) src->floppyimg =3D true; - - return 0; } @@ -15162,9 +15158,7 @@ qemuDomainPrepareDiskSourceLegacy(virDomainDiskDefP= tr disk, return -1; qemuDomainPrepareStorageSourceConfig(disk->src, cfg, priv->qemuCaps); - - if (qemuDomainPrepareDiskSourceData(disk, disk->src) < 0) - return -1; + qemuDomainPrepareDiskSourceData(disk, disk->src); if (qemuDomainSecretStorageSourcePrepare(priv, disk->src, disk->info.alias, @@ -15198,9 +15192,7 @@ qemuDomainPrepareStorageSourceBlockdev(virDomainDis= kDefPtr disk, return -1; qemuDomainPrepareStorageSourceConfig(src, cfg, priv->qemuCaps); - - if (qemuDomainPrepareDiskSourceData(disk, src) < 0) - return -1; + qemuDomainPrepareDiskSourceData(disk, src); if (qemuDomainSecretStorageSourcePrepare(priv, src, src->nodestorage, diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 14367f7320..5b3d84cea7 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -1167,10 +1167,9 @@ qemuDomainCheckCCWS390AddressSupport(const virDomain= Def *def, virQEMUCapsPtr qemuCaps, const char *devicename); -int +void qemuDomainPrepareDiskSourceData(virDomainDiskDefPtr disk, - virStorageSourcePtr src) - G_GNUC_WARN_UNUSED_RESULT; + virStorageSourcePtr src); int diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 9b7abceb40..08eec11ef9 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -223,8 +223,7 @@ testQemuDiskXMLToProps(const void *opaque) if (qemuDomainValidateStorageSource(n, data->qemuCaps) < 0) goto cleanup; - if (qemuDomainPrepareDiskSourceData(disk, n) < 0) - goto cleanup; + qemuDomainPrepareDiskSourceData(disk, n); if (!(formatProps =3D qemuBlockStorageSourceGetBlockdevProps(n, n-= >backingStore)) || !(storageSrcOnlyProps =3D qemuBlockStorageSourceGetBackendProp= s(n, false, true, true)) || --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415103; cv=none; d=zoho.com; s=zohoarc; b=HEP6MGPykdCnysJyP9fWrod/NCFJO1UdFMg+vZg/FxmSoIQpM9ij8eUvkIbxzOXbHBubc4kss+laWyuXYKbnTmiEtV88p+AmxV9MKRpFztJAroAWiXwkQFnhuSkMbJ5XEHvCQl+uHQm1bX+UvVW9OLfSL/Tg2HhnxiMTKVdnErM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415103; h=Content-Type:Content-Transfer-Encoding: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; bh=sMaqfZwFkB1hBtWY4mkadAzyrYHiyz3+94zFfI2caTQ=; b=lFDkwVimO3oolNO6Dr2tw8LQ6g54RjfOiwqV4rDWHy+hPBtUkqosS7XPZiGWh5BzxXQ3O+3dmmrE7VHFY1IgfQn68HwVGJ7tOJr+IwMaTM/7ZAeeBoy5RXs18l8PnvVSpok3XMgXFmNP3HpkS+71GtU0p+0osiGwOIqg7CYbwAM= 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 1571415103656644.7889356133862; Fri, 18 Oct 2019 09:11: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 17EE7300C5A9; Fri, 18 Oct 2019 16:11:42 +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 E4301601B3; Fri, 18 Oct 2019 16:11: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 A803B1803B48; Fri, 18 Oct 2019 16:11:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGBZ8f004575 for ; Fri, 18 Oct 2019 12:11:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4CB6D600C8; Fri, 18 Oct 2019 16:11:35 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id A0E86600D1; Fri, 18 Oct 2019 16:11:34 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:10:51 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 06/40] qemu: domain: clarify sematics of qemuDomainPrepareDiskSourceData 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.46]); Fri, 18 Oct 2019 16:11:42 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Note in the comment that this function prepares the storage source based on the configuration of the disk. Signed-off-by: Peter Krempa Reviewed-by: Daniel Henrique Barboza --- src/qemu/qemu_domain.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 29212eaa10..259cf51e2b 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -15088,8 +15088,8 @@ qemuDomainCheckCCWS390AddressSupport(const virDomai= nDef *def, * @src: source to start from * * Prepares various aspects of a storage source belonging to a disk backing - * chain. This function should be also called for detected backing chain - * members. + * chain based on the disk configuration. This function should be also cal= led + * for detected backing chain members. */ void qemuDomainPrepareDiskSourceData(virDomainDiskDefPtr disk, --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415107; cv=none; d=zoho.com; s=zohoarc; b=dw+WzLCx8SCjIJn33P3XdFz+zuzobK//XDM/E1efhek0UkEXoBiqNVkZNXShbNWCFvT58aKnu8OprTvzBAKWX3ThEy2meF8clSw//JakY8e2QX9wsEmKsjiYwwFnK+t1KVE8epHAA8socwK0Kx77BYBSHsQHhf6osO/igs8YC2c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415107; h=Content-Type:Content-Transfer-Encoding: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; bh=ukOes2Sfl6+biy408cJ/rXqyDYDxjLXxkWu88iVHBi8=; b=jaDHxsVJ+9xiWZwYQmRCH4hIy102sEIs7CI7HqhYynFbqdPuffxm+m0aUTwwmCl37DxNNks/A+Ybg0pMEDjE17vRdcGzAUauQxODtx1G5wCgCWUxgkFN77bRUMenf73OSdfZDEjyTM2fdZEAWe+4Z3K47W9yz3TOde5E2dszV9I= 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 1571415107911397.9158418720717; Fri, 18 Oct 2019 09:11:47 -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 E05773092651; Fri, 18 Oct 2019 16:11:45 +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 B7E375DD61; Fri, 18 Oct 2019 16:11: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 5EDDF180BA9E; Fri, 18 Oct 2019 16:11:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGBaJl004582 for ; Fri, 18 Oct 2019 12:11:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 41FD7600D1; Fri, 18 Oct 2019 16:11:36 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 98F8D600C8; Fri, 18 Oct 2019 16:11:35 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:10:52 +0200 Message-Id: <7a2df5f187675f6a6efedf0db00d94480829f77f.1571414890.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 07/40] qemu: domain: Tolerate NULL @disk in qemuDomainPrepareDiskSourceData 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, 18 Oct 2019 16:11:46 +0000 (UTC) Content-Type: text/plain; charset="utf-8" In some cases we want to prepare a @src which is not meant to belong to a disk and thus does not require us to copy the data. Allow passing in NULL @disk into qemuDomainPrepareDiskSourceData. Signed-off-by: Peter Krempa Reviewed-by: Daniel Henrique Barboza --- src/qemu/qemu_domain.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 259cf51e2b..3deb69cb63 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -15095,6 +15095,9 @@ void qemuDomainPrepareDiskSourceData(virDomainDiskDefPtr disk, virStorageSourcePtr src) { + if (!disk) + return; + /* transfer properties valid only for the top level image */ if (src =3D=3D disk->src) src->detect_zeroes =3D disk->detect_zeroes; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415107; cv=none; d=zoho.com; s=zohoarc; b=MjMe7LclZO/81ckX1IHmhkqAbZ+FTDo1a504UWH4zS1u/nE+UgAgW6kfwXH/nWF7by6leOEerDwsom9AwSQE3FnGeUhXCy8zLZbs+aQQ0gnwJHDRf0E2lWYXMQuySlo1WM8NZdcHZMvdN+RrYDI2sI4ur3BUOu93BxBb7THJ75o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415107; h=Content-Type:Content-Transfer-Encoding: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; bh=I4SRiw8JRddSz3cFjyJFTvtIJwhzN1GTgLjkQ9SyFZc=; b=UtnXIXBQf44MiawK+BC0WMjPAKipXSS39MLKWAhIHIy6eLMN4D67S7QHK51dxy3D5VCp2bM7x7GM7rfibPenS4H1h8JRM7p8AweqJo9TfS+YJ10x/oNqfn+vIHYMl4/swp6l5eWjODFpClo8V/wesQJpQGepdHhkyqXEVLC5bWs= 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 157141510759473.48303007302866; Fri, 18 Oct 2019 09:11:47 -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 E82F33071D8D; Fri, 18 Oct 2019 16:11: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 BDBBF60CCD; Fri, 18 Oct 2019 16:11: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 5FC1F4EE6F; Fri, 18 Oct 2019 16:11:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGBbCm004593 for ; Fri, 18 Oct 2019 12:11:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 377576012A; Fri, 18 Oct 2019 16:11:37 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8EFA5600C8; Fri, 18 Oct 2019 16:11:36 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:10:53 +0200 Message-Id: <79530aa5d8ea1557aba4c9c8632063527e41933f.1571414890.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 08/40] conf: Remove virDomainDiskPathByName 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.47]); Fri, 18 Oct 2019 16:11:46 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Last use was removed in 29682196d8f. Signed-off-by: Peter Krempa Reviewed-by: Daniel Henrique Barboza --- src/conf/domain_conf.c | 11 ----------- src/conf/domain_conf.h | 1 - src/libvirt_private.syms | 1 - 3 files changed, 13 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 88e93f6fb8..8b4e80fa8d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16922,17 +16922,6 @@ virDomainDiskIndexByName(virDomainDefPtr def, cons= t char *name, return candidate; } -/* Return the path to a disk image if a string identifies at least one - * disk belonging to the domain (both device strings 'vda' and paths - * '/path/to/file' are converted into '/path/to/file'). */ -const char * -virDomainDiskPathByName(virDomainDefPtr def, const char *name) -{ - int idx =3D virDomainDiskIndexByName(def, name, true); - - return idx < 0 ? NULL : virDomainDiskGetSource(def->disks[idx]); -} - virDomainDiskDefPtr virDomainDiskByName(virDomainDefPtr def, const char *name, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index b33e5334f4..ad8e88c2ee 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3162,7 +3162,6 @@ int virDomainDiskIndexByName(virDomainDefPtr def, con= st char *name, virDomainDiskDefPtr virDomainDiskByName(virDomainDefPtr def, const char *name, bool allow_ambiguous); -const char *virDomainDiskPathByName(virDomainDefPtr, const char *name); int virDomainDiskInsert(virDomainDefPtr def, virDomainDiskDefPtr disk) G_GNUC_WARN_UNUSED_RESULT; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 588f0a4356..e6d40d1cbe 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -362,7 +362,6 @@ virDomainDiskMirrorStateTypeFromString; virDomainDiskMirrorStateTypeToString; virDomainDiskModelTypeFromString; virDomainDiskModelTypeToString; -virDomainDiskPathByName; virDomainDiskRemove; virDomainDiskRemoveByName; virDomainDiskSetBlockIOTune; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415111; cv=none; d=zoho.com; s=zohoarc; b=S0vCvxxieoRuRzrybUYy7eyr1Dn4LybvyaJ0GgboWTXfpHL1la5cpwGoqLxrhoXC5mkVB87tAyJh1OHKmu2TB+gflrgU0xo/PRMQF1ahshhKgkJEWs5NiTfcTM85RkXJmhLLo03FaIhug0JOV2nCopYxMU9x/3ovZQPysVhfMgI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415111; h=Content-Type:Content-Transfer-Encoding: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; bh=tjPTrpZ5JdnepXP5hkEgYOP36TN+sBnm35iQ3cDz2BM=; b=Bo9dvKQm+IGpGNc05eFVnE9Xr5ROD1GceC14bsELXTA6bL2WZx78tHGqoc2MbTYZJxXWUmdaIfjzVg/OAOiVmJVOccUv6MNMXbsoEhxCodEhPPOAy/kuyEZnJ/8BDzGzhTEuwxuFExXWYsj27ZibsqEWSYfOQVcCvyig4azKMAs= 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 15714151114131001.5006374847717; Fri, 18 Oct 2019 09:11:51 -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 B3BAC3071D85; Fri, 18 Oct 2019 16:11:49 +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 6F69A60F8E; Fri, 18 Oct 2019 16:11:49 +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 2647C4EE75; Fri, 18 Oct 2019 16:11:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGBcFm004605 for ; Fri, 18 Oct 2019 12:11:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2EEA3601B3; Fri, 18 Oct 2019 16:11:38 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8405B600C8; Fri, 18 Oct 2019 16:11:37 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:10:54 +0200 Message-Id: <0e162f2985dd3eb64491eb3621dae1815e17924f.1571414890.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 09/40] conf: Introduce virDomainDiskByTarget 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.47]); Fri, 18 Oct 2019 16:11:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Introduce a simpler replacement for virDomainDiskByName when looking up by disk target. Signed-off-by: Peter Krempa Reviewed-by: Daniel Henrique Barboza --- src/conf/domain_conf.c | 16 ++++++++++++++++ src/conf/domain_conf.h | 4 ++++ src/libvirt_private.syms | 1 + 3 files changed, 21 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8b4e80fa8d..1fffd56a22 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16931,6 +16931,22 @@ virDomainDiskByName(virDomainDefPtr def, return idx < 0 ? NULL : def->disks[idx]; } + +virDomainDiskDefPtr +virDomainDiskByTarget(virDomainDefPtr def, + const char *dst) +{ + size_t i; + + for (i =3D 0; i < def->ndisks; i++) { + if (STREQ(def->disks[i]->dst, dst)) + return def->disks[i]; + } + + return NULL; +} + + int virDomainDiskInsert(virDomainDefPtr def, virDomainDiskDefPtr disk) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index ad8e88c2ee..690aa3c84b 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3162,6 +3162,10 @@ int virDomainDiskIndexByName(virDomainDefPtr def, co= nst char *name, virDomainDiskDefPtr virDomainDiskByName(virDomainDefPtr def, const char *name, bool allow_ambiguous); +virDomainDiskDefPtr +virDomainDiskByTarget(virDomainDefPtr def, + const char *dst); + int virDomainDiskInsert(virDomainDefPtr def, virDomainDiskDefPtr disk) G_GNUC_WARN_UNUSED_RESULT; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index e6d40d1cbe..2379c1ed8b 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -330,6 +330,7 @@ virDomainDiskBackingStoreParse; virDomainDiskBusTypeToString; virDomainDiskByAddress; virDomainDiskByName; +virDomainDiskByTarget; virDomainDiskCacheTypeFromString; virDomainDiskCacheTypeToString; virDomainDiskDefAssignAddress; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415111; cv=none; d=zoho.com; s=zohoarc; b=h/wBKONUR+THz+RT/cZlUy4NG3ymhPNAhiYv1Q9WhOIm4qPQIlA6Np5qOJkqK96o+xhQWKvqDD4jgpJY3ZIP1mAP9VjZ00GrFBpzlaIylJdzmB4U3+s2bCG0+Mrlhjr69ExKP23tCZQcKukePYB01Lkom3EU8UFOTR8S8+SGNyk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415111; h=Content-Type:Content-Transfer-Encoding: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; bh=ujz4+k25Z1DeRVuWdLGbt7Ff+pWlOej8eIaCh0ugw6g=; b=Iq0CFfdrajZ7ehAyMjXA/bpoJ+9BHNXoJnOS7DcOtStTP/KRDmH10hZJTVBYqhdzi09yOjgYZ7ztQb7+SmZVw3+Gefzwijlzliqv/PyECS0SIDHrbXMzDU8AttI/4E4YAB+IkdSgdjdQmoN/1ypgodHFiczorws2mz6Zl0YJ+A0= 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 1571415111794565.3870087681424; Fri, 18 Oct 2019 09:11:51 -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 341757BDA9; Fri, 18 Oct 2019 16:11:50 +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 0442960A9D; Fri, 18 Oct 2019 16:11:50 +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 AA5BD180BAA2; Fri, 18 Oct 2019 16:11:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGBdc0004618 for ; Fri, 18 Oct 2019 12:11:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 257AF60161; Fri, 18 Oct 2019 16:11:39 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7AB09600C8; Fri, 18 Oct 2019 16:11:38 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:10:55 +0200 Message-Id: <33c21c4be8cc68018d7426db8280e84e3e351224.1571414890.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 10/40] qemu: Replace use of virDomainDiskFindByBusAndDst with virDomainDiskByTarget 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.26]); Fri, 18 Oct 2019 16:11:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" In both replaced cases we have other code that verifies that the bus can't be changed or that the target is unique, so limiting the search to disks with same bus makes no sense. Signed-off-by: Peter Krempa Reviewed-by: Daniel Henrique Barboza --- src/qemu/qemu_driver.c | 7 ++----- src/qemu/qemu_hotplug.c | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index bf436f7dc3..ac5f108537 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7981,12 +7981,9 @@ qemuDomainChangeDiskLive(virDomainObjPtr vm, virDomainDeviceDef oldDev =3D { .type =3D dev->type }; int ret =3D -1; - if (!(orig_disk =3D virDomainDiskFindByBusAndDst(vm->def, - disk->bus, disk->dst)))= { + if (!(orig_disk =3D virDomainDiskByTarget(vm->def, disk->dst))) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("No device with bus '%s' and target '%s'"), - virDomainDiskBusTypeToString(disk->bus), - disk->dst); + _("disk '%s' not found"), disk->dst); goto cleanup; } diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index bf301919cc..3cb7f4cddd 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1092,7 +1092,7 @@ qemuDomainAttachDeviceDiskLive(virQEMUDriverPtr drive= r, * for devices supporting media changes */ if ((disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_CDROM || disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY) && - (orig_disk =3D virDomainDiskFindByBusAndDst(vm->def, disk->bus, di= sk->dst))) { + (orig_disk =3D virDomainDiskByTarget(vm->def, disk->dst))) { if (qemuDomainChangeEjectableMedia(driver, vm, orig_disk, disk->src, false) < 0) return -1; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415114; cv=none; d=zoho.com; s=zohoarc; b=dHiu+07I0WDzS8lzak0VEoY+gJY/yCmXqUfj55BBp9QUUX3tB9t4ca7JpXwbhsoLrxc4ZAFK7EoOzKvAINMT/rdVqC1u1HMey+ZnQ+aXw53K5b5dnoGq4Qc0p8pbudri+mA6bda0ZBVCN8I5JNm2nU1VtE7+q5nR/E+lE5Xd2xk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415114; h=Content-Type:Content-Transfer-Encoding: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; bh=9SMcqLSyjl82BqLeFLHOhmjt1StFoYOvh+UAj0P8ruk=; b=hSxtE2dzMJC/OjUxZyE2roL0IRX/31qUvvmIB8/Yj4Jq117QqSgzBr7iSVj+VZZo0OFXzhLlplpHGgLfQ/TkFdMMRT7xbMuK/rKm5EIrRmTcnfxW42wN5bJ5G9dFUMD3PC7J/wp/JoWMkojNM0GFwKX6YF3E8HsiDpmjtT04xxE= 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 1571415114798578.2519272110848; Fri, 18 Oct 2019 09:11:54 -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 411A210CC216; Fri, 18 Oct 2019 16:11:53 +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 1565F100EBD6; Fri, 18 Oct 2019 16:11:53 +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 CA51D180BAA7; Fri, 18 Oct 2019 16:11:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGBenV004626 for ; Fri, 18 Oct 2019 12:11:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1BD396012A; Fri, 18 Oct 2019 16:11:40 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7190560161; Fri, 18 Oct 2019 16:11:39 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:10:56 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 11/40] conf: Remove unused virDomainDiskFindByBusAndDst 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.6.2 (mx1.redhat.com [10.5.110.65]); Fri, 18 Oct 2019 16:11:53 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Previous commit removed last use of this function so we can get rid of it.t Signed-off-by: Peter Krempa Reviewed-by: Daniel Henrique Barboza --- src/conf/domain_conf.c | 21 --------------------- src/conf/domain_conf.h | 3 --- src/libvirt_private.syms | 1 - 3 files changed, 25 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1fffd56a22..e12d676a8c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8566,27 +8566,6 @@ virDomainDeviceFindSCSIController(const virDomainDef= *def, return NULL; } -virDomainDiskDefPtr -virDomainDiskFindByBusAndDst(virDomainDefPtr def, - int bus, - char *dst) -{ - size_t i; - - if (!dst) - return NULL; - - for (i =3D 0; i < def->ndisks; i++) { - if (def->disks[i]->bus =3D=3D bus && - STREQ(def->disks[i]->dst, dst)) { - return def->disks[i]; - } - } - - return NULL; -} - - int virDomainDiskDefAssignAddress(virDomainXMLOptionPtr xmlopt, virDomainDiskDefPtr def, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 690aa3c84b..071de9e71e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2859,9 +2859,6 @@ void virDomainDiskSetFormat(virDomainDiskDefPtr def, = int format); virDomainControllerDefPtr virDomainDeviceFindSCSIController(const virDomainDef *def, virDomainDeviceInfoPtr info); -virDomainDiskDefPtr virDomainDiskFindByBusAndDst(virDomainDefPtr def, - int bus, - char *dst); virDomainControllerDefPtr virDomainControllerDefNew(virDomainControllerTyp= e type); void virDomainControllerDefFree(virDomainControllerDefPtr def); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 2379c1ed8b..fdfe1e7295 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -345,7 +345,6 @@ virDomainDiskDiscardTypeToString; virDomainDiskEmptySource; virDomainDiskErrorPolicyTypeFromString; virDomainDiskErrorPolicyTypeToString; -virDomainDiskFindByBusAndDst; virDomainDiskGeometryTransTypeFromString; virDomainDiskGeometryTransTypeToString; virDomainDiskGetDetectZeroesMode; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415115; cv=none; d=zoho.com; s=zohoarc; b=EU4wOK3eyLa4d4FQ8B59pn6rJjlcs3Nygx9c2WnC9LE92QZz8nm0PWXof52nlu4GG8JBRvksm/vdYFtP59ViIB4SDdLV2tkA8NpN7mKZU3ZSZtKqHme8C1iiiM4SzwwJqQQSPaO5dqOGe20cykah3y8u3WB8zJEJUbJMbpvq1j8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415115; h=Content-Type:Content-Transfer-Encoding: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; bh=xVbIRdpb6WbXuRw3c7xoGqqzRC7tcGtsSzc2Cfb+v0Q=; b=dhDNcQEqku5fuEcHdyvgKHvD5OpnF2+L2Mo4w6Auh8kxEb9+Rgz+d3z98MylOEjKccYbtgsaJC8OhZsrIxDD9sXTUVFe0seEVlMlI6sVBMRZM0e59a76+XJGHCR4SoL+53ri+3+iM4lZ2GBl+WkCBFE7TfCP+0nnOW6UN3+gmJQ= 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 1571415115354848.2526304870308; Fri, 18 Oct 2019 09:11:55 -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 A8E46307B191; Fri, 18 Oct 2019 16:11:53 +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 814F061F21; Fri, 18 Oct 2019 16:11:53 +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 425F3180BAA9; Fri, 18 Oct 2019 16:11:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGBfwv004636 for ; Fri, 18 Oct 2019 12:11:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 11FE560166; Fri, 18 Oct 2019 16:11:41 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 68A7D600C8; Fri, 18 Oct 2019 16:11:40 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:10:57 +0200 Message-Id: <882451189e325ff9b934dce36209024a1b1e0783.1571414890.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 12/40] Replace virDomainDiskByName by virDomainDiskByTarget in appropriate cases 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.45]); Fri, 18 Oct 2019 16:11:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" In many cases we used virDomainDiskByName to solely look up disk by target. We have a new helper now so we can replace it. Signed-off-by: Peter Krempa Reviewed-by: Daniel Henrique Barboza --- src/libxl/libxl_driver.c | 2 +- src/qemu/qemu_blockjob.c | 6 +++--- src/qemu/qemu_domain.c | 4 ++-- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_migration.c | 3 +-- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 64b21f2073..a08bafe5ce 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -4072,7 +4072,7 @@ libxlDomainUpdateDeviceConfig(virDomainDefPtr vmdef, = virDomainDeviceDefPtr dev) switch (dev->type) { case VIR_DOMAIN_DEVICE_DISK: disk =3D dev->data.disk; - if (!(orig =3D virDomainDiskByName(vmdef, disk->dst, false))) { + if (!(orig =3D virDomainDiskByTarget(vmdef, disk->dst))) { virReportError(VIR_ERR_INVALID_ARG, _("target %s doesn't exist."), disk->dst); goto cleanup; diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index 3506fa165b..f9b3bdaff4 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -601,7 +601,7 @@ qemuBlockJobRewriteConfigDiskSource(virDomainObjPtr vm, if (!vm->newDef) return; - if (!(persistDisk =3D virDomainDiskByName(vm->newDef, disk->dst, false= ))) + if (!(persistDisk =3D virDomainDiskByTarget(vm->newDef, disk->dst))) return; if (!virStorageSourceIsSameLocation(disk->src, persistDisk->src)) @@ -839,7 +839,7 @@ qemuBlockJobGetConfigDisk(virDomainObjPtr vm, disksrc =3D disk->src; - if (!(ret =3D virDomainDiskByName(vm->newDef, disk->dst, false))) + if (!(ret =3D virDomainDiskByTarget(vm->newDef, disk->dst))) return NULL; cfgsrc =3D ret->src; @@ -884,7 +884,7 @@ qemuBlockJobClearConfigChain(virDomainObjPtr vm, if (!vm->newDef || !disk) return; - if (!(cfgdisk =3D virDomainDiskByName(vm->newDef, disk->dst, false))) + if (!(cfgdisk =3D virDomainDiskByTarget(vm->newDef, disk->dst))) return; if (!virStorageSourceIsSameLocation(disk->src, cfgdisk->src)) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 3deb69cb63..e330d2390c 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3201,7 +3201,7 @@ qemuDomainObjPrivateXMLParseBlockjobData(virDomainObj= Ptr vm, invalidData =3D true; if ((diskdst =3D virXPathString("string(./disk/@dst)", ctxt)) && - !(disk =3D virDomainDiskByName(vm->def, diskdst, false))) + !(disk =3D virDomainDiskByTarget(vm->def, diskdst))) invalidData =3D true; if ((mirror =3D virXPathString("string(./disk/@mirror)", ctxt)) && @@ -3374,7 +3374,7 @@ qemuDomainObjPrivateXMLParseJobNBD(virDomainObjPtr vm, virDomainDiskDefPtr disk; if ((dst =3D virXMLPropString(nodes[i], "dev")) && - (disk =3D virDomainDiskByName(vm->def, dst, false))) { + (disk =3D virDomainDiskByTarget(vm->def, dst))) { QEMU_DOMAIN_DISK_PRIVATE(disk)->migrating =3D true; if (qemuDomainObjPrivateXMLParseJobNBDSource(nodes[i], ctx= t, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ac5f108537..e50f2277d2 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15276,7 +15276,7 @@ qemuDomainSnapshotDiskPrepareOne(virQEMUDriverPtr d= river, /* modify disk in persistent definition only when the source is the sa= me */ if (vm->newDef && - (persistdisk =3D virDomainDiskByName(vm->newDef, dd->disk->dst, fa= lse)) && + (persistdisk =3D virDomainDiskByTarget(vm->newDef, dd->disk->dst))= && virStorageSourceIsSameLocation(dd->disk->src, persistdisk->src)) { dd->persistdisk =3D persistdisk; diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index c65491f9d6..40aa598832 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -319,8 +319,7 @@ qemuMigrationDstPrecreateStorage(virDomainObjPtr vm, VIR_DEBUG("Looking up disk target '%s' (capacity=3D%llu)", nbd->disks[i].target, nbd->disks[i].capacity); - if (!(disk =3D virDomainDiskByName(vm->def, nbd->disks[i].target, - false))) { + if (!(disk =3D virDomainDiskByTarget(vm->def, nbd->disks[i].target= ))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unable to find disk by target: %s"), nbd->disks[i].target); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415111; cv=none; d=zoho.com; s=zohoarc; b=TybegnSotdUsHp/CrB5VMAU35avgP6oYYDvU7SsZPcsnsgj6mwvoX17SffFvQfp0U8m8HxQHIJakh9sByjp9dbQdeC4j7YTeQxcg2SJfhUtTjhgm20AQ6esslKJjqd+vLs/MjzObT8MNfGSPVoni3voLqF5SsbAbugw+sk9kAMs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415111; h=Content-Type:Content-Transfer-Encoding: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; bh=6xKZz5GDlAieH9GnfS+ypLzOJtd13Xeu8rtCkpspQoo=; b=DF1GlClIdh1SVl5CpdG4kX6sQFZg6ooZmftlRaZcD1ft3HW5gOYD6JbRjNAA+XaatbhXCjgXQJPooXFxvC61S9eub167LJsNv/tGtlZYMBBaP/tYDWQYEN5FKUaJGqXO5gzX08EqKgggzwk4TZm0hlcXaUV8BPP9jjUHALuqhLg= 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 1571415111474754.2491830600962; Fri, 18 Oct 2019 09:11:51 -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 9CC80307BD27; Fri, 18 Oct 2019 16:11:49 +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 72BFF60600; Fri, 18 Oct 2019 16:11:49 +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 282DB180BAA1; Fri, 18 Oct 2019 16:11:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGBgad004646 for ; Fri, 18 Oct 2019 12:11:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 08ACA6012A; Fri, 18 Oct 2019 16:11:42 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5EBD0600C8; Fri, 18 Oct 2019 16:11:41 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:10:58 +0200 Message-Id: <895fbe345f86a616406aa52a19ff6f0c6aa5a7ff.1571414890.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 13/40] qemu: monitor: Introduce new interface to query-named-block-nodes 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, 18 Oct 2019 16:11:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Retrieve data for individual block nodes in a hash table. Currently only capacity and allocation data is extracted but this will be extended in the future. Signed-off-by: Peter Krempa --- src/qemu/qemu_monitor.c | 18 ++++++++++ src/qemu/qemu_monitor.h | 11 ++++++ src/qemu/qemu_monitor_json.c | 69 ++++++++++++++++++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 3 ++ 4 files changed, 101 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 86d3800108..b6c890f9ce 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2220,6 +2220,24 @@ qemuMonitorBlockStatsUpdateCapacityBlockdev(qemuMoni= torPtr mon, return qemuMonitorJSONBlockStatsUpdateCapacityBlockdev(mon, stats); } + +/** + * qemuMonitorBlockGetNamedNodeData: + * @mon: monitor object + * + * Uses 'query-named-block-nodes' to retrieve information about individual + * storage nodes and returns them in a hash table of qemuBlockNamedNodeDat= aPtrs + * filled with the data. The hash table keys are node names. + */ +virHashTablePtr +qemuMonitorBlockGetNamedNodeData(qemuMonitorPtr mon) +{ + QEMU_CHECK_MONITOR_NULL(mon); + + return qemuMonitorJSONBlockGetNamedNodeData(mon); +} + + int qemuMonitorBlockResize(qemuMonitorPtr mon, const char *device, diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 11048dc76a..36eb5f342d 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -676,6 +676,17 @@ int qemuMonitorBlockStatsUpdateCapacityBlockdev(qemuMo= nitorPtr mon, virHashTablePtr stats) ATTRIBUTE_NONNULL(2); + +typedef struct _qemuBlockNamedNodeData qemuBlockNamedNodeData; +typedef qemuBlockNamedNodeData *qemuBlockNamedNodeDataPtr; +struct _qemuBlockNamedNodeData { + unsigned long long capacity; + unsigned long long physical; +}; + +virHashTablePtr +qemuMonitorBlockGetNamedNodeData(qemuMonitorPtr mon); + int qemuMonitorBlockResize(qemuMonitorPtr mon, const char *device, const char *nodename, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 02308dffe6..c474ac0203 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -2879,6 +2879,75 @@ qemuMonitorJSONBlockStatsUpdateCapacityBlockdev(qemu= MonitorPtr mon, } +static void +qemuMonitorJSONBlockNamedNodeDataFree(qemuBlockNamedNodeDataPtr data) +{ + if (!data) + return; + + g_free(data); +} +G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuBlockNamedNodeData, qemuMonitorJSONBlock= NamedNodeDataFree); + + +static int +qemuMonitorJSONBlockGetNamedNodeDataWorker(size_t pos G_GNUC_UNUSED, + virJSONValuePtr val, + void *opaque) +{ + virHashTablePtr nodes =3D opaque; + virJSONValuePtr img; + const char *nodename; + g_autoptr(qemuBlockNamedNodeData) ent =3D NULL; + + ent =3D g_new0(qemuBlockNamedNodeData, 1); + + if (!(nodename =3D virJSONValueObjectGetString(val, "node-name")) || + !(img =3D virJSONValueObjectGetObject(val, "image"))) + goto broken; + + if (virJSONValueObjectGetNumberUlong(img, "virtual-size", &ent->capaci= ty) < 0) + goto broken; + + /* if actual-size is missing, image is not thin provisioned */ + if (virJSONValueObjectGetNumberUlong(img, "actual-size", &ent->physica= l) < 0) + ent->physical =3D ent->capacity; + + if (virHashAddEntry(nodes, nodename, ent) < 0) + return -1; + + ent =3D NULL; + + return 1; /* we don't want to steal the value from the JSON array */ + + broken: + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("query-named-block-nodes entry was not in expected fo= rmat")); + return -1; +} + + +virHashTablePtr +qemuMonitorJSONBlockGetNamedNodeData(qemuMonitorPtr mon) +{ + g_autoptr(virJSONValue) nodes =3D NULL; + g_autoptr(virHashTable) ret =3D NULL; + + if (!(nodes =3D qemuMonitorJSONQueryNamedBlockNodes(mon))) + return NULL; + + if (!(ret =3D virHashNew((virHashDataFreeSimple) qemuMonitorJSONBlockN= amedNodeDataFree))) + return NULL; + + if (virJSONValueArrayForeachSteal(nodes, + qemuMonitorJSONBlockGetNamedNodeData= Worker, + ret) < 0) + return NULL; + + return g_steal_pointer(&ret); +} + + int qemuMonitorJSONBlockResize(qemuMonitorPtr mon, const char *device, const char *nodename, diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 975de3759a..6ee3e912f9 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -87,6 +87,9 @@ int qemuMonitorJSONBlockStatsUpdateCapacity(qemuMonitorPt= r mon, int qemuMonitorJSONBlockStatsUpdateCapacityBlockdev(qemuMonitorPtr mon, virHashTablePtr stats); +virHashTablePtr +qemuMonitorJSONBlockGetNamedNodeData(qemuMonitorPtr mon); + int qemuMonitorJSONBlockResize(qemuMonitorPtr mon, const char *device, const char *nodename, --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415114; cv=none; d=zoho.com; s=zohoarc; b=IBmfcGTSmNF8HhX0KFItD61SOopieKaVB0K0nVwGQkb0ryz7qQ4btDL5JfY/XhSfqAlovbHpahUA+kMH7iE6u/ou9e4GaTwP/eagaAugB1eNgJepY0PDCnxC9r+dn9S7EKQGvvy60oXUQI4nnCANdVKTXEpgKTX+K5X3EfJlsbI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415114; h=Content-Type:Content-Transfer-Encoding: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; bh=9lID8HQqCmw77eqyFptkm6gppPJhXrV26aVCiSKV3tE=; b=glLCQJZuTBGR1kklR6qT3ILPAut6ys/hnCr1H4zWoEbNxr2vw0/tIgCPcGhuAcNfOlcVm5npi9V627LuZou2CW/MJaMm2a4ozH1D+JF3MCA/L5qP8PHI13Gp19yDjVYbEDeo54v+pdXFj4QwTXE5at4bLrhuo8EB6NtPxv1RRjY= 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 1571415114764477.9378924990142; Fri, 18 Oct 2019 09:11:54 -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 3AD83C057F31; Fri, 18 Oct 2019 16:11:53 +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 0FAFE1001B28; Fri, 18 Oct 2019 16:11:53 +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 C738D4EE96; Fri, 18 Oct 2019 16:11:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGBh0b004657 for ; Fri, 18 Oct 2019 12:11:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id F3E4C6012A; Fri, 18 Oct 2019 16:11:42 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 55EA5600C8; Fri, 18 Oct 2019 16:11:42 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:10:59 +0200 Message-Id: <80a50d2dd79b1b03bdc5911fcd0e945d320675f9.1571414890.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 14/40] qemu: block: Don't query monitor in qemuBlockStorageSourceCreateDetectSize 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.32]); Fri, 18 Oct 2019 16:11:53 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Calling the monitor was convenient for the implementation in qemuDomainBlockCopyCommon, but causes the snapshot code to call query-named-block-nodes for every disk. Fix this by removing the monitor call from qemuBlockStorageSourceCreateDetectSize so that the data can be reused in loops. Signed-off-by: Peter Krempa --- src/qemu/qemu_block.c | 26 +++++--------------------- src/qemu/qemu_block.h | 5 ++--- src/qemu/qemu_driver.c | 33 ++++++++++++++++++++++++++++----- 3 files changed, 35 insertions(+), 29 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 4dc4f2922d..c966b24cb6 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -2578,10 +2578,9 @@ qemuBlockStorageSourceCreate(virDomainObjPtr vm, /** * qemuBlockStorageSourceCreateDetectSize: - * @vm: domain object + * @blockNamedNodeData: hash table filled with qemuBlockNamedNodeData * @src: storage source to update size/capacity on * @templ: storage source template - * @asyncJob: qemu asynchronous job type * * When creating a storage source via blockdev-create we need to know the = size * and capacity of the original volume (e.g. when creating a snapshot or c= opy). @@ -2589,28 +2588,13 @@ qemuBlockStorageSourceCreate(virDomainObjPtr vm, * to the detected sizes from @templ. */ int -qemuBlockStorageSourceCreateDetectSize(virDomainObjPtr vm, +qemuBlockStorageSourceCreateDetectSize(virHashTablePtr blockNamedNodeData, virStorageSourcePtr src, - virStorageSourcePtr templ, - qemuDomainAsyncJob asyncJob) + virStorageSourcePtr templ) { - qemuDomainObjPrivatePtr priv =3D vm->privateData; - g_autoptr(virHashTable) stats =3D NULL; - qemuBlockStatsPtr entry; - int rc; - - if (!(stats =3D virHashCreate(10, virHashValueFree))) - return -1; - - if (qemuDomainObjEnterMonitorAsync(priv->driver, vm, asyncJob) < 0) - return -1; - - rc =3D qemuMonitorBlockStatsUpdateCapacityBlockdev(priv->mon, stats); - - if (qemuDomainObjExitMonitor(priv->driver, vm) < 0 || rc < 0) - return -1; + qemuBlockNamedNodeDataPtr entry; - if (!(entry =3D virHashLookup(stats, templ->nodeformat))) { + if (!(entry =3D virHashLookup(blockNamedNodeData, templ->nodeformat)))= { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to update capacity data for block node '%= s'"), templ->nodeformat); diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index be39c9b472..5ddeeaf6e2 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -194,7 +194,6 @@ qemuBlockStorageSourceCreate(virDomainObjPtr vm, qemuDomainAsyncJob asyncJob); int -qemuBlockStorageSourceCreateDetectSize(virDomainObjPtr vm, +qemuBlockStorageSourceCreateDetectSize(virHashTablePtr blockNamedNodeData, virStorageSourcePtr src, - virStorageSourcePtr templ, - qemuDomainAsyncJob asyncJob); + virStorageSourcePtr templ); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index e50f2277d2..e908331a93 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15252,6 +15252,7 @@ qemuDomainSnapshotDiskPrepareOne(virQEMUDriverPtr d= river, virDomainDiskDefPtr disk, virDomainSnapshotDiskDefPtr snapdisk, qemuDomainSnapshotDiskDataPtr dd, + virHashTablePtr blockNamedNodeData, bool reuse, bool blockdev, qemuDomainAsyncJob asyncJob) @@ -15355,8 +15356,8 @@ qemuDomainSnapshotDiskPrepareOne(virQEMUDriverPtr d= river, if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) return -1; } else { - if (qemuBlockStorageSourceCreateDetectSize(vm, dd->src, dd->di= sk->src, - asyncJob) < 0) + if (qemuBlockStorageSourceCreateDetectSize(blockNamedNodeData, + dd->src, dd->disk->= src) < 0) return -1; if (qemuBlockStorageSourceCreate(vm, dd->src, dd->disk->src, @@ -15385,6 +15386,7 @@ qemuDomainSnapshotDiskPrepare(virQEMUDriverPtr driv= er, virQEMUDriverConfigPtr cfg, bool reuse, bool blockdev, + virHashTablePtr blockNamedNodeData, qemuDomainAsyncJob asyncJob, qemuDomainSnapshotDiskDataPtr *rdata, size_t *rndata) @@ -15404,7 +15406,9 @@ qemuDomainSnapshotDiskPrepare(virQEMUDriverPtr driv= er, if (qemuDomainSnapshotDiskPrepareOne(driver, vm, cfg, vm->def->dis= ks[i], snapdef->disks + i, - data + ndata++, reuse, blockd= ev, + data + ndata++, + blockNamedNodeData, + reuse, blockdev, asyncJob) < 0) goto cleanup; } @@ -15495,6 +15499,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr= driver, qemuDomainSnapshotDiskDataPtr diskdata =3D NULL; size_t ndiskdata =3D 0; bool blockdev =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); + g_autoptr(virHashTable) blockNamedNodeData =3D NULL; if (virDomainObjCheckActive(vm) < 0) return -1; @@ -15502,10 +15507,21 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverP= tr driver, if (!(actions =3D virJSONValueNewArray())) return -1; + if (blockdev) { + if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) + return -1; + + blockNamedNodeData =3D qemuMonitorBlockGetNamedNodeData(priv->mon); + + if (qemuDomainObjExitMonitor(driver, vm) < 0 || !blockNamedNodeDat= a) + return -1; + } + /* prepare a list of objects to use in the vm definition so that we do= n't * have to roll back later */ if (qemuDomainSnapshotDiskPrepare(driver, vm, snap, cfg, reuse, blockd= ev, - asyncJob, &diskdata, &ndiskdata) < 0) + blockNamedNodeData, asyncJob, + &diskdata, &ndiskdata) < 0) goto cleanup; /* check whether there's anything to do */ @@ -18018,6 +18034,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, g_autoptr(qemuBlockStorageSourceChainData) crdata =3D NULL; virStorageSourcePtr n; virStorageSourcePtr mirrorBacking =3D NULL; + g_autoptr(virHashTable) blockNamedNodeData =3D NULL; int rc =3D 0; /* Preliminaries: find the disk we are editing, sanity checks */ @@ -18179,7 +18196,13 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, = priv->qemuCaps))) goto endjob; } else { - if (qemuBlockStorageSourceCreateDetectSize(vm, mirror, disk->s= rc, QEMU_ASYNC_JOB_NONE) < 0) + qemuDomainObjEnterMonitor(driver, vm); + blockNamedNodeData =3D qemuMonitorBlockGetNamedNodeData(priv->= mon); + if (qemuDomainObjExitMonitor(driver, vm) < 0 || !blockNamedNod= eData) + goto endjob; + + if (qemuBlockStorageSourceCreateDetectSize(blockNamedNodeData, + mirror, disk->src)) goto endjob; if (mirror_shallow) { --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415118; cv=none; d=zoho.com; s=zohoarc; b=OM7YoJbTfVkbss4jMvx00cy6tid8vlXx1HHnmBc31VCtSutNdn7CcbTKOJ+Ki7rNAusjqGkUam5crGgdD91Cy0LNNAv7kLHQylPVdn9su37wN3RoDbfZ6I65gMX1cyqw2QtuS9d5qaiTlf0te8Yi+G09+qLwnP1WSV8LsegPYvY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415118; h=Content-Type:Content-Transfer-Encoding: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; bh=1lA6xe2ndznSJcFDpDrsc0EHssq9xFjYoXfxpEiHedI=; b=gFAaN7gak9tcAkb53BrfUJAhLixxc6EcbHMI3Z1zD1IAgyIQjXlpvDyLoBGvhix/NqgM+ul7foQeLsoCKXwVjmzxV3R+yC8xiCMGOCwa/gEpUUzvvGV3+9Q/GHhZx+svbSJLMNRiFok+ikh5x7jTcpMNhCCmJrOboEK/voV+OJ0= 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 1571415118588784.8315897600521; Fri, 18 Oct 2019 09:11:58 -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 E06EF3071D94; Fri, 18 Oct 2019 16:11:56 +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 B2E195DC18; Fri, 18 Oct 2019 16:11:56 +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 7542A180BACE; Fri, 18 Oct 2019 16:11:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGBhr4004664 for ; Fri, 18 Oct 2019 12:11:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id E98D160161; Fri, 18 Oct 2019 16:11:43 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C14E600C8; Fri, 18 Oct 2019 16:11:43 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:11:00 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 15/40] qemu: checkpoint: Fix rollback and access to unlocked 'vm' when deleting checkpoints 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.47]); Fri, 18 Oct 2019 16:11:57 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Delete/merge bitmaps when deleting checkpoints using a 'transaction' so that we don't have to deal with halfway-failed scenarios and also fix access to 'vm' while in the monitor lock. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_checkpoint.c | 47 +++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c index 4b4ad8bb83..a225f04831 100644 --- a/src/qemu/qemu_checkpoint.c +++ b/src/qemu/qemu_checkpoint.c @@ -133,11 +133,14 @@ qemuCheckpointDiscard(virQEMUDriverPtr driver, if (!metadata_only) { qemuDomainObjPrivatePtr priv =3D vm->privateData; - bool success =3D true; bool search_parents; virDomainCheckpointDefPtr chkdef =3D virDomainCheckpointObjGetDef(= chk); + int rc; + g_autoptr(virJSONValue) actions =3D NULL; + + if (!(actions =3D virJSONValueNewArray())) + return -1; - qemuDomainObjEnterMonitor(driver, vm); parent =3D virDomainCheckpointFindByName(vm->checkpoints, chk->def->parent_name); for (i =3D 0; i < chkdef->ndisks; i++) { @@ -167,31 +170,29 @@ qemuCheckpointDiscard(virQEMUDriverPtr driver, continue; search_parents =3D false; - arr =3D virJSONValueNewArray(); - if (!arr || - virJSONValueArrayAppendString(arr, disk->bitmap) <= 0) { - success =3D false; - break; - } - if (chk =3D=3D virDomainCheckpointGetCurrent(vm->check= points) && - qemuMonitorEnableBitmap(priv->mon, node, - disk2->bitmap) < 0) { - success =3D false; - break; - } - if (qemuMonitorMergeBitmaps(priv->mon, node, - disk2->bitmap, &arr) < 0) { - success =3D false; - break; + if (!(arr =3D virJSONValueNewArray())) + return -1; + + if (virJSONValueArrayAppendString(arr, disk->bitmap) <= 0) + return -1; + + if (chk =3D=3D virDomainCheckpointGetCurrent(vm->check= points)) { + if (qemuMonitorTransactionBitmapEnable(actions, no= de, disk2->bitmap) < 0) + return -1; } + + if (qemuMonitorTransactionBitmapMerge(actions, node, d= isk2->bitmap, &arr) < 0) + return -1; } } - if (qemuMonitorDeleteBitmap(priv->mon, node, disk->bitmap) < 0= ) { - success =3D false; - break; - } + + if (qemuMonitorTransactionBitmapRemove(actions, node, disk->bi= tmap) < 0) + return -1; } - if (qemuDomainObjExitMonitor(driver, vm) < 0 || !success) + + qemuDomainObjEnterMonitor(driver, vm); + rc =3D qemuMonitorTransaction(priv->mon, &actions); + if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) return -1; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415118; cv=none; d=zoho.com; s=zohoarc; b=KNUaQAvw+p1yYSNw6m56664nnNgubR5RTS012Aglcf6Eq3LgqNIi2wNwszqqnPPrccV4FE5ZpbbsZA/vQONBDccMambSBg2nHDfjMI2+ZPrdlJ5mAff5lnUfo2WLx9qQVZ+CtEzhsi8oaP/qwqSOlMYGKf5Umk1ru24Ss4JUw1U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415118; h=Content-Type:Content-Transfer-Encoding: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; bh=cpamGbgvlXckZnC0tGJ4KmbDpJN4XUpndSBu6wERKSY=; b=RbdVrtciP5j72TCm9eSuX5pGgdg06N8U09GA0oN7CxLhsoY7SLgEUCUoay4wL8c6URgeqq4lwAKI7cSRmMaoLCGmwV3Cp1SaH48IBFkfwDKbzlhf6OQk2Uv085yD2nK0VuFaX+m9NcSGet+G9ronUUh3S/etkyMAdQOqPEQMVx4= 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 1571415118517536.3805218693695; Fri, 18 Oct 2019 09:11:58 -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 E8CCF3007F2A; Fri, 18 Oct 2019 16:11:56 +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 C02875C296; Fri, 18 Oct 2019 16:11:56 +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 7F1B24EEB9; Fri, 18 Oct 2019 16:11:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGBnHv004702 for ; Fri, 18 Oct 2019 12:11:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id A60CC60166; Fri, 18 Oct 2019 16:11:49 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0829360161; Fri, 18 Oct 2019 16:11:44 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:11:01 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 16/40] qemu: monitor: Remove non-transaction based dirty bitmap APIs 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.48]); Fri, 18 Oct 2019 16:11:57 +0000 (UTC) Content-Type: text/plain; charset="utf-8" We replaced them by use of transaction to simplify possible failure scenarios. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_monitor.c | 51 --------------- src/qemu/qemu_monitor.h | 19 ------ src/qemu/qemu_monitor_json.c | 119 ----------------------------------- src/qemu/qemu_monitor_json.h | 17 ----- tests/qemumonitorjsontest.c | 41 ------------ 5 files changed, 247 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index b6c890f9ce..8de386817b 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4480,57 +4480,6 @@ qemuMonitorGetCurrentMachineInfo(qemuMonitorPtr mon, } -int -qemuMonitorAddBitmap(qemuMonitorPtr mon, - const char *node, - const char *bitmap, - bool persistent) -{ - VIR_DEBUG("node=3D%s bitmap=3D%s persistent=3D%d", node, bitmap, persi= stent); - - QEMU_CHECK_MONITOR(mon); - - return qemuMonitorJSONAddBitmap(mon, node, bitmap, persistent); -} - -int -qemuMonitorEnableBitmap(qemuMonitorPtr mon, - const char *node, - const char *bitmap) -{ - VIR_DEBUG("node=3D%s bitmap=3D%s", node, bitmap); - - QEMU_CHECK_MONITOR(mon); - - return qemuMonitorJSONEnableBitmap(mon, node, bitmap); -} - -int -qemuMonitorMergeBitmaps(qemuMonitorPtr mon, - const char *node, - const char *dst, - virJSONValuePtr *src) -{ - VIR_DEBUG("node=3D%s dst=3D%s", node, dst); - - QEMU_CHECK_MONITOR(mon); - - return qemuMonitorJSONMergeBitmaps(mon, node, dst, src); -} - -int -qemuMonitorDeleteBitmap(qemuMonitorPtr mon, - const char *node, - const char *bitmap) -{ - VIR_DEBUG("node=3D%s bitmap=3D%s", node, bitmap); - - QEMU_CHECK_MONITOR(mon); - - return qemuMonitorJSONDeleteBitmap(mon, node, bitmap); -} - - void qemuMonitorJobInfoFree(qemuMonitorJobInfoPtr job) { diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 36eb5f342d..45f2a5a7d2 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -702,25 +702,6 @@ int qemuMonitorSetBalloon(qemuMonitorPtr mon, unsigned long long newmem); int qemuMonitorSetCPU(qemuMonitorPtr mon, int cpu, bool online); -int qemuMonitorAddBitmap(qemuMonitorPtr mon, - const char *node, - const char *bitmap, - bool persistent) - ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); -int qemuMonitorEnableBitmap(qemuMonitorPtr mon, - const char *node, - const char *bitmap) - ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); -int qemuMonitorMergeBitmaps(qemuMonitorPtr mon, - const char *node, - const char *dst, - virJSONValuePtr *src) - ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4); -int qemuMonitorDeleteBitmap(qemuMonitorPtr mon, - const char *node, - const char *bitmap) - ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); - /* XXX should we pass the virDomainDiskDefPtr instead * and hide dev_name details inside monitor. Reconsider diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index c474ac0203..0062816e3e 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -9128,125 +9128,6 @@ qemuMonitorJSONGetCurrentMachineInfo(qemuMonitorPtr= mon, } -int -qemuMonitorJSONAddBitmap(qemuMonitorPtr mon, - const char *node, - const char *bitmap, - bool persistent) -{ - int ret =3D -1; - virJSONValuePtr cmd; - virJSONValuePtr reply =3D NULL; - - if (!(cmd =3D qemuMonitorJSONMakeCommand("block-dirty-bitmap-add", - "s:node", node, - "s:name", bitmap, - "b:persistent", persistent, - NULL))) - return -1; - - if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; - - if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; - - ret =3D 0; - cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; -} - -int -qemuMonitorJSONEnableBitmap(qemuMonitorPtr mon, - const char *node, - const char *bitmap) -{ - int ret =3D -1; - virJSONValuePtr cmd; - virJSONValuePtr reply =3D NULL; - - if (!(cmd =3D qemuMonitorJSONMakeCommand("block-dirty-bitmap-enable", - "s:node", node, - "s:name", bitmap, - NULL))) - return -1; - - if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; - - if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; - - ret =3D 0; - cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; -} - -int -qemuMonitorJSONMergeBitmaps(qemuMonitorPtr mon, - const char *node, - const char *dst, - virJSONValuePtr *src) -{ - int ret =3D -1; - virJSONValuePtr cmd; - virJSONValuePtr reply =3D NULL; - - if (!(cmd =3D qemuMonitorJSONMakeCommand("block-dirty-bitmap-merge", - "s:node", node, - "s:target", dst, - "a:bitmaps", src, - NULL))) - goto cleanup; - - if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; - - if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; - - ret =3D 0; - cleanup: - virJSONValueFree(*src); - *src =3D NULL; - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; -} - -int -qemuMonitorJSONDeleteBitmap(qemuMonitorPtr mon, - const char *node, - const char *bitmap) -{ - int ret =3D -1; - virJSONValuePtr cmd; - virJSONValuePtr reply =3D NULL; - - if (!(cmd =3D qemuMonitorJSONMakeCommand("block-dirty-bitmap-remove", - "s:node", node, - "s:name", bitmap, - NULL))) - return -1; - - if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; - - if (qemuMonitorJSONCheckError(cmd, reply) < 0) - goto cleanup; - - ret =3D 0; - cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; -} - - int qemuMonitorJSONTransactionBitmapAdd(virJSONValuePtr actions, const char *node, diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 6ee3e912f9..d74ef91b83 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -627,23 +627,6 @@ int qemuMonitorJSONGetCurrentMachineInfo(qemuMonitorPtr mon, qemuMonitorCurrentMachineInfoPtr info) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); -int qemuMonitorJSONAddBitmap(qemuMonitorPtr mon, - const char *node, - const char *bitmap, - bool persistent); - -int qemuMonitorJSONEnableBitmap(qemuMonitorPtr mon, - const char *node, - const char *bitmap); - -int qemuMonitorJSONMergeBitmaps(qemuMonitorPtr mon, - const char *node, - const char *dst, - virJSONValuePtr *src); - -int qemuMonitorJSONDeleteBitmap(qemuMonitorPtr mon, - const char *node, - const char *bitmap); int qemuMonitorJSONTransactionBitmapAdd(virJSONValuePtr actions, diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index f754e4d94b..4f15d231f9 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1337,9 +1337,6 @@ GEN_TEST_FUNC(qemuMonitorJSONBlockdevTrayOpen, "foode= v", true) GEN_TEST_FUNC(qemuMonitorJSONBlockdevTrayClose, "foodev") GEN_TEST_FUNC(qemuMonitorJSONBlockdevMediumRemove, "foodev") GEN_TEST_FUNC(qemuMonitorJSONBlockdevMediumInsert, "foodev", "newnode") -GEN_TEST_FUNC(qemuMonitorJSONAddBitmap, "node", "bitmap", true) -GEN_TEST_FUNC(qemuMonitorJSONEnableBitmap, "node", "bitmap") -GEN_TEST_FUNC(qemuMonitorJSONDeleteBitmap, "node", "bitmap") GEN_TEST_FUNC(qemuMonitorJSONJobDismiss, "jobname") GEN_TEST_FUNC(qemuMonitorJSONJobCancel, "jobname", false) GEN_TEST_FUNC(qemuMonitorJSONJobComplete, "jobname") @@ -1382,40 +1379,6 @@ testQemuMonitorJSONqemuMonitorJSONNBDServerStart(con= st void *opaque) return 0; } -static int -testQemuMonitorJSONqemuMonitorJSONMergeBitmaps(const void *opaque) -{ - const testGenericData *data =3D opaque; - virDomainXMLOptionPtr xmlopt =3D data->xmlopt; - g_autoptr(qemuMonitorTest) test =3D NULL; - g_autoptr(virJSONValue) arr =3D NULL; - - if (!(test =3D qemuMonitorTestNewSchema(xmlopt, data->schema))) - return -1; - - if (!(arr =3D virJSONValueNewArray())) - return -1; - - if (virJSONValueArrayAppendString(arr, "b1") < 0 || - virJSONValueArrayAppendString(arr, "b2") < 0) - return -1; - - if (qemuMonitorTestAddItem(test, "block-dirty-bitmap-merge", - "{\"return\":{}}") < 0) - return -1; - - if (qemuMonitorJSONMergeBitmaps(qemuMonitorTestGetMonitor(test), - "node", "dst", &arr) < 0) - return -1; - - if (arr) { - VIR_TEST_VERBOSE("arr should have been cleared"); - return -1; - } - - return 0; -} - static bool testQemuMonitorJSONqemuMonitorJSONQueryCPUsEqual(struct qemuMonitorQueryCp= usEntry *a, struct qemuMonitorQueryCp= usEntry *b) @@ -3174,9 +3137,6 @@ mymain(void) DO_TEST_GEN(qemuMonitorJSONBlockdevTrayClose); DO_TEST_GEN(qemuMonitorJSONBlockdevMediumRemove); DO_TEST_GEN(qemuMonitorJSONBlockdevMediumInsert); - DO_TEST_GEN(qemuMonitorJSONAddBitmap); - DO_TEST_GEN(qemuMonitorJSONEnableBitmap); - DO_TEST_GEN(qemuMonitorJSONDeleteBitmap); DO_TEST_GEN(qemuMonitorJSONJobDismiss); DO_TEST_GEN(qemuMonitorJSONJobCancel); DO_TEST_GEN(qemuMonitorJSONJobComplete); @@ -3196,7 +3156,6 @@ mymain(void) DO_TEST(qemuMonitorJSONSendKeyHoldtime); DO_TEST(qemuMonitorSupportsActiveCommit); DO_TEST(qemuMonitorJSONNBDServerStart); - DO_TEST(qemuMonitorJSONMergeBitmaps); DO_TEST_CPU_DATA("host"); DO_TEST_CPU_DATA("full"); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415118; cv=none; d=zoho.com; s=zohoarc; b=YVQcrWUnEbGEzGXV9ZOgVdD2D8YqdkOSOs1HIsjJQ75+LATcU6oAr3LQFVVAGwAlrIKu5BoadatzC9QsfFBTtm0Ubs79ZjVNhQKTRbx2u2sPwEbI+fSZLjGtsEBdNOj+halmgRltWFR6T6HZCJfujta6nL8EH8VdrblSjhchbNw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415118; h=Content-Type:Content-Transfer-Encoding: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; bh=vGsuE5O0Te5HIyjCzHj/xeOE00oesMuKIRVj+0PpWP0=; b=iAnxtA7cw/6jfkqrZPMcVwt6TK30WOAS70X6zbX07uT6T1+qCBEsRph2tr8NPseJMp2XV2lfTNuFcRfQa6Xe7DeGC7NUojyNQuE7JeNQu5zrQumCiZawP1dUN2Nk1U0ubHjni9tAYKP4nCOzRSzMVTtc3Jmb0JbKGUXnh72RYFo= 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 1571415118902773.2211001486271; Fri, 18 Oct 2019 09:11:58 -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 5AEE7C08EC09; Fri, 18 Oct 2019 16:11:57 +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 2967061F22; Fri, 18 Oct 2019 16:11:57 +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 DEEDB1806B09; Fri, 18 Oct 2019 16:11:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGBoOk004710 for ; Fri, 18 Oct 2019 12:11:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9AC33600C4; Fri, 18 Oct 2019 16:11:50 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id F1C51600C8; Fri, 18 Oct 2019 16:11:49 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:11:02 +0200 Message-Id: <6f9bfedfbb1a773b3b3b7f02befe9df0139b7573.1571414890.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 17/40] conf: snapshot: Don't clear current snapshot when redefining an existing one 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.31]); Fri, 18 Oct 2019 16:11:57 +0000 (UTC) Content-Type: text/plain; charset="utf-8" There's no point in clearing the current snapshot when we are just changing the definition of the current snapshot as by the virtue of the 'update_current' flag the same snapshot would become current in qemuDomainSnapshotCreateXML. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/snapshot_conf.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 0e9d307321..ec47e14955 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -989,7 +989,7 @@ virDomainSnapshotRedefinePrep(virDomainObjPtr vm, virDomainSnapshotDefPtr *defptr, virDomainMomentObjPtr *snap, virDomainXMLOptionPtr xmlopt, - bool *update_current, + bool *update_current G_GNUC_UNUSED, unsigned int flags) { virDomainSnapshotDefPtr def =3D *defptr; @@ -1012,11 +1012,6 @@ virDomainSnapshotRedefinePrep(virDomainObjPtr vm, return -1; } if (other) { - if (other =3D=3D virDomainSnapshotGetCurrent(vm->snapshots)) { - *update_current =3D true; - virDomainSnapshotSetCurrent(vm->snapshots, NULL); - } - /* Drop and rebuild the parent relationship, but keep all * child relations by reusing snap. */ virDomainMomentDropParent(other); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415122; cv=none; d=zoho.com; s=zohoarc; b=WbkvIOrim7u18tSx6k/BM6tm+GfoPFyhCvoZahI2ZBGMsaIhWMI1X3YveUURw8zmpFTkQLspsxoh7ZYrtV/M9j/62rzcP0HKQQrMg/+oXM1oGIP3A0Z2kD6gy1XsXy2YSYDoNURbm/7yfUfLaULlajAeRXgpnQFhFFbmu+h0hFQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415122; h=Content-Type:Content-Transfer-Encoding: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; bh=cKA6FoKQB7rLNm5fT0lxDaBlKcVeNe82Rrori0SvYF0=; b=dTRoXJqIkpY3LitHZZv3awHi74iBDQKdOFqfA/08zTjFgStnYnUq3N1Qfm4nnc7kjCeeD5t7wJUvmWSudDtQRci9e/NIvHGjCbMdwPTgUw1O3pIw2Iu9KjTTXfeHHh+wmzdx9OaAh7OGYB45kHfjmBsbRbV2vu9dv89CVO/E8Lk= 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 1571415122701484.1112845407122; Fri, 18 Oct 2019 09:12:02 -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 EEEAB7FD6C; Fri, 18 Oct 2019 16:12:00 +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 BB3EE6061E; Fri, 18 Oct 2019 16:12:00 +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 7603C4EEBE; Fri, 18 Oct 2019 16:12:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGBpIp004718 for ; Fri, 18 Oct 2019 12:11:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9021F600C4; Fri, 18 Oct 2019 16:11:51 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id E6FF7600C1; Fri, 18 Oct 2019 16:11:50 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:11:03 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 18/40] conf: snapshot: Remove 'update_current' parameter from virDomainSnapshotRedefinePrep 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.27]); Fri, 18 Oct 2019 16:12:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The variable is unused so we can drop it. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/snapshot_conf.c | 1 - src/conf/snapshot_conf.h | 1 - src/qemu/qemu_driver.c | 2 +- src/test/test_driver.c | 2 +- 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index ec47e14955..a1d14a480a 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -989,7 +989,6 @@ virDomainSnapshotRedefinePrep(virDomainObjPtr vm, virDomainSnapshotDefPtr *defptr, virDomainMomentObjPtr *snap, virDomainXMLOptionPtr xmlopt, - bool *update_current G_GNUC_UNUSED, unsigned int flags) { virDomainSnapshotDefPtr def =3D *defptr; diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index 7e2ffa9d60..b0b52e6a34 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -136,7 +136,6 @@ int virDomainSnapshotRedefinePrep(virDomainObjPtr vm, virDomainSnapshotDefPtr *def, virDomainMomentObjPtr *snap, virDomainXMLOptionPtr xmlopt, - bool *update_current, unsigned int flags); int virDomainSnapshotRedefineValidate(virDomainSnapshotDefPtr def, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index e908331a93..501c909e49 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15918,7 +15918,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, if (redefine) { if (virDomainSnapshotRedefinePrep(vm, &def, &snap, driver->xmlopt, - &update_current, flags) < 0) + flags) < 0) goto endjob; } else { /* Easiest way to clone inactive portion of vm->def is via diff --git a/src/test/test_driver.c b/src/test/test_driver.c index ab7e5fc02a..feada30a4b 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -8614,7 +8614,7 @@ testDomainSnapshotCreateXML(virDomainPtr domain, if (redefine) { if (virDomainSnapshotRedefinePrep(vm, &def, &snap, privconn->xmlopt, - &update_current, flags) < 0) + flags) < 0) goto cleanup; } else { if (!(def->parent.dom =3D virDomainDefCopy(vm->def, --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415126; cv=none; d=zoho.com; s=zohoarc; b=NDNDX9kBm7s+Gl8oDm9sX/w7T+J0VD80Ao+bbyJJV57Aonpri9TLMAdGfsE3ZMStoIwzCFCkxQC81IKPmr5KJVm34PC9UFxjAmvLQsKaf3qjmsHgK3KV+ZhWztNATkLeeqrstfKjUuvG2kJYOX2FGJ1tuAvJ59DU3sbGKV1+sO4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415126; h=Content-Type:Content-Transfer-Encoding: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; bh=9VxxkVRAnRfhLXax3Gkix7BcfJVXklB5jeHLDlXJKtk=; b=LoWkEIHzRJErI8cJjjsyH3JMtPvLTl2ZpU8Tb6TNJBthsggdoX3qEbJ3KeRCKCVv3e7Qeusgrts7mTQBqmWJ0xIEAIb6Ai9c1HonOM/GtMTPLmELcXFata1rXPVMKKmKjhsP5JNZKreCPtZnDDS5R89xf17WaU7o++LA8MioW8M= 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 157141512661255.971182124546544; Fri, 18 Oct 2019 09:12:06 -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 E1F0910C0950; Fri, 18 Oct 2019 16:12:04 +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 ACE405DA8D; Fri, 18 Oct 2019 16:12:04 +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 2ADD91804760; Fri, 18 Oct 2019 16:12:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGBqph004725 for ; Fri, 18 Oct 2019 12:11:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 879306012A; Fri, 18 Oct 2019 16:11:52 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD0D5600C1; Fri, 18 Oct 2019 16:11:51 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:11:04 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 19/40] conf: Don't reuse variable for different object in virDomainCheckpointRedefinePrep 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.6.2 (mx1.redhat.com [10.5.110.66]); Fri, 18 Oct 2019 16:12:05 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The 'other' variable was used to store the parent of the redefined checkpoint and then the existing version of the currently redefined checkpoint. Make it less confusing by adding a 'parent' variable for the first case. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/checkpoint_conf.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/conf/checkpoint_conf.c b/src/conf/checkpoint_conf.c index b254dce7fd..ea2e77a50a 100644 --- a/src/conf/checkpoint_conf.c +++ b/src/conf/checkpoint_conf.c @@ -540,6 +540,7 @@ virDomainCheckpointRedefinePrep(virDomainObjPtr vm, { virDomainCheckpointDefPtr def =3D *defptr; char uuidstr[VIR_UUID_STRING_BUFLEN]; + virDomainMomentObjPtr parent =3D NULL; virDomainMomentObjPtr other =3D NULL; virDomainCheckpointDefPtr otherdef =3D NULL; @@ -558,12 +559,13 @@ virDomainCheckpointRedefinePrep(virDomainObjPtr vm, if (virDomainCheckpointAlignDisks(def) < 0) return -1; - if (def->parent.parent_name) - other =3D virDomainCheckpointFindByName(vm->checkpoints, - def->parent.parent_name); - if (other =3D=3D virDomainCheckpointGetCurrent(vm->checkpoints)) { - *update_current =3D true; - virDomainCheckpointSetCurrent(vm->checkpoints, NULL); + if (def->parent.parent_name && + (parent =3D virDomainCheckpointFindByName(vm->checkpoints, + def->parent.parent_name))= ) { + if (parent =3D=3D virDomainCheckpointGetCurrent(vm->checkpoints)) { + *update_current =3D true; + virDomainCheckpointSetCurrent(vm->checkpoints, NULL); + } } other =3D virDomainCheckpointFindByName(vm->checkpoints, def->parent.n= ame); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415124; cv=none; d=zoho.com; s=zohoarc; b=Fp7WphD6DuMlFnhGQ3D220EyuFKx0jvGQfo2KaHI9ZinTCynEDl244CA33xHaL5Px5w6znjmnvhuSwdaEMGebQdVxwoW1WEV0Kw+nEBv8gN5A62dTeHn/V+OSorLoQmylmkKXVt4KtZfelvAs3raqLI9LVpwhyYEu5nFah5J6U4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415124; h=Content-Type:Content-Transfer-Encoding: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; bh=C7hYAmUtSWGwh+OWVMCPhh9xID1IjrNHbeFk1btnEls=; b=Um57IZeqH24+Zk5Yewg+/icS6Whu5oiloTojhvIVJbOhYQmuQDLqRNaVPVYnl3BUnbS2ruJzlY23cPHsKJLjwOWE0a71ZH0QIpCwE4RTSyt6lGA32q21LE79vM3B4O3+pmDXlb6snaLLuam/y+nYnEc715VhH3Hf6nVOpMog0SQ= 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 1571415124856382.7294414037668; Fri, 18 Oct 2019 09:12:04 -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 5E7F07BDD5; Fri, 18 Oct 2019 16:12:03 +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 349455D71C; Fri, 18 Oct 2019 16:12:03 +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 E7586C592; Fri, 18 Oct 2019 16:12:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGBrDB004736 for ; Fri, 18 Oct 2019 12:11:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7EAC2600C4; Fri, 18 Oct 2019 16:11:53 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id D539C60161; Fri, 18 Oct 2019 16:11:52 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:11:05 +0200 Message-Id: <29d62e5e72be0452f5e2ca97a74a13e3d0d9d734.1571414890.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 20/40] conf: checkpoint: Don't clear current checkpoint when redefining an existing one 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.26]); Fri, 18 Oct 2019 16:12:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" There's no point in clearing the current checkpoint when we are just changing the definition of the current checkpoint as by the virtue of the 'update_current' flag the same checkpoint would become current in qemuCheckpointCreateXML. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/checkpoint_conf.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/conf/checkpoint_conf.c b/src/conf/checkpoint_conf.c index ea2e77a50a..7f2cfd7f4c 100644 --- a/src/conf/checkpoint_conf.c +++ b/src/conf/checkpoint_conf.c @@ -575,11 +575,6 @@ virDomainCheckpointRedefinePrep(virDomainObjPtr vm, def->parent.dom, xmlopt)) return -1; - if (other =3D=3D virDomainCheckpointGetCurrent(vm->checkpoints)) { - *update_current =3D true; - virDomainCheckpointSetCurrent(vm->checkpoints, NULL); - } - /* Drop and rebuild the parent relationship, but keep all * child relations by reusing chk. */ virDomainMomentDropParent(other); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415130; cv=none; d=zoho.com; s=zohoarc; b=IGytfoBVT236WzMvsFHfg6A9uRHJIdhcGlDK5JjeJUIMVGqKd7eNJF90s5sjsZ6D6yK27IJ38r1gHN++XT2ioJjvRFqnXu62enOOShW1J8fLi9fKsPosD5hxI6y2kqIZ8ur+IevyTqx2vwE1ydDkrJqA8SeK7+Z22jRoHvZTPRc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415130; h=Content-Type:Content-Transfer-Encoding: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; bh=KL2VQxuZ9ZPzdTVRgm0zXxk+qcFWA3chSoLfW4ELP6I=; b=TC/3DihhJz59kTJ6oMZEGYSuP3ErY4yWORxVphTCpBmk4ul4+hcos+EqRMVQU6GfTS/+Nj6YxEDDHg4RFj0ldJxHFoBYiwxz/TT1J9t1EGdffgq4ORDwPmfRu6cjUoM6d4vVKMVgAnqZ0QUi7twToQsSZfkezykm/pqA0ccx+C0= 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 1571415130033191.6259859615858; Fri, 18 Oct 2019 09:12:10 -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 8A7B2308421A; Fri, 18 Oct 2019 16:12:08 +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 5EAD360BFB; Fri, 18 Oct 2019 16:12:08 +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 10D141803B4D; Fri, 18 Oct 2019 16:12:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGBsmc004750 for ; Fri, 18 Oct 2019 12:11:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 751F2600C8; Fri, 18 Oct 2019 16:11:54 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB682600C4; Fri, 18 Oct 2019 16:11:53 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:11:06 +0200 Message-Id: <9872d98125e8cfa691b8d2910f6c38048ae4fe9b.1571414890.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 21/40] conf: checkpoint: Don't clear current checkpoint when redefining 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.40]); Fri, 18 Oct 2019 16:12:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" If we are updating the current checkpoint when redefining by mentioning the current checkpoint as a parent of the newly redefined one we don't have to clear it first. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/checkpoint_conf.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/conf/checkpoint_conf.c b/src/conf/checkpoint_conf.c index 7f2cfd7f4c..cbff2a0db0 100644 --- a/src/conf/checkpoint_conf.c +++ b/src/conf/checkpoint_conf.c @@ -562,10 +562,8 @@ virDomainCheckpointRedefinePrep(virDomainObjPtr vm, if (def->parent.parent_name && (parent =3D virDomainCheckpointFindByName(vm->checkpoints, def->parent.parent_name))= ) { - if (parent =3D=3D virDomainCheckpointGetCurrent(vm->checkpoints)) { + if (parent =3D=3D virDomainCheckpointGetCurrent(vm->checkpoints)) *update_current =3D true; - virDomainCheckpointSetCurrent(vm->checkpoints, NULL); - } } other =3D virDomainCheckpointFindByName(vm->checkpoints, def->parent.n= ame); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415128; cv=none; d=zoho.com; s=zohoarc; b=KvCj8MYSeycnkCT3NgWMTp9MNUqckwWi2+3O0GHbjFn+rvSHIadbFvG9oTOpyjZy1uh6ROlMr59Gu29WWdPR96jukibeNjpyF7nw+CwvXrXLKvn8WljTjQEaO/QPHKATJ4/YxiLGwHj77T+XvibTpW5C8O6JB9L9hgmE9YzoZ5k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415128; h=Content-Type:Content-Transfer-Encoding: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; bh=PudGMvGcomlsI14Vt9YlMuHgh4tfOLDMU63hj2Vo7sk=; b=V9B0IbD1X7B66r4QtQU211qNJ1sneZSdKtVjFF69cg4LnWbc/9SrFCCF3z7QtJmLL2mrQCin0Enn9kQsUBBZyzJuQNXb2kGsPPF35yOI6c5G70LGZuU7N+xVdcbKjA0h881nl28nfwujoLZ5oMGS0mW6NfacIpP/lWyp2l3mumw= 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 1571415128824967.1253385793605; Fri, 18 Oct 2019 09:12:08 -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 46B1D300294F; Fri, 18 Oct 2019 16:12:07 +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 19CEF60F8A; Fri, 18 Oct 2019 16:12:07 +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 C8B1C3FB43; Fri, 18 Oct 2019 16:12:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGBtVA004759 for ; Fri, 18 Oct 2019 12:11:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6E9FC60161; Fri, 18 Oct 2019 16:11:55 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id C1D41600C1; Fri, 18 Oct 2019 16:11:54 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:11:07 +0200 Message-Id: <16378247c386e5f07e93c74432fa4664c76566be.1571414890.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 22/40] qemu: checkpoint: Enforce that 'bitmap' name must match checkpoint name 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, 18 Oct 2019 16:12:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Prevent insane configurations by enforcing that disk bitmap for a checkpoint must match the name of the checkpoint. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_checkpoint.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c index a225f04831..54719e7f5c 100644 --- a/src/qemu/qemu_checkpoint.c +++ b/src/qemu/qemu_checkpoint.c @@ -271,6 +271,13 @@ qemuCheckpointPrepare(virQEMUDriverPtr driver, if (disk->type !=3D VIR_DOMAIN_CHECKPOINT_TYPE_BITMAP) continue; + if (STRNEQ(disk->bitmap, def->parent.name)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("bitmap for disk '%s' must match checkpoint n= ame '%s'"), + disk->name, def->parent.name); + goto cleanup; + } + if (vm->def->disks[i]->src->format !=3D VIR_STORAGE_FILE_QCOW2) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("checkpoint for disk %s unsupported " --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415123; cv=none; d=zoho.com; s=zohoarc; b=mINIg0IbAPaoD7xOSq+QHogpZBRthYDYFdjzgCBhH/oy4WSVhz/3FWkgs2n+zfOPFobHPFSjb5oX+O65f49vaKKzTZ7PDihsrJAwxrYOe7yfmGN85IcJyHROpmxU9KlNTY4uaRrIo9d3PQVaQSzr5YFbWfSfz/wbb6Vn35cj++Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415123; h=Content-Type:Content-Transfer-Encoding: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; bh=oWLPEfFw60bBQmmaPL9BwLb6TnFgonwxja08R5/AMF0=; b=Vs9jw7P1j6ZbGPw936swqNAr3Lr2OTzibbJVb2NA+wxohSQckj4dS7HfOpDHmCsXykLf+q4KGdEJyaJu0yPnMHfIX2ne4Y/m0To1kgME+ia/dm5zpUU3HeTiF8JK/vtSmcwrUE/QuhIw6tUDQAK68Z4uHr+IBzEpJrgis/W86J4= 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 1571415123108551.4173881017756; Fri, 18 Oct 2019 09:12:03 -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 8223318C428F; Fri, 18 Oct 2019 16:12:01 +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 5AACD60605; Fri, 18 Oct 2019 16:12:01 +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 217041803517; Fri, 18 Oct 2019 16:12:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGBuiR004765 for ; Fri, 18 Oct 2019 12:11:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6664B6012A; Fri, 18 Oct 2019 16:11:56 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC4E3600C1; Fri, 18 Oct 2019 16:11:55 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:11:08 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 23/40] qemu: checkpoint: Split out checkpoint creation code 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.6.2 (mx1.redhat.com [10.5.110.62]); Fri, 18 Oct 2019 16:12:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Separate out individual steps of creating a checkpoint from qemuCheckpointCreateXML into separate functions. This makes the function more readable and understandable and also some of the new functions will be reusable when we will be creating a checkpoint along with a backup in the upcoming patches. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_checkpoint.c | 160 ++++++++++++++++++++++++------------- src/qemu/qemu_checkpoint.h | 8 ++ 2 files changed, 111 insertions(+), 57 deletions(-) diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c index 54719e7f5c..946ae78368 100644 --- a/src/qemu/qemu_checkpoint.c +++ b/src/qemu/qemu_checkpoint.c @@ -348,6 +348,90 @@ qemuCheckpointAddActions(virDomainObjPtr vm, } +static virDomainMomentObjPtr +qemuCheckpointRedefine(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virDomainCheckpointDefPtr *def, + bool *update_current) +{ + virDomainMomentObjPtr chk =3D NULL; + + if (virDomainCheckpointRedefinePrep(vm, def, &chk, driver->xmlopt, + update_current) < 0) + return NULL; + + /* XXX Should we validate that the redefined checkpoint even + * makes sense, such as checking that qemu-img recognizes the + * checkpoint bitmap name in at least one of the domain's disks? */ + + if (chk) + return chk; + + chk =3D virDomainCheckpointAssignDef(vm->checkpoints, *def); + *def =3D NULL; + return chk; +} + + +int +qemuCheckpointCreateCommon(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virCapsPtr caps, + virDomainCheckpointDefPtr *def, + virJSONValuePtr *actions, + virDomainMomentObjPtr *chk) +{ + g_autoptr(virJSONValue) tmpactions =3D NULL; + virDomainMomentObjPtr parent; + + if (qemuCheckpointPrepare(driver, caps, vm, *def) < 0) + return -1; + + if ((parent =3D virDomainCheckpointGetCurrent(vm->checkpoints))) { + if (VIR_STRDUP((*def)->parent.parent_name, parent->def->name) < 0) + return -1; + } + + if (!(tmpactions =3D virJSONValueNewArray())) + return -1; + + if (qemuCheckpointAddActions(vm, tmpactions, parent, *def) < 0) + return -1; + + if (!(*chk =3D virDomainCheckpointAssignDef(vm->checkpoints, *def))) + return -1; + + *def =3D NULL; + + *actions =3D g_steal_pointer(&tmpactions); + return 0; +} + + +static virDomainMomentObjPtr +qemuCheckpointCreate(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virCapsPtr caps, + virDomainCheckpointDefPtr *def) +{ + g_autoptr(virJSONValue) actions =3D NULL; + virDomainMomentObjPtr chk =3D NULL; + int rc; + + if (qemuCheckpointCreateCommon(driver, vm, caps, def, &actions, &chk) = < 0) + return NULL; + + qemuDomainObjEnterMonitor(driver, vm); + rc =3D qemuMonitorTransaction(qemuDomainGetMonitor(vm), &actions); + if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) { + virDomainCheckpointObjListRemove(vm->checkpoints, chk); + return NULL; + } + + return chk; +} + + virDomainCheckpointPtr qemuCheckpointCreateXML(virDomainPtr domain, virDomainObjPtr vm, @@ -361,11 +445,8 @@ qemuCheckpointCreateXML(virDomainPtr domain, bool update_current =3D true; bool redefine =3D flags & VIR_DOMAIN_CHECKPOINT_CREATE_REDEFINE; unsigned int parse_flags =3D 0; - virDomainMomentObjPtr other =3D NULL; g_autoptr(virQEMUDriverConfig) cfg =3D NULL; g_autoptr(virCaps) caps =3D NULL; - g_autoptr(virJSONValue) actions =3D NULL; - int ret; g_autoptr(virDomainCheckpointDef) def =3D NULL; virCheckFlags(VIR_DOMAIN_CHECKPOINT_CREATE_REDEFINE, NULL); @@ -400,44 +481,30 @@ qemuCheckpointCreateXML(virDomainPtr domain, return NULL; if (redefine) { - if (virDomainCheckpointRedefinePrep(vm, &def, &chk, - driver->xmlopt, - &update_current) < 0) - goto endjob; - } else if (qemuCheckpointPrepare(driver, caps, vm, def) < 0) { - goto endjob; + chk =3D qemuCheckpointRedefine(driver, vm, &def, &update_current); + } else { + chk =3D qemuCheckpointCreate(driver, vm, caps, &def); } - if (!chk) { - if (!(chk =3D virDomainCheckpointAssignDef(vm->checkpoints, def))) - goto endjob; - - def =3D NULL; - } + if (!chk) + goto endjob; - other =3D virDomainCheckpointGetCurrent(vm->checkpoints); - if (other) { - if (!redefine && - VIR_STRDUP(chk->def->parent_name, other->def->name) < 0) - goto endjob; + if (update_current) + virDomainCheckpointSetCurrent(vm->checkpoints, chk); + + if (qemuCheckpointWriteMetadata(vm, chk, driver->caps, + driver->xmlopt, + cfg->checkpointDir) < 0) { + /* if writing of metadata fails, error out rather than trying + * to silently carry on without completing the checkpoint */ + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unable to save metadata for checkpoint %s"), + chk->def->name); + virDomainCheckpointObjListRemove(vm->checkpoints, chk); + goto endjob; } - /* actually do the checkpoint */ - if (redefine) { - /* XXX Should we validate that the redefined checkpoint even - * makes sense, such as checking that qemu-img recognizes the - * checkpoint bitmap name in at least one of the domain's disks? = */ - } else { - if (!(actions =3D virJSONValueNewArray())) - goto endjob; - if (qemuCheckpointAddActions(vm, actions, other, - virDomainCheckpointObjGetDef(chk)) < = 0) - goto endjob; - qemuDomainObjEnterMonitor(driver, vm); - ret =3D qemuMonitorTransaction(priv->mon, &actions); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || ret < 0) - goto endjob; - } + virDomainCheckpointLinkParent(vm->checkpoints, chk); /* If we fail after this point, there's not a whole lot we can do; * we've successfully created the checkpoint, so we have to go @@ -446,27 +513,6 @@ qemuCheckpointCreateXML(virDomainPtr domain, checkpoint =3D virGetDomainCheckpoint(domain, chk->def->name); endjob: - if (checkpoint) { - if (update_current) - virDomainCheckpointSetCurrent(vm->checkpoints, chk); - if (qemuCheckpointWriteMetadata(vm, chk, driver->caps, - driver->xmlopt, - cfg->checkpointDir) < 0) { - /* if writing of metadata fails, error out rather than trying - * to silently carry on without completing the checkpoint */ - virObjectUnref(checkpoint); - checkpoint =3D NULL; - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unable to save metadata for checkpoint %s"), - chk->def->name); - virDomainCheckpointObjListRemove(vm->checkpoints, chk); - } else { - virDomainCheckpointLinkParent(vm->checkpoints, chk); - } - } else if (chk) { - virDomainCheckpointObjListRemove(vm->checkpoints, chk); - } - qemuDomainObjEndJob(driver, vm); return checkpoint; diff --git a/src/qemu/qemu_checkpoint.h b/src/qemu/qemu_checkpoint.h index 49f51b1fdd..7fcbc99541 100644 --- a/src/qemu/qemu_checkpoint.h +++ b/src/qemu/qemu_checkpoint.h @@ -53,3 +53,11 @@ int qemuCheckpointDelete(virDomainObjPtr vm, virDomainCheckpointPtr checkpoint, unsigned int flags); + +int +qemuCheckpointCreateCommon(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virCapsPtr caps, + virDomainCheckpointDefPtr *def, + virJSONValuePtr *actions, + virDomainMomentObjPtr *chk); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415134; cv=none; d=zoho.com; s=zohoarc; b=JDkwrZhUsxhutyEt9EQyi40GSiHjbnn1V/5Y0WzTCRkJofDkU20xrHVXa9XWV7vm40Ve14wglNAtvhJMJmQCBCBcHv0dhlLEe8Up575mPaKIq5EwQ2rnG45NDrqWFJ/WXbRevFbomQSTlorIdlLq4o20x1LmZWmL/Hf+SRsV61o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415134; h=Content-Type:Content-Transfer-Encoding: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; bh=+dAwGth5cNshjWpGzpjn/20OF85UGRk5NY5XdpUlw4s=; b=Ng6EppscM7k4qz554nEAJB3SEdGIbD0dtkf9pRz3ttWcnZ7d/c+kEs0NKwFxrXCJWvXt7XzHjGqOuT/lBS4jotZE+ZvWrUg3Rf6d1DWiO3vqUtiRDgYbdP/r40u4Dhh7eJ/L6heXvR0EMAgyua6DvdcwvwBpByXhbuOXEsvD0PU= 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 1571415134262115.10027049212238; Fri, 18 Oct 2019 09:12:14 -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 2A6D72B8C; Fri, 18 Oct 2019 16:12:12 +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 EF73960BF4; Fri, 18 Oct 2019 16:12:11 +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 B17F23FB48; Fri, 18 Oct 2019 16:12:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGBvNp004796 for ; Fri, 18 Oct 2019 12:11:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5C94A6012A; Fri, 18 Oct 2019 16:11:57 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id B30B8600C8; Fri, 18 Oct 2019 16:11:56 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:11:09 +0200 Message-Id: <8e7f5a82005f5bfbdcf1bd90a3bcf23c3cc3b475.1571414890.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 24/40] qemu: checkpoint: Extract finalizing steps of checkpoint creation 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.6.2 (mx1.redhat.com [10.5.110.71]); Fri, 18 Oct 2019 16:12:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Extract the linking and saving bits of checkpoint creation into qemuCheckpointCreateFinalize so that qemuCheckpointCreateXML is a bit simpler and also makes it reusable in the backup code. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_checkpoint.c | 44 +++++++++++++++++++++++++------------- src/qemu/qemu_checkpoint.h | 7 ++++++ 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c index 946ae78368..6a272f9dab 100644 --- a/src/qemu/qemu_checkpoint.c +++ b/src/qemu/qemu_checkpoint.c @@ -432,6 +432,34 @@ qemuCheckpointCreate(virQEMUDriverPtr driver, } +int +qemuCheckpointCreateFinalize(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virQEMUDriverConfigPtr cfg, + virDomainMomentObjPtr chk, + bool update_current) +{ + if (update_current) + virDomainCheckpointSetCurrent(vm->checkpoints, chk); + + if (qemuCheckpointWriteMetadata(vm, chk, driver->caps, + driver->xmlopt, + cfg->checkpointDir) < 0) { + /* if writing of metadata fails, error out rather than trying + * to silently carry on without completing the checkpoint */ + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unable to save metadata for checkpoint %s"), + chk->def->name); + virDomainCheckpointObjListRemove(vm->checkpoints, chk); + return -1; + } + + virDomainCheckpointLinkParent(vm->checkpoints, chk); + + return 0; +} + + virDomainCheckpointPtr qemuCheckpointCreateXML(virDomainPtr domain, virDomainObjPtr vm, @@ -489,22 +517,8 @@ qemuCheckpointCreateXML(virDomainPtr domain, if (!chk) goto endjob; - if (update_current) - virDomainCheckpointSetCurrent(vm->checkpoints, chk); - - if (qemuCheckpointWriteMetadata(vm, chk, driver->caps, - driver->xmlopt, - cfg->checkpointDir) < 0) { - /* if writing of metadata fails, error out rather than trying - * to silently carry on without completing the checkpoint */ - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unable to save metadata for checkpoint %s"), - chk->def->name); - virDomainCheckpointObjListRemove(vm->checkpoints, chk); + if (qemuCheckpointCreateFinalize(driver, vm, cfg, chk, update_current)= < 0) goto endjob; - } - - virDomainCheckpointLinkParent(vm->checkpoints, chk); /* If we fail after this point, there's not a whole lot we can do; * we've successfully created the checkpoint, so we have to go diff --git a/src/qemu/qemu_checkpoint.h b/src/qemu/qemu_checkpoint.h index 7fcbc99541..d0ea8f000f 100644 --- a/src/qemu/qemu_checkpoint.h +++ b/src/qemu/qemu_checkpoint.h @@ -61,3 +61,10 @@ qemuCheckpointCreateCommon(virQEMUDriverPtr driver, virDomainCheckpointDefPtr *def, virJSONValuePtr *actions, virDomainMomentObjPtr *chk); + +int +qemuCheckpointCreateFinalize(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virQEMUDriverConfigPtr cfg, + virDomainMomentObjPtr chk, + bool update_current); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415127; cv=none; d=zoho.com; s=zohoarc; b=fXjdjrA+x0PyxbXj3fBvZPsWADL7w6r4Q441mFUXOlwmOMRGT5WPwUxgpRPcubBQcwS3Q5mlQuGHr4Rj2YbIrBZk/FfpLJuGCjAZb+toZW6eZXLlKaGboFM47FQ2zEmuHhlVHDME+S1PGERosD0XMNlflJNymDMSTz74P06pqw0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415127; h=Content-Type:Content-Transfer-Encoding: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; bh=1EobUcMZYRafaWIkltocvkXTn7XhjelVFJPnpqR0LoQ=; b=PIcqKvi3WRI38H4CicdYl/9UmIcpIip5+Glz+feF35r4VKXXtH6dxU4j0yRKDjLAB5y+MSTWRP0AAVsHhMfRbGszvvKo9jgIP75l4EMZAmibwW0/u/69nzbyFvXpKgbOIk6OiJ99FkY7V1Mnely3ftq4s/46NgMlGHKcDyYuBOY= 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 1571415127178477.0949635079512; Fri, 18 Oct 2019 09:12:07 -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 8D163C024AEE; Fri, 18 Oct 2019 16:12:05 +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 5724A60BFB; Fri, 18 Oct 2019 16:12:05 +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 F10BD1803B48; Fri, 18 Oct 2019 16:12:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGBwNr004825 for ; Fri, 18 Oct 2019 12:11:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 545DF6012A; Fri, 18 Oct 2019 16:11:58 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id AAD71600C1; Fri, 18 Oct 2019 16:11:57 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:11:10 +0200 Message-Id: <65fa8f4bdbb21b4cef23f23627abd9ec58ff4cd0.1571414890.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 25/40] qemu: monitor: Add helper for generating data for block bitmap merging 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.32]); Fri, 18 Oct 2019 16:12:06 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Introduce qemuMonitorTransactionBitmapMergeSourceAddBitmap which adds the appropriate entry into a virJSONValue array to be used with qemuMonitorTransactionBitmapMerge. Bitmap merging supports two possible formats and this new helper implements the more universal one specifying also the source node name. In addition use the new helper in the testQemuMonitorJSONTransaction test. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_monitor.c | 9 +++++++++ src/qemu/qemu_monitor.h | 4 ++++ src/qemu/qemu_monitor_json.c | 21 +++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 5 +++++ tests/qemumonitorjsontest.c | 4 ++-- 5 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 8de386817b..57229a68c0 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4551,6 +4551,15 @@ qemuMonitorTransactionBitmapMerge(virJSONValuePtr ac= tions, } +int +qemuMonitorTransactionBitmapMergeSourceAddBitmap(virJSONValuePtr sources, + const char *sourcenode, + const char *sourcebitmap) +{ + return qemuMonitorJSONTransactionBitmapMergeSourceAddBitmap(sources, s= ourcenode, sourcebitmap); +} + + int qemuMonitorTransactionSnapshotLegacy(virJSONValuePtr actions, const char *device, diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 45f2a5a7d2..a1c980e40e 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1364,6 +1364,10 @@ qemuMonitorTransactionBitmapMerge(virJSONValuePtr ac= tions, const char *node, const char *target, virJSONValuePtr *sources); +int +qemuMonitorTransactionBitmapMergeSourceAddBitmap(virJSONValuePtr sources, + const char *sourcenode, + const char *sourcebitmap); int qemuMonitorTransactionSnapshotLegacy(virJSONValuePtr actions, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 0062816e3e..545911069e 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -9199,6 +9199,27 @@ qemuMonitorJSONTransactionBitmapMerge(virJSONValuePt= r actions, } +int +qemuMonitorJSONTransactionBitmapMergeSourceAddBitmap(virJSONValuePtr sourc= es, + const char *sourcenod= e, + const char *sourcebit= map) +{ + g_autoptr(virJSONValue) sourceobj =3D NULL; + + if (virJSONValueObjectCreate(&sourceobj, + "s:node", sourcenode, + "s:name", sourcebitmap, + NULL) < 0) + return -1; + + if (virJSONValueArrayAppend(sources, sourceobj) < 0) + return -1; + + sourceobj =3D NULL; + return 0; +} + + int qemuMonitorJSONTransactionSnapshotLegacy(virJSONValuePtr actions, const char *device, diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index d74ef91b83..6617783797 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -652,6 +652,11 @@ qemuMonitorJSONTransactionBitmapMerge(virJSONValuePtr = actions, const char *target, virJSONValuePtr *sources); +int +qemuMonitorJSONTransactionBitmapMergeSourceAddBitmap(virJSONValuePtr sourc= es, + const char *sourcenod= e, + const char *sourcebit= map); + int qemuMonitorJSONTransactionSnapshotLegacy(virJSONValuePtr actions, const char *device, diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 4f15d231f9..cefa0f08cf 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -2982,8 +2982,8 @@ testQemuMonitorJSONTransaction(const void *opaque) !(mergebitmaps =3D virJSONValueNewArray())) return -1; - if (virJSONValueArrayAppendString(mergebitmaps, "mergemap1") < 0 || - virJSONValueArrayAppendString(mergebitmaps, "mergemap2") < 0) + if (qemuMonitorTransactionBitmapMergeSourceAddBitmap(mergebitmaps, "no= de1", "bitmap1") < 0 || + qemuMonitorTransactionBitmapMergeSourceAddBitmap(mergebitmaps, "no= de2", "bitmap2") < 0) return -1; if (qemuMonitorTransactionBitmapAdd(actions, "node1", "bitmap1", true,= true) < 0 || --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415137; cv=none; d=zoho.com; s=zohoarc; b=BufkR9L2Q2oajkpWE4d5Xgjf0OO9SqjL0/p2MpkN5q4qUj+z3Puy/4wKdb2zcT5mFojZyBmKVK01jonfyBBKwYp/53IGlxQWdBq6gWMY9cAOtteWbQsDzV6qlefnrXmX6o/hDREyAymMJRHJDJoEdQi0QWD11LutGH6ed6bpoGY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415137; h=Content-Type:Content-Transfer-Encoding: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; bh=GRL7UMFRtV7CROLD6XMpSWEH1eRrKcnmbC489omE8xA=; b=VxhmJRbBGPQagmWyZRbFIrtY/4qbkYiyqWUzuZ+0fx2klDPZWaRkeLo3njQG1goduzvrQ7/d6of36KDL2wd3LmaG6z6zUeaWkcqH04VJWa3uwt4m42gPhfDaBM7kI/0H41Zeqlo7mH2FlvYajQJeHo1riWkcLZdUvc/3quI/4XQ= 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 1571415137467781.4394514737879; Fri, 18 Oct 2019 09:12:17 -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 C831F315C000; Fri, 18 Oct 2019 16:12:15 +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 9BF105C290; Fri, 18 Oct 2019 16:12: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 411C53FB4D; Fri, 18 Oct 2019 16:12:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGBxrT004863 for ; Fri, 18 Oct 2019 12:11:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4A28A600C8; Fri, 18 Oct 2019 16:11:59 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id A1862600C1; Fri, 18 Oct 2019 16:11:58 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:11:11 +0200 Message-Id: <9081b5150aa7e0d0588b30e418e5ca595d2eb53a.1571414890.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 26/40] qemu: checkpoint: Use qemuMonitorTransactionBitmapMergeSourceAddBitmap 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, 18 Oct 2019 16:12:16 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Use the new helper in qemuCheckpointDiscard rather than constructing the array manually. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_checkpoint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c index 6a272f9dab..937d9d6b3e 100644 --- a/src/qemu/qemu_checkpoint.c +++ b/src/qemu/qemu_checkpoint.c @@ -173,7 +173,7 @@ qemuCheckpointDiscard(virQEMUDriverPtr driver, if (!(arr =3D virJSONValueNewArray())) return -1; - if (virJSONValueArrayAppendString(arr, disk->bitmap) <= 0) + if (qemuMonitorTransactionBitmapMergeSourceAddBitmap(a= rr, node, disk->bitmap) < 0) return -1; if (chk =3D=3D virDomainCheckpointGetCurrent(vm->check= points)) { --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415133; cv=none; d=zoho.com; s=zohoarc; b=NFpzvIQdVDO2R0l21kwd3XeAkx1P7n70PBlKC9SOa4ZlDJya45LC1XS0WgBX1op06CNxVmF7SvkZrYYKIY62G6MTelI42MqO4hHUxPm3ZKreFjtEzX8XDa0OW/fBuJ4qNAAUzdpW8yyfGuIn1pLz00GQENINn8p52c2aZIexyyM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415133; h=Content-Type:Content-Transfer-Encoding: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; bh=H9vXgy7rirLHFD0UUL3f4/vETyUlR5Osq37DNwgDZlM=; b=JHYFLhyjVPrseYTnyimbOVQjlf956ZTQIWfacUWH4c00EphDcBUvuHAbm6teX18sj/GQp7bW6G6Wkb/R+yCDJ7yuy36gJStCNhFgAbb0fTrA2zc6KtEbKNy+17O1E+a1Rx8+yZwqroV+cGyRALoEoJ2zx2DgPSI2tFUh4nH3hMM= 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 1571415133063875.015762968198; Fri, 18 Oct 2019 09:12:13 -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 04E9F4FCCE; Fri, 18 Oct 2019 16:12:11 +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 D19FE601B3; Fri, 18 Oct 2019 16:12:10 +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 88AF93FB46; Fri, 18 Oct 2019 16:12:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGC0GC004889 for ; Fri, 18 Oct 2019 12:12:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 40E2260167; Fri, 18 Oct 2019 16:12:00 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 96C72600C8; Fri, 18 Oct 2019 16:11:59 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:11:12 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 27/40] qemu: blockjob: Refactor qemuBlockJobEventProcessConcludedTransition 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.30]); Fri, 18 Oct 2019 16:12:12 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Use only one switch case selecting job type and decide what's successful outcome on a case-by-case basis. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_blockjob.c | 81 ++++++++++++---------------------------- 1 file changed, 23 insertions(+), 58 deletions(-) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index f9b3bdaff4..127a04e840 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -1254,75 +1254,40 @@ qemuBlockJobEventProcessConcludedTransition(qemuBlo= ckJobDataPtr job, virDomainObjPtr vm, qemuDomainAsyncJob asyncJob) { - switch ((qemuBlockjobState) job->newstate) { - case QEMU_BLOCKJOB_STATE_COMPLETED: - switch ((qemuBlockJobType) job->type) { - case QEMU_BLOCKJOB_TYPE_PULL: + bool success =3D job->newstate =3D=3D QEMU_BLOCKJOB_STATE_COMPLETED; + + switch ((qemuBlockJobType) job->type) { + case QEMU_BLOCKJOB_TYPE_PULL: + if (success) qemuBlockJobProcessEventCompletedPull(driver, vm, job, asyncJo= b); - break; + break; - case QEMU_BLOCKJOB_TYPE_COMMIT: + case QEMU_BLOCKJOB_TYPE_COMMIT: + if (success) qemuBlockJobProcessEventCompletedCommit(driver, vm, job, async= Job); - break; - - case QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT: - qemuBlockJobProcessEventCompletedActiveCommit(driver, vm, job,= asyncJob); - break; - - case QEMU_BLOCKJOB_TYPE_CREATE: - qemuBlockJobProcessEventConcludedCreate(driver, vm, job, async= Job); - break; - - case QEMU_BLOCKJOB_TYPE_COPY: - if (job->state =3D=3D QEMU_BLOCKJOB_STATE_PIVOTING) - qemuBlockJobProcessEventConcludedCopyPivot(driver, vm, job= , asyncJob); - else - qemuBlockJobProcessEventConcludedCopyAbort(driver, vm, job= , asyncJob); - break; - - case QEMU_BLOCKJOB_TYPE_NONE: - case QEMU_BLOCKJOB_TYPE_INTERNAL: - case QEMU_BLOCKJOB_TYPE_LAST: - default: - break; - } break; - case QEMU_BLOCKJOB_STATE_FAILED: - case QEMU_BLOCKJOB_STATE_CANCELLED: - switch ((qemuBlockJobType) job->type) { - case QEMU_BLOCKJOB_TYPE_PULL: - case QEMU_BLOCKJOB_TYPE_COMMIT: - break; - - case QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT: + case QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT: + if (success) + qemuBlockJobProcessEventCompletedActiveCommit(driver, vm, job,= asyncJob); + else qemuBlockJobProcessEventFailedActiveCommit(driver, vm, job); - break; + break; - case QEMU_BLOCKJOB_TYPE_CREATE: - qemuBlockJobProcessEventConcludedCreate(driver, vm, job, async= Job); - break; + case QEMU_BLOCKJOB_TYPE_CREATE: + qemuBlockJobProcessEventConcludedCreate(driver, vm, job, asyncJob); + break; - case QEMU_BLOCKJOB_TYPE_COPY: + case QEMU_BLOCKJOB_TYPE_COPY: + if (job->state =3D=3D QEMU_BLOCKJOB_STATE_PIVOTING && success) + qemuBlockJobProcessEventConcludedCopyPivot(driver, vm, job, as= yncJob); + else qemuBlockJobProcessEventConcludedCopyAbort(driver, vm, job, as= yncJob); - break; - - case QEMU_BLOCKJOB_TYPE_NONE: - case QEMU_BLOCKJOB_TYPE_INTERNAL: - case QEMU_BLOCKJOB_TYPE_LAST: - default: - break; - } break; - /* states below are impossible in this handler */ - case QEMU_BLOCKJOB_STATE_READY: - case QEMU_BLOCKJOB_STATE_NEW: - case QEMU_BLOCKJOB_STATE_RUNNING: - case QEMU_BLOCKJOB_STATE_CONCLUDED: - case QEMU_BLOCKJOB_STATE_ABORTING: - case QEMU_BLOCKJOB_STATE_PIVOTING: - case QEMU_BLOCKJOB_STATE_LAST: + case QEMU_BLOCKJOB_TYPE_NONE: + case QEMU_BLOCKJOB_TYPE_INTERNAL: + case QEMU_BLOCKJOB_TYPE_LAST: default: break; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415136; cv=none; d=zoho.com; s=zohoarc; b=Hp8FNfFknRsfEdR0ZEt5oQb/W4sLPWOV3a4Af0OKRtQWYSVpLyHOENdP6NNXQZPVpswhNIdqMhMKCHup54EyPXj/ARUXa+cksdPpSYGsmzEQAWUq0VJ2VGFNpaGQM9s/iNpn/E3Hx4QpSuhWaiukDveiXN0Awk/eYkxjmJPTWiw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415136; h=Content-Type:Content-Transfer-Encoding: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; bh=U6xhCpCdtdIA+E6dOdnLaxQtZMk64741AYLzsl2sCPU=; b=PaEXtP6Ny7pPpqNj7yAsmAR1qyTPzB4U0Kx5jKpPN5VQuMMdT6r4r9NWf7O2tSMzatZmddySzN0VYdnGx8iKP5rHVlugxjbk/m2VScvO722rS9+UlTe0e87EPLkgnHUjBwnIkBRV2uCL6eAVupBKF9vPd+tYmldjPu3yWNvF8nA= 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 157141513610449.12774257155911; Fri, 18 Oct 2019 09:12:16 -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 80C43315C036; Fri, 18 Oct 2019 16:12:14 +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 573DB60BF4; Fri, 18 Oct 2019 16:12:14 +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 171481803B4C; Fri, 18 Oct 2019 16:12:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGCAMT005141 for ; Fri, 18 Oct 2019 12:12:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id D003B60167; Fri, 18 Oct 2019 16:12:10 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8DE80600C1; Fri, 18 Oct 2019 16:12:00 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:11:13 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 28/40] qemu: blockjob: Use 'g_free' in qemuBlockJobDataDispose 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.41]); Fri, 18 Oct 2019 16:12:15 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Prepare the function for addition of new members to clean. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_blockjob.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index 127a04e840..e12dcde729 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -82,8 +82,8 @@ qemuBlockJobDataDispose(void *obj) if (job->type =3D=3D QEMU_BLOCKJOB_TYPE_CREATE) virObjectUnref(job->data.create.src); - VIR_FREE(job->name); - VIR_FREE(job->errmsg); + g_free(job->name); + g_free(job->errmsg); } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415140; cv=none; d=zoho.com; s=zohoarc; b=cYw+92RJbjqjk3Gzi9Nd5YxMJ652V4qsizADz8P47auxv/bR7CzPsWCZQq2aQCcJ42ASRct+bOXQb5YDF+gFOuZ3bDyqU0bDUGcEydQPUIvmeSUplbNNeG3s/0PcJhlcTcxgGBfY1UVvvvOUM9ODog3WjHRxuDkBW94BHBt7aGQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415140; h=Content-Type:Content-Transfer-Encoding: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; bh=Huiewkj4c7sgCrE/jgLVyEVZGlL54hlGEtAx9qlj7FQ=; b=Nfu4dnr1oU2U2NFnhkL/szbxdJ3vRsfOEI4Im+qvAPUrK9Q3Gj4domAFE+i6wPjMPXBsr+XxTPcD7kPWzzjWAFr+eI5w/a5eLNiE48KfzPEeK8j8kia9nTSmDPyS5jwp8RP2yw9x4AR3SWXZwa6dV6wNp8cJDJo9dLBeQgLvgyc= 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 1571415140215184.06468461949999; Fri, 18 Oct 2019 09:12:20 -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 57A398AE40; Fri, 18 Oct 2019 16:12:18 +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 2A2703DE5; Fri, 18 Oct 2019 16:12: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 D65CF1803B53; Fri, 18 Oct 2019 16:12:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGCGbR005195 for ; Fri, 18 Oct 2019 12:12:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id DD5176012A; Fri, 18 Oct 2019 16:12:16 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 16903600C1; Fri, 18 Oct 2019 16:12:10 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:11:14 +0200 Message-Id: <21996dbe271580887bb2b4d319459b40a93f9d84.1571414890.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 29/40] backup: Document new XML for backups 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.25]); Fri, 18 Oct 2019 16:12:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" From: Eric Blake Prepare for new backup APIs by describing the XML that will represent a backup. The XML resembles snapshots and checkpoints in being able to select actions for a set of disks, but has other differences. It can support both push model (the hypervisor does the backup directly into the destination file) and pull model (the hypervisor exposes an access port for a third party to grab what is necessary). Add testsuite coverage for some minimal uses of the XML. The element within tries to model the same elements as a under , but sharing the RNG grammar proved to be hairy. That is in part because while use to describe a host resource in use by the guest, a backup job is using a host resource that is not visible to the guest: a push backup action is instead describing a (which ultimately could be a remote network resource, but for simplicity the RNG just validates a local file for now), and a pull backup action is instead describing a temporary local file (which probably should not be a remote resource). A future refactoring may thus introduce some way to parameterize RNG to accept ... so that the name of the subelement can be for domain, or or as needed for backups. Future patches may improve this area of code. Signed-off-by: Eric Blake --- docs/docs.html.in | 3 +- docs/format.html.in | 1 + docs/formatbackup.html.in | 168 ++++++++++++++ docs/formatcheckpoint.html.in | 12 +- docs/index.html.in | 3 +- docs/schemas/domainbackup.rng | 219 +++++++++++++++++++ libvirt.spec.in | 1 + mingw-libvirt.spec.in | 2 + tests/Makefile.am | 2 + tests/domainbackupxml2xmlin/backup-pull.xml | 9 + tests/domainbackupxml2xmlin/backup-push.xml | 9 + tests/domainbackupxml2xmlin/empty.xml | 1 + tests/domainbackupxml2xmlout/backup-pull.xml | 9 + tests/domainbackupxml2xmlout/backup-push.xml | 9 + tests/domainbackupxml2xmlout/empty.xml | 7 + tests/virschematest.c | 2 + 16 files changed, 449 insertions(+), 8 deletions(-) create mode 100644 docs/formatbackup.html.in create mode 100644 docs/schemas/domainbackup.rng create mode 100644 tests/domainbackupxml2xmlin/backup-pull.xml create mode 100644 tests/domainbackupxml2xmlin/backup-push.xml create mode 100644 tests/domainbackupxml2xmlin/empty.xml create mode 100644 tests/domainbackupxml2xmlout/backup-pull.xml create mode 100644 tests/domainbackupxml2xmlout/backup-push.xml create mode 100644 tests/domainbackupxml2xmlout/empty.xml diff --git a/docs/docs.html.in b/docs/docs.html.in index 6cf09f51bc..6eb85b8d25 100644 --- a/docs/docs.html.in +++ b/docs/docs.html.in @@ -82,7 +82,8 @@ node devices, secrets, snapshots, - checkpoints + checkpoints, + backup jobs
URI format
The URI formats used for connecting to libvirt
diff --git a/docs/format.html.in b/docs/format.html.in index 3be2237663..d013528fe0 100644 --- a/docs/format.html.in +++ b/docs/format.html.in @@ -27,6 +27,7 @@
  • Secrets
  • Snapshots
  • Checkpoints
  • +
  • Backup jobs
  • Command line validation

    diff --git a/docs/formatbackup.html.in b/docs/formatbackup.html.in new file mode 100644 index 0000000000..272d9cf6ab --- /dev/null +++ b/docs/formatbackup.html.in @@ -0,0 +1,168 @@ + + + + +

    Backup XML format

    + +
      + +

      Backup XML

      + +

      + Creating a backup, whether full or incremental, is done + via virDomainBackupBegin(), which takes an XML + description of the actions to perform, as well as an optional + second XML document describing a + checkpoint to create at the same point in time. See + also a comparison between + the various state capture APIs. +

      +

      + There are two general modes for backups: a push mode (where the + hypervisor writes out the data to the destination file, which + may be local or remote), and a pull mode (where the hypervisor + creates an NBD server that a third-party client can then read as + needed, and which requires the use of temporary storage, + typically local, until the backup is complete). +

      +

      + The instructions for beginning a backup job are provided as + attributes and elements of the + top-level domainbackup element. This element + includes an optional attribute mode which can be + either "push" or "pull" (default + push). virDomainBackupGetXMLDesc() can be used to + see the actual values selected for elements omitted during + creation (for example, learning which port the NBD server is + using in the pull model or what file names libvirt generated + when none were supplied). The following child elements and attributes + are supported: +

      +
      +
      attribute id
      +
      Ignored on input, this element is the job id of the backup + operation returned on success + from virDomainBackupBegin(), and is used for + selecting which backup operation to target + during virDomainBackupGetXMLDesc() + and virDomainBackupEnd().
      +
      incremental
      +
      An optional element giving the name of an existing + checkpoint of the domain, which will be used to make this + backup an incremental one. In the push model, only changes + since the named checkpoint are written to the destination. In + the pull model, the NBD server uses the + NBD_OPT_SET_META_CONTEXT extension to advertise to the client + which portions of the export contain changes since the named + checkpoint. If omitted, a full backup is performed. +
      +
      server
      +
      Present only for a pull mode backup. Contains the same + attributes as + the protocol + element of a disk attached via NBD in the domain (such as + transport, socket, name, port, or tls), necessary to set up an + NBD server that exposes the content of each disk at the time + the backup is started. +
      +
      disks
      +
      An optional listing of instructions for disks participating + in the backup (if omitted, all disks participate and libvirt + attempts to generate filenames by appending the current + timestamp as a suffix). If the entire element was omitted on + input, then all disks participate in the backup, otherwise, + only the disks explicitly listed which do not also + use backup=3D'no' will participate. On output, this + is the state of each of the domain's disk in relation to the + backup operation. +
      +
      disk
      +
      This sub-element describes the backup properties of a + specific disk, with the following attributes and child + elements: +
      +
      name
      +
      A mandatory attribute which must match + the <target dev=3D'name'/> + of one of + the disk + devices specified for the domain at the time of + the checkpoint.
      +
      backup
      +
      Setting this attribute to yes(default) spec= ifies + that the disk should take part in the backup and using + no excludes the disk from the backup.
      +
      type
      +
      A mandatory attribute to describe the type of the + disk, except when backup=3D'no' is + used. Valid values include file, + block, or network. + Similar to a disk declaration for a domain, the choice of = type + controls what additional sub-elements are needed to descri= be + the destination (such as protocol for a + network destination).
      +
      target
      +
      Valid only for push mode backups, this is the + primary sub-element that describes the file name of + the backup destination, similar to + the source sub-element of a domain + disk. An optional sub-element driver can + also be used, with an attribute type to + specify a destination format different from + qcow2.
      +
      scratch
      +
      Valid only for pull mode backups, this is the + primary sub-element that describes the file name of + the local scratch file to be used in facilitating the + backup, and is similar to the source + sub-element of a domain disk.
      +
      +
      +
      +
      +
      + +

      Examples

      + +

      Use virDomainBackupBegin() to perform a full + backup using push mode. The example lets libvirt pick the + destination and format for 'vda', fully specifies that we want a + raw backup of 'vdb', and omits 'vdc' from the operation. +

      +
      +<domainbackup>
      +  <disks/>
      +    <disk name=3D'vda' backup=3D'yes'/>
      +    <disk name=3D'vdb' type=3D'file'>
      +      <target file=3D'/path/to/vdb.backup'/>
      +      <driver type=3D'raw'/>
      +    </disk>
      +    <disk name=3D'vdc' backup=3D'no'/>
      +  </disks/>
      +</domainbackup>
      +    
      + +

      If the previous full backup also passed a parameter describing + checkpoint XML that resulted + in a checkpoint named 1525889631, we can make + another call to virDomainBackupBegin() to perform + an incremental backup of just the data changed since that + checkpoint, this time using the following XML to start a pull + model export of the 'vda' and 'vdb' disks, where a third-party + NBD client connecting to '/path/to/server' completes the backup + (omitting 'vdc' from the explicit list has the same effect as + the backup=3D'no' from the previous example): +

      +
      +<domainbackup mode=3D"pull">
      +  <incremental>1525889631</incremental>
      +  <server transport=3D"unix" socket=3D"/path/to/server"/>
      +  <disks/>
      +    <disk name=3D'vda' backup=3D'yes' type=3D'file'>
      +      <scratch file=3D'/path/to/file1.scratch'/>
      +    </disk>
      +  </disks/>
      +</domainbackup>
      +    
      + + diff --git a/docs/formatcheckpoint.html.in b/docs/formatcheckpoint.html.in index 044bbfe4b0..ee56194523 100644 --- a/docs/formatcheckpoint.html.in +++ b/docs/formatcheckpoint.html.in @@ -28,12 +28,12 @@ first checkpoint and the second backup operation), it is possible to do an offline reconstruction of the state of the disk at the time of the second backup without having to copy as - much data as a second full backup would require. Future API - additions will make it possible to create checkpoints in - conjunction with a backup - via virDomainBackupBegin() or with an external - snapshot via virDomainSnapshotCreateXML2; but for - now, libvirt exposes enough support to create disk checkpoints + much data as a second full backup would require. Most disk + checkpoints are created in conjunction with a backup + via virDomainBackupBegin(), although a future API + addition of virDomainSnapshotCreateXML2() will also + make this possible when creating external snapshots; however, + libvirt also exposes enough support to create disk checkpoints independently from a backup operation via virDomainCheckpointCreateXML() since 5.6.0. Likewise, the creation of checkpoints when diff --git a/docs/index.html.in b/docs/index.html.in index 7d0ab650e3..26e8406917 100644 --- a/docs/index.html.in +++ b/docs/index.html.in @@ -59,7 +59,8 @@ node devices, secrets, snapshots, - checkpoints + checkpoints, + backup jobs
      Wiki
      Read further community contributed content
      diff --git a/docs/schemas/domainbackup.rng b/docs/schemas/domainbackup.rng new file mode 100644 index 0000000000..92327e7077 --- /dev/null +++ b/docs/schemas/domainbackup.rng @@ -0,0 +1,219 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + push + + + + + + + pull + + + + + + + + tcp + + + + + + + + + + + + + + + + + + unix + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + begin + inprogress + ready + + + + + + + + + + + + + + + + + + + on + + + + + + no + + + + + + + + file + + + + + + + + + + + + + + + + + block + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + file + + + + + + + + + + + + + block + + + + + + + + + + + + + + + + + diff --git a/libvirt.spec.in b/libvirt.spec.in index dcad08cb5f..0565992907 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -1900,6 +1900,7 @@ exit 0 %{_datadir}/libvirt/schemas/capability.rng %{_datadir}/libvirt/schemas/cputypes.rng %{_datadir}/libvirt/schemas/domain.rng +%{_datadir}/libvirt/schemas/domainbackup.rng %{_datadir}/libvirt/schemas/domaincaps.rng %{_datadir}/libvirt/schemas/domaincheckpoint.rng %{_datadir}/libvirt/schemas/domaincommon.rng diff --git a/mingw-libvirt.spec.in b/mingw-libvirt.spec.in index c29f3eeed2..453570fc3c 100644 --- a/mingw-libvirt.spec.in +++ b/mingw-libvirt.spec.in @@ -233,6 +233,7 @@ rm -rf $RPM_BUILD_ROOT%{mingw64_libexecdir}/libvirt-gue= sts.sh %{mingw32_datadir}/libvirt/schemas/capability.rng %{mingw32_datadir}/libvirt/schemas/cputypes.rng %{mingw32_datadir}/libvirt/schemas/domain.rng +%{mingw32_datadir}/libvirt/schemas/domainbackup.rng %{mingw32_datadir}/libvirt/schemas/domaincaps.rng %{mingw32_datadir}/libvirt/schemas/domaincheckpoint.rng %{mingw32_datadir}/libvirt/schemas/domaincommon.rng @@ -324,6 +325,7 @@ rm -rf $RPM_BUILD_ROOT%{mingw64_libexecdir}/libvirt-gue= sts.sh %{mingw64_datadir}/libvirt/schemas/capability.rng %{mingw64_datadir}/libvirt/schemas/cputypes.rng %{mingw64_datadir}/libvirt/schemas/domain.rng +%{mingw64_datadir}/libvirt/schemas/domainbackup.rng %{mingw64_datadir}/libvirt/schemas/domaincaps.rng %{mingw64_datadir}/libvirt/schemas/domaincheckpoint.rng %{mingw64_datadir}/libvirt/schemas/domaincommon.rng diff --git a/tests/Makefile.am b/tests/Makefile.am index a9acd88670..d7459de9b1 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -89,6 +89,8 @@ EXTRA_DIST =3D \ capabilityschemadata \ commanddata \ cputestdata \ + domainbackupxml2xmlin \ + domainbackupxml2xmlout \ domaincapsschemadata \ domainconfdata \ domainschemadata \ diff --git a/tests/domainbackupxml2xmlin/backup-pull.xml b/tests/domainback= upxml2xmlin/backup-pull.xml new file mode 100644 index 0000000000..2ce5cd6711 --- /dev/null +++ b/tests/domainbackupxml2xmlin/backup-pull.xml @@ -0,0 +1,9 @@ + + 1525889631 + + + + + + + diff --git a/tests/domainbackupxml2xmlin/backup-push.xml b/tests/domainback= upxml2xmlin/backup-push.xml new file mode 100644 index 0000000000..1b7d3061fd --- /dev/null +++ b/tests/domainbackupxml2xmlin/backup-push.xml @@ -0,0 +1,9 @@ + + 1525889631 + + + + + + + diff --git a/tests/domainbackupxml2xmlin/empty.xml b/tests/domainbackupxml2= xmlin/empty.xml new file mode 100644 index 0000000000..7ed511f97b --- /dev/null +++ b/tests/domainbackupxml2xmlin/empty.xml @@ -0,0 +1 @@ + diff --git a/tests/domainbackupxml2xmlout/backup-pull.xml b/tests/domainbac= kupxml2xmlout/backup-pull.xml new file mode 100644 index 0000000000..2ce5cd6711 --- /dev/null +++ b/tests/domainbackupxml2xmlout/backup-pull.xml @@ -0,0 +1,9 @@ + + 1525889631 + + + + + + + diff --git a/tests/domainbackupxml2xmlout/backup-push.xml b/tests/domainbac= kupxml2xmlout/backup-push.xml new file mode 100644 index 0000000000..1b7d3061fd --- /dev/null +++ b/tests/domainbackupxml2xmlout/backup-push.xml @@ -0,0 +1,9 @@ + + 1525889631 + + + + + + + diff --git a/tests/domainbackupxml2xmlout/empty.xml b/tests/domainbackupxml= 2xmlout/empty.xml new file mode 100644 index 0000000000..13600fbb1c --- /dev/null +++ b/tests/domainbackupxml2xmlout/empty.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/tests/virschematest.c b/tests/virschematest.c index dabbc02163..330c42b010 100644 --- a/tests/virschematest.c +++ b/tests/virschematest.c @@ -221,6 +221,8 @@ mymain(void) "lxcxml2xmloutdata", "bhyvexml2argvdata", "genericxml2xmli= ndata", "genericxml2xmloutdata", "xlconfigdata", "libxlxml2domconf= igdata", "qemuhotplugtestdomains"); + DO_TEST_DIR("domainbackup.rng", "domainbackupxml2xmlin", + "domainbackupxml2xmlout"); DO_TEST_DIR("domaincaps.rng", "domaincapsschemadata"); DO_TEST_DIR("domaincheckpoint.rng", "qemudomaincheckpointxml2xmlin", "qemudomaincheckpointxml2xmlout"); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415143; cv=none; d=zoho.com; s=zohoarc; b=MEuJqGuJorYbDCnYb0Hxizgk5j6jf19Qq9BMMzmqvnBQx/YmeuZWG1ALij0Q4t5c9gZjP1mi+s2dXzRaHlWpYdTOIzEyZWcZUrTfcbTlNOllm1mNhpiRkOpe5mg8+OUsTvWEfDIScU5Zz1vga9K9ao8ffqOYrzmNrdsRLYEtMGw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415143; h=Content-Type:Content-Transfer-Encoding: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; bh=odmh5QEvXb+y8UdtZbqflHgCHjuBhlBV95txd1hOToY=; b=jpvypLRy6LIG76OuhBEF2pMQ2ZzEq3W5yfhVinpNsnhqxaj9YB/kIgitZtHHtDlpf/6PX7bnoX/P7L1PvjDH28h/5Uv5gzr2VZJM0AavCLnZvMO4XddqyHUJIeu7bXQKDz9qa+s1EheGmZs357QsLfMNn9ns4PZj/CHlMLI1oh8= 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 1571415143889554.0680967861629; Fri, 18 Oct 2019 09:12:23 -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 067FB307B19B; Fri, 18 Oct 2019 16:12: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 CEDA47E21; Fri, 18 Oct 2019 16:12:21 +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 8F9071803B59; Fri, 18 Oct 2019 16:12:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGCHlr005209 for ; Fri, 18 Oct 2019 12:12:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id D310A60166; Fri, 18 Oct 2019 16:12:17 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 35390600C1; Fri, 18 Oct 2019 16:12:17 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:11:15 +0200 Message-Id: <6564db7ba5795df306e3d61d8d50c7f08b6cd5fb.1571414890.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 30/40] backup: Introduce virDomainBackup APIs 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-Type: text/plain; charset="utf-8" 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, 18 Oct 2019 16:12:22 +0000 (UTC) From: Eric Blake Introduce a few new public APIs related to incremental backups. This builds on the previous notion of a checkpoint (without an existing checkpoint, the new API is a full backup, differing from virDomainBlockCopy in the point of time chosen and in operation on multiple disks at once); and also allows creation of a new checkpoint at the same time as starting the backup (after all, an incremental backup is only useful if it covers the state since the previous backup). A backup job also affects filtering a listing of domains, as well as adding event reporting for signaling when a push model backup completes (where the hypervisor creates the backup); note that the pull model does not have an event (starting the backup lets a third party access the data, and only the third party knows when it is finished). Since multiple backup jobs can be run in parallel in the future (well, qemu doesn't support it yet, but we don't want to preclude the idea), virDomainBackupBegin() returns a positive job id, and the id is also visible in the backup XML. But until a future libvirt release adds a bunch of APIs related to parallel job management where job ids will actually matter, the documentation is also clear that job id 0 means the 'currently running backup job' (provided one exists), for use in virDomainBackupGetXMLDesc() and virDomainBackupEnd(). The full list of new APIs: virDomainBackupBegin; virDomainBackupEnd; virDomainBackupGetXMLDesc; Signed-off-by: Eric Blake Reviewed-by: Daniel P. Berrang=C3=A9 --- include/libvirt/libvirt-domain.h | 26 ++++- src/driver-hypervisor.h | 20 ++++ src/libvirt-domain-checkpoint.c | 7 +- src/libvirt-domain.c | 191 +++++++++++++++++++++++++++++++ src/libvirt_public.syms | 8 ++ tools/virsh-domain.c | 4 +- 6 files changed, 252 insertions(+), 4 deletions(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 22277b0a84..2d9f69f7d4 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -3267,6 +3267,7 @@ typedef enum { VIR_DOMAIN_JOB_OPERATION_SNAPSHOT =3D 6, VIR_DOMAIN_JOB_OPERATION_SNAPSHOT_REVERT =3D 7, VIR_DOMAIN_JOB_OPERATION_DUMP =3D 8, + VIR_DOMAIN_JOB_OPERATION_BACKUP =3D 9, # ifdef VIR_ENUM_SENTINELS VIR_DOMAIN_JOB_OPERATION_LAST @@ -3282,6 +3283,14 @@ typedef enum { */ # define VIR_DOMAIN_JOB_OPERATION "operation" +/** + * VIR_DOMAIN_JOB_ID: + * + * virDomainGetJobStats field: the id of the job (so far, only for jobs + * started by virDomainBackupBegin()), as VIR_TYPED_PARAM_INT. + */ +# define VIR_DOMAIN_JOB_ID "id" + /** * VIR_DOMAIN_JOB_TIME_ELAPSED: * @@ -4106,7 +4115,8 @@ typedef void (*virConnectDomainEventMigrationIteratio= nCallback)(virConnectPtr co * @nparams: size of the params array * @opaque: application specific data * - * This callback occurs when a job (such as migration) running on the doma= in + * This callback occurs when a job (such as migration or push-model + * virDomainBackupBegin()) running on the domain * is completed. The params array will contain statistics of the just comp= leted * job as virDomainGetJobStats would return. The callback must not free @p= arams * (the array will be freed once the callback finishes). @@ -4916,4 +4926,18 @@ int virDomainGetGuestInfo(virDomainPtr domain, int *nparams, unsigned int flags); + +int virDomainBackupBegin(virDomainPtr domain, + const char *backupXML, + const char *checkpointXML, + unsigned int flags); + +char *virDomainBackupGetXMLDesc(virDomainPtr domain, + int id, + unsigned int flags); + +int virDomainBackupEnd(virDomainPtr domain, + int id, + unsigned int flags); + #endif /* LIBVIRT_DOMAIN_H */ diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index 015b2cd01c..cf69cf528d 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -1372,6 +1372,23 @@ typedef int int *nparams, unsigned int flags); + +typedef int +(*virDrvDomainBackupBegin)(virDomainPtr domain, + const char *backupXML, + const char *checkpointXML, + unsigned int flags); + +typedef char * +(*virDrvDomainBackupGetXMLDesc)(virDomainPtr domain, + int id, + unsigned int flags); + +typedef int +(*virDrvDomainBackupEnd)(virDomainPtr domain, + int id, + unsigned int flags); + typedef struct _virHypervisorDriver virHypervisorDriver; typedef virHypervisorDriver *virHypervisorDriverPtr; @@ -1632,4 +1649,7 @@ struct _virHypervisorDriver { virDrvDomainCheckpointGetParent domainCheckpointGetParent; virDrvDomainCheckpointDelete domainCheckpointDelete; virDrvDomainGetGuestInfo domainGetGuestInfo; + virDrvDomainBackupBegin domainBackupBegin; + virDrvDomainBackupGetXMLDesc domainBackupGetXMLDesc; + virDrvDomainBackupEnd domainBackupEnd; }; diff --git a/src/libvirt-domain-checkpoint.c b/src/libvirt-domain-checkpoin= t.c index fa391f8a06..432c2d5a52 100644 --- a/src/libvirt-domain-checkpoint.c +++ b/src/libvirt-domain-checkpoint.c @@ -102,8 +102,11 @@ virDomainCheckpointGetConnect(virDomainCheckpointPtr c= heckpoint) * @flags: bitwise-OR of supported virDomainCheckpointCreateFlags * * Create a new checkpoint using @xmlDesc, with a top-level - * element, on a running @domain. Note that @xmlDesc - * must validate against the XML schema. + * element, on a running @domain. Note that + * @xmlDesc must validate against the XML schema. + * Typically, it is more common to create a new checkpoint as part of + * kicking off a backup job with virDomainBackupBegin(); however, it + * is also possible to start a checkpoint without a backup. * * See Checkpoint X= ML * for more details on @xmlDesc. In particular, some hypervisors may requi= re diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index dcab179e6e..7564c9eee1 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -12497,3 +12497,194 @@ int virDomainGetLaunchSecurityInfo(virDomainPtr d= omain, virDispatchError(domain->conn); return -1; } + + +/** + * virDomainBackupBegin: + * @domain: a domain object + * @backupXML: description of the requested backup + * @checkpointXML: description of a checkpoint to create or NULL + * @flags: unused; callers must pass 0 + * + * Start a point-in-time backup job for the specified disks of a + * running domain. + * + * A backup job is mutually exclusive with domain migration + * (particularly when the job sets up an NBD export, since it is not + * possible to tell any NBD clients about a server migrating between + * hosts). For now, backup jobs are also mutually exclusive with any + * other block job on the same device, although this restriction may + * be lifted in a future release. Progress of the backup job can be + * tracked via virDomainGetJobStats(). The job remains active until a + * subsequent call to virDomainBackupEnd(), even if it no longer has + * anything to copy. + * + * There are two fundamental backup approaches. The first, called a + * push model, instructs the hypervisor to copy the state of the guest + * disk to the designated storage destination (which may be on the + * local file system or a network device). In this mode, the + * hypervisor writes the content of the guest disk to the destination, + * then emits VIR_DOMAIN_EVENT_ID_JOB_COMPLETED when the backup is + * either complete or failed (the backup image is invalid if the job + * fails or virDomainBackupEnd() is used prior to the event being + * emitted). + * + * The second, called a pull model, instructs the hypervisor to expose + * the state of the guest disk over an NBD export. A third-party + * client can then connect to this export and read whichever portions + * of the disk it desires. In this mode, there is no event; libvirt + * has to be informed via virDomainBackupEnd() when the third-party + * NBD client is done and the backup resources can be released. + * + * The @backupXML parameter contains details about the backup in the top-l= evel + * element , including which backup mode to use, whether the + * backup is incremental from a previous checkpoint, which disks + * participate in the backup, the destination for a push model backup, + * and the temporary storage and NBD server details for a pull model + * backup. + * + * virDomainBackupGetXMLDesc() can be called to learn actual + * values selected. For more information, see + * formatcheckpoint.html#BackupAttributes. + * + * The @checkpointXML parameter is optional; if non-NULL, then libvirt + * behaves as if virDomainCheckpointCreateXML() were called to create + * a checkpoint atomically covering the same point in time as the + * backup. + * The creation of a new checkpoint allows for future incremental backups. + * Note that some hypervisors may require a particular disk format, such as + * qcow2, in order to take advantage of checkpoints, while allowing arbitr= ary + * formats if checkpoints are not involved. + * + * Returns a non-negative job id on success or negative on failure. + * This id is then passed to virDomainBackupGetXMLDesc() and + * virDomainBackupEnd(). + */ +int +virDomainBackupBegin(virDomainPtr domain, + const char *backupXML, + const char *checkpointXML, + unsigned int flags) +{ + virConnectPtr conn; + + VIR_DOMAIN_DEBUG(domain, "backupXML=3D%s, checkpointXML=3D%s, flags=3D= 0x%x", + NULLSTR(backupXML), NULLSTR(checkpointXML), flags); + + virResetLastError(); + + virCheckDomainReturn(domain, -1); + conn =3D domain->conn; + + virCheckNonNullArgGoto(backupXML, error); + virCheckReadOnlyGoto(conn->flags, error); + + if (conn->driver->domainBackupBegin) { + int ret; + ret =3D conn->driver->domainBackupBegin(domain, backupXML, checkpo= intXML, + flags); + if (ret < 0) + goto error; + return ret; + } + + virReportUnsupportedError(); + error: + virDispatchError(conn); + return -1; +} + + +/** + * virDomainBackupGetXMLDesc: + * @domain: a domain object + * @id: the id of an active backup job + * @flags: extra flags; not used yet, so callers should always pass 0 + * + * In some cases, a user can start a backup job without supplying all + * details and rely on libvirt to fill in the rest (for example, + * selecting the port used for an NBD export). This API can then be + * used to learn what default values were chosen. + * + * @id can either be the return value of a previous virDomainBackupBegin(). + * + * Returns a NUL-terminated UTF-8 encoded XML instance or NULL in + * case of error. The caller must free() the returned value. + */ +char * +virDomainBackupGetXMLDesc(virDomainPtr domain, + int id, + unsigned int flags) +{ + virConnectPtr conn; + + VIR_DOMAIN_DEBUG(domain, "id=3D%d, flags=3D0x%x", id, flags); + + virResetLastError(); + + virCheckDomainReturn(domain, NULL); + conn =3D domain->conn; + + virCheckNonNegativeArgGoto(id, error); + + if (conn->driver->domainBackupGetXMLDesc) { + char *ret; + ret =3D conn->driver->domainBackupGetXMLDesc(domain, id, flags); + if (!ret) + goto error; + return ret; + } + + virReportUnsupportedError(); + error: + virDispatchError(conn); + return NULL; +} + + +/** + * virDomainBackupEnd: + * @domain: a domain object + * @id: the id of an active backup job + * @flags: unused; callers must pass 0 + * + * Conclude a point-in-time backup job of the given domain. + * + * In case of a push model backup the backup is aborted and will be incomp= lete. + * + * This API is asynchronous thus a successful return does not indicate tha= t the + * job was concluded yet. + * + * Returns 0 if the backup job termination was requested successfully, or = -1 on + * failure. + */ +int +virDomainBackupEnd(virDomainPtr domain, + int id, + unsigned int flags) +{ + virConnectPtr conn; + + VIR_DOMAIN_DEBUG(domain, "id=3D%d, flags=3D0x%x", id, flags); + + virResetLastError(); + + virCheckDomainReturn(domain, -1); + conn =3D domain->conn; + + virCheckReadOnlyGoto(conn->flags, error); + virCheckNonNegativeArgGoto(id, error); + + if (conn->driver->domainBackupEnd) { + int ret; + ret =3D conn->driver->domainBackupEnd(domain, id, flags); + if (ret < 0) + goto error; + return ret; + } + + virReportUnsupportedError(); + error: + virDispatchError(conn); + return -1; +} diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 40655fbbf5..bf7ef80741 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -858,7 +858,15 @@ LIBVIRT_5.7.0 { } LIBVIRT_5.6.0; LIBVIRT_5.8.0 { + global: virConnectSetIdentity; } LIBVIRT_5.7.0; +LIBVIRT_5.9.0 { + global: + virDomainBackupBegin; + virDomainBackupEnd; + virDomainBackupGetXMLDesc; +} LIBVIRT_5.8.0; + # .... define new API here using predicted next version number .... diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 3ba8451470..5ecc8a229c 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -6080,7 +6080,9 @@ VIR_ENUM_IMPL(virshDomainJobOperation, N_("Outgoing migration"), N_("Snapshot"), N_("Snapshot revert"), - N_("Dump")); + N_("Dump"), + N_("Backup"), +); static const char * virshDomainJobOperationToString(int op) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415143; cv=none; d=zoho.com; s=zohoarc; b=e0M694mNClfIST9e932YPPcei/uZFaIuEtsg9tubSmuu4xioUz0IHm9CAihXsElstD9e8BcCVwVHpSNK1QKzZmwRTQim85bYA95hW5JuuoxBJuiBl/3+Rh2r+v7Oxu/BOHiHpzEhuFC6mGmLWVcLzYY5SkdTdFfSsrmOoccy1pI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415143; h=Content-Type:Content-Transfer-Encoding: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; bh=tWPKty0nAYsXYtLIG3VFVxqkwz+qNGQN96IdBtKfLj0=; b=lLq2U5UpK6Fh5mWGNq8SUaIaMSSYxJtllnVuy2OE5jksO1RY1ct5xXms7n2BXptJju87GbYw2674Ey8OsYBdQMRwrDvA3HBqfhoyE+vOTBLgOMI0tOlIbn/VGIX4N3I6qwWCLBlz9/WjEfYhlcLUIJeaqBOOQYi2LS5TewxVSoU= 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 1571415143092487.92532361032465; Fri, 18 Oct 2019 09:12:23 -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 6AC7A7F770; Fri, 18 Oct 2019 16:12:21 +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 42B7779A0; Fri, 18 Oct 2019 16:12:21 +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 F3B7D3FB4F; Fri, 18 Oct 2019 16:12:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGCIt6005239 for ; Fri, 18 Oct 2019 12:12:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id CE24B60161; Fri, 18 Oct 2019 16:12:18 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2C834600C1; Fri, 18 Oct 2019 16:12:18 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:11:16 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 31/40] backup: Implement backup APIs for remote driver 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-Type: text/plain; charset="utf-8" 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.27]); Fri, 18 Oct 2019 16:12:21 +0000 (UTC) From: Eric Blake This one is fairly straightforward - the generator already does what we need. Signed-off-by: Eric Blake Reviewed-by: Daniel P. Berrang=C3=A9 --- src/remote/remote_driver.c | 3 ++ src/remote/remote_protocol.x | 53 +++++++++++++++++++++++++++++++++++- src/remote_protocol-structs | 28 +++++++++++++++++++ 3 files changed, 83 insertions(+), 1 deletion(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 9228c7d0ed..d04f2f9098 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8748,6 +8748,9 @@ static virHypervisorDriver hypervisor_driver =3D { .domainCheckpointGetParent =3D remoteDomainCheckpointGetParent, /* 5.6= .0 */ .domainCheckpointDelete =3D remoteDomainCheckpointDelete, /* 5.6.0 */ .domainGetGuestInfo =3D remoteDomainGetGuestInfo, /* 5.7.0 */ + .domainBackupBegin =3D remoteDomainBackupBegin, /* 5.9.0 */ + .domainBackupGetXMLDesc =3D remoteDomainBackupGetXMLDesc, /* 5.9.0 */ + .domainBackupEnd =3D remoteDomainBackupEnd, /* 5.9.0 */ }; static virNetworkDriver network_driver =3D { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index f4e3392212..8de088be6a 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -3744,6 +3744,37 @@ struct remote_connect_set_identity_args { unsigned int flags; }; +struct remote_domain_backup_begin_args { + remote_nonnull_domain dom; + remote_string disk_xml; + remote_string checkpoint_xml; + unsigned int flags; +}; + +struct remote_domain_backup_begin_ret { + int id; +}; + +struct remote_domain_backup_get_xml_desc_args { + remote_nonnull_domain dom; + int id; + unsigned int flags; +}; + +struct remote_domain_backup_get_xml_desc_ret { + remote_nonnull_string xml; +}; + +struct remote_domain_backup_end_args { + remote_nonnull_domain dom; + int id; + unsigned int flags; +}; + +struct remote_domain_backup_end_ret { + int retcode; +}; + /*----- Protocol. -----*/ /* Define the program number, protocol version and procedure numbers here.= */ @@ -6617,5 +6648,25 @@ enum remote_procedure { * @generate: client * @acl: connect:write */ - REMOTE_PROC_CONNECT_SET_IDENTITY =3D 419 + REMOTE_PROC_CONNECT_SET_IDENTITY =3D 419, + + /** + * @generate: both + * @acl: domain:checkpoint + * @acl: domain:block_write + */ + REMOTE_PROC_DOMAIN_BACKUP_BEGIN =3D 420, + + /** + * @generate: both + * @priority: high + * @acl: domain:read + */ + REMOTE_PROC_DOMAIN_BACKUP_GET_XML_DESC =3D 421, + + /** + * @generate: both + * @acl: domain:checkpoint + */ + REMOTE_PROC_DOMAIN_BACKUP_END =3D 422 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 51606e7473..b549ee0b3d 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -3114,6 +3114,31 @@ struct remote_connect_set_identity_args { } params; u_int flags; }; +struct remote_domain_backup_begin_args { + remote_nonnull_domain dom; + remote_string disk_xml; + remote_string checkpoint_xml; + u_int flags; +}; +struct remote_domain_backup_begin_ret { + int id; +}; +struct remote_domain_backup_get_xml_desc_args { + remote_nonnull_domain dom; + int id; + u_int flags; +}; +struct remote_domain_backup_get_xml_desc_ret { + remote_nonnull_string xml; +}; +struct remote_domain_backup_end_args { + remote_nonnull_domain dom; + int id; + u_int flags; +}; +struct remote_domain_backup_end_ret { + int retcode; +}; enum remote_procedure { REMOTE_PROC_CONNECT_OPEN =3D 1, REMOTE_PROC_CONNECT_CLOSE =3D 2, @@ -3534,4 +3559,7 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_CHECKPOINT_DELETE =3D 417, REMOTE_PROC_DOMAIN_GET_GUEST_INFO =3D 418, REMOTE_PROC_CONNECT_SET_IDENTITY =3D 419, + REMOTE_PROC_DOMAIN_BACKUP_BEGIN =3D 420, + REMOTE_PROC_DOMAIN_BACKUP_GET_XML_DESC =3D 421, + REMOTE_PROC_DOMAIN_BACKUP_END =3D 422, }; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415143; cv=none; d=zoho.com; s=zohoarc; b=XuZonhkE1c6pIwzVCPkosywmpZIvwFgrEIPYQSRJm3ISmjXM0EUjdEyeDIvyMJ9LXP9qXtfNusdjaXrnOXo98wAEDmJkqFBj/9PNcEFn5vgfeOQSrFBgshtDjZ8V7XVeeDTg8q3P0OG8M2rsRuV5pJVEV7rIWAxsugp40eUyRME= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415143; h=Content-Type:Content-Transfer-Encoding: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; bh=VfG9isQT4pm2sEfi2hwmSxPbtOte8WMORAEHWDaJC9I=; b=lOTwUtJ9WUlRtHQj9tvp9qc3ftJnDZPo55Nkoeb2mVKMsDOfufochq1kWlGQWTGSXBt64w5fwjy8x/6VmspXw5NtYrYTgSd8mEeoA4+S2mRSrD6CobYPmiRpyd4LdWZCkZQKoREYnV1HAuzvLei9cThcS8E3BQu7xuFS/csiH00= 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 1571415143146380.5243996443394; Fri, 18 Oct 2019 09:12:23 -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 85DF488384B; Fri, 18 Oct 2019 16:12:21 +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 5D45C5D9CA; Fri, 18 Oct 2019 16:12:21 +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 1F7941803B55; Fri, 18 Oct 2019 16:12:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGCJUt005279 for ; Fri, 18 Oct 2019 12:12:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id EC7DB60161; Fri, 18 Oct 2019 16:12:19 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2701660167; Fri, 18 Oct 2019 16:12:18 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:11:17 +0200 Message-Id: <070f3dce12b833ae457468524fd5e6d841c327fd.1571414890.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 32/40] backup: Parse and output backup 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.6.2 (mx1.redhat.com [10.5.110.69]); Fri, 18 Oct 2019 16:12:22 +0000 (UTC) Content-Type: text/plain; charset="utf-8" From: Eric Blake Accept XML describing a generic block job, and output it again as needed. This may still need a few tweaks to match the documented XML and RNG schema. Signed-off-by: Eric Blake --- src/conf/Makefile.inc.am | 2 + src/conf/backup_conf.c | 518 +++++++++++++++++++++++++++++++++++++++ src/conf/backup_conf.h | 102 ++++++++ src/conf/virconftypes.h | 3 + src/libvirt_private.syms | 8 + 5 files changed, 633 insertions(+) create mode 100644 src/conf/backup_conf.c create mode 100644 src/conf/backup_conf.h diff --git a/src/conf/Makefile.inc.am b/src/conf/Makefile.inc.am index 5035b9b524..debc6f4eef 100644 --- a/src/conf/Makefile.inc.am +++ b/src/conf/Makefile.inc.am @@ -12,6 +12,8 @@ NETDEV_CONF_SOURCES =3D \ $(NULL) DOMAIN_CONF_SOURCES =3D \ + conf/backup_conf.c \ + conf/backup_conf.h \ conf/capabilities.c \ conf/capabilities.h \ conf/checkpoint_conf.c \ diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c new file mode 100644 index 0000000000..123e71d4d2 --- /dev/null +++ b/src/conf/backup_conf.c @@ -0,0 +1,518 @@ +/* + * backup_conf.c: domain backup XML processing + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#include + +#include "configmake.h" +#include "internal.h" +#include "virbuffer.h" +#include "datatypes.h" +#include "domain_conf.h" +#include "virlog.h" +#include "viralloc.h" +#include "backup_conf.h" +#include "virstoragefile.h" +#include "viruuid.h" +#include "virfile.h" +#include "virerror.h" +#include "virxml.h" +#include "virstring.h" +#include "virhash.h" +#include "virenum.h" + +#define VIR_FROM_THIS VIR_FROM_DOMAIN + +VIR_LOG_INIT("conf.backup_conf"); + +VIR_ENUM_DECL(virDomainBackup); +VIR_ENUM_IMPL(virDomainBackup, + VIR_DOMAIN_BACKUP_TYPE_LAST, + "default", + "push", + "pull"); + +/* following values appear in the status XML */ +VIR_ENUM_DECL(virDomainBackupDiskState); +VIR_ENUM_IMPL(virDomainBackupDiskState, + VIR_DOMAIN_BACKUP_DISK_STATE_LAST, + "", + "running", + "complete", + "failed", + "cancelling", + "cancelled"); + +void +virDomainBackupDefFree(virDomainBackupDefPtr def) +{ + size_t i; + + if (!def) + return; + + g_free(def->incremental); + virStorageNetHostDefFree(1, def->server); + + for (i =3D 0; i < def->ndisks; i++) { + virDomainBackupDiskDefPtr disk =3D def->disks + i; + + g_free(disk->name); + virObjectUnref(disk->store); + } + + g_free(def->disks); + g_free(def); +} + + +static int +virDomainBackupDiskDefParseXML(xmlNodePtr node, + xmlXPathContextPtr ctxt, + virDomainBackupDiskDefPtr def, + bool push, + unsigned int flags, + virDomainXMLOptionPtr xmlopt) +{ + VIR_XPATH_NODE_AUTORESTORE(ctxt); + g_autofree char *type =3D NULL; + g_autofree char *driver =3D NULL; + g_autofree char *backup =3D NULL; + g_autofree char *state =3D NULL; + int tmp; + xmlNodePtr srcNode; + unsigned int storageSourceParseFlags =3D 0; + bool internal =3D flags & VIR_DOMAIN_BACKUP_PARSE_INTERNAL; + + if (internal) + storageSourceParseFlags =3D VIR_DOMAIN_DEF_PARSE_STATUS; + + ctxt->node =3D node; + + if (!(def->name =3D virXMLPropString(node, "name"))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing name from disk backup element")); + return -1; + } + + def->backup =3D VIR_TRISTATE_BOOL_YES; + + if ((backup =3D virXMLPropString(node, "backup"))) { + if ((tmp =3D virTristateBoolTypeFromString(backup)) <=3D 0) { + virReportError(VIR_ERR_XML_ERROR, + _("invalid disk 'backup' state '%s'"), backup); + return -1; + } + + def->backup =3D tmp; + } + + /* don't parse anything else if backup is disabled */ + if (def->backup =3D=3D VIR_TRISTATE_BOOL_NO) + return 0; + + if (internal) { + tmp =3D 0; + if (!(state =3D virXMLPropString(node, "state")) || + (tmp =3D virDomainBackupDiskStateTypeFromString(state)) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("disk '%s' backup state wrong or missing'"), = def->name); + return -1; + } + + def->state =3D tmp; + } + + if (!(def->store =3D virStorageSourceNew())) + return -1; + + if ((type =3D virXMLPropString(node, "type"))) { + if ((def->store->type =3D virStorageTypeFromString(type)) <=3D 0 || + def->store->type =3D=3D VIR_STORAGE_TYPE_VOLUME || + def->store->type =3D=3D VIR_STORAGE_TYPE_DIR) { + virReportError(VIR_ERR_XML_ERROR, + _("unknown disk backup type '%s'"), type); + return -1; + } + } else { + def->store->type =3D VIR_STORAGE_TYPE_FILE; + } + + if (push) + srcNode =3D virXPathNode("./target", ctxt); + else + srcNode =3D virXPathNode("./scratch", ctxt); + + if (srcNode && + virDomainStorageSourceParse(srcNode, ctxt, def->store, + storageSourceParseFlags, xmlopt) < 0) + return -1; + + if ((driver =3D virXPathString("string(./driver/@type)", ctxt))) { + def->store->format =3D virStorageFileFormatTypeFromString(driver); + if (def->store->format <=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown disk backup driver '%s'"), driver); + return -1; + } else if (!push && def->store->format !=3D VIR_STORAGE_FILE_QCOW2= ) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("pull mode requires qcow2 driver, not '%s'"), + driver); + return -1; + } + } + + return 0; +} + + +static virDomainBackupDefPtr +virDomainBackupDefParse(xmlXPathContextPtr ctxt, + virDomainXMLOptionPtr xmlopt, + unsigned int flags) +{ + g_autoptr(virDomainBackupDef) def =3D NULL; + g_autofree xmlNodePtr *nodes =3D NULL; + xmlNodePtr node =3D NULL; + g_autofree char *mode =3D NULL; + bool push; + size_t i; + int n; + + def =3D g_new0(virDomainBackupDef, 1); + + def->type =3D VIR_DOMAIN_BACKUP_TYPE_PUSH; + + if ((mode =3D virXMLPropString(ctxt->node, "mode"))) { + if ((def->type =3D virDomainBackupTypeFromString(mode)) <=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown backup mode '%s'"), mode); + return NULL; + } + } + + push =3D def->type =3D=3D VIR_DOMAIN_BACKUP_TYPE_PUSH; + + if (flags & VIR_DOMAIN_BACKUP_PARSE_INTERNAL) { + g_autofree char *tmp =3D virXMLPropString(ctxt->node, "id"); + if (tmp && virStrToLong_i(tmp, NULL, 10, &def->id) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("invalid 'id' value '%s'"), tmp); + return NULL; + } + } + + def->incremental =3D virXPathString("string(./incremental)", ctxt); + + if ((node =3D virXPathNode("./server", ctxt))) { + if (def->type !=3D VIR_DOMAIN_BACKUP_TYPE_PULL) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("use of requires pull mode backup")); + return NULL; + } + + def->server =3D g_new0(virStorageNetHostDef, 1); + + if (virDomainStorageNetworkParseHost(node, def->server) < 0) + return NULL; + + if (def->server->transport =3D=3D VIR_STORAGE_NET_HOST_TRANS_RDMA)= { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("transport rdma is not supported for = ")); + return NULL; + } + + if (def->server->transport =3D=3D VIR_STORAGE_NET_HOST_TRANS_UNIX = && + def->server->socket[0] !=3D '/') { + virReportError(VIR_ERR_XML_ERROR, + _("backup socket path '%s' must be absolute"), + def->server->socket); + return NULL; + } + } + + if ((n =3D virXPathNodeSet("./disks/*", ctxt, &nodes)) < 0) + return NULL; + + def->disks =3D g_new0(virDomainBackupDiskDef, n); + + def->ndisks =3D n; + for (i =3D 0; i < def->ndisks; i++) { + if (virDomainBackupDiskDefParseXML(nodes[i], ctxt, + &def->disks[i], push, + flags, xmlopt) < 0) + return NULL; + } + + return g_steal_pointer(&def); +} + + +virDomainBackupDefPtr +virDomainBackupDefParseString(const char *xmlStr, + virDomainXMLOptionPtr xmlopt, + unsigned int flags) +{ + virDomainBackupDefPtr ret =3D NULL; + g_autoptr(xmlDoc) xml =3D NULL; + int keepBlanksDefault =3D xmlKeepBlanksDefault(0); + + if ((xml =3D virXMLParse(NULL, xmlStr, _("(domain_backup)")))) { + xmlKeepBlanksDefault(keepBlanksDefault); + ret =3D virDomainBackupDefParseNode(xml, xmlDocGetRootElement(xml), + xmlopt, flags); + } + xmlKeepBlanksDefault(keepBlanksDefault); + + return ret; +} + + +virDomainBackupDefPtr +virDomainBackupDefParseNode(xmlDocPtr xml, + xmlNodePtr root, + virDomainXMLOptionPtr xmlopt, + unsigned int flags) +{ + g_autoptr(xmlXPathContext) ctxt =3D NULL; + g_autofree char *schema =3D NULL; + + if (!virXMLNodeNameEqual(root, "domainbackup")) { + virReportError(VIR_ERR_XML_ERROR, "%s", _("domainbackup")); + return NULL; + } + + if (!(flags & VIR_DOMAIN_BACKUP_PARSE_INTERNAL)) { + if (!(schema =3D virFileFindResource("domainbackup.rng", + abs_top_srcdir "/docs/schemas", + PKGDATADIR "/schemas"))) + return NULL; + + if (virXMLValidateAgainstSchema(schema, xml) < 0) + return NULL; + } + + if (!(ctxt =3D virXMLXPathContextNew(xml))) + return NULL; + + ctxt->node =3D root; + return virDomainBackupDefParse(ctxt, xmlopt, flags); +} + + +static int +virDomainBackupDiskDefFormat(virBufferPtr buf, + virDomainBackupDiskDefPtr disk, + bool push, + bool internal) +{ + g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) childBuf =3D VIR_BUFFER_INITIALIZER; + const char *sourcename =3D "scratch"; + unsigned int storageSourceFormatFlags =3D 0; + + if (push) + sourcename =3D "target"; + + if (internal) + storageSourceFormatFlags |=3D VIR_DOMAIN_DEF_FORMAT_STATUS; + + virBufferSetChildIndent(&childBuf, buf); + + virBufferEscapeString(&attrBuf, " name=3D'%s'", disk->name); + virBufferAsprintf(&attrBuf, " backup=3D'%s'", virTristateBoolTypeToStr= ing(disk->backup)); + if (internal) + virBufferAsprintf(&attrBuf, " state=3D'%s'", virDomainBackupDiskSt= ateTypeToString(disk->state)); + + if (disk->backup =3D=3D VIR_TRISTATE_BOOL_YES) { + virBufferAsprintf(&attrBuf, " type=3D'%s'", virStorageTypeToString= (disk->store->type)); + + if (disk->store->format > 0) + virBufferEscapeString(&childBuf, "\n", + virStorageFileFormatTypeToString(disk->s= tore->format)); + + if (virDomainDiskSourceFormat(&childBuf, disk->store, sourcename, + 0, false, storageSourceFormatFlags, = NULL) < 0) + return -1; + } + + return virXMLFormatElement(buf, "disk", &attrBuf, &childBuf); +} + + +int +virDomainBackupDefFormat(virBufferPtr buf, + virDomainBackupDefPtr def, + bool internal) +{ + g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) childBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) serverAttrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) disksChildBuf =3D VIR_BUFFER_INITIALIZER; + size_t i; + + virBufferSetChildIndent(&childBuf, buf); + virBufferSetChildIndent(&disksChildBuf, &childBuf); + + virBufferAsprintf(&attrBuf, " mode=3D'%s'", virDomainBackupTypeToStrin= g(def->type)); + virBufferAsprintf(&attrBuf, " id=3D'%d'", def->id); + + virBufferEscapeString(&childBuf, "%s\n", de= f->incremental); + + if (def->server) { + virBufferAsprintf(&serverAttrBuf, " transport=3D'%s'", + virStorageNetHostTransportTypeToString(def->serv= er->transport)); + virBufferEscapeString(&serverAttrBuf, " name=3D'%s'", def->server-= >name); + if (def->server->port) + virBufferAsprintf(&serverAttrBuf, " port=3D'%u'", def->server-= >port); + virBufferEscapeString(&serverAttrBuf, " socket=3D'%s'", def->serve= r->socket); + } + + if (virXMLFormatElement(&childBuf, "server", &serverAttrBuf, NULL) < 0) + return -1; + + for (i =3D 0; i < def->ndisks; i++) { + if (virDomainBackupDiskDefFormat(&disksChildBuf, &def->disks[i], + def->type =3D=3D VIR_DOMAIN_BACKU= P_TYPE_PUSH, + internal) < 0) + return -1; + } + + if (virXMLFormatElement(&childBuf, "disks", NULL, &disksChildBuf) < 0) + return -1; + + if (virXMLFormatElement(buf, "domainbackup", &attrBuf, &childBuf) < 0) + return -1; + + return 0; +} + + +static int +virDomainBackupDefAssignStore(virDomainBackupDiskDefPtr disk, + virStorageSourcePtr src, + const char *suffix) +{ + if (virStorageSourceIsEmpty(src)) { + if (disk->store) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("disk '%s' has no media"), disk->name); + return -1; + } + } else if (src->readonly) { + if (disk->store) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("backup of readonly disk '%s' makes no sense"= ), + disk->name); + return -1; + } + } else if (!disk->store) { + if (virStorageSourceGetActualType(src) =3D=3D VIR_STORAGE_TYPE_FIL= E) { + if (!(disk->store =3D virStorageSourceNew())) + return -1; + + disk->store->type =3D VIR_STORAGE_TYPE_FILE; + disk->store->path =3D g_strdup_printf("%s.%s", src->path, suff= ix); + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("refusing to generate file name for disk '%s'= "), + disk->name); + return -1; + } + } + + return 0; +} + + +int +virDomainBackupAlignDisks(virDomainBackupDefPtr def, + virDomainDefPtr dom, + const char *suffix) +{ + g_autoptr(virHashTable) disks =3D NULL; + size_t i; + int ndisks; + bool backup_all =3D false; + + + if (!(disks =3D virHashNew(NULL))) + return -1; + + /* Unlikely to have a guest without disks but technically possible. */ + if (!dom->ndisks) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("domain must have at least one disk to perform ba= ckup")); + return -1; + } + + /* Double check requested disks. */ + for (i =3D 0; i < def->ndisks; i++) { + virDomainBackupDiskDefPtr backupdisk =3D &def->disks[i]; + virDomainDiskDefPtr domdisk; + + if (!(domdisk =3D virDomainDiskByTarget(dom, backupdisk->name))) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("no disk named '%s'"), backupdisk->name); + return -1; + } + + if (virHashAddEntry(disks, backupdisk->name, NULL) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("disk '%s' specified twice"), + backupdisk->name); + return -1; + } + + if (backupdisk->backup =3D=3D VIR_TRISTATE_BOOL_YES && + virDomainBackupDefAssignStore(backupdisk, domdisk->src, suffix= ) < 0) + return -1; + } + + if (def->ndisks =3D=3D 0) + backup_all =3D true; + + ndisks =3D def->ndisks; + if (VIR_EXPAND_N(def->disks, def->ndisks, dom->ndisks - def->ndisks) <= 0) + return -1; + + for (i =3D 0; i < dom->ndisks; i++) { + virDomainBackupDiskDefPtr backupdisk =3D NULL; + virDomainDiskDefPtr domdisk =3D dom->disks[i]; + + if (virHashHasEntry(disks, domdisk->dst)) + continue; + + backupdisk =3D &def->disks[ndisks++]; + + if (VIR_STRDUP(backupdisk->name, domdisk->dst) < 0) + return -1; + + if (backup_all && + !virStorageSourceIsEmpty(domdisk->src) && + !domdisk->src->readonly) { + backupdisk->backup =3D VIR_TRISTATE_BOOL_YES; + + if (virDomainBackupDefAssignStore(backupdisk, domdisk->src, su= ffix) < 0) + return -1; + } else { + backupdisk->backup =3D VIR_TRISTATE_BOOL_NO; + } + } + + return 0; +} diff --git a/src/conf/backup_conf.h b/src/conf/backup_conf.h new file mode 100644 index 0000000000..3be594b7da --- /dev/null +++ b/src/conf/backup_conf.h @@ -0,0 +1,102 @@ +/* + * backup_conf.h: domain backup XML processing + * (based on domain_conf.h) + * + * Copyright (C) 2006-2019 Red Hat, Inc. + * Copyright (C) 2006-2008 Daniel P. Berrange + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#pragma once + +#include "internal.h" +#include "virconftypes.h" + +/* Items related to incremental backup state */ + +typedef enum { + VIR_DOMAIN_BACKUP_TYPE_DEFAULT =3D 0, + VIR_DOMAIN_BACKUP_TYPE_PUSH, + VIR_DOMAIN_BACKUP_TYPE_PULL, + + VIR_DOMAIN_BACKUP_TYPE_LAST +} virDomainBackupType; + +typedef enum { + VIR_DOMAIN_BACKUP_DISK_STATE_NONE =3D 0, + VIR_DOMAIN_BACKUP_DISK_STATE_RUNNING, + VIR_DOMAIN_BACKUP_DISK_STATE_COMPLETE, + VIR_DOMAIN_BACKUP_DISK_STATE_FAILED, + VIR_DOMAIN_BACKUP_DISK_STATE_CANCELLING, + VIR_DOMAIN_BACKUP_DISK_STATE_CANCELLED, + VIR_DOMAIN_BACKUP_DISK_STATE_LAST +} virDomainBackupDiskState; + +/* Stores disk-backup information */ +typedef struct _virDomainBackupDiskDef virDomainBackupDiskDef; +typedef virDomainBackupDiskDef *virDomainBackupDiskDefPtr; +struct _virDomainBackupDiskDef { + char *name; /* name matching the ndisks */ + virDomainBackupDiskDef *disks; +}; + +typedef enum { + VIR_DOMAIN_BACKUP_PARSE_INTERNAL =3D 1 << 0, +} virDomainBackupParseFlags; + +virDomainBackupDefPtr +virDomainBackupDefParseString(const char *xmlStr, + virDomainXMLOptionPtr xmlopt, + unsigned int flags); + +virDomainBackupDefPtr +virDomainBackupDefParseNode(xmlDocPtr xml, + xmlNodePtr root, + virDomainXMLOptionPtr xmlopt, + unsigned int flags); +void +virDomainBackupDefFree(virDomainBackupDefPtr def); + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainBackupDef, virDomainBackupDefFree); + +int +virDomainBackupDefFormat(virBufferPtr buf, + virDomainBackupDefPtr def, + bool internal); +int +virDomainBackupAlignDisks(virDomainBackupDefPtr backup, + virDomainDefPtr dom, + const char *suffix); diff --git a/src/conf/virconftypes.h b/src/conf/virconftypes.h index 462842f324..9ed9b68b65 100644 --- a/src/conf/virconftypes.h +++ b/src/conf/virconftypes.h @@ -93,6 +93,9 @@ typedef virDomainABIStability *virDomainABIStabilityPtr; typedef struct _virDomainActualNetDef virDomainActualNetDef; typedef virDomainActualNetDef *virDomainActualNetDefPtr; +typedef struct _virDomainBackupDef virDomainBackupDef; +typedef virDomainBackupDef *virDomainBackupDefPtr; + typedef struct _virDomainBIOSDef virDomainBIOSDef; typedef virDomainBIOSDef *virDomainBIOSDefPtr; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index fdfe1e7295..b4deab520e 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -42,6 +42,14 @@ virAccessPermStorageVolTypeFromString; virAccessPermStorageVolTypeToString; +# conf/backup_conf.h +virDomainBackupAlignDisks; +virDomainBackupDefFormat; +virDomainBackupDefFree; +virDomainBackupDefParseNode; +virDomainBackupDefParseString; + + # conf/capabilities.h virCapabilitiesAddGuest; virCapabilitiesAddGuestDomain; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415146; cv=none; d=zoho.com; s=zohoarc; b=XD4QR1V3YPr/rVSSd5GxI6jMwiZ6tQ97xH9nDO1T+HIMxg++guSyQ2BTngdJYAwd7spTMrWes51azQHA+jngKTrHqezbyqIwCPIpmTygZEQTGO6E/dkyEzPZ8w4OfbCzYJgHQpHkIfmyK22BgnAkTTQWa2rHwhjh3iKz8FnAA2o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415146; h=Content-Type:Content-Transfer-Encoding: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; bh=uLPZOLcuF6O/8ksXuPn9EfyqE8N68mmJlHD0pdCdloQ=; b=E3b8JJtJBW5ZOcdcNAPUfJmoPZveaHyJJdNQLHj7j1jzdzkyAMyYhdwUEfDyJumydT3jk8nsPmf6Q/QEopj40xzM/YPNMyngBYn4Psciii73dgC47gN6eP3/q07taRDIIJJPk2zbcgyH8z4NfDsnbgA+n6WFZn6QR/mN47S2b6w= 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 1571415146801341.6949373451862; Fri, 18 Oct 2019 09:12:26 -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 1C6A9C04959E; Fri, 18 Oct 2019 16:12:25 +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 D2A0560619; Fri, 18 Oct 2019 16:12:24 +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 7AB2D3FB55; Fri, 18 Oct 2019 16:12:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGCN5J005367 for ; Fri, 18 Oct 2019 12:12:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6E7E2600C8; Fri, 18 Oct 2019 16:12:23 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id C414E600C1; Fri, 18 Oct 2019 16:12:20 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:11:18 +0200 Message-Id: <2b25a8b3e09569ae8ed2d97561ffd9ab5f729489.1571414890.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 33/40] backup: Implement virsh support for backup 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, 18 Oct 2019 16:12:25 +0000 (UTC) Content-Type: text/plain; charset="utf-8" From: Eric Blake Introduce virsh commands for performing backup jobs. Signed-off-by: Eric Blake --- tools/Makefile.am | 1 + tools/virsh-backup.c | 209 +++++++++++++++++++++++++++++++++++++++++++ tools/virsh-backup.h | 21 +++++ tools/virsh.c | 2 + tools/virsh.h | 1 + tools/virsh.pod | 37 ++++++++ 6 files changed, 271 insertions(+) create mode 100644 tools/virsh-backup.c create mode 100644 tools/virsh-backup.h diff --git a/tools/Makefile.am b/tools/Makefile.am index 68320c7246..813cfaeb53 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -233,6 +233,7 @@ virt_login_shell_helper_CFLAGS =3D \ virsh_SOURCES =3D \ virsh.c virsh.h \ + virsh-backup.c virsh-backup.h\ virsh-checkpoint.c virsh-checkpoint.h \ virsh-completer.c virsh-completer.h \ virsh-completer-domain.c virsh-completer-domain.h \ diff --git a/tools/virsh-backup.c b/tools/virsh-backup.c new file mode 100644 index 0000000000..7719b4f3cc --- /dev/null +++ b/tools/virsh-backup.c @@ -0,0 +1,209 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#include +#include "virsh-backup.h" +#include "virsh-util.h" + +#include "internal.h" +#include "virfile.h" + +/* + * "backup-begin" command + */ +static const vshCmdInfo info_backup_begin[] =3D { + {.name =3D "help", + .data =3D N_("Start a disk backup of a live domain") + }, + {.name =3D "desc", + .data =3D N_("Use XML to start a full or incremental disk backup of a= live " + "domain, optionally creating a checkpoint") + }, + {.name =3D NULL} +}; + +static const vshCmdOptDef opts_backup_begin[] =3D { + VIRSH_COMMON_OPT_DOMAIN_FULL(0), + {.name =3D "backupxml", + .type =3D VSH_OT_STRING, + .help =3D N_("domain backup XML"), + }, + {.name =3D "checkpointxml", + .type =3D VSH_OT_STRING, + .help =3D N_("domain checkpoint XML"), + }, + {.name =3D NULL} +}; + +static bool +cmdBackupBegin(vshControl *ctl, + const vshCmd *cmd) +{ + g_autoptr(virshDomain) dom =3D NULL; + const char *backup_from =3D NULL; + g_autofree char *backup_buffer =3D NULL; + const char *check_from =3D NULL; + g_autofree char *check_buffer =3D NULL; + unsigned int flags =3D 0; + int id; + + if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + return false; + + if (vshCommandOptStringReq(ctl, cmd, "backupxml", &backup_from) < 0) + return false; + + if (!backup_from) { + backup_buffer =3D vshStrdup(ctl, ""); + } else { + if (virFileReadAll(backup_from, VSH_MAX_XML_FILE, &backup_buffer) = < 0) { + vshSaveLibvirtError(); + return false; + } + } + + if (vshCommandOptStringReq(ctl, cmd, "checkpointxml", &check_from) < 0) + return false; + if (check_from) { + if (virFileReadAll(check_from, VSH_MAX_XML_FILE, &check_buffer) < = 0) { + vshSaveLibvirtError(); + return false; + } + } + + if ((id =3D virDomainBackupBegin(dom, backup_buffer, check_buffer, fla= gs)) < 0) + return false; + + vshPrint(ctl, _("Backup id %d started\n"), id); + + return true; +} + + +/* + * "backup-dumpxml" command + */ +static const vshCmdInfo info_backup_dumpxml[] =3D { + {.name =3D "help", + .data =3D N_("Dump XML for an ongoing domain block backup job") + }, + {.name =3D "desc", + .data =3D N_("Backup Dump XML") + }, + {.name =3D NULL} +}; + +static const vshCmdOptDef opts_backup_dumpxml[] =3D { + VIRSH_COMMON_OPT_DOMAIN_FULL(0), + {.name =3D "id", + .type =3D VSH_OT_INT, + .help =3D N_("backup job id"), + }, + {.name =3D NULL} +}; + +static bool +cmdBackupDumpXML(vshControl *ctl, + const vshCmd *cmd) +{ + g_autoptr(virshDomain) dom =3D NULL; + g_autofree char *xml =3D NULL; + unsigned int flags =3D 0; + int id =3D 0; + + if (vshCommandOptBool(cmd, "security-info")) + flags |=3D VIR_DOMAIN_XML_SECURE; + + if (vshCommandOptInt(ctl, cmd, "id", &id) < 0) + return false; + + if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + return false; + + if (!(xml =3D virDomainBackupGetXMLDesc(dom, id, flags))) + return false; + + vshPrint(ctl, "%s", xml); + return true; +} + + +/* + * "backup-end" command + */ +static const vshCmdInfo info_backup_end[] =3D { + {.name =3D "help", + .data =3D N_("Conclude a disk backup of a live domain") + }, + {.name =3D "desc", + .data =3D N_("End a domain block backup job") + }, + {.name =3D NULL} +}; + +static const vshCmdOptDef opts_backup_end[] =3D { + VIRSH_COMMON_OPT_DOMAIN_FULL(0), + {.name =3D "id", + .type =3D VSH_OT_INT, + .help =3D N_("backup job id"), + }, + {.name =3D NULL} +}; + +static bool +cmdBackupEnd(vshControl *ctl, const vshCmd *cmd) +{ + g_autoptr(virshDomain) dom =3D NULL; + unsigned int flags =3D 0; + int id =3D 0; + int rc; + + if (vshCommandOptInt(ctl, cmd, "id", &id) < 0) + return false; + + if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + return false; + + if ((rc =3D virDomainBackupEnd(dom, id, flags)) < 0) + return false; + + vshPrint(ctl, _("Backup id %d terminated"), id); + + return true; +} + + +const vshCmdDef backupCmds[] =3D { + {.name =3D "backup-begin", + .handler =3D cmdBackupBegin, + .opts =3D opts_backup_begin, + .info =3D info_backup_begin, + .flags =3D 0 + }, + {.name =3D "backup-dumpxml", + .handler =3D cmdBackupDumpXML, + .opts =3D opts_backup_dumpxml, + .info =3D info_backup_dumpxml, + .flags =3D 0 + }, + {.name =3D "backup-end", + .handler =3D cmdBackupEnd, + .opts =3D opts_backup_end, + .info =3D info_backup_end, + .flags =3D 0 + }, + {.name =3D NULL} +}; diff --git a/tools/virsh-backup.h b/tools/virsh-backup.h new file mode 100644 index 0000000000..95c2f5a424 --- /dev/null +++ b/tools/virsh-backup.h @@ -0,0 +1,21 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#pragma once + +#include "virsh.h" + +extern const vshCmdDef backupCmds[]; diff --git a/tools/virsh.c b/tools/virsh.c index a3553ddd36..59c3ddb4b7 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -47,6 +47,7 @@ #include "virstring.h" #include "virgettext.h" +#include "virsh-backup.h" #include "virsh-checkpoint.h" #include "virsh-console.h" #include "virsh-domain.h" @@ -831,6 +832,7 @@ static const vshCmdGrp cmdGroups[] =3D { {VIRSH_CMD_GRP_NODEDEV, "nodedev", nodedevCmds}, {VIRSH_CMD_GRP_SECRET, "secret", secretCmds}, {VIRSH_CMD_GRP_SNAPSHOT, "snapshot", snapshotCmds}, + {VIRSH_CMD_GRP_BACKUP, "backup", backupCmds}, {VIRSH_CMD_GRP_STORAGE_POOL, "pool", storagePoolCmds}, {VIRSH_CMD_GRP_STORAGE_VOL, "volume", storageVolCmds}, {VIRSH_CMD_GRP_VIRSH, "virsh", virshCmds}, diff --git a/tools/virsh.h b/tools/virsh.h index b4e610b2a4..d84659124a 100644 --- a/tools/virsh.h +++ b/tools/virsh.h @@ -51,6 +51,7 @@ #define VIRSH_CMD_GRP_NWFILTER "Network Filter" #define VIRSH_CMD_GRP_SECRET "Secret" #define VIRSH_CMD_GRP_SNAPSHOT "Snapshot" +#define VIRSH_CMD_GRP_BACKUP "Backup" #define VIRSH_CMD_GRP_HOST_AND_HV "Host and Hypervisor" #define VIRSH_CMD_GRP_VIRSH "Virsh itself" diff --git a/tools/virsh.pod b/tools/virsh.pod index cf2798e71a..83cb315506 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -1327,6 +1327,43 @@ addresses, currently 'lease' to read DHCP leases, 'a= gent' to query the guest OS via an agent, or 'arp' to get IP from host's arp tables. If unspecified, 'lease' is the default. +=3Ditem B I [I] +[I + +Begin a new backup job, and output the resulting job id on success. If +I is omitted, this defaults to a full backup using a push +model to filenames generated by libvirt; supplying XML allows +fine-tuning such as requesting an incremental backup relative to an +earlier checkpoint, controlling which disks participate or which +filenames are involved, or requesting the use of a pull model backup. +The B command shows any resulting values assigned by +libvirt. For more information on backup XML, see: +L. + +If I is specified, a second file with a top-level +element of is used to create a simultaneous +checkpoint, for doing a later incremental backup relative to the time +the backup was created. See B for more details on +checkpoints. + +This command returns as soon as possible, and the backup job runs in +the background; the progress of a push model backup can be checked +with B or by waiting for an event with B (the +progress of a pull model backup is under the control of whatever third +party connects to the NBD export). The job is ended with B. + +=3Ditem B I [I] + +Output XML describing the backup job I. The default for I is +0, which works as long as there are no parallel jobs; it is also +possible to use the positive id printed by B on success. + +=3Ditem B I [I] + +End the current backup job I. The default for I is 0, which +works as long as there are no parallel jobs; it is also possible to +use the positive id printed by B on success. + =3Ditem B I [I<--inactive>] Print a table showing the brief information of all virtual interfaces --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415149; cv=none; d=zoho.com; s=zohoarc; b=Q2Xm+KM1a/OXFbnCf6TuzsolVEHcxxV648uPvId1AyPXo/dK66/ysFdIvc9KkRkfgd2c/t+qOrSVxQFk7/lIN7bVIZYnZQlockYJK8yM8x4Arpp+fybYAAZYxqX9xczPXu4/yAdE2voQL+lRimJTBZdxasQu2ADLR5rkFLss+ME= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415149; h=Content-Type:Content-Transfer-Encoding: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; bh=C8UaELx8D7owFLgmcMdt0F25NdKAdNOdwCh3a22oY28=; b=HfspHu18enN0wGlyKXYqN8LV0v01Ud82EBi5GB+hNeA+WzaZvD0nSkYXt8UQ7TBWVGXQSBf1Zb9iXnGnthsjDtXF8fPrkhOqJpxfINQC4YGLnVF5Dsx73f5UlJvjiDduZX6VlV/BlLk0XKjOdATpcYTongDgoYnWIC8utG6seXs= 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 1571415149127897.9754178045089; Fri, 18 Oct 2019 09:12:29 -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 90F2718B20E8; Fri, 18 Oct 2019 16:12:27 +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 6A045600C4; Fri, 18 Oct 2019 16:12: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 26BC71803B5C; Fri, 18 Oct 2019 16:12:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGCOjv005379 for ; Fri, 18 Oct 2019 12:12:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 66C99600C8; Fri, 18 Oct 2019 16:12:24 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC55C600C1; Fri, 18 Oct 2019 16:12:23 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:11:19 +0200 Message-Id: <4379c6b3a82cf878802d4bc8bb354a857bc94aa9.1571414890.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 34/40] Add 'backup' block job type 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.6.2 (mx1.redhat.com [10.5.110.70]); Fri, 18 Oct 2019 16:12:28 +0000 (UTC) Content-Type: text/plain; charset="utf-8" A backup job may consist of many backup sub-blockjobs. Add the new blockjob type and add all type converter strings. Signed-off-by: Peter Krempa Reviewed-by: Eric Blake --- examples/c/misc/event-test.c | 3 +++ include/libvirt/libvirt-domain.h | 3 +++ src/conf/domain_conf.c | 2 +- src/qemu/qemu_blockjob.c | 2 ++ src/qemu/qemu_blockjob.h | 1 + src/qemu/qemu_domain.c | 2 ++ src/qemu/qemu_driver.c | 1 + tools/virsh-domain.c | 4 +++- 8 files changed, 16 insertions(+), 2 deletions(-) diff --git a/examples/c/misc/event-test.c b/examples/c/misc/event-test.c index 5db572175d..ae282a5027 100644 --- a/examples/c/misc/event-test.c +++ b/examples/c/misc/event-test.c @@ -891,6 +891,9 @@ blockJobTypeToStr(int type) case VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT: return "active layer block commit"; + + case VIR_DOMAIN_BLOCK_JOB_TYPE_BACKUP: + return "backup"; } return "unknown"; diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 2d9f69f7d4..08829a613a 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -2446,6 +2446,9 @@ typedef enum { * exists as long as sync is active */ VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_COMMIT =3D 4, + /* Backup (virDomainBackupBegin), job exists until virDomainBackupEnd = */ + VIR_DOMAIN_BLOCK_JOB_TYPE_BACKUP =3D 5, + # ifdef VIR_ENUM_SENTINELS VIR_DOMAIN_BLOCK_JOB_TYPE_LAST # endif diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e12d676a8c..18c6e48c70 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1227,7 +1227,7 @@ VIR_ENUM_IMPL(virDomainOsDefFirmware, VIR_ENUM_DECL(virDomainBlockJob); VIR_ENUM_IMPL(virDomainBlockJob, VIR_DOMAIN_BLOCK_JOB_TYPE_LAST, - "", "", "copy", "", "active-commit", + "", "", "copy", "", "active-commit", "", ); VIR_ENUM_IMPL(virDomainMemoryModel, diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index e12dcde729..6d66d75ed7 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -65,6 +65,7 @@ VIR_ENUM_IMPL(qemuBlockjob, "copy", "commit", "active-commit", + "backup", "", "create"); @@ -1285,6 +1286,7 @@ qemuBlockJobEventProcessConcludedTransition(qemuBlock= JobDataPtr job, qemuBlockJobProcessEventConcludedCopyAbort(driver, vm, job, as= yncJob); break; + case QEMU_BLOCKJOB_TYPE_BACKUP: case QEMU_BLOCKJOB_TYPE_NONE: case QEMU_BLOCKJOB_TYPE_INTERNAL: case QEMU_BLOCKJOB_TYPE_LAST: diff --git a/src/qemu/qemu_blockjob.h b/src/qemu/qemu_blockjob.h index d8da918f2f..8b28990801 100644 --- a/src/qemu/qemu_blockjob.h +++ b/src/qemu/qemu_blockjob.h @@ -60,6 +60,7 @@ typedef enum { QEMU_BLOCKJOB_TYPE_COPY =3D VIR_DOMAIN_BLOCK_JOB_TYPE_COPY, QEMU_BLOCKJOB_TYPE_COMMIT =3D VIR_DOMAIN_BLOCK_JOB_TYPE_COMMIT, QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT =3D VIR_DOMAIN_BLOCK_JOB_TYPE_ACTIVE_= COMMIT, + QEMU_BLOCKJOB_TYPE_BACKUP =3D VIR_DOMAIN_BLOCK_JOB_TYPE_BACKUP, /* Additional enum values local to qemu */ QEMU_BLOCKJOB_TYPE_INTERNAL, QEMU_BLOCKJOB_TYPE_CREATE, diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index e330d2390c..d5a2ddaa8c 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2556,6 +2556,7 @@ qemuDomainObjPrivateXMLFormatBlockjobIterator(void *p= ayload, virBufferAddLit(&attrBuf, " shallownew=3D'yes'"); break; + case QEMU_BLOCKJOB_TYPE_BACKUP: case QEMU_BLOCKJOB_TYPE_NONE: case QEMU_BLOCKJOB_TYPE_INTERNAL: case QEMU_BLOCKJOB_TYPE_LAST: @@ -3139,6 +3140,7 @@ qemuDomainObjPrivateXMLParseBlockjobDataSpecific(qemu= BlockJobDataPtr job, } break; + case QEMU_BLOCKJOB_TYPE_BACKUP: case QEMU_BLOCKJOB_TYPE_NONE: case QEMU_BLOCKJOB_TYPE_INTERNAL: case QEMU_BLOCKJOB_TYPE_LAST: diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 501c909e49..330345b5de 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17434,6 +17434,7 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver, case QEMU_BLOCKJOB_TYPE_PULL: case QEMU_BLOCKJOB_TYPE_COMMIT: + case QEMU_BLOCKJOB_TYPE_BACKUP: case QEMU_BLOCKJOB_TYPE_INTERNAL: case QEMU_BLOCKJOB_TYPE_CREATE: virReportError(VIR_ERR_OPERATION_INVALID, diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 5ecc8a229c..6a658a33a1 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -2562,7 +2562,9 @@ VIR_ENUM_IMPL(virshDomainBlockJob, N_("Block Pull"), N_("Block Copy"), N_("Block Commit"), - N_("Active Block Commit")); + N_("Active Block Commit"), + N_("Backup"), +); static const char * virshDomainBlockJobToString(int type) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415150; cv=none; d=zoho.com; s=zohoarc; b=Iqw0t5HYRiWCwU6T97xMQkBMkxs67EdzaM9ZVU47jyetNB8BRY+sNK2WOXmNNyXATMnvC04/5xNebVApW9rLfT7BQ82XD+xMsWkLQD9hBSPn2GGIsNWJv458XC7VbxeCU7fIN9hZcY2KjtrD5D9LCqZULyAWbBupVmhiZNPazCk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415150; h=Content-Type:Content-Transfer-Encoding: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; bh=thS0pLHGVsegtE/6FCvlXL3JXiS/OsLzZW4AfVaRbis=; b=LPOrRazhhVSuCpcTeJl2axYhjWjrlWh+Z4Tdgjkh74KS6EWx5nUpHnNC0syxfjN7fz8UVZP68v50TRBhmanOYb6ez5PZmRL/gvUfpmc6Qk92SNc2thVartHM8V76g0df/ybo+dztCq98TFRjDvfSMzdkzKiAE27V/8FsOGVQSwo= 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 1571415150353922.9184506426711; Fri, 18 Oct 2019 09:12:30 -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 D6DEB1017C0D; Fri, 18 Oct 2019 16:12: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 ACCD260CCD; Fri, 18 Oct 2019 16:12:28 +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 6EC7E3FB59; Fri, 18 Oct 2019 16:12:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGCPe6005419 for ; Fri, 18 Oct 2019 12:12:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 61B72600C4; Fri, 18 Oct 2019 16:12:25 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id B5D2B6012A; Fri, 18 Oct 2019 16:12:24 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:11:20 +0200 Message-Id: <79d70cc72b0780ae44350164a9488738322c52e9.1571414890.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 35/40] qemu: monitor: Add support for blockdev-backup via 'transaction' 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.6.2 (mx1.redhat.com [10.5.110.64]); Fri, 18 Oct 2019 16:12:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Implement the transaction actions generator for blockdev-backup. Signed-off-by: Peter Krempa Reviewed-by: Eric Blake --- src/qemu/qemu_monitor.c | 13 +++++++++++++ src/qemu/qemu_monitor.h | 15 +++++++++++++++ src/qemu/qemu_monitor_json.c | 29 +++++++++++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 8 ++++++++ tests/qemumonitorjsontest.c | 8 +++++++- 5 files changed, 72 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 57229a68c0..6fd2c72769 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4579,3 +4579,16 @@ qemuMonitorTransactionSnapshotBlockdev(virJSONValueP= tr actions, { return qemuMonitorJSONTransactionSnapshotBlockdev(actions, node, overl= ay); } + + +int +qemuMonitorTransactionBackup(virJSONValuePtr actions, + const char *device, + const char *jobname, + const char *target, + const char *bitmap, + qemuMonitorTransactionBackupSyncMode syncmode) +{ + return qemuMonitorJSONTransactionBackup(actions, device, jobname, targ= et, + bitmap, syncmode); +} diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index a1c980e40e..51c421d6ee 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1379,3 +1379,18 @@ int qemuMonitorTransactionSnapshotBlockdev(virJSONValuePtr actions, const char *node, const char *overlay); + +typedef enum { + QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_MODE_NONE =3D 0, + QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_MODE_INCREMENTAL, + QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_MODE_FULL, + QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_MODE_LAST, +} qemuMonitorTransactionBackupSyncMode; + +int +qemuMonitorTransactionBackup(virJSONValuePtr actions, + const char *device, + const char *jobname, + const char *target, + const char *bitmap, + qemuMonitorTransactionBackupSyncMode syncmode= ); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 545911069e..51603d2631 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -9254,6 +9254,35 @@ qemuMonitorJSONTransactionSnapshotBlockdev(virJSONVa= luePtr actions, NULL); } +VIR_ENUM_DECL(qemuMonitorTransactionBackupSyncMode); +VIR_ENUM_IMPL(qemuMonitorTransactionBackupSyncMode, + QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_MODE_LAST, + "none", + "incremental", + "full"); + +int +qemuMonitorJSONTransactionBackup(virJSONValuePtr actions, + const char *device, + const char *jobname, + const char *target, + const char *bitmap, + qemuMonitorTransactionBackupSyncMode sync= mode) +{ + const char *syncmodestr =3D qemuMonitorTransactionBackupSyncModeTypeTo= String(syncmode); + + return qemuMonitorJSONTransactionAdd(actions, + "blockdev-backup", + "s:device", device, + "s:job-id", jobname, + "s:target", target, + "s:sync", syncmodestr, + "S:bitmap", bitmap, + "T:auto-finalize", VIR_TRISTATE_B= OOL_YES, + "T:auto-dismiss", VIR_TRISTATE_BO= OL_NO, + NULL); +} + static qemuMonitorJobInfoPtr qemuMonitorJSONGetJobInfoOne(virJSONValuePtr data) diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 6617783797..dc291fa53f 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -667,3 +667,11 @@ int qemuMonitorJSONTransactionSnapshotBlockdev(virJSONValuePtr actions, const char *node, const char *overlay); + +int +qemuMonitorJSONTransactionBackup(virJSONValuePtr actions, + const char *device, + const char *jobname, + const char *target, + const char *bitmap, + qemuMonitorTransactionBackupSyncMode sync= mode); diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index cefa0f08cf..0ea4579866 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -2992,7 +2992,13 @@ testQemuMonitorJSONTransaction(const void *opaque) qemuMonitorTransactionBitmapDisable(actions, "node4", "bitmap4") <= 0 || qemuMonitorTransactionBitmapMerge(actions, "node5", "bitmap5", &me= rgebitmaps) < 0 || qemuMonitorTransactionSnapshotLegacy(actions, "dev6", "path", "qco= w2", true) < 0 || - qemuMonitorTransactionSnapshotBlockdev(actions, "node7", "overlay7= ") < 0) + qemuMonitorTransactionSnapshotBlockdev(actions, "node7", "overlay7= ") < 0 || + qemuMonitorTransactionBackup(actions, "dev8", "job8", "target8", "= bitmap8", + QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_= MODE_NONE) < 0 || + qemuMonitorTransactionBackup(actions, "dev9", "job9", "target9", "= bitmap9", + QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_= MODE_INCREMENTAL) < 0 || + qemuMonitorTransactionBackup(actions, "devA", "jobA", "targetA", "= bitmapA", + QEMU_MONITOR_TRANSACTION_BACKUP_SYNC_= MODE_FULL) < 0) return -1; if (qemuMonitorTestAddItem(test, "transaction", "{\"return\":{}}") < 0) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415154; cv=none; d=zoho.com; s=zohoarc; b=baNyJcbRTKzQR37cRrT9e6lERwqEUHkd7bltVQRb2KmtO2iIs7dvW0/3JrUt/2+Bns7P8asbYPEcVg5DaeOIEnjdwPpJJYM9iK2tuOWACGS05XnqYklPTMoUCaswwEzDwEoPuF1ONSJo2/FSq7hYwK95ZDtYqIAm8fTF5d/L85U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415154; h=Content-Type:Content-Transfer-Encoding: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; bh=WwdvqAyo9LFsKXL1YWZpnJ4DxDVbXAh+aZWxoTDzWvE=; b=PrIeC9KbemjVThmw40lLiU0NYjJ5/DMFq1h4dXleh8hA+XivRwHo+5gj3vk8sA16AZ0UP79qwpwmIAfRkim08Ucs1uY2ap8XrUTh7ZT6TiSXsdcwl+CEOeVeQmDcpaPFe5YhjFCV0dKypNrsIiKpOlluZe80cVMtRKDG+lcHQQA= 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 1571415154211975.7493331789848; Fri, 18 Oct 2019 09:12:34 -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 AD112C08C33E; Fri, 18 Oct 2019 16:12:32 +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 7ABF0100EBD7; Fri, 18 Oct 2019 16:12:32 +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 381EF180BA9E; Fri, 18 Oct 2019 16:12:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGCQY8005433 for ; Fri, 18 Oct 2019 12:12:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id 595BC600C4; Fri, 18 Oct 2019 16:12:26 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id AEB90600D1; Fri, 18 Oct 2019 16:12:25 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:11:21 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 36/40] qemu: domain: Track backup job 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.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.31]); Fri, 18 Oct 2019 16:12:33 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Store the data of a backup job along with the index counter for new backup jobs in the status XML. Currently we will support only one backup job and thus there's no necessity to add arrays of jobs. Signed-off-by: Peter Krempa Reviewed-by: Eric Blake --- src/qemu/qemu_domain.c | 72 ++++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_domain.h | 4 +++ 2 files changed, 76 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index d5a2ddaa8c..738f06bc5b 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -61,6 +61,7 @@ #include "locking/domain_lock.h" #include "virdomainsnapshotobjlist.h" #include "virdomaincheckpointobjlist.h" +#include "backup_conf.h" #ifdef MAJOR_IN_MKDEV # include @@ -2108,6 +2109,8 @@ qemuDomainObjPrivateAlloc(void *opaque) priv->migMaxBandwidth =3D QEMU_DOMAIN_MIG_BANDWIDTH_MAX; priv->driver =3D opaque; + priv->backupnextid =3D 1; + return priv; error: @@ -2177,6 +2180,10 @@ qemuDomainObjPrivateDataClear(qemuDomainObjPrivatePt= r priv) virHashRemoveAll(priv->blockjobs); virHashRemoveAll(priv->dbusVMStates); + + virDomainBackupDefFree(priv->backup); + priv->backup =3D NULL; + priv->backupnextid =3D 1; } @@ -2593,6 +2600,29 @@ qemuDomainObjPrivateXMLFormatBlockjobs(virBufferPtr = buf, } +static int +qemuDomainObjPrivateXMLFormatBackups(virBufferPtr buf, + virDomainObjPtr vm) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) childBuf =3D VIR_BUFFER_INITIALIZER; + + virBufferSetChildIndent(&childBuf, buf); + + if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_INCREMENTAL_BACKUP)) + return 0; + + virBufferAsprintf(&attrBuf, " nextid=3D'%llu'", priv->backupnextid); + + if (priv->backup && + virDomainBackupDefFormat(&childBuf, priv->backup, true) < 0) + return -1; + + return virXMLFormatElement(buf, "backups", &attrBuf, &childBuf); +} + + void qemuDomainObjPrivateXMLFormatAllowReboot(virBufferPtr buf, virTristateBool allowReboot) @@ -2907,6 +2937,9 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf, if (qemuDomainObjPrivateXMLFormatSlirp(buf, vm) < 0) return -1; + if (qemuDomainObjPrivateXMLFormatBackups(buf, vm) < 0) + return -1; + return 0; } @@ -3272,6 +3305,42 @@ qemuDomainObjPrivateXMLParseBlockjobs(virDomainObjPt= r vm, } +static int +qemuDomainObjPrivateXMLParseBackups(qemuDomainObjPrivatePtr priv, + xmlXPathContextPtr ctxt) +{ + g_autofree xmlNodePtr *nodes =3D NULL; + ssize_t nnodes =3D 0; + + priv->backupnextid =3D 1; + if (virXPathULongLong("string(./backups/@nextid)", ctxt, + &priv->backupnextid) =3D=3D -2) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("failed to parse next backup job id")); + return -1; + } + + if ((nnodes =3D virXPathNodeSet("./backups/domainbackup", ctxt, &nodes= )) < 0) + return -1; + + if (nnodes > 1) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("only one backup job is supported")); + return -1; + } + + if (nnodes =3D=3D 0) + return 0; + + if (!(priv->backup =3D virDomainBackupDefParseNode(ctxt->doc, nodes[0], + priv->driver->xmlopt, + VIR_DOMAIN_BACKUP_PAR= SE_INTERNAL))) + return -1; + + return 0; +} + + int qemuDomainObjPrivateXMLParseAllowReboot(xmlXPathContextPtr ctxt, virTristateBool *allowReboot) @@ -3696,6 +3765,9 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, if (qemuDomainObjPrivateXMLParseBlockjobs(vm, priv, ctxt) < 0) goto error; + if (qemuDomainObjPrivateXMLParseBackups(priv, ctxt) < 0) + goto error; + qemuDomainStorageIdReset(priv); if (virXPathULongLong("string(./nodename/@index)", ctxt, &priv->nodenameindex) =3D=3D -2) { diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 5b3d84cea7..765801895c 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -396,6 +396,10 @@ struct _qemuDomainObjPrivate { virHashTablePtr dbusVMStates; bool disableSlirp; + + /* Running backup jobs. */ + unsigned long long backupnextid; + virDomainBackupDefPtr backup; }; #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 Mon May 6 21:21:54 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=1571415153; cv=none; d=zoho.com; s=zohoarc; b=L/uuJKAwq3ytEZ1soaLCdNorNpI+mNSRYhQe9oacRrekBCAkF5Bfew8PBo8S/MyVKw4zJDXPOrPWiQMdCJM0GsvdRpr5iUpfv+PFuOduM+8m+2DWMsRqv3BTqg5ti3gipW+Xov4Se8E7HW9nXQTHCa71JTETesGL7sc2fDTXyEM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415153; h=Content-Type:Content-Transfer-Encoding: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; bh=vVGIGglKUzi3jNKJeoHfUQYTBGkFAjZE1VctHjIh7m0=; b=Ut+Q+QoTvJCdc/eGUmIqOjijjYzjBfW4cbM+3sZibB4DDaMGfL7et6QqGVoQwlCDlJtFIKJ0g2aPEi9n7keO/8CMPt4WRxcRrnFrpQ1iZilZon6H9iTxxauUMjVJxQ2d5iOhdDd3z081CjjY3vtTfLPNbsjX9pStyL+/4TGrPj4= 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 1571415153366591.7856042249937; Fri, 18 Oct 2019 09:12:33 -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 95BCD10C094F; Fri, 18 Oct 2019 16:12:31 +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 6A60F6061E; Fri, 18 Oct 2019 16:12:31 +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 1F3133FB5B; Fri, 18 Oct 2019 16:12:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGCRSl005443 for ; Fri, 18 Oct 2019 12:12:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4F3EA600D1; Fri, 18 Oct 2019 16:12:27 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id A541A600C4; Fri, 18 Oct 2019 16:12:26 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:11:22 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 37/40] qemu: blockjob: Track internal data for 'backup' blockjob 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.6.2 (mx1.redhat.com [10.5.110.66]); Fri, 18 Oct 2019 16:12:32 +0000 (UTC) Content-Type: text/plain; charset="utf-8" A backup blockjob needs to be able to notify the parent backup job as well as track all data to be able to clean up the bitmap and blockdev used for the backup. Add the data structure, job allocation function and status XML formatter and parser. Signed-off-by: Peter Krempa --- src/qemu/qemu_blockjob.c | 33 +++++++++++++++++++++++++++++++++ src/qemu/qemu_blockjob.h | 18 ++++++++++++++++++ src/qemu/qemu_domain.c | 21 +++++++++++++++++++++ 3 files changed, 72 insertions(+) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index 6d66d75ed7..6f190b3485 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -83,6 +83,11 @@ qemuBlockJobDataDispose(void *obj) if (job->type =3D=3D QEMU_BLOCKJOB_TYPE_CREATE) virObjectUnref(job->data.create.src); + if (job->type =3D=3D QEMU_BLOCKJOB_TYPE_BACKUP) { + virObjectUnref(job->data.backup.store); + g_free(job->data.backup.bitmap); + } + g_free(job->name); g_free(job->errmsg); } @@ -350,6 +355,34 @@ qemuBlockJobDiskNewCopy(virDomainObjPtr vm, } +qemuBlockJobDataPtr +qemuBlockJobDiskNewBackup(virDomainObjPtr vm, + virDomainDiskDefPtr disk, + virStorageSourcePtr store, + const char *bitmap, + int jobid) +{ + g_autoptr(qemuBlockJobData) job =3D NULL; + g_autofree char *jobname =3D NULL; + + jobname =3D g_strdup_printf("backup-%s-%s", disk->dst, disk->src->node= format); + + if (!(job =3D qemuBlockJobDataNew(QEMU_BLOCKJOB_TYPE_BACKUP, jobname))) + return NULL; + + job->data.backup.bitmap =3D g_strdup(bitmap); + job->data.backup.store =3D virObjectRef(store); + job->data.backup.jobid =3D jobid; + + /* backup jobs are usually started in bulk by transaction so the caller + * shall save the status XML */ + if (qemuBlockJobRegister(job, vm, disk, false) < 0) + return NULL; + + return g_steal_pointer(&job); +} + + /** * qemuBlockJobDiskGetJob: * @disk: disk definition diff --git a/src/qemu/qemu_blockjob.h b/src/qemu/qemu_blockjob.h index 8b28990801..21b07ff884 100644 --- a/src/qemu/qemu_blockjob.h +++ b/src/qemu/qemu_blockjob.h @@ -106,6 +106,16 @@ struct _qemuBlockJobCopyData { }; +typedef struct _qemuBlockJobBackupData qemuBlockJobBackupData; +typedef qemuBlockJobBackupData *qemuBlockJobDataBackupPtr; + +struct _qemuBlockJobBackupData { + virStorageSourcePtr store; + char *bitmap; + int jobid; +}; + + typedef struct _qemuBlockJobData qemuBlockJobData; typedef qemuBlockJobData *qemuBlockJobDataPtr; @@ -123,6 +133,7 @@ struct _qemuBlockJobData { qemuBlockJobCommitData commit; qemuBlockJobCreateData create; qemuBlockJobCopyData copy; + qemuBlockJobBackupData backup; } data; int type; /* qemuBlockJobType */ @@ -181,6 +192,13 @@ qemuBlockJobDiskNewCopy(virDomainObjPtr vm, bool shallow, bool reuse); +qemuBlockJobDataPtr +qemuBlockJobDiskNewBackup(virDomainObjPtr vm, + virDomainDiskDefPtr disk, + virStorageSourcePtr store, + const char *bitmap, + int jobid); + qemuBlockJobDataPtr qemuBlockJobDiskGetJob(virDomainDiskDefPtr disk) ATTRIBUTE_NONNULL(1); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 738f06bc5b..b649341c9c 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2564,6 +2564,16 @@ qemuDomainObjPrivateXMLFormatBlockjobIterator(void *= payload, break; case QEMU_BLOCKJOB_TYPE_BACKUP: + virBufferEscapeString(&childBuf, "\n", jo= b->data.backup.bitmap); + virBufferAsprintf(&childBuf, "\n", job->dat= a.backup.jobid); + if (job->data.backup.store && + qemuDomainObjPrivateXMLFormatBlockjobFormatSource(&childBu= f, + "store", + job->dat= a.backup.store, + data->xm= lopt, + false) <= 0) + return -1; + case QEMU_BLOCKJOB_TYPE_NONE: case QEMU_BLOCKJOB_TYPE_INTERNAL: case QEMU_BLOCKJOB_TYPE_LAST: @@ -3174,6 +3184,17 @@ qemuDomainObjPrivateXMLParseBlockjobDataSpecific(qem= uBlockJobDataPtr job, break; case QEMU_BLOCKJOB_TYPE_BACKUP: + if (!(job->data.backup.bitmap =3D virXPathString("string(./bi= tmap/@name)", ctxt))) + goto broken; + + if (virXPathInt("string(./backup/@id)", ctxt, &job->data.backu= p.jobid) < 0) + goto broken; + + if (!(tmp =3D virXPathNode("./store", ctxt)) || + !(job->data.backup.store =3D qemuDomainObjPrivateXMLParseB= lockjobChain(tmp, ctxt, xmlopt))) + goto broken; + break; + case QEMU_BLOCKJOB_TYPE_NONE: case QEMU_BLOCKJOB_TYPE_INTERNAL: case QEMU_BLOCKJOB_TYPE_LAST: --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 21:21:54 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=1571415158; cv=none; d=zoho.com; s=zohoarc; b=i4aMPoEyhoIDUHwpR2yj6Qj8+QiQRwNROGt6sO8ooMGZZt/3ycBLqcDOb2CX8/KSQeX0bKzECNyAJhl65eHIEBUjDNuZXkOWeDrEa+5gL9kyy2AYR/qsfRN/8RQA0uf4qR5ywzNWQ7e4y6edEMIleb1tBkLES3iz1sNfCcT/cZs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571415158; h=Content-Type:Content-Transfer-Encoding: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; bh=WY6YJVXs71GLdyLs7otm4MbrEU5u3xnNYPufVR+f458=; b=Wu1hnW+99iXW6era14uGqQ1BfJ3k7IvjrRXLEhqAcI3i2AtcqC2cAo7mUcRzhCJBRjCmGGf2p8PHSPl+zhGFKA325NnlFfmmw7f9QP1jalybT9nMdyPM1CsARRLOtJh9l/gFekJkPEDjKlyVIee62HNB/5YIK8YSK8jJ7T8+PZs= 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 1571415158160588.2848843540429; Fri, 18 Oct 2019 09:12:38 -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 9B08F309BF17; Fri, 18 Oct 2019 16:12:36 +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 797435D9DC; Fri, 18 Oct 2019 16:12:36 +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 38DF63FB5E; Fri, 18 Oct 2019 16:12:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9IGCSah005468 for ; Fri, 18 Oct 2019 12:12:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 460D5600D1; Fri, 18 Oct 2019 16:12:28 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C28D600C8; Fri, 18 Oct 2019 16:12:27 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 18 Oct 2019 18:11:23 +0200 Message-Id: <963759a964789d913d05d7aac5e8e9a8c9dda4c3.1571414890.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RFC 38/40] tests: qemustatusxml2xml: Add test for 'pull' type backup job 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.45]); Fri, 18 Oct 2019 16:12:37 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: Eric Blake --- .../qemustatusxml2xmldata/backup-pull-in.xml | 607 ++++++++++++++++++ .../qemustatusxml2xmldata/backup-pull-out.xml | 1 + tests/qemuxml2xmltest.c | 2 + 3 files changed, 610 insertions(+) create mode 100644 tests/qemustatusxml2xmldata/backup-pull-in.xml create mode 120000 tests/qemustatusxml2xmldata/backup-pull-out.xml diff --git a/tests/qemustatusxml2xmldata/backup-pull-in.xml b/tests/qemusta= tusxml2xmldata/backup-pull-in.xml new file mode 100644 index 0000000000..afb23bfe96 --- /dev/null +++ b/tests/qemustatusxml2xmldata/backup-pull-in.xml @@ -0,0 +1,607 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 12345 + + + + + + + + + + copy + 0439a4a8-db56-4933-9183-d8681d7b0746 + 1024000 + 1024000 + 1 + + /machine + + + hvm + + + + + + + + + + + + + + destroy + restart + restart + + + + + + /usr/bin/qemu-system-x86_64 + + + + + + + + + + + + + + + + + + + pull3.qcow2 + + + + + + + + + + + pull2.qcow2 + + + + + + + + + + + pull1.qcow2 + + + + + + + + + + + pull0.qcow2 + + + + + + + + + +
      + + + + + + + + + + + + + + + + + + + + + + + commit3.qcow2 + + + + + + + + + + + commit2.qcow2 + + + + + + + + + + + commit1.qcow2 + + + + + + + + + + + commit0.qcow2 + + + + + + + + + +
      + + + + + + + + + + + + + + + + + + + + + + + copy3.qcow2 + + + + + + + + + + + copy2.qcow2 + + + + + + + + + + + copy1.qcow2 + + + + + + + + + + + copy0.qcow2 + + + + + + + + + +
      + + + + + + + + + + + + + + + + + + + + + + + activecommit3.qcow2 + + + + + + + + + + + activecommit2.qcow2 + + + + + + + + + + + activecommit1.qcow2 + + + + + + + + + + + activecommit0.qcow2 + + + + + + + + + +
      + + + + + + +
      + + + + + + + + + + + + + + + + + + + + + + + + + + +