From nobody Fri Mar 29 12:36:34 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=1567519721; cv=none; d=zoho.com; s=zohoarc; b=RdazQpRooNnW41R9LWORAtHiRqLVusK5c6goFjjN9pVXtFN+UWLGU+UirXe0SPCc9BTzbw0P2mQFmEhVAwTJOOmsoxVcweNuk6HDd71p/c9n/udAkGVssPdTsgpdErdMaef+obd1Nv2CbK5+6TVKMrGDS6V9uCEey8/xuBTriXo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567519721; 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:ARC-Authentication-Results; bh=5OOl3wh67cm+lm477hHdirF1IS5sStvkj5IuPPZMDZ0=; b=DFM9TtWI89acpiOS3ogKqqXeh9145mrqMU4cJjKnUk1pc3o1nN/I7t8IJaqV429cBBc3KyO6LAb/lO4Xx3t5wPvSc3irnqOK7EF5QkTiJveFogOvUdBQtJx9FG63jF006PKAGXomQYZ334cJwwcsp4wkI4MYJX3Lsht7Eek1HyQ= 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 1567519721642661.1936471514048; Tue, 3 Sep 2019 07:08:41 -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 EA5983084288; Tue, 3 Sep 2019 14:08:39 +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 AFBF06012E; Tue, 3 Sep 2019 14:08:39 +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 6E59624F30; Tue, 3 Sep 2019 14:08:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x83E8GKn009527 for ; Tue, 3 Sep 2019 10:08:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3B2F51001B05; Tue, 3 Sep 2019 14:08:16 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id B9218100195C for ; Tue, 3 Sep 2019 14:08:15 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 3 Sep 2019 16:07:54 +0200 Message-Id: <8535e05606ae07e014d118fd829f53197607610c.1567519340.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 01/18] qemu: block: Use correct type when creating image size JSON entries 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.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.40]); Tue, 03 Sep 2019 14:08:40 +0000 (UTC) The 'u' modifier creates an unsigned int JSON attribute but the disk size and capacity fields are unsigned long long. If the size of the created image would be more than 4GiB we'd overflow and create sub-4G image. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_block.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 66b1d116d8..e33aad4458 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -2034,7 +2034,7 @@ qemuBlockStorageSourceCreateGetFormatPropsGeneric(vir= StorageSourcePtr src, if (virJSONValueObjectCreate(&props, "s:driver", driver, "s:file", src->nodestorage, - "u:size", src->capacity, + "U:size", src->capacity, NULL) < 0) return -1; @@ -2100,7 +2100,7 @@ qemuBlockStorageSourceCreateGetFormatPropsLUKS(virSto= rageSourcePtr src, if (virJSONValueObjectAdd(luksprops, "s:driver", "luks", "s:file", src->nodestorage, - "u:size", src->capacity, + "U:size", src->capacity, NULL) < 0) return -1; @@ -2153,7 +2153,7 @@ qemuBlockStorageSourceCreateGetFormatPropsQcow2(virSt= orageSourcePtr src, if (virJSONValueObjectCreate(&qcow2props, "s:driver", "qcow2", "s:file", src->nodestorage, - "u:size", src->capacity, + "U:size", src->capacity, "S:version", qcow2version, NULL) < 0) return -1; @@ -2177,7 +2177,7 @@ qemuBlockStorageSourceCreateGetFormatPropsQcow(virSto= rageSourcePtr src, if (virJSONValueObjectCreate(&qcowprops, "s:driver", "qcow", "s:file", src->nodestorage, - "u:size", src->capacity, + "U:size", src->capacity, NULL) < 0) return -1; @@ -2200,7 +2200,7 @@ qemuBlockStorageSourceCreateGetFormatPropsQed(virStor= ageSourcePtr src, if (virJSONValueObjectCreate(&qedprops, "s:driver", "qed", "s:file", src->nodestorage, - "u:size", src->capacity, + "U:size", src->capacity, NULL) < 0) return -1; @@ -2373,7 +2373,7 @@ qemuBlockStorageSourceCreateGetStorageProps(virStorag= eSourcePtr src, "s:driver", driver, "S:filename", filename, "A:location", &location, - "u:size", src->physical, + "U:size", src->physical, NULL) < 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 Fri Mar 29 12:36:34 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=1567519733; cv=none; d=zoho.com; s=zohoarc; b=ezu/fVvCCetYQbzoaHF0Fmbihstbg0ru8Zy+EWWmVbukJJFV8nH3wdbZ9ue9Dbe0zQCRfDE3moT63tovCavUOMNJjAoXtPzhQER/KghZfgffKMtL6YP+8ZpMZ+CuY0hGAF5o3wMCmcRlSfFvOKC3hOQJ1sOh7jm5tn1TdFl+tnM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567519733; 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:ARC-Authentication-Results; bh=WUoo7+zSM2lo/n6GXTPkFGhymZr04I5XTdxqNsPnP/Y=; b=JyZbD5lang9ttx7SYauetBJjGINzYyC/myOr8YCUZcPEVMPE6Z3JQWGchN8GTDDm+XEDiO6xv07Gjw8ItsPorEfQEPGcuasNN2ne1iheihqocoweZ2fIGTwkXQ+y++zgfg62tFT8DzkKj722b/jnrQ7qE0ACDbxKlUiwoM6LTBU= 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 1567519733782334.60524742969335; Tue, 3 Sep 2019 07:08:53 -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 5E647A36F11; Tue, 3 Sep 2019 14:08:52 +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 36FFF6013A; Tue, 3 Sep 2019 14:08:52 +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 EE90B24F33; Tue, 3 Sep 2019 14:08:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x83E8Hfi009533 for ; Tue, 3 Sep 2019 10:08:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0C67F100197A; Tue, 3 Sep 2019 14:08:17 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A3761001B0B for ; Tue, 3 Sep 2019 14:08:16 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 3 Sep 2019 16:07:55 +0200 Message-Id: <3dacf5cbe5897b4de06163b94fea1991eafdd4c0.1567519340.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 02/18] tests: qemublock: Use bigger numbers as dummy capacity/physical 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.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.68]); Tue, 03 Sep 2019 14:08:52 +0000 (UTC) Actually test that the full range is available. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemublocktest.c | 4 ++-- tests/qemublocktestdata/imagecreate/luks-encopts.json | 4 ++-- tests/qemublocktestdata/imagecreate/luks-noopts.json | 4 ++-- .../qemublocktestdata/imagecreate/network-gluster-qcow2.json | 4 ++-- tests/qemublocktestdata/imagecreate/network-rbd-qcow2.json | 4 ++-- .../qemublocktestdata/imagecreate/network-sheepdog-qcow2.json | 4 ++-- tests/qemublocktestdata/imagecreate/network-ssh-qcow2.json | 4 ++-- tests/qemublocktestdata/imagecreate/qcow2-backing-luks.json | 4 ++-- .../qemublocktestdata/imagecreate/qcow2-backing-raw-nbd.json | 4 ++-- tests/qemublocktestdata/imagecreate/qcow2-backing-raw.json | 4 ++-- .../imagecreate/qcow2-luks-encopts-backing.json | 4 ++-- tests/qemublocktestdata/imagecreate/qcow2-luks-encopts.json | 4 ++-- tests/qemublocktestdata/imagecreate/qcow2-luks-noopts.json | 4 ++-- tests/qemublocktestdata/imagecreate/qcow2.json | 4 ++-- tests/qemublocktestdata/imagecreate/raw.json | 2 +- 15 files changed, 29 insertions(+), 29 deletions(-) diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 0bc4b65449..1bf72a4615 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -420,8 +420,8 @@ testQemuImageCreate(const void *opaque) return -1; /* fake some sizes */ - src->capacity =3D 1337; - src->physical =3D 42; + src->capacity =3D UINT_MAX * 2ULL; + src->physical =3D UINT_MAX + 1ULL; if (qemuDomainValidateStorageSource(src, data->qemuCaps) < 0) return -1; diff --git a/tests/qemublocktestdata/imagecreate/luks-encopts.json b/tests/= qemublocktestdata/imagecreate/luks-encopts.json index f065ad89a7..c5ca863f5b 100644 --- a/tests/qemublocktestdata/imagecreate/luks-encopts.json +++ b/tests/qemublocktestdata/imagecreate/luks-encopts.json @@ -2,7 +2,7 @@ protocol: { "driver": "file", "filename": "/var/lib/libvirt/images/i.img", - "size": 42 + "size": 4294967296 } format: @@ -15,5 +15,5 @@ format: "ivgen-hash-alg": "sha256", "driver": "luks", "file": "0123456789ABCDEF0123456789ABCDE", - "size": 1337 + "size": 8589934590 } diff --git a/tests/qemublocktestdata/imagecreate/luks-noopts.json b/tests/q= emublocktestdata/imagecreate/luks-noopts.json index 1ea1948119..8a0944151d 100644 --- a/tests/qemublocktestdata/imagecreate/luks-noopts.json +++ b/tests/qemublocktestdata/imagecreate/luks-noopts.json @@ -2,7 +2,7 @@ protocol: { "driver": "file", "filename": "/var/lib/libvirt/images/i.img", - "size": 42 + "size": 4294967296 } format: @@ -10,5 +10,5 @@ format: "key-secret": "0123456789ABCDEF0123456789ABCDE-encalias", "driver": "luks", "file": "0123456789ABCDEF0123456789ABCDE", - "size": 1337 + "size": 8589934590 } diff --git a/tests/qemublocktestdata/imagecreate/network-gluster-qcow2.json= b/tests/qemublocktestdata/imagecreate/network-gluster-qcow2.json index aee7bfd401..3e35beb088 100644 --- a/tests/qemublocktestdata/imagecreate/network-gluster-qcow2.json +++ b/tests/qemublocktestdata/imagecreate/network-gluster-qcow2.json @@ -17,12 +17,12 @@ protocol: } ] }, - "size": 42 + "size": 4294967296 } format: { "driver": "qcow2", "file": "0123456789ABCDEF0123456789ABCDE", - "size": 1337 + "size": 8589934590 } diff --git a/tests/qemublocktestdata/imagecreate/network-rbd-qcow2.json b/t= ests/qemublocktestdata/imagecreate/network-rbd-qcow2.json index 56d9c0f1ed..67e2679dae 100644 --- a/tests/qemublocktestdata/imagecreate/network-rbd-qcow2.json +++ b/tests/qemublocktestdata/imagecreate/network-rbd-qcow2.json @@ -15,12 +15,12 @@ protocol: } ] }, - "size": 42 + "size": 4294967296 } format: { "driver": "qcow2", "file": "0123456789ABCDEF0123456789ABCDE", - "size": 1337 + "size": 8589934590 } diff --git a/tests/qemublocktestdata/imagecreate/network-sheepdog-qcow2.jso= n b/tests/qemublocktestdata/imagecreate/network-sheepdog-qcow2.json index b7272625a2..d86bef6bc8 100644 --- a/tests/qemublocktestdata/imagecreate/network-sheepdog-qcow2.json +++ b/tests/qemublocktestdata/imagecreate/network-sheepdog-qcow2.json @@ -9,12 +9,12 @@ protocol: }, "vdi": "asdf/i.qcow2" }, - "size": 42 + "size": 4294967296 } format: { "driver": "qcow2", "file": "0123456789ABCDEF0123456789ABCDE", - "size": 1337 + "size": 8589934590 } diff --git a/tests/qemublocktestdata/imagecreate/network-ssh-qcow2.json b/t= ests/qemublocktestdata/imagecreate/network-ssh-qcow2.json index 31416ed4fc..d58054c081 100644 --- a/tests/qemublocktestdata/imagecreate/network-ssh-qcow2.json +++ b/tests/qemublocktestdata/imagecreate/network-ssh-qcow2.json @@ -8,12 +8,12 @@ protocol: "port": "1234" } }, - "size": 42 + "size": 4294967296 } format: { "driver": "qcow2", "file": "0123456789ABCDEF0123456789ABCDE", - "size": 1337 + "size": 8589934590 } diff --git a/tests/qemublocktestdata/imagecreate/qcow2-backing-luks.json b/= tests/qemublocktestdata/imagecreate/qcow2-backing-luks.json index 63ba35dc79..5f9a800c6c 100644 --- a/tests/qemublocktestdata/imagecreate/qcow2-backing-luks.json +++ b/tests/qemublocktestdata/imagecreate/qcow2-backing-luks.json @@ -2,14 +2,14 @@ protocol: { "driver": "file", "filename": "/var/lib/libvirt/images/i.qcow2", - "size": 42 + "size": 4294967296 } format: { "driver": "qcow2", "file": "0123456789ABCDEF0123456789ABCDE", - "size": 1337, + "size": 8589934590, "backing-file": "/var/lib/libvirt/images/i.img", "backing-fmt": "luks" } diff --git a/tests/qemublocktestdata/imagecreate/qcow2-backing-raw-nbd.json= b/tests/qemublocktestdata/imagecreate/qcow2-backing-raw-nbd.json index b9d1d97302..c10ab98c8a 100644 --- a/tests/qemublocktestdata/imagecreate/qcow2-backing-raw-nbd.json +++ b/tests/qemublocktestdata/imagecreate/qcow2-backing-raw-nbd.json @@ -2,14 +2,14 @@ protocol: { "driver": "file", "filename": "/var/lib/libvirt/images/i.qcow2", - "size": 42 + "size": 4294967296 } format: { "driver": "qcow2", "file": "0123456789ABCDEF0123456789ABCDE", - "size": 1337, + "size": 8589934590, "backing-file": "nbd://example.com:1234", "backing-fmt": "raw" } diff --git a/tests/qemublocktestdata/imagecreate/qcow2-backing-raw.json b/t= ests/qemublocktestdata/imagecreate/qcow2-backing-raw.json index 8176c8dadd..eb9fb413f6 100644 --- a/tests/qemublocktestdata/imagecreate/qcow2-backing-raw.json +++ b/tests/qemublocktestdata/imagecreate/qcow2-backing-raw.json @@ -2,14 +2,14 @@ protocol: { "driver": "file", "filename": "/var/lib/libvirt/images/i.qcow2", - "size": 42 + "size": 4294967296 } format: { "driver": "qcow2", "file": "0123456789ABCDEF0123456789ABCDE", - "size": 1337, + "size": 8589934590, "backing-file": "/var/lib/libvirt/images/i.img", "backing-fmt": "raw" } diff --git a/tests/qemublocktestdata/imagecreate/qcow2-luks-encopts-backing= .json b/tests/qemublocktestdata/imagecreate/qcow2-luks-encopts-backing.json index a57617dfac..641b5e04c9 100644 --- a/tests/qemublocktestdata/imagecreate/qcow2-luks-encopts-backing.json +++ b/tests/qemublocktestdata/imagecreate/qcow2-luks-encopts-backing.json @@ -2,14 +2,14 @@ protocol: { "driver": "file", "filename": "/var/lib/libvirt/images/i.qcow2", - "size": 42 + "size": 4294967296 } format: { "driver": "qcow2", "file": "0123456789ABCDEF0123456789ABCDE", - "size": 1337, + "size": 8589934590, "backing-file": "/var/lib/libvirt/images/i.qcow2", "backing-fmt": "qcow2", "encrypt": { diff --git a/tests/qemublocktestdata/imagecreate/qcow2-luks-encopts.json b/= tests/qemublocktestdata/imagecreate/qcow2-luks-encopts.json index 8796726fcb..28c85ec90b 100644 --- a/tests/qemublocktestdata/imagecreate/qcow2-luks-encopts.json +++ b/tests/qemublocktestdata/imagecreate/qcow2-luks-encopts.json @@ -2,14 +2,14 @@ protocol: { "driver": "file", "filename": "/var/lib/libvirt/images/i.qcow2", - "size": 42 + "size": 4294967296 } format: { "driver": "qcow2", "file": "0123456789ABCDEF0123456789ABCDE", - "size": 1337, + "size": 8589934590, "encrypt": { "key-secret": "0123456789ABCDEF0123456789ABCDE-encalias", "cipher-alg": "serpent-256", diff --git a/tests/qemublocktestdata/imagecreate/qcow2-luks-noopts.json b/t= ests/qemublocktestdata/imagecreate/qcow2-luks-noopts.json index f9caaee6bb..b5063a846d 100644 --- a/tests/qemublocktestdata/imagecreate/qcow2-luks-noopts.json +++ b/tests/qemublocktestdata/imagecreate/qcow2-luks-noopts.json @@ -2,14 +2,14 @@ protocol: { "driver": "file", "filename": "/var/lib/libvirt/images/i.qcow2", - "size": 42 + "size": 4294967296 } format: { "driver": "qcow2", "file": "0123456789ABCDEF0123456789ABCDE", - "size": 1337, + "size": 8589934590, "encrypt": { "key-secret": "0123456789ABCDEF0123456789ABCDE-encalias", "format": "luks" diff --git a/tests/qemublocktestdata/imagecreate/qcow2.json b/tests/qemublo= cktestdata/imagecreate/qcow2.json index 7142cf67b6..732763b763 100644 --- a/tests/qemublocktestdata/imagecreate/qcow2.json +++ b/tests/qemublocktestdata/imagecreate/qcow2.json @@ -2,12 +2,12 @@ protocol: { "driver": "file", "filename": "/var/lib/libvirt/images/i.qcow2", - "size": 42 + "size": 4294967296 } format: { "driver": "qcow2", "file": "0123456789ABCDEF0123456789ABCDE", - "size": 1337 + "size": 8589934590 } diff --git a/tests/qemublocktestdata/imagecreate/raw.json b/tests/qemublock= testdata/imagecreate/raw.json index 06abb25ab9..89a6c2d237 100644 --- a/tests/qemublocktestdata/imagecreate/raw.json +++ b/tests/qemublocktestdata/imagecreate/raw.json @@ -2,7 +2,7 @@ protocol: { "driver": "file", "filename": "/var/lib/libvirt/images/i.img", - "size": 42 + "size": 4294967296 } format: --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Mar 29 12:36:34 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=1567519721; cv=none; d=zoho.com; s=zohoarc; b=f5xRMcaFw4ogeh8inWIf0NUMstaF+iW/QDYv+5kmImyfb4BjPLJ1Q0DiO7CGXpdEVMG2vVRjCaYmVm9bzk5RJYVSSjD9kaHiZk7iRYLnaEtT0YJDhqilokLzh98GfKdn+dcpAfIZo2M5HNAjujYfSQQyXv1w+C+q4t8Hlz0Bbio= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567519721; 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:ARC-Authentication-Results; bh=Du/OO8EA84rLU0k0nHqSzkxLBpj8XksTdMDHLdqEHLw=; b=VsDClqGPGZ6xpJ+u8l/IKpjEOxPJGgCJef/pqF9VaOI7cmeUTbugxMV+3cAFYtnZ5+xLIVsE7fUCks7dr4W2+Ojb58aqXzE3MyRprGA4Cn0q13rETjj+l+zGUO4VMmpI/2eehS24AkgwtZCljv0n2S/3YakpvKxlJT/KNVa4Eyg= 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 1567519721976983.2958860793188; Tue, 3 Sep 2019 07:08:41 -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 AE3313082E61; Tue, 3 Sep 2019 14:08:40 +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 89AD960923; Tue, 3 Sep 2019 14:08:40 +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 3F67A1802216; Tue, 3 Sep 2019 14:08:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x83E8H6s009544 for ; Tue, 3 Sep 2019 10:08:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id D03BF100195C; Tue, 3 Sep 2019 14:08:17 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A28310016EB for ; Tue, 3 Sep 2019 14:08:17 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 3 Sep 2019 16:07:56 +0200 Message-Id: <3917cf38b2aaca7c0a9bd38162370ee4aa694e5d.1567519340.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 03/18] qemu: monitor: Fix formatting of 'offset' in qemuMonitorJSONSaveMemory 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.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.46]); Tue, 03 Sep 2019 14:08:41 +0000 (UTC) The offset is unsigned long long thus 'U' must be used. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_monitor_json.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index da1e89dded..e4404f0199 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -3123,7 +3123,7 @@ static int qemuMonitorJSONSaveMemory(qemuMonitorPtr m= on, int ret =3D -1; virJSONValuePtr cmd =3D qemuMonitorJSONMakeCommand(cmdtype, "U:val", offset, - "u:size", length, + "U:size", length, "s:filename", path, NULL); virJSONValuePtr reply =3D NULL; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Mar 29 12:36:34 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=1567519727; cv=none; d=zoho.com; s=zohoarc; b=KcrvW/IAw7eTd2zZnb/xw+9auDeJp3V4i2gX0GA3gqOypEOt5ncx+os21s/1DRH9dDpnS5cAMl6hamqwGBqVWW7KLWrp+IgPwlFYbBw2maKjrNrUPQOOtWiwkhpqLUnrvHCgyv4iVU2e6E6OdNS4YbaKyIazIoHvjy1vNLk4pRk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567519727; 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:ARC-Authentication-Results; bh=sm1Hhfh8efVfUlkumuMa3orBAE4xYC6UvOoPGCpw58U=; b=i3JPL/o9DLa+Vg41EDEEdlrvMQTZ7fpHi2tLMPkqwBcA3iR7kvv4ARR2aXRWnfvg0sroFuhpAOO5GOIgssonJ4B+n9YzqWq6IgSpcUdAVKdT7ART1IqlxFOeBiyRvjcItVfAf22NTsSd1ZHkSxV8uh06ql4N8F39utm/2e1yeVA= 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 1567519727720307.0033870135509; Tue, 3 Sep 2019 07:08: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 50F5510C0312; Tue, 3 Sep 2019 14:08:46 +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 2A8685DC18; Tue, 3 Sep 2019 14:08: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 E0357180221F; Tue, 3 Sep 2019 14:08:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x83E8I94009553 for ; Tue, 3 Sep 2019 10:08:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id A12AB10016EB; Tue, 3 Sep 2019 14:08:18 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2ADF2100195C for ; Tue, 3 Sep 2019 14:08:18 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 3 Sep 2019 16:07:57 +0200 Message-Id: <206b2565200069f745ff8d3922ccc4c29125d732.1567519340.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 04/18] qemu: block: Unify conditions to format backing store of format node definition 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.65]); Tue, 03 Sep 2019 14:08:46 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Move all bits of the formatting of the 'backing' attribute to a single condition and make it use a single extracted copy of the backing store. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_block.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index e33aad4458..54b829efed 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1404,32 +1404,34 @@ qemuBlockStorageSourceGetBlockdevFormatProps(virSto= rageSourcePtr src) virJSONValuePtr qemuBlockStorageSourceGetBlockdevProps(virStorageSourcePtr src) { - bool backingSupported =3D src->format >=3D VIR_STORAGE_FILE_BACKING; + virStorageSourcePtr backingStore =3D src->backingStore; VIR_AUTOPTR(virJSONValue) props =3D NULL; - if (virStorageSourceHasBacking(src) && !backingSupported) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("storage format '%s' does not support backing sto= re"), - virStorageFileFormatTypeToString(src->format)); - return NULL; - } - if (!(props =3D qemuBlockStorageSourceGetBlockdevFormatProps(src))) return NULL; if (virJSONValueObjectAppendString(props, "file", src->nodestorage) < = 0) return NULL; - if (src->backingStore && backingSupported) { - if (virStorageSourceHasBacking(src)) { - if (virJSONValueObjectAppendString(props, "backing", - src->backingStore->nodeform= at) < 0) - return NULL; + if (backingStore) { + if (src->format >=3D VIR_STORAGE_FILE_BACKING) { + if (virStorageSourceIsBacking(backingStore)) { + if (virJSONValueObjectAppendString(props, "backing", + backingStore->nodeforma= t) < 0) + return NULL; + } else { + /* chain is terminated, indicate that no detection should = happen + * in qemu */ + if (virJSONValueObjectAppendNull(props, "backing") < 0) + return NULL; + } } else { - /* chain is terminated, indicate that no detection should happ= en - * in qemu */ - if (virJSONValueObjectAppendNull(props, "backing") < 0) + if (virStorageSourceIsBacking(backingStore)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("storage format '%s' does not support bac= king store"), + virStorageFileFormatTypeToString(src->forma= t)); return NULL; + } } } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Mar 29 12:36:34 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=1567519727; cv=none; d=zoho.com; s=zohoarc; b=XNcHDKOmZTdn1RNxS0Prvkw4O0bcgS98Q/qxV8IVGTWOuTndAUSvisDUMzVwnsXrYyH+RKttQ2WxRfAg4IznCC9+iUM6WOGBU8toI/sd1YelmExv/8iJALScGY1WN996OhyeMSEU/05qRoIdNqpbL6d2NNTcATKx6B2s8ASTRfQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567519727; 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:ARC-Authentication-Results; bh=mi5/RHbYZTeQX0tGHQx+7NogUBfAuBMDxRYfAjsphJ4=; b=Jnk1Wa33JaOroCAanp1na2OixWwaLRBolu6+lQS3TJtz41ihtLfFxo5iZN7h2lzkJOK/qxrrJ8qcJVtmih3tg9yhU6AGrVFvQpkqx/leSVoyabiZc3nA8L2hmFuNyebfg3A1FNuCC6m+7ANgU28Bm8kDZp9hmRo5OMvGRxqQZRs= 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 1567519727956772.4340487938038; Tue, 3 Sep 2019 07:08:47 -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 73AE2C08EC0B; Tue, 3 Sep 2019 14:08:46 +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 496DD608C1; Tue, 3 Sep 2019 14:08: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 0D7141802220; Tue, 3 Sep 2019 14:08:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x83E8Jl2009560 for ; Tue, 3 Sep 2019 10:08:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 724331001B05; Tue, 3 Sep 2019 14:08:19 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id EFFE2100195C for ; Tue, 3 Sep 2019 14:08:18 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 3 Sep 2019 16:07:58 +0200 Message-Id: <1c1fcbc6a83f2fcc6c83967ca660a97dd3844eff.1567519340.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 05/18] qemu: block: Explicitly specify backingStore when creating format layer props 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]); Tue, 03 Sep 2019 14:08:46 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Pass in backing store explicitly to qemuBlockStorageSourceGetBlockdevProps and fix the callers. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_block.c | 8 +++++--- src/qemu/qemu_block.h | 3 ++- tests/qemublocktest.c | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 54b829efed..fb631276c9 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1396,15 +1396,16 @@ qemuBlockStorageSourceGetBlockdevFormatProps(virSto= rageSourcePtr src) * qemuBlockStorageSourceGetBlockdevProps: * * @src: storage source to format + * @backingStore: a storage source to use as backing of @src * * Formats @src into a JSON object which can be used with blockdev-add or * -blockdev. The formatted object contains both the storage and format la= yer * in nested form including link to the backing chain layer if necessary. */ virJSONValuePtr -qemuBlockStorageSourceGetBlockdevProps(virStorageSourcePtr src) +qemuBlockStorageSourceGetBlockdevProps(virStorageSourcePtr src, + virStorageSourcePtr backingStore) { - virStorageSourcePtr backingStore =3D src->backingStore; VIR_AUTOPTR(virJSONValue) props =3D NULL; if (!(props =3D qemuBlockStorageSourceGetBlockdevFormatProps(src))) @@ -1484,7 +1485,8 @@ qemuBlockStorageSourceAttachPrepareBlockdev(virStorag= eSourcePtr src, if (VIR_ALLOC(data) < 0) return NULL; - if (!(data->formatProps =3D qemuBlockStorageSourceGetBlockdevProps(src= )) || + if (!(data->formatProps =3D qemuBlockStorageSourceGetBlockdevProps(src, + src->= backingStore)) || !(data->storageProps =3D qemuBlockStorageSourceGetBackendProps(src= , false, false, autor= eadonly))) diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index a5e970fa1e..8c96a9b940 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -66,7 +66,8 @@ virURIPtr qemuBlockStorageSourceGetURI(virStorageSourcePtr src); virJSONValuePtr -qemuBlockStorageSourceGetBlockdevProps(virStorageSourcePtr src); +qemuBlockStorageSourceGetBlockdevProps(virStorageSourcePtr src, + virStorageSourcePtr backingStore); virJSONValuePtr qemuBlockStorageGetCopyOnReadProps(virDomainDiskDefPtr disk); diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 1bf72a4615..bb0579056e 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -226,7 +226,7 @@ testQemuDiskXMLToProps(const void *opaque) if (qemuDomainPrepareDiskSourceData(disk, n, NULL, data->qemuCaps)= < 0) goto cleanup; - if (!(formatProps =3D qemuBlockStorageSourceGetBlockdevProps(n)) || + if (!(formatProps =3D qemuBlockStorageSourceGetBlockdevProps(n, n-= >backingStore)) || !(storageSrcOnlyProps =3D qemuBlockStorageSourceGetBackendProp= s(n, false, true, true)) || !(storageProps =3D qemuBlockStorageSourceGetBackendProps(n, fa= lse, false, true))) { if (!data->fail) { --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Mar 29 12:36:34 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=1567519731; cv=none; d=zoho.com; s=zohoarc; b=McN3BJzWEfYAE/qIIUJuheIhGV47w7w/ogl/N2LRV+iSkhAT1FLDIJVvdZ9/JTgYRDZHe3Cpxu6aH9lq5Hw7iDDbFoGVWjPpQidBnKPx0cd92Pb3FY832ooZTjX/7aRf7C6lRmagN+QNa26E/GCQUs9wtGbHUQCgPUPNmgNW2L0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567519731; 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:ARC-Authentication-Results; bh=vpe4ww9j2sLwramv6kkXbdmk4agviRVdAxLOl3Co3x8=; b=h21uI8eusIcaXWelBHZ9i51kr6sA4UicfrnpL1//jOeSlsirMnrspVBb36rseREnhigB1L7IHbK5N98U+I4DCUdTGBFd8PD8AuddCxivJp6+Dpyplt5U8VvWvFi7AM+NB+VTaKDAJfX8dlWIbl/LS0FhlNZcy3bVldSRBWE+3Pg= 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 1567519731370969.1887377631172; Tue, 3 Sep 2019 07:08: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 4528418C4290; Tue, 3 Sep 2019 14:08:50 +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 1595C60619; Tue, 3 Sep 2019 14:08: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 CA56924F32; Tue, 3 Sep 2019 14:08:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x83E8Kvs009576 for ; Tue, 3 Sep 2019 10:08:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 451DC100195C; Tue, 3 Sep 2019 14:08:20 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id C237D10016EB for ; Tue, 3 Sep 2019 14:08:19 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 3 Sep 2019 16:07:59 +0200 Message-Id: <6482fcab146af699bc7bf4a939f93da06897a64b.1567519340.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 06/18] qemu: command: Refactor qemuBuildStorageSourceChainAttachPrepareBlockdevInternal 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]); Tue, 03 Sep 2019 14:08:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Extract the loop and supporting infrastructure to the caller as only one of the two callers actually cares about looping and rename the helper to qemuBuildStorageSourceChainAttachPrepareBlockdevOne. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 57 +++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 1ca1ecd2f0..05c35919bf 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10720,33 +10720,23 @@ qemuBuildStorageSourceChainAttachPrepareDrive(vir= DomainDiskDefPtr disk, } -static qemuBlockStorageSourceChainDataPtr -qemuBuildStorageSourceChainAttachPrepareBlockdevInternal(virStorageSourceP= tr top, - virQEMUCapsPtr qe= muCaps, - bool onlyTop) +static int +qemuBuildStorageSourceChainAttachPrepareBlockdevOne(qemuBlockStorageSource= ChainData *data, + virStorageSourcePtr sr= c, + virQEMUCapsPtr qemuCap= s) { VIR_AUTOPTR(qemuBlockStorageSourceAttachData) elem =3D NULL; - VIR_AUTOPTR(qemuBlockStorageSourceChainData) data =3D NULL; - virStorageSourcePtr n; - - if (VIR_ALLOC(data) < 0) - return NULL; - - for (n =3D top; virStorageSourceIsBacking(n); n =3D n->backingStore) { - if (!(elem =3D qemuBlockStorageSourceAttachPrepareBlockdev(n, true= ))) - return NULL; - if (qemuBuildStorageSourceAttachPrepareCommon(n, elem, qemuCaps) <= 0) - return NULL; + if (!(elem =3D qemuBlockStorageSourceAttachPrepareBlockdev(src, true))) + return -1; - if (VIR_APPEND_ELEMENT(data->srcdata, data->nsrcdata, elem) < 0) - return NULL; + if (qemuBuildStorageSourceAttachPrepareCommon(src, elem, qemuCaps) < 0) + return -1; - if (onlyTop) - break; - } + if (VIR_APPEND_ELEMENT(data->srcdata, data->nsrcdata, elem) < 0) + return -1; - VIR_RETURN_PTR(data); + return 0; } @@ -10762,8 +10752,18 @@ qemuBlockStorageSourceChainDataPtr qemuBuildStorageSourceChainAttachPrepareBlockdev(virStorageSourcePtr top, virQEMUCapsPtr qemuCaps) { - return qemuBuildStorageSourceChainAttachPrepareBlockdevInternal(top, q= emuCaps, - false); + VIR_AUTOPTR(qemuBlockStorageSourceChainData) data =3D NULL; + virStorageSourcePtr n; + + if (VIR_ALLOC(data) < 0) + return NULL; + + for (n =3D top; virStorageSourceIsBacking(n); n =3D n->backingStore) { + if (qemuBuildStorageSourceChainAttachPrepareBlockdevOne(data, n, q= emuCaps) < 0) + return NULL; + } + + VIR_RETURN_PTR(data); } @@ -10779,6 +10779,13 @@ qemuBlockStorageSourceChainDataPtr qemuBuildStorageSourceChainAttachPrepareBlockdevTop(virStorageSourcePtr to= p, virQEMUCapsPtr qemuCap= s) { - return qemuBuildStorageSourceChainAttachPrepareBlockdevInternal(top, q= emuCaps, - true); + VIR_AUTOPTR(qemuBlockStorageSourceChainData) data =3D NULL; + + if (VIR_ALLOC(data) < 0) + return NULL; + + if (qemuBuildStorageSourceChainAttachPrepareBlockdevOne(data, top, qem= uCaps) < 0) + return NULL; + + VIR_RETURN_PTR(data); } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Mar 29 12:36:34 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=1567519735; cv=none; d=zoho.com; s=zohoarc; b=mzZQFMZVpxdrKUtRo0SphsvDhzHMGHM/9dlJHqRB7XX+Zs+948UUX0Y9U4ehhj+AzwV+0Qh4eOuDnCC+Z6QWZxqfYufEoQA1Fw50M1tUn0Ds5RhOti/jsowPiaJVoZU+PL/WWxYgBArUBaOUrbagF91bZFP8RWganNmEWlKuz3s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567519735; 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:ARC-Authentication-Results; bh=rYYVXzEgZh3y8L36JQmvlZ37QeynYJbVWS8q95A1pZA=; b=OEVn5ky0OhhJ27ZCWn+LhEJ9mcTVFRCeRBiTPXUcEDuB6Se6WbfJMjIeua401P9fR0DtTJuh9+8RC6l/S48RE6mdv+Xxfl0zw2+osz4ZS/6txiV+zyGlb9zju6UhejpZEfEeSYIcRnsp0a7AOl7ktVikLaFxFMe36IB+Ftieed8= 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 156751973536697.88524416785503; Tue, 3 Sep 2019 07:08:55 -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 957F23A17F; Tue, 3 Sep 2019 14:08: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 7154C60C57; Tue, 3 Sep 2019 14:08: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 3354924F37; Tue, 3 Sep 2019 14:08:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x83E8LMU009583 for ; Tue, 3 Sep 2019 10:08:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 171CE10016EB; Tue, 3 Sep 2019 14:08:21 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 948141001B05 for ; Tue, 3 Sep 2019 14:08:20 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 3 Sep 2019 16:08:00 +0200 Message-Id: <7eebb4d30f20353446adce85b9490db3d2d7c3cd.1567519340.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 07/18] qemu: block: explicitly pass backing store to qemuBlockStorageSourceAttachPrepareBlockdev 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.38]); Tue, 03 Sep 2019 14:08:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Pass backing store as an argument rather than extracting it locally and fix the callers. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_block.c | 4 +++- src/qemu/qemu_block.h | 1 + src/qemu/qemu_command.c | 2 +- src/qemu/qemu_migration.c | 4 +++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index fb631276c9..4b5dd30e17 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1464,6 +1464,7 @@ qemuBlockStorageSourceAttachDataFree(qemuBlockStorage= SourceAttachDataPtr data) /** * qemuBlockStorageSourceAttachPrepareBlockdev: * @src: storage source to prepare data from + * @backingStore: storage source to use as backing of @src * @autoreadonly: use 'auto-read-only' feature of qemu * * Creates a qemuBlockStorageSourceAttachData structure containing data to= attach @@ -1478,6 +1479,7 @@ qemuBlockStorageSourceAttachDataFree(qemuBlockStorage= SourceAttachDataPtr data) */ qemuBlockStorageSourceAttachDataPtr qemuBlockStorageSourceAttachPrepareBlockdev(virStorageSourcePtr src, + virStorageSourcePtr backingSto= re, bool autoreadonly) { VIR_AUTOPTR(qemuBlockStorageSourceAttachData) data =3D NULL; @@ -1486,7 +1488,7 @@ qemuBlockStorageSourceAttachPrepareBlockdev(virStorag= eSourcePtr src, return NULL; if (!(data->formatProps =3D qemuBlockStorageSourceGetBlockdevProps(src, - src->= backingStore)) || + backi= ngStore)) || !(data->storageProps =3D qemuBlockStorageSourceGetBackendProps(src= , false, false, autor= eadonly))) diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index 8c96a9b940..2de614b159 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -109,6 +109,7 @@ VIR_DEFINE_AUTOPTR_FUNC(qemuBlockStorageSourceAttachDat= a, qemuBlockStorageSourceAttachDataPtr qemuBlockStorageSourceAttachPrepareBlockdev(virStorageSourcePtr src, + virStorageSourcePtr backingSto= re, bool autoreadonly); qemuBlockStorageSourceAttachDataPtr diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 05c35919bf..fa8bf39359 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10727,7 +10727,7 @@ qemuBuildStorageSourceChainAttachPrepareBlockdevOne= (qemuBlockStorageSourceChainD { VIR_AUTOPTR(qemuBlockStorageSourceAttachData) elem =3D NULL; - if (!(elem =3D qemuBlockStorageSourceAttachPrepareBlockdev(src, true))) + if (!(elem =3D qemuBlockStorageSourceAttachPrepareBlockdev(src, src->b= ackingStore, true))) return -1; if (qemuBuildStorageSourceAttachPrepareCommon(src, elem, qemuCaps) < 0) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index bd40a8e70d..e387deb497 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -832,7 +832,9 @@ qemuMigrationSrcNBDStorageCopyBlockdev(virQEMUDriverPtr= driver, /* Migration via blockdev-mirror was supported sooner than the auto-re= ad-only * feature was added to qemu */ - if (!(data =3D qemuBlockStorageSourceAttachPrepareBlockdev(copysrc, fa= lse))) + if (!(data =3D qemuBlockStorageSourceAttachPrepareBlockdev(copysrc, + copysrc->back= ingStore, + false))) goto cleanup; if (qemuDomainObjEnterMonitorAsync(driver, vm, --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Mar 29 12:36:34 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=1567519738; cv=none; d=zoho.com; s=zohoarc; b=CnEBW/eTfTp/1Jz2IODv+WkVvzCj6bEQwnFrYWBRoDuwbF01VZEfCeSdMQ0h+DKBXTDBLgV6FdG4RLJ9UFJur99Jx8wHAxl6eecmhoPwS3Nev+JA8WPFiq80ZnAM+heT62SoVndsvy7TpOaCw+aID3bFMArsKk9xb1O9Nwwfe7E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567519738; 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:ARC-Authentication-Results; bh=dF+BSf1BMrAEnvX0AMmTJgfzuoNjOSeQtZf4FZZyktg=; b=DiLk4CCsyIixI8/y5cWgDbYwE+rtub5lZYRFnZEQ0sNk9WyTqbZuKQrxZZJT15TAqgzfPrFpjnsuN7mNw+sOik/y3eOqYZQHeMWGRowVz1TOqVcD+qZ6hbo1A5iUiGghMc1Ukl6tP7+taeTW1OzbUrEFFKMPR2g65xPg51flxkY= 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 1567519738769129.84219060312375; Tue, 3 Sep 2019 07:08:58 -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 648A26CFC3; Tue, 3 Sep 2019 14:08: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 3D0F9194BB; Tue, 3 Sep 2019 14:08: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 E87F2180BAA0; Tue, 3 Sep 2019 14:08:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x83E8LPX009598 for ; Tue, 3 Sep 2019 10:08:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id DC58A100197A; Tue, 3 Sep 2019 14:08:21 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 64BD910016EB for ; Tue, 3 Sep 2019 14:08:21 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 3 Sep 2019 16:08:01 +0200 Message-Id: <05f4a5dd752d64ab01b1176d9c7d79177d4a3862.1567519340.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 08/18] qemu: Explicitly pass backing store to qemuBuildStorageSourceChainAttachPrepareBlockdevTop 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]); Tue, 03 Sep 2019 14:08:57 +0000 (UTC) Content-Type: text/plain; charset="utf-8" In some cases we'll need to pass in a backing store which is not recorded as the backing store of @src. Export backingStore as variable and fix all callers to pass in the backing store. No semantic changes for now. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 12 +++++++++--- src/qemu/qemu_command.h | 1 + src/qemu/qemu_driver.c | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index fa8bf39359..9cd46e8ea7 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10723,11 +10723,12 @@ qemuBuildStorageSourceChainAttachPrepareDrive(vir= DomainDiskDefPtr disk, static int qemuBuildStorageSourceChainAttachPrepareBlockdevOne(qemuBlockStorageSource= ChainData *data, virStorageSourcePtr sr= c, + virStorageSourcePtr ba= ckingStore, virQEMUCapsPtr qemuCap= s) { VIR_AUTOPTR(qemuBlockStorageSourceAttachData) elem =3D NULL; - if (!(elem =3D qemuBlockStorageSourceAttachPrepareBlockdev(src, src->b= ackingStore, true))) + if (!(elem =3D qemuBlockStorageSourceAttachPrepareBlockdev(src, backin= gStore, true))) return -1; if (qemuBuildStorageSourceAttachPrepareCommon(src, elem, qemuCaps) < 0) @@ -10759,7 +10760,9 @@ qemuBuildStorageSourceChainAttachPrepareBlockdev(vi= rStorageSourcePtr top, return NULL; for (n =3D top; virStorageSourceIsBacking(n); n =3D n->backingStore) { - if (qemuBuildStorageSourceChainAttachPrepareBlockdevOne(data, n, q= emuCaps) < 0) + if (qemuBuildStorageSourceChainAttachPrepareBlockdevOne(data, n, + n->backing= Store, + qemuCaps) = < 0) return NULL; } @@ -10770,6 +10773,7 @@ qemuBuildStorageSourceChainAttachPrepareBlockdev(vi= rStorageSourcePtr top, /** * qemuBuildStorageSourceChainAttachPrepareBlockdevTop: * @top: storage source chain + * @backingStore: a storage source to use as backing of @top * @qemuCaps: qemu capabilities object * * Prepares qemuBlockStorageSourceChainDataPtr for attaching of @top image= only @@ -10777,6 +10781,7 @@ qemuBuildStorageSourceChainAttachPrepareBlockdev(vi= rStorageSourcePtr top, */ qemuBlockStorageSourceChainDataPtr qemuBuildStorageSourceChainAttachPrepareBlockdevTop(virStorageSourcePtr to= p, + virStorageSourcePtr ba= ckingStore, virQEMUCapsPtr qemuCap= s) { VIR_AUTOPTR(qemuBlockStorageSourceChainData) data =3D NULL; @@ -10784,7 +10789,8 @@ qemuBuildStorageSourceChainAttachPrepareBlockdevTop= (virStorageSourcePtr top, if (VIR_ALLOC(data) < 0) return NULL; - if (qemuBuildStorageSourceChainAttachPrepareBlockdevOne(data, top, qem= uCaps) < 0) + if (qemuBuildStorageSourceChainAttachPrepareBlockdevOne(data, top, bac= kingStore, + qemuCaps) < 0) return NULL; VIR_RETURN_PTR(data); diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 6f97e7bc0c..60f9843b03 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -119,6 +119,7 @@ qemuBuildStorageSourceChainAttachPrepareBlockdev(virSto= rageSourcePtr top, qemuBlockStorageSourceChainDataPtr qemuBuildStorageSourceChainAttachPrepareBlockdevTop(virStorageSourcePtr to= p, + virStorageSourcePtr ba= ckingStore, virQEMUCapsPtr qemuCap= s); char diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 78f5471b79..df677d8f4c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18547,6 +18547,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, } if (!(crdata =3D qemuBuildStorageSourceChainAttachPrepareBlock= devTop(mirror, + = mirror->backingStore, = priv->qemuCaps))) goto endjob; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Mar 29 12:36:34 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=1567519739; cv=none; d=zoho.com; s=zohoarc; b=Ye40w3w6xLJkyIWpE5OhO3YzOBBm+dgY2qlQiljnTaoPkObJbV4CrwZf99W0aUwymcL2LfnRyZ4kbRam0bQCtJDP6jzOXDZx1A3F/u+94Kr3dOlwtNrRBCi2DQMzFv9FETZaEH/P3QMM0Wl4LY9947hD7HKQlLHydlUQJnbiiU4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567519739; 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:ARC-Authentication-Results; bh=TsEGAlJoA1lp0rrKkM/TLtW+uyLuKbxLwcIX5MhfB1A=; b=egZC0GKuiH1877lHqU+FIa6CqHy3SPXdkPLqZS8Kqe+s7ifzRzm9m2WFfYHaai0gp99PjU+UnFcAk6Js1LSQDaAReYrhTuiRLwILWBraGYl0fwYeR24nysalDQmLQKIOdZKg8iJBD94Nv17/Q/ZdklM5kOkjFtySfSIxlFjbAwE= 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 1567519739334807.2521544885125; Tue, 3 Sep 2019 07:08:59 -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 4305018C4295; Tue, 3 Sep 2019 14:08:58 +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 13B1A5ED3C; Tue, 3 Sep 2019 14:08:58 +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 B078624C10; Tue, 3 Sep 2019 14:08:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x83E8MFv009610 for ; Tue, 3 Sep 2019 10:08:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id ACFAA1001B05; Tue, 3 Sep 2019 14:08:22 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 368A510016EB for ; Tue, 3 Sep 2019 14:08:22 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 3 Sep 2019 16:08:02 +0200 Message-Id: <7a246afdf10056fafb207aaa07f71d8ac665fa07.1567519340.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 09/18] qemu: driver: Fix shallow non-reuse block copy 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.62]); Tue, 03 Sep 2019 14:08:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The code preparing data for creating/attaching the target image of block copy didn't use the correct reference to the existing backing chain in case when the copy should inherit it. This meant that qemu actually opened a second copy of the chain and operated on that. This would de-sync qemu from libvirt's view of node names. Luckily this is only hypothetical at this point since it happens only when -blockdev is enabled. Fix it by passing 'mirrorBacking' which has the proper data as the backing store when calling qemuBuildStorageSourceChainAttachPrepareBlockdevTop. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index df677d8f4c..1fa8fe8391 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18544,10 +18544,12 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, * new image must refer to it in the metadata */ mirrorBacking =3D disk->src->backingStore; } + } else { + mirrorBacking =3D mirror->backingStore; } if (!(crdata =3D qemuBuildStorageSourceChainAttachPrepareBlock= devTop(mirror, - = mirror->backingStore, + = mirrorBacking, = priv->qemuCaps))) goto endjob; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Mar 29 12:36:34 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=1567519743; cv=none; d=zoho.com; s=zohoarc; b=gNx5G4Byz+4c8kxPpuh3nc54MJI/RSmDkYIsFPmKjJhOh8SaxgOsS19uJLLenAmvehrzzgWkMFATj4ma1t75LMqL+3mqWMS0KoM/Qj/GimE0qmzBkm2zRWC+q+XWs++CzSacLRzGvDKvSxSs0LtWpErpcOnP8tEB/IrIUwn3tqI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567519743; 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:ARC-Authentication-Results; bh=2OHljciohFnplLxvirk5KDnU/xrR8ka12BWOdArhJC8=; b=XjonGVXEvzdhNm9bET8zWtC3QKZcjIXFISUW43b68Zr6T4i8QZ2n1FinRZ9NzWs2MZec/sEhtM4EHOwrn7zjHbcUzqH9A9rDr2u6w2j7PjXErzrCJa6eGIBz4y8qIR7p+ub8+iJZcTtTq3a1DzncIO/ELfCNlb1AkSJ4YfqtGGY= 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 156751974320849.386140954094685; Tue, 3 Sep 2019 07:09:03 -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 1A73B801AC6; Tue, 3 Sep 2019 14:09:02 +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 E256A6012A; Tue, 3 Sep 2019 14:09: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 9C963245A8; Tue, 3 Sep 2019 14:09:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x83E8NKr009621 for ; Tue, 3 Sep 2019 10:08:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7CB561001B11; Tue, 3 Sep 2019 14:08:23 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 065571001B05 for ; Tue, 3 Sep 2019 14:08:22 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 3 Sep 2019 16:08:03 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 10/18] qemu: snapshot: Fix image lock handling when taking a snapshot 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.67]); Tue, 03 Sep 2019 14:09:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" When we take a snapshot we must properly remove our locking infrastructure locks. This was broken by commit 3817fa10c4ad9 which attempted to properly track the readonly state for the image as the locking code was executed after this change. Since we forced the image which was locked as read-write to read-only prior to unlocking it the write lock was not dropped. Fix it by moving the locking code prior to modifying the readonly flag. https://bugzilla.redhat.com/show_bug.cgi?id=3D1745618 Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 1fa8fe8391..ccbec5408d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15432,6 +15432,13 @@ qemuDomainSnapshotUpdateDiskSources(virQEMUDriverP= tr driver, if (qemuSecurityMoveImageMetadata(driver, vm, dd->disk->src, dd->src) = < 0) VIR_WARN("Unable to move disk metadata on vm %s", vm->def->name); + /* unlock the write lock on the original image as qemu will no longer = write to it */ + virDomainLockImageDetach(driver->lockManager, vm, dd->disk->src); + + /* unlock also the new image if the VM is paused to follow the locking= semantics */ + if (virDomainObjGetState(vm, NULL) !=3D VIR_DOMAIN_RUNNING) + virDomainLockImageDetach(driver->lockManager, vm, dd->src); + /* the old disk image is now readonly */ dd->disk->src->readonly =3D true; @@ -15550,23 +15557,8 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPt= r driver, ret =3D 0; cleanup: - if (ret < 0) { + if (ret < 0) virErrorPreserveLast(&orig_err); - } else { - /* on successful snapshot we need to remove locks from the now-old - * disks and if the VM is paused release locks on the images since= qemu - * stopped using them*/ - bool paused =3D virDomainObjGetState(vm, NULL) !=3D VIR_DOMAIN_RUN= NING; - - for (i =3D 0; i < ndiskdata; i++) { - if (paused) - virDomainLockImageDetach(driver->lockManager, vm, - diskdata[i].disk->src); - - virDomainLockImageDetach(driver->lockManager, vm, - diskdata[i].disk->src->backingStore); - } - } if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0 || (vm->newDef && virDomainSaveConfig(cfg->configDir, driver->caps, --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Mar 29 12:36:34 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=1567519742; cv=none; d=zoho.com; s=zohoarc; b=WO3DqkukcxVzPiyf40UMUk6My4sOHEyr4d4Fn7+vBfNDfeBr5v1I8PpyYLVIDdq0Tg5ykgdYG9IPVx4kipwrbp4ycPpGtLe/OHj8N4iOhF1dFCwNGtOu7jAJx0/His6U8tRnr8Gdlr1IPo6/WO/oj5Xfv27lSMA1feADojYhkFQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567519742; 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:ARC-Authentication-Results; bh=shEVqL6rmU7NihAjehR0Tm4F6104oaO1a7RX19Q+bGY=; b=K5WoYWhxk10teTXP2Ec67XV3Ijmyi4QGkHAYFjcO1Jg2krnDR8kWcrpmgntP35rE2FbVwRHJN1/Gq3iu7M9If2p6FyzTXizsQg/zGGjOXegI95DtcyMowRE28jyk3STSmBIFu0oviCeg1L6KWNxlOTBSf6j1e0HUbhH1ztpGl+g= 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 1567519742448710.165783181026; Tue, 3 Sep 2019 07:09:02 -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 3F8FDC065128; Tue, 3 Sep 2019 14:09: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 16272588F; Tue, 3 Sep 2019 14:09: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 C7E6E180BAA6; Tue, 3 Sep 2019 14:09:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x83E8OAX009640 for ; Tue, 3 Sep 2019 10:08:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4B4971001B05; Tue, 3 Sep 2019 14:08:24 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id C90DF100197A for ; Tue, 3 Sep 2019 14:08:23 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 3 Sep 2019 16:08:04 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 11/18] qemu: snapshot: Save status and config XMLs only on success 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.31]); Tue, 03 Sep 2019 14:09:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" We changed to always saving the status and config XMLs to simplify code. After a few more refactors it's now possible to move it to the appropriate place and save the XMLs only on success again. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ccbec5408d..fd9dbe854d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15554,17 +15554,17 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverP= tr driver, if (rc < 0) goto cleanup; + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0 || + (vm->newDef && virDomainSaveConfig(cfg->configDir, driver->caps, + vm->newDef) < 0)) + goto cleanup; + ret =3D 0; cleanup: if (ret < 0) virErrorPreserveLast(&orig_err); - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0 || - (vm->newDef && virDomainSaveConfig(cfg->configDir, driver->caps, - vm->newDef) < 0)) - ret =3D -1; - qemuDomainSnapshotDiskDataCleanup(diskdata, ndiskdata, driver, vm); virErrorRestore(&orig_err); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Mar 29 12:36:34 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=1567519747; cv=none; d=zoho.com; s=zohoarc; b=hSfWKjduDQl79oHqgNGiL1ngKJdXp7au4q7YYDWlfaOZ/3tRyQ5rM36+KWW1kQVXuH6nZtdb/SBUQatBR/KojOVsJKwGPjgtzM8KTtlk9WujxB4VCsSDqrn9uo6zHhkFQFc1hqu4WuTD2uKE2yzIVURj8NDVXL8j+uJs6Mz0Xgk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567519747; 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:ARC-Authentication-Results; bh=QzlyQmCLey36i3OvcjJocV5HecLn+wK2lqMdj0tLZlo=; b=Lv6B1r26fxNd0FmW7JZSVG9eDVFyMS3rj05sPw/3eRcGLN2nogDajEmNe6nnAx6dZHjt6Swt7d6vhk89lGAUMhryhevzSXo8EvnQ79ld17cb8ap1gCskpGw0c0Kxm2+27hkK0suh2RZh9i32jmX5GFTjetGQRvxQRZ44N3/gcw8= 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 1567519747448962.8940492616892; Tue, 3 Sep 2019 07:09:07 -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 E64A13CA06; Tue, 3 Sep 2019 14:09:05 +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 B358760610; Tue, 3 Sep 2019 14:09: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 667F2206CE; Tue, 3 Sep 2019 14:09:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x83E8PZZ009653 for ; Tue, 3 Sep 2019 10:08:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1A70F100197A; Tue, 3 Sep 2019 14:08:25 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9861B10016EB for ; Tue, 3 Sep 2019 14:08:24 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 3 Sep 2019 16:08:05 +0200 Message-Id: <50528dd99c757154b177aa525ff4af2b20960d53.1567519340.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 12/18] qemu: snapshot: Move error preservation to qemuDomainSnapshotDiskDataCleanup 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.39]); Tue, 03 Sep 2019 14:09:06 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Make qemuDomainSnapshotDiskDataCleanup cleanup section friendly by moving the error preservation code inside it. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index fd9dbe854d..139a8eff03 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15271,11 +15271,14 @@ qemuDomainSnapshotDiskDataCleanup(qemuDomainSnaps= hotDiskDataPtr data, virQEMUDriverPtr driver, virDomainObjPtr vm) { + virErrorPtr orig_err; size_t i; if (!data) return; + virErrorPreserveLast(&orig_err); + for (i =3D 0; i < ndata; i++) { /* on success of the snapshot the 'src' and 'persistsrc' propertie= s will * be set to NULL by qemuDomainSnapshotUpdateDiskSources */ @@ -15299,6 +15302,7 @@ qemuDomainSnapshotDiskDataCleanup(qemuDomainSnapsho= tDiskDataPtr data, } VIR_FREE(data); + virErrorRestore(&orig_err); } @@ -15503,7 +15507,6 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr= driver, bool reuse =3D (flags & VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT) !=3D 0; qemuDomainSnapshotDiskDataPtr diskdata =3D NULL; size_t ndiskdata =3D 0; - virErrorPtr orig_err =3D NULL; if (virDomainObjCheckActive(vm) < 0) return -1; @@ -15562,12 +15565,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPt= r driver, ret =3D 0; cleanup: - if (ret < 0) - virErrorPreserveLast(&orig_err); - qemuDomainSnapshotDiskDataCleanup(diskdata, ndiskdata, driver, vm); - virErrorRestore(&orig_err); - return ret; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Mar 29 12:36:34 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=1567519746; cv=none; d=zoho.com; s=zohoarc; b=L6i873axYkaHw0kayxYWxYtC7cdz/WqDRGtDpMjWQ++PQPrtSqpUAGwi6k1kDvhgalN6c11EnCEEUzzIb4O3Fu/I3ov+0VuCWpRMH8VEhEHrxzwSUmr69fUUu8zQuhrUK6+okOCPaIa0k+u6ctEeby6EkV39did78hxns5ZnJ9A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567519746; 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:ARC-Authentication-Results; bh=mfhDQd+GMwr+dQGlPW/MVa29bQK99Pj079MLNz3O7l0=; b=d7jwPe1hZRfmMaoFIKXK7n5SUU9nxDnGcgFnsx1swDkB13KinlMX/NWmraTUf72ZNG4AsQpX6lZDPC8DMWNHHJovqMjONPuSVxJutx3h5aG0w9wl5/zgpdTs5RTgSlbEex8QEQZUNoVb/accTEOnDhS0JuQDKX5ILc96tX71JvM= 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 1567519746773799.4813370492801; Tue, 3 Sep 2019 07:09: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 3551C3CA11; Tue, 3 Sep 2019 14:09: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 E9D765DE5C; Tue, 3 Sep 2019 14:09: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 A0501180BAAB; Tue, 3 Sep 2019 14:09:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x83E8PGS009664 for ; Tue, 3 Sep 2019 10:08:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id E043B10016EB; Tue, 3 Sep 2019 14:08:25 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 68A2E1001B05 for ; Tue, 3 Sep 2019 14:08:25 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 3 Sep 2019 16:08:06 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 13/18] qemu: snapshot: Rename external disk snapshot handling functions 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.39]); Tue, 03 Sep 2019 14:09:05 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Fix and unify the naming of external snapshot preparation functions. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 64 +++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 139a8eff03..60bc725b09 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15266,10 +15266,10 @@ typedef qemuDomainSnapshotDiskData *qemuDomainSna= pshotDiskDataPtr; static void -qemuDomainSnapshotDiskDataCleanup(qemuDomainSnapshotDiskDataPtr data, - size_t ndata, - virQEMUDriverPtr driver, - virDomainObjPtr vm) +qemuDomainSnapshotDiskCleanup(qemuDomainSnapshotDiskDataPtr data, + size_t ndata, + virQEMUDriverPtr driver, + virDomainObjPtr vm) { virErrorPtr orig_err; size_t i; @@ -15281,7 +15281,7 @@ qemuDomainSnapshotDiskDataCleanup(qemuDomainSnapsho= tDiskDataPtr data, for (i =3D 0; i < ndata; i++) { /* on success of the snapshot the 'src' and 'persistsrc' propertie= s will - * be set to NULL by qemuDomainSnapshotUpdateDiskSources */ + * be set to NULL by qemuDomainSnapshotDiskUpdateSource */ if (data[i].src) { if (data[i].created && virStorageFileUnlink(data[i].src) < 0) { @@ -15307,12 +15307,12 @@ qemuDomainSnapshotDiskDataCleanup(qemuDomainSnaps= hotDiskDataPtr data, static int -qemuDomainSnapshotDiskDataCollectOne(virQEMUDriverPtr driver, - virDomainObjPtr vm, - virDomainDiskDefPtr disk, - virDomainSnapshotDiskDefPtr snapdisk, - qemuDomainSnapshotDiskDataPtr dd, - bool reuse) +qemuDomainSnapshotDiskPrepareOne(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virDomainDiskDefPtr disk, + virDomainSnapshotDiskDefPtr snapdisk, + qemuDomainSnapshotDiskDataPtr dd, + bool reuse) { char *backingStoreStr; virDomainDiskDefPtr persistdisk; @@ -15363,18 +15363,18 @@ qemuDomainSnapshotDiskDataCollectOne(virQEMUDrive= rPtr driver, /** - * qemuDomainSnapshotDiskDataCollect: + * qemuDomainSnapshotDiskPrepare: * * Collects and prepares a list of structures that hold information about = disks * that are selected for the snapshot. */ static int -qemuDomainSnapshotDiskDataCollect(virQEMUDriverPtr driver, - virDomainObjPtr vm, - virDomainMomentObjPtr snap, - bool reuse, - qemuDomainSnapshotDiskDataPtr *rdata, - size_t *rndata) +qemuDomainSnapshotDiskPrepare(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virDomainMomentObjPtr snap, + bool reuse, + qemuDomainSnapshotDiskDataPtr *rdata, + size_t *rndata) { size_t i; qemuDomainSnapshotDiskDataPtr data; @@ -15389,9 +15389,9 @@ qemuDomainSnapshotDiskDataCollect(virQEMUDriverPtr = driver, if (snapdef->disks[i].snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION= _NONE) continue; - if (qemuDomainSnapshotDiskDataCollectOne(driver, vm, vm->def->disk= s[i], - snapdef->disks + i, - data + ndata++, reuse) < = 0) + if (qemuDomainSnapshotDiskPrepareOne(driver, vm, vm->def->disks[i], + snapdef->disks + i, + data + ndata++, reuse) < 0) goto cleanup; } @@ -15400,13 +15400,13 @@ qemuDomainSnapshotDiskDataCollect(virQEMUDriverPt= r driver, ret =3D 0; cleanup: - qemuDomainSnapshotDiskDataCleanup(data, ndata, driver, vm); + qemuDomainSnapshotDiskCleanup(data, ndata, driver, vm); return ret; } static void -qemuDomainSnapshotUpdateDiskSourcesRenumber(virStorageSourcePtr src) +qemuDomainSnapshotDiskUpdateSourceRenumber(virStorageSourcePtr src) { virStorageSourcePtr next; unsigned int idx =3D 1; @@ -15417,7 +15417,7 @@ qemuDomainSnapshotUpdateDiskSourcesRenumber(virStor= ageSourcePtr src) /** - * qemuDomainSnapshotUpdateDiskSources: + * qemuDomainSnapshotDiskUpdateSource: * @driver: QEMU driver * @vm: domain object * @dd: snapshot disk data object @@ -15425,9 +15425,9 @@ qemuDomainSnapshotUpdateDiskSourcesRenumber(virStor= ageSourcePtr src) * Updates disk definition after a successful snapshot. */ static void -qemuDomainSnapshotUpdateDiskSources(virQEMUDriverPtr driver, - virDomainObjPtr vm, - qemuDomainSnapshotDiskDataPtr dd) +qemuDomainSnapshotDiskUpdateSource(virQEMUDriverPtr driver, + virDomainObjPtr vm, + qemuDomainSnapshotDiskDataPtr dd) { /* storage driver access won'd be needed */ if (dd->initialized) @@ -15451,7 +15451,7 @@ qemuDomainSnapshotUpdateDiskSources(virQEMUDriverPt= r driver, VIR_STEAL_PTR(dd->disk->src, dd->src); /* fix numbering of disks */ - qemuDomainSnapshotUpdateDiskSourcesRenumber(dd->disk->src); + qemuDomainSnapshotDiskUpdateSourceRenumber(dd->disk->src); if (dd->persistdisk) { VIR_STEAL_PTR(dd->persistsrc->backingStore, dd->persistdisk->src); @@ -15516,8 +15516,8 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr= driver, /* prepare a list of objects to use in the vm definition so that we do= n't * have to roll back later */ - if (qemuDomainSnapshotDiskDataCollect(driver, vm, snap, reuse, - &diskdata, &ndiskdata) < 0) + if (qemuDomainSnapshotDiskPrepare(driver, vm, snap, reuse, + &diskdata, &ndiskdata) < 0) goto cleanup; /* check whether there's anything to do */ @@ -15551,7 +15551,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr= driver, virDomainAuditDisk(vm, dd->disk->src, dd->src, "snapshot", rc >=3D= 0); if (rc =3D=3D 0) - qemuDomainSnapshotUpdateDiskSources(driver, vm, dd); + qemuDomainSnapshotDiskUpdateSource(driver, vm, dd); } if (rc < 0) @@ -15565,7 +15565,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr= driver, ret =3D 0; cleanup: - qemuDomainSnapshotDiskDataCleanup(diskdata, ndiskdata, driver, vm); + qemuDomainSnapshotDiskCleanup(diskdata, ndiskdata, driver, vm); return ret; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Mar 29 12:36:34 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=1567519750; cv=none; d=zoho.com; s=zohoarc; b=Kg1GGoZuEBFyBoVThso0JZPchshluBbFPPHJjLrZXnUuI+1s5LchJLleFsf8WuKorEy43V66JX7MXTQCdsTa9uxwohtjP5G/oJQVS1BnLq5EJj9sNCpMzX210Gb17G/1vRt2xJAmRJJEltTyws4m1a7xSKfmrsyhjPtXp2DOiTo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567519750; 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:ARC-Authentication-Results; bh=9rmOdB5ZSulAMnlBPDGndz1FTr2D9q067fMohscmCOU=; b=eI24T6rW/Ypihr7W6B9LHBAqRsoo0FU1iN5MBTCzNzB4vgJBVMOQ/Gn9PlaHdYyee2p3arSHmW+IdJdbaty9DTOG38dX8cXrbVF9Kgh0xXu3pY3ItX0eVSRcuUgaP/2YtDTQTZjg1yJRl1zBcP43wcvZ+1fggsxtUFjfzW1qqt4= 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 1567519750513968.167158973125; Tue, 3 Sep 2019 07:09:10 -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 661B051EFB; Tue, 3 Sep 2019 14:09:09 +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 34D7C60A35; Tue, 3 Sep 2019 14:09:09 +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 ED739149F6; Tue, 3 Sep 2019 14:09:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x83E8QXo009674 for ; Tue, 3 Sep 2019 10:08:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id B0FD2100195C; Tue, 3 Sep 2019 14:08:26 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A0DB10016EB for ; Tue, 3 Sep 2019 14:08:26 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 3 Sep 2019 16:08:07 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 14/18] qemu: Disband qemuDomainSnapshotCreateSingleDiskActive 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.30]); Tue, 03 Sep 2019 14:09:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" After we always assume support for the 'transaction' command (c358adc57113b) and follow-up cleanups qemuDomainSnapshotCreateSingleDiskActive lost its value. Move the code into appropriate helpers and remove the function. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 53 ++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 33 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 60bc725b09..397f943a1b 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15358,6 +15358,22 @@ qemuDomainSnapshotDiskPrepareOne(virQEMUDriverPtr = driver, } } + /* pre-create the image file so that we can label it before handing it= to qemu */ + if (!reuse && dd->src->type !=3D VIR_STORAGE_TYPE_BLOCK) { + if (virStorageFileCreate(dd->src) < 0) { + virReportSystemError(errno, _("failed to create image file '%s= '"), + NULLSTR(dd->src->path)); + return -1; + } + dd->created =3D true; + } + + /* set correct security, cgroup and locking options on the new image */ + if (qemuDomainStorageSourceAccessAllow(driver, vm, dd->src, false, tru= e) < 0) + return -1; + + dd->prepared =3D true; + return 0; } @@ -15460,36 +15476,6 @@ qemuDomainSnapshotDiskUpdateSource(virQEMUDriverPt= r driver, } -static int -qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver, - virDomainObjPtr vm, - qemuDomainSnapshotDiskDataPtr dd, - virJSONValuePtr actions, - bool reuse) -{ - if (qemuBlockSnapshotAddLegacy(actions, dd->disk, dd->src, reuse) < 0) - return -1; - - /* pre-create the image file so that we can label it before handing it= to qemu */ - if (!reuse && dd->src->type !=3D VIR_STORAGE_TYPE_BLOCK) { - if (virStorageFileCreate(dd->src) < 0) { - virReportSystemError(errno, _("failed to create image file '%s= '"), - NULLSTR(dd->src->path)); - return -1; - } - dd->created =3D true; - } - - /* set correct security, cgroup and locking options on the new image */ - if (qemuDomainStorageSourceAccessAllow(driver, vm, dd->src, false, tru= e) < 0) - return -1; - - dd->prepared =3D true; - - return 0; -} - - /* The domain is expected to be locked and active. */ static int qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver, @@ -15531,9 +15517,10 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPt= r driver, * VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL with a valid file name and * qcow2 format. */ for (i =3D 0; i < ndiskdata; i++) { - if (qemuDomainSnapshotCreateSingleDiskActive(driver, vm, - &diskdata[i], - actions, reuse) < 0) + if (qemuBlockSnapshotAddLegacy(actions, + diskdata[i].disk, + diskdata[i].src, + reuse) < 0) goto cleanup; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Mar 29 12:36:34 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=1567519754; cv=none; d=zoho.com; s=zohoarc; b=EeH++Wu7lJP7Tams9LprRGOii0XfbN20kyx1qRE6YMWNQyqqggiI6TbLp234icfCm4OTdmipV6fjMrOUz4xvyhykrY7zSd07XLFDHruH0CA9jD9c3k/Knk+AjYv1tgU+r1WxEXeXc/xKJr737UJ9KYvw/n/SCt/vpUh6YT0f7xQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567519754; 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:ARC-Authentication-Results; bh=6Se9tmtIdorP48ktY5cZwHEeJQAvIMbTfXg59x0kjZc=; b=Eznb25srofVOnKbGwFiuLPgalIm8pNMPb+G9w6EZ3cQthf8pHy+aiMKDfoPemIDDB1n7R86Ao06kiTS9Afu3E7zKc5twZ424/Qb93oNvLrVx7T+4jQySUllqRfOicYbp/CuaxXcE+qjPRkVXZlkDcAvlxzISBphSQ9TKaDkSGhg= 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 1567519754342621.172284786631; Tue, 3 Sep 2019 07:09:14 -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 23B8110F23F4; Tue, 3 Sep 2019 14:09:13 +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 ECEA557B0; Tue, 3 Sep 2019 14:09:12 +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 B4735180B536; Tue, 3 Sep 2019 14:09:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x83E8Rwt009692 for ; Tue, 3 Sep 2019 10:08:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8425B100195C; Tue, 3 Sep 2019 14:08:27 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0CB641001B05 for ; Tue, 3 Sep 2019 14:08:26 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 3 Sep 2019 16:08:08 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 15/18] qemu: Merge use of 'reuse' flag in qemuDomainSnapshotDiskPrepareOne 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.6.2 (mx1.redhat.com [10.5.110.66]); Tue, 03 Sep 2019 14:09:13 +0000 (UTC) Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 397f943a1b..39d9118953 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15356,16 +15356,16 @@ qemuDomainSnapshotDiskPrepareOne(virQEMUDriverPtr= driver, else VIR_FREE(backingStoreStr); } - } - - /* pre-create the image file so that we can label it before handing it= to qemu */ - if (!reuse && dd->src->type !=3D VIR_STORAGE_TYPE_BLOCK) { - if (virStorageFileCreate(dd->src) < 0) { - virReportSystemError(errno, _("failed to create image file '%s= '"), - NULLSTR(dd->src->path)); - return -1; + } else { + /* pre-create the image file so that we can label it before handin= g it to qemu */ + if (dd->src->type !=3D VIR_STORAGE_TYPE_BLOCK) { + if (virStorageFileCreate(dd->src) < 0) { + virReportSystemError(errno, _("failed to create image file= '%s'"), + NULLSTR(dd->src->path)); + return -1; + } + dd->created =3D true; } - dd->created =3D true; } /* set correct security, cgroup and locking options on the new image */ --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Mar 29 12:36:34 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=1567519734; cv=none; d=zoho.com; s=zohoarc; b=W90A99IDeuDpJaW9zRzwOsyNRzA4XLAETzYQNkjzHOFE2MoMGIblNL/YnBg65R+HFFKDfXR7yZbAissiaKAZBJBTjC7kdEBkHV3VO3bty+4Qirg7e/05gQFgpXFBUVh7jYR60Op3CLbXBkn1xSLNsV552+9xWbG/+lX1vOZmfb4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567519734; 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:ARC-Authentication-Results; bh=Lt9nVtXWj0oz1bKmQeCsSGYw+LI/o4QdRmIKs31ADIc=; b=FfZJWaecQtS/9b8WKI+WIp9gG+5ef7jELj76eL+9P/075PLDXmJ6ORzIdE1sit5HRErurUC0GGVASwN5Nso/QnwUSc4dQLfGRqd0TVEw3h2afpeSUA1p+cEnKjAPnqDV30kz7Q+vTsMNRTJ0Y576UeeG0IgQeUiZb1uEetbr1Bk= 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 1567519734682497.8606643299895; Tue, 3 Sep 2019 07:08:54 -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 4F238C05975D; Tue, 3 Sep 2019 14:08: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 265895D6D0; Tue, 3 Sep 2019 14:08: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 DB81F180BA9C; Tue, 3 Sep 2019 14:08:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x83E8SJe009705 for ; Tue, 3 Sep 2019 10:08:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 54A4F10016EB; Tue, 3 Sep 2019 14:08:28 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id D1946100195C for ; Tue, 3 Sep 2019 14:08:27 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 3 Sep 2019 16:08:09 +0200 Message-Id: <992efc60bf5267bcdae8a6c263c05d89a232ad34.1567519340.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 16/18] qemu: snapshot: Skip overlay file creation/interogation if unsupported 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.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.32]); Tue, 03 Sep 2019 14:08:53 +0000 (UTC) With blockdev we'll be able to support protocols which are not supported by the storage backends in libvirt. This means that we have to be able to skip the creation and relative storage path reading if it's not supported. This will make it impossible to use relative backing for network protocols but that would be almost insane anyways. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 53 ++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 39d9118953..8a0f1697cb 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15316,6 +15316,8 @@ qemuDomainSnapshotDiskPrepareOne(virQEMUDriverPtr d= river, { char *backingStoreStr; virDomainDiskDefPtr persistdisk; + bool supportsCreate; + bool supportsBacking; dd->disk =3D disk; @@ -15340,31 +15342,38 @@ qemuDomainSnapshotDiskPrepareOne(virQEMUDriverPtr= driver, return -1; } - if (qemuDomainStorageFileInit(driver, vm, dd->src, NULL) < 0) - return -1; - - dd->initialized =3D true; + supportsCreate =3D virStorageFileSupportsCreate(dd->src); + supportsBacking =3D virStorageFileSupportsBackingChainTraversal(dd->sr= c); - /* relative backing store paths need to be updated so that relative - * block commit still works */ - if (reuse) { - if (virStorageFileGetBackingStoreStr(dd->src, &backingStoreStr) < = 0) + if (supportsCreate || supportsBacking) { + if (qemuDomainStorageFileInit(driver, vm, dd->src, NULL) < 0) return -1; - if (backingStoreStr !=3D NULL) { - if (virStorageIsRelative(backingStoreStr)) - VIR_STEAL_PTR(dd->relPath, backingStoreStr); - else - VIR_FREE(backingStoreStr); - } - } else { - /* pre-create the image file so that we can label it before handin= g it to qemu */ - if (dd->src->type !=3D VIR_STORAGE_TYPE_BLOCK) { - if (virStorageFileCreate(dd->src) < 0) { - virReportSystemError(errno, _("failed to create image file= '%s'"), - NULLSTR(dd->src->path)); - return -1; + + dd->initialized =3D true; + + /* relative backing store paths need to be updated so that relative + * block commit still works */ + if (reuse) { + if (supportsBacking) { + if (virStorageFileGetBackingStoreStr(dd->src, &backingStor= eStr) < 0) + return -1; + if (backingStoreStr !=3D NULL) { + if (virStorageIsRelative(backingStoreStr)) + VIR_STEAL_PTR(dd->relPath, backingStoreStr); + else + VIR_FREE(backingStoreStr); + } + } + } else { + /* pre-create the image file so that we can label it before ha= nding it to qemu */ + if (supportsCreate && dd->src->type !=3D VIR_STORAGE_TYPE_BLOC= K) { + if (virStorageFileCreate(dd->src) < 0) { + virReportSystemError(errno, _("failed to create image = file '%s'"), + NULLSTR(dd->src->path)); + return -1; + } + dd->created =3D true; } - dd->created =3D true; } } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Mar 29 12:36:34 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=1567519738; cv=none; d=zoho.com; s=zohoarc; b=cApCiBxSv5W5h2VSe1yJr51uOL3XH0ynRsjjcsXoPSVgUQ5wYBN/28ybXboBFgJfaSH3MbYxB5nr0AnfVLsF8xABCHrJjKiwJ3T1CUSimwla/BlO8qjfIh/lb6SMPLQYKbEHLS7EgaUADRnYU5JRC3jag95KYzMvcq5gdNT1k0E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567519738; 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:ARC-Authentication-Results; bh=1OTHHklm5dUV/14Ghjrji+U1RIBuNaAH1NPScv+wnIk=; b=kyx179gIFD69qrd7EUboqwKiN1v0oPjCcqOpqXIOtWLD+U9Iw7bHJ7GMavSeE3w82J28Pi6cA8dGs30n7K5OtXXPBzvTwIqmIFVTBAFKi4cOQXERxQNd/S+pbIJZ+JWtw+HHdjDll6YxDiP47aN/gp+FtiH1/q2mUYmuzGOg0Bc= 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 15675197387860.2990096250400711; Tue, 3 Sep 2019 07:08: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 EAE1730A76A2; Tue, 3 Sep 2019 14:08: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 BBCC45D70D; Tue, 3 Sep 2019 14:08: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 7C9D4180BA9F; Tue, 3 Sep 2019 14:08:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x83E8Tp9009710 for ; Tue, 3 Sep 2019 10:08:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 263341001B05; Tue, 3 Sep 2019 14:08:29 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id A2FDF10016EB for ; Tue, 3 Sep 2019 14:08:28 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 3 Sep 2019 16:08:10 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 17/18] qemu: Add -blockdev support for external snapshots 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.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.47]); Tue, 03 Sep 2019 14:08:58 +0000 (UTC) Use the code for creating or attaching new storage source in the snapshot code and switch to 'blockdev-snapshot' for creating the snapshot itself. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 104 ++++++++++++++++++++++++++++++++++------- 1 file changed, 88 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8a0f1697cb..9523da4cfc 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15256,6 +15256,8 @@ struct _qemuDomainSnapshotDiskData { bool prepared; /* @src was prepared using qemuDomainStorageSourceAcces= sAllow */ virDomainDiskDefPtr disk; char *relPath; /* relative path component to fill into original disk */ + qemuBlockStorageSourceChainDataPtr crdata; + bool blockdevadded; virStorageSourcePtr persistsrc; virDomainDiskDefPtr persistdisk; @@ -15269,7 +15271,8 @@ static void qemuDomainSnapshotDiskCleanup(qemuDomainSnapshotDiskDataPtr data, size_t ndata, virQEMUDriverPtr driver, - virDomainObjPtr vm) + virDomainObjPtr vm, + qemuDomainAsyncJob asyncJob) { virErrorPtr orig_err; size_t i; @@ -15283,6 +15286,15 @@ qemuDomainSnapshotDiskCleanup(qemuDomainSnapshotDi= skDataPtr data, /* on success of the snapshot the 'src' and 'persistsrc' propertie= s will * be set to NULL by qemuDomainSnapshotDiskUpdateSource */ if (data[i].src) { + if (data[i].blockdevadded) { + if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) = =3D=3D 0) { + + qemuBlockStorageSourceAttachRollback(qemuDomainGetMoni= tor(vm), + data[i].crdata->s= rcdata[0]); + ignore_value(qemuDomainObjExitMonitor(driver, vm)); + } + } + if (data[i].created && virStorageFileUnlink(data[i].src) < 0) { VIR_WARN("Unable to remove just-created %s", @@ -15299,6 +15311,7 @@ qemuDomainSnapshotDiskCleanup(qemuDomainSnapshotDis= kDataPtr data, } virObjectUnref(data[i].persistsrc); VIR_FREE(data[i].relPath); + qemuBlockStorageSourceChainDataFree(data[i].crdata); } VIR_FREE(data); @@ -15309,15 +15322,21 @@ qemuDomainSnapshotDiskCleanup(qemuDomainSnapshotD= iskDataPtr data, static int qemuDomainSnapshotDiskPrepareOne(virQEMUDriverPtr driver, virDomainObjPtr vm, + virQEMUDriverConfigPtr cfg, virDomainDiskDefPtr disk, virDomainSnapshotDiskDefPtr snapdisk, qemuDomainSnapshotDiskDataPtr dd, - bool reuse) + bool reuse, + bool blockdev, + qemuDomainAsyncJob asyncJob) { + qemuDomainObjPrivatePtr priv =3D vm->privateData; char *backingStoreStr; virDomainDiskDefPtr persistdisk; + VIR_AUTOUNREF(virStorageSourcePtr) terminator =3D NULL; bool supportsCreate; bool supportsBacking; + int rc; dd->disk =3D disk; @@ -15383,6 +15402,44 @@ qemuDomainSnapshotDiskPrepareOne(virQEMUDriverPtr = driver, dd->prepared =3D true; + if (blockdev) { + /* create a terminator for the snapshot disks so that qemu does no= t try + * to open them at first */ + if (!(terminator =3D virStorageSourceNew())) + return -1; + + if (qemuDomainPrepareStorageSourceBlockdev(dd->disk, dd->src, + priv, cfg) < 0) + return -1; + + if (!(dd->crdata =3D qemuBuildStorageSourceChainAttachPrepareBlock= devTop(dd->src, + = terminator, + = priv->qemuCaps))) + return -1; + + if (reuse) { + if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) + return -1; + + rc =3D qemuBlockStorageSourceAttachApply(qemuDomainGetMonitor(= vm), + dd->crdata->srcdata[0]); + + if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + return -1; + } else { + if (qemuBlockStorageSourceCreateDetectSize(vm, dd->src, dd->di= sk->src, + asyncJob) < 0) + return -1; + + if (qemuBlockStorageSourceCreate(vm, dd->src, dd->disk->src, + NULL, dd->crdata->srcdata[0], + asyncJob) < 0) + return -1; + } + + dd->blockdevadded =3D true; + } + return 0; } @@ -15397,7 +15454,10 @@ static int qemuDomainSnapshotDiskPrepare(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainMomentObjPtr snap, + virQEMUDriverConfigPtr cfg, bool reuse, + bool blockdev, + qemuDomainAsyncJob asyncJob, qemuDomainSnapshotDiskDataPtr *rdata, size_t *rndata) { @@ -15414,9 +15474,10 @@ qemuDomainSnapshotDiskPrepare(virQEMUDriverPtr dri= ver, if (snapdef->disks[i].snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION= _NONE) continue; - if (qemuDomainSnapshotDiskPrepareOne(driver, vm, vm->def->disks[i], + if (qemuDomainSnapshotDiskPrepareOne(driver, vm, cfg, vm->def->dis= ks[i], snapdef->disks + i, - data + ndata++, reuse) < 0) + data + ndata++, reuse, blockd= ev, + asyncJob) < 0) goto cleanup; } @@ -15425,7 +15486,7 @@ qemuDomainSnapshotDiskPrepare(virQEMUDriverPtr driv= er, ret =3D 0; cleanup: - qemuDomainSnapshotDiskCleanup(data, ndata, driver, vm); + qemuDomainSnapshotDiskCleanup(data, ndata, driver, vm, asyncJob); return ret; } @@ -15446,13 +15507,15 @@ qemuDomainSnapshotDiskUpdateSourceRenumber(virSto= rageSourcePtr src) * @driver: QEMU driver * @vm: domain object * @dd: snapshot disk data object + * @blockdev: -blockdev is in use for the VM * * Updates disk definition after a successful snapshot. */ static void qemuDomainSnapshotDiskUpdateSource(virQEMUDriverPtr driver, virDomainObjPtr vm, - qemuDomainSnapshotDiskDataPtr dd) + qemuDomainSnapshotDiskDataPtr dd, + bool blockdev) { /* storage driver access won'd be needed */ if (dd->initialized) @@ -15476,7 +15539,8 @@ qemuDomainSnapshotDiskUpdateSource(virQEMUDriverPtr= driver, VIR_STEAL_PTR(dd->disk->src, dd->src); /* fix numbering of disks */ - qemuDomainSnapshotDiskUpdateSourceRenumber(dd->disk->src); + if (!blockdev) + qemuDomainSnapshotDiskUpdateSourceRenumber(dd->disk->src); if (dd->persistdisk) { VIR_STEAL_PTR(dd->persistsrc->backingStore, dd->persistdisk->src); @@ -15502,6 +15566,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr= driver, bool reuse =3D (flags & VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT) !=3D 0; qemuDomainSnapshotDiskDataPtr diskdata =3D NULL; size_t ndiskdata =3D 0; + bool blockdev =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); if (virDomainObjCheckActive(vm) < 0) return -1; @@ -15511,8 +15576,8 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr= driver, /* 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, reuse, - &diskdata, &ndiskdata) < 0) + if (qemuDomainSnapshotDiskPrepare(driver, vm, snap, cfg, reuse, blockd= ev, + asyncJob, &diskdata, &ndiskdata) < 0) goto cleanup; /* check whether there's anything to do */ @@ -15526,11 +15591,18 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverP= tr driver, * VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL with a valid file name and * qcow2 format. */ for (i =3D 0; i < ndiskdata; i++) { - if (qemuBlockSnapshotAddLegacy(actions, - diskdata[i].disk, - diskdata[i].src, - reuse) < 0) - goto cleanup; + if (blockdev) { + if (qemuBlockSnapshotAddBlockdev(actions, + diskdata[i].disk, + diskdata[i].src)) + goto cleanup; + } else { + if (qemuBlockSnapshotAddLegacy(actions, + diskdata[i].disk, + diskdata[i].src, + reuse) < 0) + goto cleanup; + } } if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) @@ -15547,7 +15619,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr= driver, virDomainAuditDisk(vm, dd->disk->src, dd->src, "snapshot", rc >=3D= 0); if (rc =3D=3D 0) - qemuDomainSnapshotDiskUpdateSource(driver, vm, dd); + qemuDomainSnapshotDiskUpdateSource(driver, vm, dd, blockdev); } if (rc < 0) @@ -15561,7 +15633,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr= driver, ret =3D 0; cleanup: - qemuDomainSnapshotDiskCleanup(diskdata, ndiskdata, driver, vm); + qemuDomainSnapshotDiskCleanup(diskdata, ndiskdata, driver, vm, asyncJo= b); return ret; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Mar 29 12:36:34 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=1567519742; cv=none; d=zoho.com; s=zohoarc; b=erdD43mJ0/HdYfEZBbYozNwfD+4lDiz2GTHfU6Imcq3sijOYBhPW68c/ODqbhmwHLuCpFipveQ+MwZISK3nlBG3mDjWRwbSFVxxUuB9NcwGYZ1YjFXkZ1k50FmHEIexgOBtpMXuE6BytX40Z7L4J3HcXPDZIFvL/2CMFtech8Jo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567519742; 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:ARC-Authentication-Results; bh=ZhO/J/BOaNSmnFabqtgb6JMBsQMsUxugFOj9TnhKbOg=; b=LbsFxkvzlgpWtLHN9VsBcyCLPpFaSFY1Zcqi6MFWRNobQGzfQmYU5iauS++8cwx+hhJARRaW8JF/I6+7ywc/cUYfPWE4meFLLOu03depGpITudWTCMhQ8TAFF/GeuyRVqt0LTHe0FZkw1my9eMgd34NTP8rsT+TkeqyNwer2pBk= 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 1567519742338523.7320179751381; Tue, 3 Sep 2019 07:09:02 -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 110EA18005F6; Tue, 3 Sep 2019 14:09:01 +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 B4BAA58BB; Tue, 3 Sep 2019 14:09: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 65B3424B33; Tue, 3 Sep 2019 14:09:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x83E8TMB009724 for ; Tue, 3 Sep 2019 10:08:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id EA1AF10016EB; Tue, 3 Sep 2019 14:08:29 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 73FA91001B05 for ; Tue, 3 Sep 2019 14:08:29 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 3 Sep 2019 16:08:11 +0200 Message-Id: <4721baae4addfb332780ed78538b10c03eef0d51.1567519340.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 18/18] qemu: Defer support checks for external active snapshots to blockdev code or qemu 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.6.2 (mx1.redhat.com [10.5.110.63]); Tue, 03 Sep 2019 14:09:01 +0000 (UTC) Remove libvit's support check for the target of an external snapshot to the blockdev code or qemu. This will potentially require a more complex cleanup but removes a level of hardcoded feature checks. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 9523da4cfc..1c8d78834c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14917,7 +14917,8 @@ qemuDomainSnapshotPrepareDiskExternalInactive(virDo= mainSnapshotDiskDefPtr snapdi static int qemuDomainSnapshotPrepareDiskExternalActive(virDomainSnapshotDiskDefPtr sn= apdisk, - virDomainDiskDefPtr domdisk) + virDomainDiskDefPtr domdisk, + bool blockdev) { int actualType =3D virStorageSourceGetActualType(snapdisk->src); @@ -14934,6 +14935,10 @@ qemuDomainSnapshotPrepareDiskExternalActive(virDom= ainSnapshotDiskDefPtr snapdisk break; case VIR_STORAGE_TYPE_NETWORK: + /* defer all of the checking to either qemu or libvirt's blockdev = code */ + if (blockdev) + break; + switch ((virStorageNetProtocol) snapdisk->src->protocol) { case VIR_STORAGE_NET_PROTOCOL_GLUSTER: break; @@ -14981,7 +14986,8 @@ static int qemuDomainSnapshotPrepareDiskExternal(virDomainDiskDefPtr disk, virDomainSnapshotDiskDefPtr snapdisk, bool active, - bool reuse) + bool reuse, + bool blockdev) { struct stat st; int err; @@ -15004,7 +15010,7 @@ qemuDomainSnapshotPrepareDiskExternal(virDomainDisk= DefPtr disk, if (qemuDomainSnapshotPrepareDiskExternalInactive(snapdisk, disk) = < 0) return -1; } else { - if (qemuDomainSnapshotPrepareDiskExternalActive(snapdisk, disk) < = 0) + if (qemuDomainSnapshotPrepareDiskExternalActive(snapdisk, disk, bl= ockdev) < 0) return -1; } @@ -15105,6 +15111,8 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm, virDomainSnapshotDefPtr def, unsigned int *flags) { + qemuDomainObjPrivatePtr priv =3D vm->privateData; + bool blockdev =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); int ret =3D -1; size_t i; bool active =3D virDomainObjIsActive(vm); @@ -15163,7 +15171,7 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm, } if (qemuDomainSnapshotPrepareDiskExternal(dom_disk, disk, - active, reuse) < 0) + active, reuse, block= dev) < 0) goto cleanup; external++; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list