From nobody Mon Nov 25 07:26:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1607738357; cv=none; d=zohomail.com; s=zohoarc; b=bVs3Qz9no83ns60kU6yZNWnYVB+Y4D58YdkJF54FOCV3LqOFhTuIKzD6lfHyad/hwDEQjHm3u9WSa2e+uThtHkdaV5KYzoW0lj/+QMkIozMdfUr0QBGQTb6FLQZ8sIC6DsIMJvcsGa3gLoyFcES5RGM5h6UmTkMwaXY6DjLSEbQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607738357; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=89mdHJXsYsb9ZFdJ+6kycFnI51DwW72q1KY77VZiJK0=; b=YriuW2sP3KL7FJGkv54ekjPTQZUK1RjnhRifTcYbL7n4uPOcrkEq/GLrr17FxWPbjs+oUA9y0vmPH/uKs9eNnriSW/FU+WBybXkyo8Zt3TOvrvc0XoGehSUcVifvoLG4b9D/C1qc2vu/FwGMKeTHZp8lVqIFFTwK2GBgxkaptc0= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 160773835704735.37931420038831; Fri, 11 Dec 2020 17:59:17 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-17-TW-y7COJPEqV-ZnYQ88Jcg-1; Fri, 11 Dec 2020 20:59:13 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7F1B159; Sat, 12 Dec 2020 01:59:06 +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 725831975E; Sat, 12 Dec 2020 01:59:03 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 80164180954D; Sat, 12 Dec 2020 01:58:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0BC1wuA8011555 for ; Fri, 11 Dec 2020 20:58:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9958D2026D12; Sat, 12 Dec 2020 01:58:56 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 94CAC2026D48 for ; Sat, 12 Dec 2020 01:58:54 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 41D6A1010424 for ; Sat, 12 Dec 2020 01:58:54 +0000 (UTC) Received: from mail-qt1-f180.google.com (mail-qt1-f180.google.com [209.85.160.180]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-35-CXz7eTXkMOqzt7GK4VxXKA-1; Fri, 11 Dec 2020 20:58:52 -0500 Received: by mail-qt1-f180.google.com with SMTP id b9so7975266qtr.2 for ; Fri, 11 Dec 2020 17:58:52 -0800 (PST) Received: from gabell (209-6-122-159.s2973.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [209.6.122.159]) by smtp.gmail.com with ESMTPSA id j2sm1266148qkm.58.2020.12.11.17.58.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Dec 2020 17:58:50 -0800 (PST) X-MC-Unique: TW-y7COJPEqV-ZnYQ88Jcg-1 X-MC-Unique: CXz7eTXkMOqzt7GK4VxXKA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:content-transfer-encoding; bh=89mdHJXsYsb9ZFdJ+6kycFnI51DwW72q1KY77VZiJK0=; b=ZC24MDOsXE+ZLX1eFlF3h5xMVvWKn5ZD+qDSnO3+T+o+fBWBS9FAWt+dPgtEOMq1SZ 3HwLMkrFBKeh+5HfKMq+St+6fRP0mAF+6BScBy1OCCcttS9SYuvmlH0ISfIDniHhWpIS XRDqs5pJi3Go3vjqlP9kChbQ6E1w+w76Us3WiSFklyVFjtzIntEWLC+snaWtILs5qqeR unK1vZZLSyILO2AwJGfhehUEffGiS5Bf20chOwLQ8BagKSYYuzAnvUAhSWsU5R4V0mre nRsPQPZIyeHoYnRxWEPscjMBntn5m31lHldFUvu6IGopNTSKh82VHEmtW/8c0Xv5OtC7 LpBQ== X-Gm-Message-State: AOAM5301V/G5l2oTwJVgYJO7UIIhkZS4w1zPnl93TlE2Q6WQI5DdnY6v eGWJSFYJAT+2lFFoLwIxovLSy9Nm3w== X-Google-Smtp-Source: ABdhPJzuQXiugs/Jcq6ihVAaOWfEzkL1VlEDbbpe+7mSvzKpWH1lk2MPtYYxphZzdn8/A46bgoJAGA== X-Received: by 2002:ac8:aca:: with SMTP id g10mr19586562qti.204.1607738331607; Fri, 11 Dec 2020 17:58:51 -0800 (PST) Date: Fri, 11 Dec 2020 20:58:48 -0500 From: Masayoshi Mizuma To: libvir-list@redhat.com Subject: To start multiple KVM guests from one qcow2 image with transient disk option Message-ID: <20201212015848.7vzqjilkdmppupik@gabell> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello, I would like to start multiple KVM guests from one qcow2 image, and discard the changes which the KVM guests done. transient disk option is useful for discarding the changes, however, we cannot start multiple KVM guest from one qcow2 image because the image is write-locked=C2=A0by the first guest to be started. I suppose the disk which transient option is enabled don't need to get the write lock because any changes go to the overlay image, and the overlay image is removed when the guest shutdown. qemu has 'locking' option and the write lock is disabled when locking=3Doff. To implement that, I have two ideas. I would appreciate it if you could give me the ideas which way is better (or another way). 1. Add an element to handle 'locking' qemu option. Like as: =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 2. Add locking=3Doff internally only if the transient disk option is enable= d. =C2=A0 =C2=A0The sample code is as follows: diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 23415b323c..6fafe22ca3 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10186,6 +10186,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlo= pt, def->src->shared =3D true; } else if (virXMLNodeNameEqual(cur, "transient")) { def->transient =3D true; + def->src->transient =3D true; } else if (!encryption && virXMLNodeNameEqual(cur, "encryption")) { if (!(encryption =3D virStorageEncryptionParseNode(cur, ctxt))) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 4640e339c0..3db888d08b 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1211,6 +1211,12 @@ qemuBlockStorageSourceGetBackendProps(virStorageSour= cePtr src, "s:discard", "unmap", NULL) < 0) return NULL; + + if (src->transient) { + if (virJSONValueObjectAdd(fileprops, + "S:locking", "off", NULL) < 0) + return NULL; + } } } =20 diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 15494c3415..7823810df6 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1182,7 +1182,8 @@ qemuSnapshotDiskPrepareDisksTransient(virDomainObjPtr= vm, snapdisk->src =3D virStorageSourceNew(); snapdisk->src->type =3D VIR_STORAGE_TYPE_FILE; snapdisk->src->format =3D VIR_STORAGE_FILE_QCOW2; - snapdisk->src->path =3D g_strdup_printf("%s.TRANSIENT", domdisk->s= rc->path); + snapdisk->src->path =3D g_strdup_printf("%s.TRANSIENT-%s", + domdisk->src->path, vm->def-= >name); =20 if (virFileExists(snapdisk->src->path)) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 87763cf389..70c963bd42 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -384,6 +384,8 @@ struct _virStorageSource { /* these must not be used apart from formatting the output JSON in the= qemu driver */ char *ssh_user; bool ssh_host_key_check_disabled; + + bool transient; }; =20 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virStorageSource, virObjectUnref); -- Thanks, Masa