From nobody Mon Feb 9 12:24:57 2026 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=1611364565; cv=none; d=zohomail.com; s=zohoarc; b=Zm6XXFc3u2txDetqgL5l45W/xHpvYdmgOfll3v7JoJap9Slew6gzF2k4tf+fn5BWMJkoSwyfn1WztbancDcHEVTLiNQN449V19U41+piYL0bw3byoR2LmfP4HTVzmUbHIVhnr5pZgD0Kmjqcd4uji0MQKiF1a9GNW90DXnoNzI0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611364565; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=AE42CeOn4gIl9iGGSHm5pOwdOLXZ6TuUs4DZFjA5hyg=; b=LgZNu4sntzoYoqZleNu0JqlAu5iETA4KNouydBijKX29JYTjcBeUkg8FiUPNV0ugpYCG0iCzOrc14CUYRI1VoJ+phkjUwav6TH7Cx2kBBnCBClJyv5HQzTKfTYL2UeuiSlkGytKP52OLYWJNlK/moTbyChO/iDQTcjwiq+WYqD8= 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 1611364565077326.8284220117488; Fri, 22 Jan 2021 17:16:05 -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-162-HN5iJ_wGOKy1zYk5qIMsQA-1; Fri, 22 Jan 2021 20:15:37 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A6EA9801FD4; Sat, 23 Jan 2021 01:15:31 +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 83C74100AE4B; Sat, 23 Jan 2021 01:15:31 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 507D71809CA0; Sat, 23 Jan 2021 01:15:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 10N1BYp1001166 for ; Fri, 22 Jan 2021 20:11:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id C8E2410336C0; Sat, 23 Jan 2021 01:11:34 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C4F831031F52 for ; Sat, 23 Jan 2021 01:11:34 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (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 B2BC9811E76 for ; Sat, 23 Jan 2021 01:11:34 +0000 (UTC) Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-589-EcPsq1MCMfSj92jSOdZfxg-1; Fri, 22 Jan 2021 20:11:32 -0500 Received: by mail-qt1-f178.google.com with SMTP id v3so5607612qtw.4 for ; Fri, 22 Jan 2021 17:11:32 -0800 (PST) Received: from localhost (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 23sm5021485qks.71.2021.01.22.17.11.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Jan 2021 17:11:31 -0800 (PST) X-MC-Unique: HN5iJ_wGOKy1zYk5qIMsQA-1 X-MC-Unique: EcPsq1MCMfSj92jSOdZfxg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AE42CeOn4gIl9iGGSHm5pOwdOLXZ6TuUs4DZFjA5hyg=; b=uVpagqjdPGT31jkBqlNQMdP+38pEEzffYeSdGl8qMnyYx3qDHKV+r45cj/NMk+O0y+ wdXtQB5XPsiyCZPNPCS1/xkSofHYsQirr2LKiqRx1+PKP/3B+EQ6VfnfLJ0/jx0iBU4t 7zWggKg2z9I5T7T2ZS6ynB3dBAlPLyvpCfx25xursUQJ8+9okoZ4oVCu4T463c5RmHmA WtmM41dS5o7lp7iTYLlCCQmOA9raLCL5dbSLbtSdWmj9gZas6DJ6Ie2SjOXCrQ9vLyD0 czeAbZBWLIT8PlPY+ILMfIivepd0bWjg6/CDC+T5g9g79Ihndyzd8FXVv+gKrVnxSpyn fe3Q== X-Gm-Message-State: AOAM5327WKwUvdIiRYBaFeuJqz5A2vH7GV5htVYsqsuX0q3po+/CBEXx /j0sXp099OoLP7CuV48JgVKzgG7uFw== X-Google-Smtp-Source: ABdhPJwN+ImfRl50Eavob6gnOrysAIYSnK8n5B3l1+1prciXbVTdodEmsJkmU/tfp5AMgbV0LhGlOA== X-Received: by 2002:ac8:5d09:: with SMTP id f9mr6976947qtx.157.1611364292035; Fri, 22 Jan 2021 17:11:32 -0800 (PST) From: Masayoshi Mizuma To: libvir-list@redhat.com Subject: [RFC PATCH 6/7] qemu: Add check whether the transient disks are sharable Date: Fri, 22 Jan 2021 20:11:05 -0500 Message-Id: <20210123011106.11126-7-msys.mizuma@gmail.com> In-Reply-To: <20210123011106.11126-1-msys.mizuma@gmail.com> References: <20210123011106.11126-1-msys.mizuma@gmail.com> 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.3 X-loop: libvir-list@redhat.com Cc: Masayoshi Mizuma , Masayoshi Mizuma 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.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 2 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Masayoshi Mizuma Check whether the transient disks are shareable or not. If followings are true, the transient disks are shareable. - qemu has blockdev and hotplug feature - the all disk bus support hot-plug Signed-off-by: Masayoshi Mizuma --- src/qemu/qemu_command.c | 17 +++++++++++++---- src/qemu/qemu_domain.h | 3 +++ src/qemu/qemu_process.c | 38 +++++++++++++++++++++++++++++++++++++- 3 files changed, 53 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 81a27703c5..d5958f46ef 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2063,10 +2063,14 @@ qemuBuildDiskCommandLine(virCommandPtr cmd, const virDomainDef *def, virDomainDiskDefPtr disk, virQEMUCapsPtr qemuCaps, - unsigned int bootindex) + unsigned int bootindex, + qemuDomainObjPrivatePtr priv) { g_autofree char *optstr =3D NULL; =20 + if ((disk->transient) && (priv->TransientDiskSharable)) + disk->src->readonly =3D true; + if (qemuBuildDiskSourceCommandLine(cmd, disk, qemuCaps) < 0) return -1; =20 @@ -2084,6 +2088,10 @@ qemuBuildDiskCommandLine(virCommandPtr cmd, if (qemuCommandAddExtDevice(cmd, &disk->info) < 0) return -1; =20 + /* All disks are hot-added later if TransientDiskSharable is true */ + if (priv->TransientDiskSharable) + return 0; + virCommandAddArg(cmd, "-device"); =20 if (!(optstr =3D qemuBuildDiskDeviceStr(def, disk, bootindex, @@ -2098,7 +2106,8 @@ qemuBuildDiskCommandLine(virCommandPtr cmd, static int qemuBuildDisksCommandLine(virCommandPtr cmd, const virDomainDef *def, - virQEMUCapsPtr qemuCaps) + virQEMUCapsPtr qemuCaps, + qemuDomainObjPrivatePtr priv) { size_t i; unsigned int bootCD =3D 0; @@ -2154,7 +2163,7 @@ qemuBuildDisksCommandLine(virCommandPtr cmd, if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY) bootindex =3D 0; =20 - if (qemuBuildDiskCommandLine(cmd, def, disk, qemuCaps, bootindex) = < 0) + if (qemuBuildDiskCommandLine(cmd, def, disk, qemuCaps, bootindex, = priv) < 0) return -1; } =20 @@ -9935,7 +9944,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, VIR_DOMAIN_CONTROLLER_TYPE_C= CID) < 0) return NULL; =20 - if (qemuBuildDisksCommandLine(cmd, def, qemuCaps) < 0) + if (qemuBuildDisksCommandLine(cmd, def, qemuCaps, priv) < 0) return NULL; =20 if (qemuBuildFilesystemCommandLine(cmd, def, qemuCaps, priv) < 0) diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 154339ef8f..37b050def4 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -267,6 +267,9 @@ struct _qemuDomainObjPrivate { /* prevent deletion of disk overlay files between startup = and * succesful setup of the overlays */ bool inhibitDiskTransientDelete; + + /* True if the all transient disks are sharable */ + bool TransientDiskSharable; }; =20 #define QEMU_DOMAIN_PRIVATE(vm) \ diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index f87a3c0f60..2e2d1c6fea 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6892,6 +6892,40 @@ qemuProcessEnablePerf(virDomainObjPtr vm) return 0; } =20 +static void +qemuCheckTransientDiskSharable(virDomainObjPtr vm) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + bool hotplug =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_PCIE_ROOT_PO= RT_HOTPLUG); + size_t i; + + priv->TransientDiskSharable =3D false; + + if (!hotplug) + return; + + for (i =3D 0; i < vm->def->ndisks; i++) { + virDomainDiskDefPtr disk =3D vm->def->disks[i]; + + if (disk->transient && disk->bus !=3D VIR_DOMAIN_DISK_BUS_LAST) + return; + } + + priv->TransientDiskSharable =3D true; +} + +static int +qemuProcessCreateDisksTransient(virDomainObjPtr vm, + qemuDomainAsyncJob asyncJob) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + + if (priv->TransientDiskSharable) + return qemuHotplugCreateDisksTransient(vm, asyncJob); + else + return qemuSnapshotCreateDisksTransient(vm, asyncJob); +} + =20 /** * qemuProcessLaunch: @@ -6982,6 +7016,8 @@ qemuProcessLaunch(virConnectPtr conn, incoming !=3D NULL) < 0) goto cleanup; =20 + qemuCheckTransientDiskSharable(vm); + VIR_DEBUG("Building emulator command line"); if (!(cmd =3D qemuBuildCommandLine(driver, qemuDomainLogContextGetManager(logCtx= t), @@ -7228,7 +7264,7 @@ qemuProcessLaunch(virConnectPtr conn, goto cleanup; =20 VIR_DEBUG("Setting up transient disk"); - if (qemuSnapshotCreateDisksTransient(vm, asyncJob) < 0) + if (qemuProcessCreateDisksTransient(vm, asyncJob) < 0) goto cleanup; =20 ret =3D 0; --=20 2.27.0