From nobody Fri May 17 06:07:55 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1621601277; cv=none; d=zohomail.com; s=zohoarc; b=J4Nr1p6GNdSLYBnc7ZfLyTRLDa8cG5mFMNUYUJo8sgYKAzW4v9pN9w9iZzN5NgcmP8cUj5nRFAn9WSJX/heSBLZHvVl+U887KutoG1n1hB/T8vPN8Ipaxd48aFSNfyMFRvUSa/+7q8hI121MSWGf9ih0lP6zsSeH7aNf+3KzdYs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601277; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=16pscrs5fkf42qV0o8i238IA69d04LMNd+wfL11Fe7w=; b=VRNP7S6frX5enFUmC6Xvh6LaOATF0PJKxzQVj17/pLowsUGCtG+miL1b1HRL39nb3J9/PX74fNWsk39hPePHpdJ1H3WID/6zFOxqnIGQEOgkGVMC1L9eYPxZ2/Um17gsZcpEOicxUxT5kG9UgD6rWE4uW/P6d68Z0C/zEMKgm9c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass 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 1621601277144460.86197968609304; Fri, 21 May 2021 05:47:57 -0700 (PDT) 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-411-s_r3IRvtMcO_bX6UcDQxXg-1; Fri, 21 May 2021 08:47:53 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 21EE18A9F4E; Fri, 21 May 2021 12:47:47 +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 EE1FB5C730; Fri, 21 May 2021 12:47: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 95F761800BB4; Fri, 21 May 2021 12:47:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LClgRL030910 for ; Fri, 21 May 2021 08:47:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 819B669FB1; Fri, 21 May 2021 12:47:42 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE11669FCE for ; Fri, 21 May 2021 12:47:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601275; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=16pscrs5fkf42qV0o8i238IA69d04LMNd+wfL11Fe7w=; b=chIG7LKCLDJM5KAEPRViHlu1WZZmZ7aeUephY5Egz8kQpQqrLCd2FwtMCqHQPM9Riv4/2l WwggxEwbF8XmYlrmXQHdg8JXt6oSJnDS7rsVCbDYcszpkhtTUYE1zvm+qfppF+vSky19ZD OdpEBS2r6u8KC87zCnlYmTxaYd/f2I4= X-MC-Unique: s_r3IRvtMcO_bX6UcDQxXg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/35] qemu: snapshot: Extract setup of snapshot disk definition for transient disks Date: Fri, 21 May 2021 14:47:01 +0200 Message-Id: <8779d99daffd2083913d538e378f5787761fd864.1621601160.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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.79 on 10.5.11.16 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The code will be later reused when adding support for sharing the backing image of the snapshot. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_snapshot.c | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index fd6669433b..c3cff46bc9 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1168,6 +1168,29 @@ qemuSnapshotDiskPrepareActiveExternal(virDomainObj *= vm, } +static virDomainSnapshotDiskDef * +qemuSnapshotGetTransientDiskDef(virDomainDiskDef *domdisk) +{ + g_autoptr(virDomainSnapshotDiskDef) snapdisk =3D g_new0(virDomainSnaps= hotDiskDef, 1); + + snapdisk->name =3D g_strdup(domdisk->dst); + snapdisk->snapshot =3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; + 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->src->= path); + + if (virFileExists(snapdisk->src->path)) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("Overlay file '%s' for transient disk '%s' alread= y exists"), + snapdisk->src->path, domdisk->dst); + return NULL; + } + + return g_steal_pointer(&snapdisk); +} + + static qemuSnapshotDiskContext * qemuSnapshotDiskPrepareDisksTransient(virDomainObj *vm, virQEMUDriverConfig *cfg, @@ -1181,26 +1204,15 @@ qemuSnapshotDiskPrepareDisksTransient(virDomainObj = *vm, for (i =3D 0; i < vm->def->ndisks; i++) { virDomainDiskDef *domdisk =3D vm->def->disks[i]; - g_autoptr(virDomainSnapshotDiskDef) snapdisk =3D g_new0(virDomainS= napshotDiskDef, 1); + g_autoptr(virDomainSnapshotDiskDef) snapdisk =3D NULL; if (!domdisk->transient) continue; /* validation code makes sure that we do this only for local disks * with a file source */ - snapdisk->name =3D g_strdup(domdisk->dst); - snapdisk->snapshot =3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL; - 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); - - if (virFileExists(snapdisk->src->path)) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, - _("Overlay file '%s' for transient disk '%s' al= ready exists"), - snapdisk->src->path, domdisk->dst); - return NULL; - } + + snapdisk =3D qemuSnapshotGetTransientDiskDef(domdisk); if (qemuSnapshotDiskPrepareOne(vm, cfg, domdisk, snapdisk, snapctxt->dd + snapctxt->ndd++, --=20 2.31.1 From nobody Fri May 17 06:07:55 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1621601276; cv=none; d=zohomail.com; s=zohoarc; b=POZvQun5v9ewUf9z7iEIEKIqF7yGYYZdpJbe6NLXSw5Lri3GOye5fu9aV69aIahJ8PFyu9+gkGsuBQuYMF9H7Fi5QHDM7MeoZo7rAUFpQ4uoDwcB8ZIad4bEbX1YXIbDzXg/gMdj+6/AZJ7xaG2XhRmQA6Uu5w2eozP58ouaciA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601276; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bKDPzqeVdDnJ29YXGYyXgNdGvUf92PsLP7wg+k2jn+c=; b=OP0HwudcY7tutkjFqMH0PWhkVn6/bEdbS2uBPDy+DhvyY7UUDgvMM0T6SIe5RkV5Y9P+z9BWqFQKd/v6CVYFS8erbe1OehtUXx37TXFh4wMIABp/82/Z4ffMnHk9Kf98CiChuaA3Rn9IDj0XUAXyGyUZoEv8O3AHC/e54442ACU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass 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 1621601276836268.3505605244176; Fri, 21 May 2021 05:47:56 -0700 (PDT) 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-455-5tCIi4ShNoWaQPXPepzUNg-1; Fri, 21 May 2021 08:47:53 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 14B62180FD75; Fri, 21 May 2021 12:47:47 +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 CD4045C1BB; Fri, 21 May 2021 12:47: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 7123144A5E; Fri, 21 May 2021 12:47:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LClhua030932 for ; Fri, 21 May 2021 08:47:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 982AF421F; Fri, 21 May 2021 12:47:43 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED6D569FB1 for ; Fri, 21 May 2021 12:47:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601275; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=bKDPzqeVdDnJ29YXGYyXgNdGvUf92PsLP7wg+k2jn+c=; b=dRfw5FZwTv70WeNBW3RnCkYIJWm7t/nLQMjhCA1HSN7KbdFVqFuN+hqGCsrnDNBtmjwz5m St2z/h8xQu/XlEQ6KIoU8aDRn+vj0oul9AFjwrddIItgRdd3rmT/rG85S0zTIOw44fhK/n rlDMm8xCxAtf9CDinFqg5tYUSEa1SUo= X-MC-Unique: 5tCIi4ShNoWaQPXPepzUNg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/35] qemu: process: Setup transient disks only when starting a fresh VM Date: Fri, 21 May 2021 14:47:02 +0200 Message-Id: <719a0ae4e08e05e9b14b7d472b27d38ec4e9871b.1621601160.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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.79 on 10.5.11.16 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Creating the overlay for the disk is needed when starting a new VM only. Additionally for now migration with transient disks is forbidden anyways. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_process.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 35213f81ec..543b50f875 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7289,9 +7289,11 @@ qemuProcessLaunch(virConnectPtr conn, qemuProcessAutoDestroyAdd(driver, vm, conn) < 0) goto cleanup; - VIR_DEBUG("Setting up transient disk"); - if (qemuSnapshotCreateDisksTransient(vm, asyncJob) < 0) - goto cleanup; + if (!incoming && !snapshot) { + VIR_DEBUG("Setting up transient disk"); + if (qemuSnapshotCreateDisksTransient(vm, asyncJob) < 0) + goto cleanup; + } ret =3D 0; --=20 2.31.1 From nobody Fri May 17 06:07:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1621601285; cv=none; d=zohomail.com; s=zohoarc; b=e61ghrVKAAAyUJs/zNvMJtJaZJJUIP9tX4dyn33ilAqG4pDfb+NEu6/zegnmNniwsEIWyjbq3m+iaho9txRgca/lEbaIrZitIZaZfjE0TKCTDhWWQWEGpF14O0AMK+cC2p6W44sQcEDj/wEtlhiI+UyertWp/WEMrLSBJIXFMUM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601285; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yfSllShJgppq+/MI5TVRLA8+gqJkBy8DccqSmM4J3ks=; b=lSZ3ws2l0h/nLGLJIWZTaYZJcFXZCwqpCdN+M40ELxyIdkMwqLLCEcxsDt/HczmNJJVQlQnnyGVeBS9jTuit1NPEROmEDNruUrHL0cu8twmeH0lLQ5HMmhIUvz3MPe3aZ7qZCGA6g71KNJ6D7gsSWQFdRyXHlzMBFWDp9Eil2/Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 162160128522519.186813800189043; Fri, 21 May 2021 05:48:05 -0700 (PDT) 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-560-NvhmYcL9PKaHsYCsBApj8A-1; Fri, 21 May 2021 08:48:02 -0400 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 F3805107ACF6; Fri, 21 May 2021 12:47: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 C98C6100AE43; Fri, 21 May 2021 12:47: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 984D2180B464; Fri, 21 May 2021 12:47:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LCli0E030941 for ; Fri, 21 May 2021 08:47:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id A6F9059468; Fri, 21 May 2021 12:47:44 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1562B5945B for ; Fri, 21 May 2021 12:47:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601284; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=yfSllShJgppq+/MI5TVRLA8+gqJkBy8DccqSmM4J3ks=; b=LseAGIYjzpn4keRt8nIhCvOhD3GcbjjDNJAEXbiqd3RNf6OLOwZ0Bm2XqKCf55b/4EaZFB qStiTrFGZgr3bpiHNnm8cfyMW+PXd01R6k+sMSXQnZKexGddR6sP2tlr1hzXUaampO2YsC GDJpKAfFY5RNjfMEmy/eZaneXBt3V84= X-MC-Unique: NvhmYcL9PKaHsYCsBApj8A-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/35] qemuSnapshotDiskPrepareOne: Pass in qemuSnapshotDiskContext Date: Fri, 21 May 2021 14:47:03 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Rather than filling various parts of the context from arguments pass in the whole context. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_snapshot.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index c3cff46bc9..b93b9b9fb0 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1030,12 +1030,11 @@ qemuSnapshotDiskPrepareOne(virDomainObj *vm, virQEMUDriverConfig *cfg, virDomainDiskDef *disk, virDomainSnapshotDiskDef *snapdisk, - qemuSnapshotDiskData *dd, + qemuSnapshotDiskContext *snapctxt, GHashTable *blockNamedNodeData, bool reuse, bool updateConfig, - qemuDomainAsyncJob asyncJob, - virJSONValue *actions) + qemuDomainAsyncJob asyncJob) { qemuDomainObjPrivate *priv =3D vm->privateData; virQEMUDriver *driver =3D priv->driver; @@ -1043,6 +1042,7 @@ qemuSnapshotDiskPrepareOne(virDomainObj *vm, virDomainDiskDef *persistdisk; bool supportsCreate; bool updateRelativeBacking =3D false; + qemuSnapshotDiskData *dd =3D snapctxt->dd + snapctxt->ndd++; dd->disk =3D disk; @@ -1115,13 +1115,13 @@ qemuSnapshotDiskPrepareOne(virDomainObj *vm, blockNamedNodeData, asyncJo= b) < 0) return -1; - if (qemuSnapshotDiskBitmapsPropagate(dd, actions, blockNamedNodeDa= ta) < 0) + if (qemuSnapshotDiskBitmapsPropagate(dd, snapctxt->actions, blockN= amedNodeData) < 0) return -1; - if (qemuBlockSnapshotAddBlockdev(actions, dd->disk, dd->src) < 0) + if (qemuBlockSnapshotAddBlockdev(snapctxt->actions, dd->disk, dd->= src) < 0) return -1; } else { - if (qemuBlockSnapshotAddLegacy(actions, dd->disk, dd->src, reuse) = < 0) + if (qemuBlockSnapshotAddLegacy(snapctxt->actions, dd->disk, dd->sr= c, reuse) < 0) return -1; } @@ -1155,12 +1155,11 @@ qemuSnapshotDiskPrepareActiveExternal(virDomainObj = *vm, if (qemuSnapshotDiskPrepareOne(vm, cfg, vm->def->disks[i], snapdef->disks + i, - snapctxt->dd + snapctxt->ndd++, + snapctxt, blockNamedNodeData, reuse, true, - asyncJob, - snapctxt->actions) < 0) + asyncJob) < 0) return NULL; } @@ -1214,13 +1213,11 @@ qemuSnapshotDiskPrepareDisksTransient(virDomainObj = *vm, snapdisk =3D qemuSnapshotGetTransientDiskDef(domdisk); - if (qemuSnapshotDiskPrepareOne(vm, cfg, domdisk, snapdisk, - snapctxt->dd + snapctxt->ndd++, + if (qemuSnapshotDiskPrepareOne(vm, cfg, domdisk, snapdisk, snapctx= t, blockNamedNodeData, false, false, - asyncJob, - snapctxt->actions) < 0) + asyncJob) < 0) return NULL; } --=20 2.31.1 From nobody Fri May 17 06:07:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1621601346; cv=none; d=zohomail.com; s=zohoarc; b=TirOcvtYA5qmkPaDwBIrzE3I89mvR0XYlrI5RlPYWxk+T0ZFyYRLzb0CG8p/o9w869jj3J1sEa772s612SOQhOdGFx3BvcRsLkAaFNz+6UT+y3RxdKDtoY7XBhW4ZOPue5XQ6tYzUKB6bMIogs8dszVnx4rsLPotFYtbvCs/9Lc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601346; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=j5Et+hxYbXsc63LGYT4gs/J53PGPwbE0vRXW1cKsG1I=; b=UrwYHBWEKKzzPXSv+9VSmU6G74FkAumzwJiFyE8wCUVMxtrHSC3Urg2LB4P4LQl2uH6mieRgh9quFrgRsw1uFx4Pa8n+fcGAn6UQsns4Y57+Dy/99TLjlyi/RmF9ol3yffhv8IrXKFll0C38otu8WE378LO0v2JKzND5Dv5e1js= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1621601346751907.4266325516099; Fri, 21 May 2021 05:49:06 -0700 (PDT) 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-460-PJc0K-xoNQWHgAmv5Yoirg-1; Fri, 21 May 2021 08:48:01 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F13125B394; Fri, 21 May 2021 12:47: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 CE06A5C67A; Fri, 21 May 2021 12:47: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 9DB01180102A; Fri, 21 May 2021 12:47:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LCljBH030946 for ; Fri, 21 May 2021 08:47:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id B1B6A69FCE; Fri, 21 May 2021 12:47:45 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 140275945B for ; Fri, 21 May 2021 12:47:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601345; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=j5Et+hxYbXsc63LGYT4gs/J53PGPwbE0vRXW1cKsG1I=; b=TBCuM/c1s7QrR3AjRG9yogX1KLK1G99yaQIv6pCatVvVbjKa59ejHLLNUzNnAPVI0MyWnV YjuRMkWDmlz/IEL9zx9vlc/7AzKOI6KibpL6w8XvxgtEp0vxLuyXcIWWUEK/HKZLdC2pan 5NsTfNMHFiDXSIlBbyxlvJQLis8Sh60= X-MC-Unique: PJc0K-xoNQWHgAmv5Yoirg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/35] qemuSnapshotDiskContext: Store virQEMUDriverConfig in the struct Date: Fri, 21 May 2021 14:47:04 +0200 Message-Id: <7b5d502e01787d1498ed462a39ff4e7cb8c45c66.1621601160.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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.79 on 10.5.11.16 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The config is used both with the preparation and execution functions, so we can store it in the context to simplify other helpers. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_snapshot.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index b93b9b9fb0..def2733958 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -896,6 +896,8 @@ struct _qemuSnapshotDiskContext { virJSONValue *actions; + virQEMUDriverConfig *cfg; + /* needed for automatic cleanup of 'dd' */ virDomainObj *vm; qemuDomainAsyncJob asyncJob; @@ -909,11 +911,14 @@ qemuSnapshotDiskContextNew(size_t ndisks, virDomainObj *vm, qemuDomainAsyncJob asyncJob) { + qemuDomainObjPrivate *priv =3D vm->privateData; + virQEMUDriver *driver =3D priv->driver; qemuSnapshotDiskContext *ret =3D g_new0(qemuSnapshotDiskContext, 1); ret->dd =3D g_new0(qemuSnapshotDiskData, ndisks); ret->actions =3D virJSONValueNewArray(); ret->vm =3D vm; + ret->cfg =3D virQEMUDriverGetConfig(driver); ret->asyncJob =3D asyncJob; return ret; @@ -930,6 +935,8 @@ qemuSnapshotDiskContextCleanup(qemuSnapshotDiskContext = *snapctxt) qemuSnapshotDiskCleanup(snapctxt->dd, snapctxt->ndd, snapctxt->vm, sna= pctxt->asyncJob); + virObjectUnref(snapctxt->cfg); + g_free(snapctxt); } --=20 2.31.1 From nobody Fri May 17 06:07:55 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1621601295; cv=none; d=zohomail.com; s=zohoarc; b=MX75P9N9N1jfYeepfHxwZnUYhcKv6Ba/lSxFis5LBVpSvRZmrlcM045DKHnd3r/QoKITxFJlR9HaJURvPlMsL+caykeA7AJBi+ixzpOpxYUk4eNw6LtxprVnmYb6fCTa7tYtBHqEpUN+TcHvJyn157gwm5I1zZhY5ut30BqqaEs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601295; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sH3XulkNMxJS2jAk43ti8RGD4nrGOoEGA4FA2wrdAbA=; b=GdQSmhAL212Z4JV/5ecF25CJ7TpXTZGnIxtAUzg3zbDt4RnmAIerhWm30Ck88qMcyJ4UsJiF1dTKOTgWsDaLi6D8OI9nCzdPuVN2eHDKSKdcXtakR1QP5LqgPkpTXHnxCNXH4iFRcbuZXki8+2Yfhzw+CRADfv7SQLEszJFfP2s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass 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 1621601295044685.6756997203861; Fri, 21 May 2021 05:48:15 -0700 (PDT) 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-561-kcS6_UkVNDeKER43jzTcSg-1; Fri, 21 May 2021 08:48:11 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 90526108BC4A; Fri, 21 May 2021 12:48:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6EDEE60C17; Fri, 21 May 2021 12:48: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 2CAF544A60; Fri, 21 May 2021 12:47:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LClkE3030957 for ; Fri, 21 May 2021 08:47:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id C1FF0421F; Fri, 21 May 2021 12:47:46 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 289842B166 for ; Fri, 21 May 2021 12:47:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601294; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=sH3XulkNMxJS2jAk43ti8RGD4nrGOoEGA4FA2wrdAbA=; b=E/RcRqX5H0fnb0kE3EBkEXqmeIGaHh5SrAm0QKABwg3fiAhHzI9GRLwBbeAqaSYERx8pTr CVG4u4YVP1AmpEMbjK7OVklH0a+oZWd+sZpPF1XKymp3wcyqj82pU1jNHgvhQf5c19S+Lb RBFN+nFdZBhgf2fHvWk/kk4IACjpIro= X-MC-Unique: kcS6_UkVNDeKER43jzTcSg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/35] qemuSnapshotDiskPrepareOne: Use data from qemuSnapshotDiskContext Date: Fri, 21 May 2021 14:47:05 +0200 Message-Id: <546953bc31388e7118e1de1bfcb8b239cd8dd532.1621601160.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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.79 on 10.5.11.12 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Remove all the arguments which are present in qemuSnapshotDiskContext. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_snapshot.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index def2733958..0a93621b75 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1033,16 +1033,14 @@ qemuSnapshotDiskPrepareOneBlockdev(virQEMUDriver *d= river, static int -qemuSnapshotDiskPrepareOne(virDomainObj *vm, - virQEMUDriverConfig *cfg, +qemuSnapshotDiskPrepareOne(qemuSnapshotDiskContext *snapctxt, virDomainDiskDef *disk, virDomainSnapshotDiskDef *snapdisk, - qemuSnapshotDiskContext *snapctxt, GHashTable *blockNamedNodeData, bool reuse, - bool updateConfig, - qemuDomainAsyncJob asyncJob) + bool updateConfig) { + virDomainObj *vm =3D snapctxt->vm; qemuDomainObjPrivate *priv =3D vm->privateData; virQEMUDriver *driver =3D priv->driver; bool blockdev =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); @@ -1118,8 +1116,8 @@ qemuSnapshotDiskPrepareOne(virDomainObj *vm, dd->prepared =3D true; if (blockdev) { - if (qemuSnapshotDiskPrepareOneBlockdev(driver, vm, dd, cfg, reuse, - blockNamedNodeData, asyncJo= b) < 0) + if (qemuSnapshotDiskPrepareOneBlockdev(driver, vm, dd, snapctxt->c= fg, reuse, + blockNamedNodeData, snapctx= t->asyncJob) < 0) return -1; if (qemuSnapshotDiskBitmapsPropagate(dd, snapctxt->actions, blockN= amedNodeData) < 0) @@ -1145,7 +1143,6 @@ qemuSnapshotDiskPrepareOne(virDomainObj *vm, static qemuSnapshotDiskContext * qemuSnapshotDiskPrepareActiveExternal(virDomainObj *vm, virDomainMomentObj *snap, - virQEMUDriverConfig *cfg, bool reuse, GHashTable *blockNamedNodeData, qemuDomainAsyncJob asyncJob) @@ -1160,13 +1157,12 @@ qemuSnapshotDiskPrepareActiveExternal(virDomainObj = *vm, if (snapdef->disks[i].snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION= _NONE) continue; - if (qemuSnapshotDiskPrepareOne(vm, cfg, vm->def->disks[i], + if (qemuSnapshotDiskPrepareOne(snapctxt, + vm->def->disks[i], snapdef->disks + i, - snapctxt, blockNamedNodeData, reuse, - true, - asyncJob) < 0) + true) < 0) return NULL; } @@ -1199,7 +1195,6 @@ qemuSnapshotGetTransientDiskDef(virDomainDiskDef *dom= disk) static qemuSnapshotDiskContext * qemuSnapshotDiskPrepareDisksTransient(virDomainObj *vm, - virQEMUDriverConfig *cfg, GHashTable *blockNamedNodeData, qemuDomainAsyncJob asyncJob) { @@ -1220,11 +1215,10 @@ qemuSnapshotDiskPrepareDisksTransient(virDomainObj = *vm, snapdisk =3D qemuSnapshotGetTransientDiskDef(domdisk); - if (qemuSnapshotDiskPrepareOne(vm, cfg, domdisk, snapdisk, snapctx= t, + if (qemuSnapshotDiskPrepareOne(snapctxt, domdisk, snapdisk, blockNamedNodeData, false, - false, - asyncJob) < 0) + false) < 0) return NULL; } @@ -1349,7 +1343,7 @@ qemuSnapshotCreateActiveExternalDisks(virDomainObj *v= m, /* prepare a list of objects to use in the vm definition so that we do= n't * have to roll back later */ - if (!(snapctxt =3D qemuSnapshotDiskPrepareActiveExternal(vm, snap, cfg= , reuse, + if (!(snapctxt =3D qemuSnapshotDiskPrepareActiveExternal(vm, snap, reu= se, blockNamedNodeD= ata, asyncJob))) return -1; @@ -1383,7 +1377,7 @@ qemuSnapshotCreateDisksTransient(virDomainObj *vm, if (!(blockNamedNodeData =3D qemuBlockGetNamedNodeData(vm, asyncJo= b))) return -1; - if (!(snapctxt =3D qemuSnapshotDiskPrepareDisksTransient(vm, cfg, + if (!(snapctxt =3D qemuSnapshotDiskPrepareDisksTransient(vm, blockNamedN= odeData, asyncJob))) return -1; --=20 2.31.1 From nobody Fri May 17 06:07:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1621601288; cv=none; d=zohomail.com; s=zohoarc; b=JREdytsOuluY6Qod1zIqHQoYjCnjFknDvnvlHDFpO05Uk8dWyYss+UHRdJZ+kQx1JEX/4M+oI4jyz4deKJSWXAAgIONKO2+gHbyiu+C4y/bY+sFEcz5o2/RwpvGtJvFMZjzArv+Vtu8DAFJsPrruwMpSB7QHtdEs9uxexv8OdVE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601288; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9gDgv2aoYd6kQ3dJ5E/UPv7p2R24tUs9jWgk37zNvn4=; b=SR+8orY5l/7TsE+PACf6pyVzsIfu7JsKFg6NLpbMF5kXXpHKNVEbDDTiDQ/HJhygqEeBokfx9uAkMGt7ZUv4ofDGd+9mvVcOCPH3Ay4ijqLCJ3JjD5iAI6wqpNixodRaRdMVk36jmAalNnjbut6WrbnoKkobHgLJ3ZSmzA5jD3Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 162160128851027.033481589989037; Fri, 21 May 2021 05:48:08 -0700 (PDT) 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-232-9Oys4TJ0Or-0u909gxKlcg-1; Fri, 21 May 2021 08:48:05 -0400 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 AD1B0108BC1A; Fri, 21 May 2021 12:47:59 +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 835D3E158; Fri, 21 May 2021 12:47:59 +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 23CBA180B465; Fri, 21 May 2021 12:47:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LCllmg030969 for ; Fri, 21 May 2021 08:47:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id C8E5150F89; Fri, 21 May 2021 12:47:47 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D0FA421F for ; Fri, 21 May 2021 12:47:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601287; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=9gDgv2aoYd6kQ3dJ5E/UPv7p2R24tUs9jWgk37zNvn4=; b=JL0/W12IQLm3vY4B+rhbGrfBC9lM+RJ5g6Jk6f5L1rry3ufvqbmJCJwz03n7wVhrWlU9KT HFU5eapNa/sSg2FbWNtIFRxAuHjpo2SQ03ldrVr6Mln+DahedjlrfFLRH9bGAg+Zx1QrAK 4Vjck53IUmFxJL47Ig7zUcV9U9QhmJM= X-MC-Unique: 9Oys4TJ0Or-0u909gxKlcg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/35] qemuSnapshotDiskCreate: Use 'cfg' from the qemuSnapshotDiskContext Date: Fri, 21 May 2021 14:47:06 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" We store the virQEMUDriverConfig object in the context. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_snapshot.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 0a93621b75..8855a019cb 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1285,8 +1285,7 @@ qemuSnapshotDiskUpdateSource(virDomainObj *vm, static int -qemuSnapshotDiskCreate(qemuSnapshotDiskContext *snapctxt, - virQEMUDriverConfig *cfg) +qemuSnapshotDiskCreate(qemuSnapshotDiskContext *snapctxt) { qemuDomainObjPrivate *priv =3D snapctxt->vm->privateData; virQEMUDriver *driver =3D priv->driver; @@ -1317,9 +1316,9 @@ qemuSnapshotDiskCreate(qemuSnapshotDiskContext *snapc= txt, if (rc < 0) return -1; - if (virDomainObjSave(snapctxt->vm, driver->xmlopt, cfg->stateDir) < 0 = || + if (virDomainObjSave(snapctxt->vm, driver->xmlopt, snapctxt->cfg->stat= eDir) < 0 || (snapctxt->vm->newDef && virDomainDefSave(snapctxt->vm->newDef, dr= iver->xmlopt, - cfg->configDir) < 0)) + snapctxt->cfg->configDir= ) < 0)) return -1; return 0; @@ -1332,7 +1331,6 @@ qemuSnapshotCreateActiveExternalDisks(virDomainObj *v= m, virDomainMomentObj *snap, GHashTable *blockNamedNodeData, unsigned int flags, - virQEMUDriverConfig *cfg, qemuDomainAsyncJob asyncJob) { bool reuse =3D (flags & VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT) !=3D 0; @@ -1347,7 +1345,7 @@ qemuSnapshotCreateActiveExternalDisks(virDomainObj *v= m, blockNamedNodeD= ata, asyncJob))) return -1; - if (qemuSnapshotDiskCreate(snapctxt, cfg) < 0) + if (qemuSnapshotDiskCreate(snapctxt) < 0) return -1; return 0; @@ -1368,8 +1366,6 @@ qemuSnapshotCreateDisksTransient(virDomainObj *vm, qemuDomainAsyncJob asyncJob) { qemuDomainObjPrivate *priv =3D vm->privateData; - virQEMUDriver *driver =3D priv->driver; - g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); g_autoptr(qemuSnapshotDiskContext) snapctxt =3D NULL; g_autoptr(GHashTable) blockNamedNodeData =3D NULL; @@ -1382,7 +1378,7 @@ qemuSnapshotCreateDisksTransient(virDomainObj *vm, asyncJob))) return -1; - if (qemuSnapshotDiskCreate(snapctxt, cfg) < 0) + if (qemuSnapshotDiskCreate(snapctxt) < 0) return -1; } @@ -1518,7 +1514,7 @@ qemuSnapshotCreateActiveExternal(virQEMUDriver *drive= r, /* the domain is now paused if a memory snapshot was requested */ if ((ret =3D qemuSnapshotCreateActiveExternalDisks(vm, snap, - blockNamedNodeData, f= lags, cfg, + blockNamedNodeData, f= lags, QEMU_ASYNC_JOB_SNAPSH= OT)) < 0) goto cleanup; --=20 2.31.1 From nobody Fri May 17 06:07:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1621601356; cv=none; d=zohomail.com; s=zohoarc; b=P3vyZHPzLhkqJHPaHbFpWGrdkDL6f+e5LRxqzB6jwEmZjSUd/GGK1nWYiXCKP1QMkIUMpD/YutyTy2lJstakruQ+qBKV6ztvVkQ4/b31776Uv3gA9dEbHoSdFF/J07oYq3mxB9TZUgRSd/fz5dp1p3DsyGMU9bzhInIvQnzAeIM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601356; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yjmqBaVZDTziBjRVK7mw16rdycggNWgRqf0HDR+fWLE=; b=H6eDXeazCasfcWSwJNfH7Fm/Q9nOb7TB4LAlqmyPF16DunXeHobm3Nbg7tJ+bD+JMBiY2Dnfkaoqn2cVcy7unQiSnRCDRhUgqUYZfJz7DejNuZIorcUmN+dyjF4bophOhjTaPH2q7HMsPcYTNWRkq7G1SpuXUgKdwrop5jukH+w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1621601356872946.3032234411093; Fri, 21 May 2021 05:49:16 -0700 (PDT) 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-26-SuuIOcZJMX-K_Uy36cCwHA-1; Fri, 21 May 2021 08:48:12 -0400 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 ACD286972D; Fri, 21 May 2021 12:48:03 +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 6483C1037E86; Fri, 21 May 2021 12:48: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 261451801267; Fri, 21 May 2021 12:48:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LClmKx030976 for ; Fri, 21 May 2021 08:47:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id DE58750F89; Fri, 21 May 2021 12:47:48 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4189E421F for ; Fri, 21 May 2021 12:47:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601355; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=yjmqBaVZDTziBjRVK7mw16rdycggNWgRqf0HDR+fWLE=; b=FUov3IlaeJzPDsqUF1Q44ymcUi15B16keuQJk7SRF1NPE2ncvG4Y2VRp2W/VfRdMafERZ1 EceqO3HVMKS1pGmGAkCZxpBZp3N9cvNaMiUjZ/4hO6IY6Kph922oNPZLGfc+IkhZbBKOYw ZNAeqIJBNmHeXbkl3x3N+1/G1S6cTUU= X-MC-Unique: SuuIOcZJMX-K_Uy36cCwHA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/35] qemu: snapshot: move transient snapshot code to qemu_process Date: Fri, 21 May 2021 14:47:07 +0200 Message-Id: <1a3966cf749821a03a395ac2e12fd9a5ad81c769.1621601160.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The code deals with the startup of the VM and just uses the snapshot code to achieve the desired outcome. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_process.c | 61 +++++++++++++++++++++++++++++- src/qemu/qemu_snapshot.c | 82 +++------------------------------------- src/qemu/qemu_snapshot.h | 26 ++++++++++++- 3 files changed, 89 insertions(+), 80 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 543b50f875..9222f16caa 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6937,6 +6937,65 @@ qemuProcessEnablePerf(virDomainObj *vm) } +static int +qemuProcessSetupDisksTransientSnapshot(virDomainObj *vm, + qemuDomainAsyncJob asyncJob) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + g_autoptr(qemuSnapshotDiskContext) snapctxt =3D NULL; + g_autoptr(GHashTable) blockNamedNodeData =3D NULL; + size_t i; + + if (!(blockNamedNodeData =3D qemuBlockGetNamedNodeData(vm, asyncJob))) + return -1; + + snapctxt =3D qemuSnapshotDiskContextNew(vm->def->ndisks, vm, asyncJob); + + for (i =3D 0; i < vm->def->ndisks; i++) { + virDomainDiskDef *domdisk =3D vm->def->disks[i]; + g_autoptr(virDomainSnapshotDiskDef) snapdisk =3D NULL; + + if (!domdisk->transient) + continue; + + /* validation code makes sure that we do this only for local disks + * with a file source */ + + snapdisk =3D qemuSnapshotGetTransientDiskDef(domdisk); + + if (qemuSnapshotDiskPrepareOne(snapctxt, domdisk, snapdisk, + blockNamedNodeData, + false, + false) < 0) + return -1; + } + + if (qemuSnapshotDiskCreate(snapctxt) < 0) + return -1; + + /* the overlays are established, so they can be deleted on shutdown */ + priv->inhibitDiskTransientDelete =3D false; + + return 0; +} + + +static int +qemuProcessSetupDisksTransient(virDomainObj *vm, + qemuDomainAsyncJob asyncJob) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + + if (!(virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV))) + return 0; + + if (qemuProcessSetupDisksTransientSnapshot(vm, asyncJob) < 0) + return -1; + + return 0; +} + + /** * qemuProcessLaunch: * @@ -7291,7 +7350,7 @@ qemuProcessLaunch(virConnectPtr conn, if (!incoming && !snapshot) { VIR_DEBUG("Setting up transient disk"); - if (qemuSnapshotCreateDisksTransient(vm, asyncJob) < 0) + if (qemuProcessSetupDisksTransient(vm, asyncJob) < 0) goto cleanup; } diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 8855a019cb..928b7af287 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -906,7 +906,7 @@ struct _qemuSnapshotDiskContext { typedef struct _qemuSnapshotDiskContext qemuSnapshotDiskContext; -static qemuSnapshotDiskContext * +qemuSnapshotDiskContext * qemuSnapshotDiskContextNew(size_t ndisks, virDomainObj *vm, qemuDomainAsyncJob asyncJob) @@ -925,7 +925,7 @@ qemuSnapshotDiskContextNew(size_t ndisks, } -static void +void qemuSnapshotDiskContextCleanup(qemuSnapshotDiskContext *snapctxt) { if (!snapctxt) @@ -940,8 +940,6 @@ qemuSnapshotDiskContextCleanup(qemuSnapshotDiskContext = *snapctxt) g_free(snapctxt); } -G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuSnapshotDiskContext, qemuSnapshotDiskCon= textCleanup); - /** * qemuSnapshotDiskBitmapsPropagate: @@ -1032,7 +1030,7 @@ qemuSnapshotDiskPrepareOneBlockdev(virQEMUDriver *dri= ver, } -static int +int qemuSnapshotDiskPrepareOne(qemuSnapshotDiskContext *snapctxt, virDomainDiskDef *disk, virDomainSnapshotDiskDef *snapdisk, @@ -1170,7 +1168,7 @@ qemuSnapshotDiskPrepareActiveExternal(virDomainObj *v= m, } -static virDomainSnapshotDiskDef * +virDomainSnapshotDiskDef * qemuSnapshotGetTransientDiskDef(virDomainDiskDef *domdisk) { g_autoptr(virDomainSnapshotDiskDef) snapdisk =3D g_new0(virDomainSnaps= hotDiskDef, 1); @@ -1193,39 +1191,6 @@ qemuSnapshotGetTransientDiskDef(virDomainDiskDef *do= mdisk) } -static qemuSnapshotDiskContext * -qemuSnapshotDiskPrepareDisksTransient(virDomainObj *vm, - GHashTable *blockNamedNodeData, - qemuDomainAsyncJob asyncJob) -{ - g_autoptr(qemuSnapshotDiskContext) snapctxt =3D NULL; - size_t i; - - snapctxt =3D qemuSnapshotDiskContextNew(vm->def->ndisks, vm, asyncJob); - - for (i =3D 0; i < vm->def->ndisks; i++) { - virDomainDiskDef *domdisk =3D vm->def->disks[i]; - g_autoptr(virDomainSnapshotDiskDef) snapdisk =3D NULL; - - if (!domdisk->transient) - continue; - - /* validation code makes sure that we do this only for local disks - * with a file source */ - - snapdisk =3D qemuSnapshotGetTransientDiskDef(domdisk); - - if (qemuSnapshotDiskPrepareOne(snapctxt, domdisk, snapdisk, - blockNamedNodeData, - false, - false) < 0) - return NULL; - } - - return g_steal_pointer(&snapctxt); -} - - static void qemuSnapshotDiskUpdateSourceRenumber(virStorageSource *src) { @@ -1284,7 +1249,7 @@ qemuSnapshotDiskUpdateSource(virDomainObj *vm, } -static int +int qemuSnapshotDiskCreate(qemuSnapshotDiskContext *snapctxt) { qemuDomainObjPrivate *priv =3D snapctxt->vm->privateData; @@ -1352,43 +1317,6 @@ qemuSnapshotCreateActiveExternalDisks(virDomainObj *= vm, } -/** - * qemuSnapshotCreateDisksTransient: - * @vm: domain object - * @asyncJob: qemu async job type - * - * Creates overlays on top of disks which are configured as . = Note - * that the validation code ensures that disks have appropriate - * configuration. - */ -int -qemuSnapshotCreateDisksTransient(virDomainObj *vm, - qemuDomainAsyncJob asyncJob) -{ - qemuDomainObjPrivate *priv =3D vm->privateData; - g_autoptr(qemuSnapshotDiskContext) snapctxt =3D NULL; - g_autoptr(GHashTable) blockNamedNodeData =3D NULL; - - if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) { - if (!(blockNamedNodeData =3D qemuBlockGetNamedNodeData(vm, asyncJo= b))) - return -1; - - if (!(snapctxt =3D qemuSnapshotDiskPrepareDisksTransient(vm, - blockNamedN= odeData, - asyncJob))) - return -1; - - if (qemuSnapshotDiskCreate(snapctxt) < 0) - return -1; - } - - /* the overlays are established, so they can be deleted on shutdown */ - priv->inhibitDiskTransientDelete =3D false; - - return 0; -} - - static int qemuSnapshotCreateActiveExternal(virQEMUDriver *driver, virDomainObj *vm, diff --git a/src/qemu/qemu_snapshot.h b/src/qemu/qemu_snapshot.h index 62ff22221d..4fba7e4e24 100644 --- a/src/qemu/qemu_snapshot.h +++ b/src/qemu/qemu_snapshot.h @@ -55,6 +55,28 @@ qemuSnapshotDelete(virDomainObj *vm, virDomainSnapshotPtr snapshot, unsigned int flags); + +typedef struct _qemuSnapshotDiskContext qemuSnapshotDiskContext; + +qemuSnapshotDiskContext * +qemuSnapshotDiskContextNew(size_t ndisks, + virDomainObj *vm, + qemuDomainAsyncJob asyncJob); + +void +qemuSnapshotDiskContextCleanup(qemuSnapshotDiskContext *snapctxt); + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuSnapshotDiskContext, qemuSnapshotDiskCon= textCleanup); + +int +qemuSnapshotDiskPrepareOne(qemuSnapshotDiskContext *snapctxt, + virDomainDiskDef *disk, + virDomainSnapshotDiskDef *snapdisk, + GHashTable *blockNamedNodeData, + bool reuse, + bool updateConfig); int -qemuSnapshotCreateDisksTransient(virDomainObj *vm, - qemuDomainAsyncJob asyncJob); +qemuSnapshotDiskCreate(qemuSnapshotDiskContext *snapctxt); + +virDomainSnapshotDiskDef * +qemuSnapshotGetTransientDiskDef(virDomainDiskDef *domdisk); --=20 2.31.1 From nobody Fri May 17 06:07:55 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1621601287; cv=none; d=zohomail.com; s=zohoarc; b=h4zD+mzlH7rCRmI3Qm8cvcVJSd7E3RcmJPMbdp3ynfc0eRQ9ZQ6ENQf9Hv9dDGNfse+zNOUXiww4PeSKd5DSVywVLu0zKuc8uPuRTaZ6if58lZVQBYi4ML2MHUxKiSAfSMX6m8rUHi8+qMbjnM98q845D7UvO/CuppX0dtfIyrU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601287; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VND12Ane5M20ZXhy1YxuIDSTVWfvVaQ1KWMAadt+Cgo=; b=QU9MyAVDERfp99nU+GzEMuF7GMXsbtwaIfcNEswg55pnCZ1tDnizNUIy73S9wpnWrfEj845KU0xL65WlGt5Y9+yMV6caogWTlQKO+T/BoQom/Pxt+1G/y8I7+UWcnRQ4C8uNN+XTAzBQCrcHNCd9hO0Nn1LNi58GvBiI4BCwMd4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass 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 1621601287757971.2385576961958; Fri, 21 May 2021 05:48:07 -0700 (PDT) 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-181-L97gDv3dO4GHJL7v0-_yHA-1; Fri, 21 May 2021 08:48:03 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 055AC107ACCD; Fri, 21 May 2021 12:47:58 +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 D51C72B198; Fri, 21 May 2021 12:47: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 A10DD180B464; Fri, 21 May 2021 12:47:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LClnlF030990 for ; Fri, 21 May 2021 08:47:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id E87D85945B; Fri, 21 May 2021 12:47:49 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50D04421F for ; Fri, 21 May 2021 12:47:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601286; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=VND12Ane5M20ZXhy1YxuIDSTVWfvVaQ1KWMAadt+Cgo=; b=gcUQ8+P88qOONlBInczzZm8RDjPF1PbDfvmzLtu6bqnKUx123w/W/IESwTcUtSSFkiShHR j2XoUZFUZAvztGh+XzmG7aVXqmxMzIJ9NDjmEIEABbeV5wc2+ZqQei//u0cVSug6EfbTnV 8D8lfkZZL0ZqUrvr68oRPgAOdW4DoxE= X-MC-Unique: L97gDv3dO4GHJL7v0-_yHA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/35] qemu_snapshot: Add the guest name to the transient disk path Date: Fri, 21 May 2021 14:47:08 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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.79 on 10.5.11.12 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Masayoshi Mizuma Later patches will implement sharing of the backing file, so we'll need to be able to discriminate the overlays per VM. Signed-off-by: Masayoshi Mizuma Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_process.c | 2 +- src/qemu/qemu_snapshot.c | 6 ++++-- src/qemu/qemu_snapshot.h | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 9222f16caa..d743a581b3 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6961,7 +6961,7 @@ qemuProcessSetupDisksTransientSnapshot(virDomainObj *= vm, /* validation code makes sure that we do this only for local disks * with a file source */ - snapdisk =3D qemuSnapshotGetTransientDiskDef(domdisk); + snapdisk =3D qemuSnapshotGetTransientDiskDef(domdisk, vm->def->nam= e); if (qemuSnapshotDiskPrepareOne(snapctxt, domdisk, snapdisk, blockNamedNodeData, diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 928b7af287..29e86342d6 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1169,7 +1169,8 @@ qemuSnapshotDiskPrepareActiveExternal(virDomainObj *v= m, virDomainSnapshotDiskDef * -qemuSnapshotGetTransientDiskDef(virDomainDiskDef *domdisk) +qemuSnapshotGetTransientDiskDef(virDomainDiskDef *domdisk, + const char *suffix) { g_autoptr(virDomainSnapshotDiskDef) snapdisk =3D g_new0(virDomainSnaps= hotDiskDef, 1); @@ -1178,7 +1179,8 @@ qemuSnapshotGetTransientDiskDef(virDomainDiskDef *dom= disk) 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->src->= path); + snapdisk->src->path =3D g_strdup_printf("%s.TRANSIENT-%s", + domdisk->src->path, suffix); if (virFileExists(snapdisk->src->path)) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, diff --git a/src/qemu/qemu_snapshot.h b/src/qemu/qemu_snapshot.h index 4fba7e4e24..ad2bdb1114 100644 --- a/src/qemu/qemu_snapshot.h +++ b/src/qemu/qemu_snapshot.h @@ -79,4 +79,5 @@ int qemuSnapshotDiskCreate(qemuSnapshotDiskContext *snapctxt); virDomainSnapshotDiskDef * -qemuSnapshotGetTransientDiskDef(virDomainDiskDef *domdisk); +qemuSnapshotGetTransientDiskDef(virDomainDiskDef *domdisk, + const char *suffix); --=20 2.31.1 From nobody Fri May 17 06:07:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1621601291; cv=none; d=zohomail.com; s=zohoarc; b=azrkKh6uQ5USkMvbPalIjUj7Pa4WlQY9Mqy4lqfhuVAGOs6uXn8Lm4z3NoK9hNWElyZg/SWIRsGSyl36D9PQwEJchakefTjdFUGNguPDa4LSe8Rj2P/zEt/HYCNb4cfNVmNVeo9hsFqk/MH2NaEW0kLMjT7mFCL+fXnKM5zHx1s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601291; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MhES0pbfZhWuTi1jayo1UwkrALZ6Bu8Z67v7VMHm8RM=; b=MmKGdj7GroSwCLLQs/BX64diGt87F5ieQEICSSfGLnW5DbWWHebJzsgmKsvdlviJLVD6pB2poX+foopIKzwucfYqT6G48gs9yhhPhfTJwyIUyLUSxGV8IO9ddiSi+eMGRvJN4hE7XisH5X4ZPpfD7VRFJG4JMFLSsneuK/4ujtw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1621601291821772.8821786031486; Fri, 21 May 2021 05:48:11 -0700 (PDT) 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-536-PRefy8qUNrOp5tvuEsoNLg-1; Fri, 21 May 2021 08:48:07 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3A1D66409F; Fri, 21 May 2021 12:48:02 +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 1BE811964B; Fri, 21 May 2021 12:48:02 +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 D66C91801028; Fri, 21 May 2021 12:48:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LClpof031002 for ; Fri, 21 May 2021 08:47:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 023F169FB1; Fri, 21 May 2021 12:47:51 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 647FE78620 for ; Fri, 21 May 2021 12:47:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601290; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=MhES0pbfZhWuTi1jayo1UwkrALZ6Bu8Z67v7VMHm8RM=; b=L1lFMlHqEkB15dvBvzZRBFZFpBSCNswXFnLy83TaG1YuJF2bvc5Z3tpsvTZ54gu3DECrQt fkJFI7weWBGgNvICjKStRuOm/JQR37hi8mNEFlHzk3h9YOBTsnVWBBi3fa+wt/dSIzF/eq bwfZoS5h1PaTdOB1xVOFRW1hqvM/gGM= X-MC-Unique: PRefy8qUNrOp5tvuEsoNLg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/35] qemu: Move 'bootindex' handling for disks out of command line formatter Date: Fri, 21 May 2021 14:47:09 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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.79 on 10.5.11.11 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The logic assigning the bootindices from the legacy boot orded configuration was spread through the command line formatters for the disk device and for the floppy controller. This patch adds 'effectiveBootindex' property to the disk private data which holds the calculated boot index and moves the logic of determining the boot index into 'qemuProcessPrepareDomainDiskBootorder' called from 'qemuProcessPrepareDomainStorage'. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 63 +++++++-------------------------------- src/qemu/qemu_domain.h | 4 +++ src/qemu/qemu_process.c | 66 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 53 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index dcc060bde9..b01421f61b 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1976,13 +1976,11 @@ qemuCommandAddExtDevice(virCommand *cmd, static int qemuBuildFloppyCommandLineControllerOptions(virCommand *cmd, const virDomainDef *def, - virQEMUCaps *qemuCaps, - unsigned int bootFloppy) + virQEMUCaps *qemuCaps) { g_auto(virBuffer) fdc_opts =3D VIR_BUFFER_INITIALIZER; bool explicitfdc =3D qemuDomainNeedsFDC(def); bool hasfloppy =3D false; - unsigned int bootindex; char driveLetter; size_t i; @@ -1993,26 +1991,21 @@ qemuBuildFloppyCommandLineControllerOptions(virComm= and *cmd, g_autofree char *backendStr =3D NULL; g_autofree char *bootindexStr =3D NULL; virDomainDiskDef *disk =3D def->disks[i]; + qemuDomainDiskPrivate *diskPriv =3D QEMU_DOMAIN_DISK_PRIVATE(disk); if (disk->bus !=3D VIR_DOMAIN_DISK_BUS_FDC) continue; hasfloppy =3D true; - if (disk->info.bootIndex) { - bootindex =3D disk->info.bootIndex; - } else { - bootindex =3D bootFloppy; - bootFloppy =3D 0; - } - if (disk->info.addr.drive.unit) driveLetter =3D 'B'; else driveLetter =3D 'A'; - if (bootindex) - bootindexStr =3D g_strdup_printf("bootindex%c=3D%u", driveLett= er, bootindex); + if (diskPriv->effectiveBootindex > 0) + bootindexStr =3D g_strdup_printf("bootindex%c=3D%u", driveLett= er, + diskPriv->effectiveBootindex); /* with -blockdev we setup the floppy device and it's backend with= -device */ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) { @@ -2210,66 +2203,30 @@ qemuBuildDisksCommandLine(virCommand *cmd, virQEMUCaps *qemuCaps) { size_t i; - unsigned int bootCD =3D 0; - unsigned int bootFloppy =3D 0; - unsigned int bootDisk =3D 0; bool blockdev =3D virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV); - for (i =3D 0; i < def->os.nBootDevs; i++) { - switch (def->os.bootDevs[i]) { - case VIR_DOMAIN_BOOT_CDROM: - bootCD =3D i + 1; - break; - case VIR_DOMAIN_BOOT_FLOPPY: - bootFloppy =3D i + 1; - break; - case VIR_DOMAIN_BOOT_DISK: - bootDisk =3D i + 1; - break; - } - } - /* If we want to express the floppy drives via -device, the controller= needs * to be instantiated prior to that */ if (blockdev && - qemuBuildFloppyCommandLineControllerOptions(cmd, def, qemuCaps, bo= otFloppy) < 0) + qemuBuildFloppyCommandLineControllerOptions(cmd, def, qemuCaps) < = 0) return -1; for (i =3D 0; i < def->ndisks; i++) { virDomainDiskDef *disk =3D def->disks[i]; + qemuDomainDiskPrivate *diskPriv =3D QEMU_DOMAIN_DISK_PRIVATE(disk); unsigned int bootindex =3D 0; - if (disk->info.bootIndex) { - bootindex =3D disk->info.bootIndex; - } else { - switch (disk->device) { - case VIR_DOMAIN_DISK_DEVICE_CDROM: - bootindex =3D bootCD; - bootCD =3D 0; - break; - case VIR_DOMAIN_DISK_DEVICE_DISK: - case VIR_DOMAIN_DISK_DEVICE_LUN: - bootindex =3D bootDisk; - bootDisk =3D 0; - break; - case VIR_DOMAIN_DISK_DEVICE_FLOPPY: - case VIR_DOMAIN_DISK_DEVICE_LAST: - default: - break; - } - } - /* The floppy device itself does not support the bootindex property * so we need to set it up for the controller */ - if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY) - bootindex =3D 0; + if (disk->device !=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY) + bootindex =3D diskPriv->effectiveBootindex; if (qemuBuildDiskCommandLine(cmd, def, disk, qemuCaps, bootindex) = < 0) return -1; } if (!blockdev && - qemuBuildFloppyCommandLineControllerOptions(cmd, def, qemuCaps, bo= otFloppy) < 0) + qemuBuildFloppyCommandLineControllerOptions(cmd, def, qemuCaps) < = 0) return -1; return 0; diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 2626f5dcaa..4fc1969d9e 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -288,6 +288,10 @@ struct _qemuDomainDiskPrivate { char *qomName; /* QOM path of the disk (also refers to the block backe= nd) */ char *nodeCopyOnRead; /* nodename of the disk-wide copy-on-read blockd= ev layer */ + + unsigned int effectiveBootindex; /* boot index of the disk based on one + of the two ways we use to select a= boot + device */ }; #define QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src) \ diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index d743a581b3..7fe051505b 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6290,6 +6290,70 @@ qemuProcessPrepareDomainNUMAPlacement(virDomainObj *= vm) } +static void +qemuProcessPrepareDomainDiskBootorder(virDomainDef *def) +{ + size_t i; + unsigned int bootCD =3D 0; + unsigned int bootFloppy =3D 0; + unsigned int bootDisk =3D 0; + + for (i =3D 0; i < def->os.nBootDevs; i++) { + switch ((virDomainBootOrder) def->os.bootDevs[i]) { + case VIR_DOMAIN_BOOT_CDROM: + bootCD =3D i + 1; + break; + + case VIR_DOMAIN_BOOT_FLOPPY: + bootFloppy =3D i + 1; + break; + + case VIR_DOMAIN_BOOT_DISK: + bootDisk =3D i + 1; + break; + + case VIR_DOMAIN_BOOT_NET: + /* network boot is handled in network device formatting code */ + case VIR_DOMAIN_BOOT_LAST: + default: + break; + } + } + + for (i =3D 0; i < def->ndisks; i++) { + virDomainDiskDef *disk =3D def->disks[i]; + qemuDomainDiskPrivate *diskPriv =3D QEMU_DOMAIN_DISK_PRIVATE(disk); + + if (disk->info.bootIndex > 0) { + diskPriv->effectiveBootindex =3D disk->info.bootIndex; + continue; + } + + switch (disk->device) { + case VIR_DOMAIN_DISK_DEVICE_CDROM: + diskPriv->effectiveBootindex =3D bootCD; + bootCD =3D 0; + break; + + case VIR_DOMAIN_DISK_DEVICE_DISK: + case VIR_DOMAIN_DISK_DEVICE_LUN: + diskPriv->effectiveBootindex =3D bootDisk; + bootDisk =3D 0; + break; + + case VIR_DOMAIN_DISK_DEVICE_FLOPPY: + diskPriv->effectiveBootindex =3D bootFloppy; + bootFloppy =3D 0; + break; + + case VIR_DOMAIN_DISK_DEVICE_LAST: + default: + break; + } + } +} + + static int qemuProcessPrepareDomainStorage(virQEMUDriver *driver, virDomainObj *vm, @@ -6316,6 +6380,8 @@ qemuProcessPrepareDomainStorage(virQEMUDriver *driver, return -1; } + qemuProcessPrepareDomainDiskBootorder(vm->def); + return 0; } --=20 2.31.1 From nobody Fri May 17 06:07:55 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1621601344; cv=none; d=zohomail.com; s=zohoarc; b=HpaDxtMMJdkolJULbIWwNZta1aqkD0Emk1ok2VjtzHP1uHC07Y6+05KrlaReNJbOoL9Oik9tfAklsCskgY0ASOwA9pYigLsY6XfVmq00dWf2UYHUuT8t7o8cdr03XqPfH4Fq7/5/GlqrIh/b73FWV8gSUxPXYgw6qLWYUAGmNKs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601344; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bmd+esMwtrTnBGj4rHC+tvJ5rrB6nJaHAJh50yhbJgo=; b=SSApP/VqIEHyIAFR0wspvprY19w30w7+xelxAvJ6+vuHDmTy2KyE2crWjSbMaB4t33BwI28D0uSWx3FNcKGPKHX0UKVfZe66y9IuqWTUR1qaVicEj1d/sJon7Eqkppg8JIWOEIguebPPjdUQ2vIUy2ihTfQ35a70vgLrm86EHjA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass 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 1621601344812241.38637338224885; Fri, 21 May 2021 05:49:04 -0700 (PDT) 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-508-5lSrBEkLNFqX4nnfSstNXg-1; Fri, 21 May 2021 08:48:08 -0400 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 1EB8C108BD0C; Fri, 21 May 2021 12:48:03 +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 BB08D1037F2D; Fri, 21 May 2021 12:48:02 +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 855AF1801265; Fri, 21 May 2021 12:48:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LCm1kT031048 for ; Fri, 21 May 2021 08:48:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7D335421F; Fri, 21 May 2021 12:48:01 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id D8DC11964B for ; Fri, 21 May 2021 12:47:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601343; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=bmd+esMwtrTnBGj4rHC+tvJ5rrB6nJaHAJh50yhbJgo=; b=NpyljNBFqjXBDXRfMMFnSAZXibDAccyrRbr0J4+R1mZNkUorox//nwaDTH2zNIyE8oNAt3 J0ylRNEVNmodAZ0KGXOv1ZOHyQDcvtkEENoH0yVrTYVDyhftO1Bwhcq303OZGO36GzVwKu zBC5h444ZzkHzzHS1ow2Bc2Wfs7sxaE= X-MC-Unique: 5lSrBEkLNFqX4nnfSstNXg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/35] qemu: Move bootindex usage logic into qemuBuildDiskDeviceStr Date: Fri, 21 May 2021 14:47:10 +0200 Message-Id: <11d2d9d36258971b74250eff3544c0e510568f60.1621601160.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" We can skip the formatting of the bootindex for floppies directly at the place where it's being formatted. Signed-off-by: Peter Krempa --- src/qemu/qemu_command.c | 23 ++++++++--------------- src/qemu/qemu_command.h | 1 - src/qemu/qemu_hotplug.c | 2 +- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index b01421f61b..200f9a04b1 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1659,9 +1659,9 @@ qemuBuildDriveDevCacheStr(virDomainDiskDef *disk, char * qemuBuildDiskDeviceStr(const virDomainDef *def, virDomainDiskDef *disk, - unsigned int bootindex, virQEMUCaps *qemuCaps) { + qemuDomainDiskPrivate *diskPriv =3D QEMU_DOMAIN_DISK_PRIVATE(disk); g_auto(virBuffer) opt =3D VIR_BUFFER_INITIALIZER; const char *contAlias; g_autofree char *backendAlias =3D NULL; @@ -1876,8 +1876,10 @@ qemuBuildDiskDeviceStr(const virDomainDef *def, } virBufferAsprintf(&opt, ",id=3D%s", disk->info.alias); - if (bootindex) - virBufferAsprintf(&opt, ",bootindex=3D%u", bootindex); + /* bootindex for floppies is configured via the fdc controller */ + if (disk->device !=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY && + diskPriv->effectiveBootindex > 0) + virBufferAsprintf(&opt, ",bootindex=3D%u", diskPriv->effectiveBoot= index); if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKIO)) { if (disk->blockio.logical_block_size > 0) virBufferAsprintf(&opt, ",logical_block_size=3D%u", @@ -2164,8 +2166,7 @@ static int qemuBuildDiskCommandLine(virCommand *cmd, const virDomainDef *def, virDomainDiskDef *disk, - virQEMUCaps *qemuCaps, - unsigned int bootindex) + virQEMUCaps *qemuCaps) { g_autofree char *optstr =3D NULL; @@ -2188,8 +2189,7 @@ qemuBuildDiskCommandLine(virCommand *cmd, virCommandAddArg(cmd, "-device"); - if (!(optstr =3D qemuBuildDiskDeviceStr(def, disk, bootindex, - qemuCaps))) + if (!(optstr =3D qemuBuildDiskDeviceStr(def, disk, qemuCaps))) return -1; virCommandAddArg(cmd, optstr); @@ -2213,15 +2213,8 @@ qemuBuildDisksCommandLine(virCommand *cmd, for (i =3D 0; i < def->ndisks; i++) { virDomainDiskDef *disk =3D def->disks[i]; - qemuDomainDiskPrivate *diskPriv =3D QEMU_DOMAIN_DISK_PRIVATE(disk); - unsigned int bootindex =3D 0; - - /* The floppy device itself does not support the bootindex property - * so we need to set it up for the controller */ - if (disk->device !=3D VIR_DOMAIN_DISK_DEVICE_FLOPPY) - bootindex =3D diskPriv->effectiveBootindex; - if (qemuBuildDiskCommandLine(cmd, def, disk, qemuCaps, bootindex) = < 0) + if (qemuBuildDiskCommandLine(cmd, def, disk, qemuCaps) < 0) return -1; } diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 4f1d2bf755..188e63ea1f 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -146,7 +146,6 @@ qemuBuildStorageSourceChainAttachPrepareBlockdevTop(vir= StorageSource *top, char *qemuBuildDiskDeviceStr(const virDomainDef *def, virDomainDiskDef *disk, - unsigned int bootindex, virQEMUCaps *qemuCaps); /* Current, best practice */ diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index a64cddb9e7..7a1b413be0 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -734,7 +734,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, goto cleanup; } - if (!(devstr =3D qemuBuildDiskDeviceStr(vm->def, disk, 0, priv->qemuCa= ps))) + if (!(devstr =3D qemuBuildDiskDeviceStr(vm->def, disk, priv->qemuCaps)= )) goto cleanup; VIR_REALLOC_N(vm->def->disks, vm->def->ndisks + 1); --=20 2.31.1 From nobody Fri May 17 06:07:55 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1621601357; cv=none; d=zohomail.com; s=zohoarc; b=iP+BGbCRpttsaFh5RuCgxXEnSwqKYhbCNoBxsaVpsR3iD11iNTOurNz6oM1AiEg2+lqV5IS5OmrTf9A/8EZSeil1Zm29itcVYkbOwuC+C3sLkK7auX8IOQ21oA/E6e6TUdIafOvTqenpWy4dyQw85TXjdZKJR/jtqqRxHKvWW7A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601357; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ngkzzGKO810yDcJYi8MVgVSUVMNy21JItQ2HKdIZVxg=; b=P9vr0nmuefTXibakk1s+IQswKTF9sM8nsZ25/w7ibVJ2xrCwbQx+tLTGm4ceEsvtDn2FUhKqYuP7IrMOGjjbpc1CYSywBDLqVO75wBK6NyZfkb6SU6uy+bYDr55ixx803gm8STuClU006eDlEJVkTn38qEzyl7+IX9QxVCG8PEA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass 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 1621601357658557.461665877842; Fri, 21 May 2021 05:49:17 -0700 (PDT) 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-119-qHnmDsE0NvO8SLevdMeP5A-1; Fri, 21 May 2021 08:48:14 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2B4E36D4F6; Fri, 21 May 2021 12:48: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 0539F69FB4; Fri, 21 May 2021 12:48: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 BACDC1801268; Fri, 21 May 2021 12:48:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LCm2wX031062 for ; Fri, 21 May 2021 08:48:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 987EE69FCE; Fri, 21 May 2021 12:48:02 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id E6622421F for ; Fri, 21 May 2021 12:48:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601356; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ngkzzGKO810yDcJYi8MVgVSUVMNy21JItQ2HKdIZVxg=; b=hxAm0adZ2FGzn7FY91i59EmnlJrkwFY/VkXwbVllhf+1bsDwurXO6No6fMcreb5Cud9pec LKtyvSjCjkiMlbn6YOWGgqJ/ONEinsBOtbQVWBcTZX1lWzua3ggBgBfLKezOHB6yc7BbAB Lgp76rdWPh49iXoh8V/pmlHFjZeY3ho= X-MC-Unique: qHnmDsE0NvO8SLevdMeP5A-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/35] qemuxml2argvtest: Remove pointless tests for keywrapping on s390 Date: Fri, 21 May 2021 14:47:11 +0200 Message-Id: <28c435912eee3f87ec0bc4c4b138500c3db09071.1621601160.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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.79 on 10.5.11.11 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" There were two negative tests for the keywrapping feature on s390 when the feature flag was missing. For now both shared the error message thus worked fine, but with the upcoming patch to move some disk validation code from the command line formatter to validation code will change the error message in case the disk capabilities are missing. Drop the test cases which don't provide any capability and keep those that have the disk capabilities present as they are sufficient to prove the feature. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemuxml2argvtest.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 25b0c81f21..ecf63f20fd 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -3161,7 +3161,6 @@ mymain(void) DO_TEST_FAILURE("machine-aeskeywrap-on-caps", QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390); - DO_TEST_FAILURE("machine-aeskeywrap-on-caps", NONE); DO_TEST("machine-aeskeywrap-on-cap", QEMU_CAPS_AES_KEY_WRAP, @@ -3170,7 +3169,6 @@ mymain(void) DO_TEST_FAILURE("machine-aeskeywrap-on-cap", QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390); - DO_TEST_FAILURE("machine-aeskeywrap-on-cap", NONE); DO_TEST("machine-aeskeywrap-off-caps", QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP, @@ -3179,7 +3177,6 @@ mymain(void) DO_TEST_FAILURE("machine-aeskeywrap-off-caps", QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390); - DO_TEST_FAILURE("machine-aeskeywrap-off-caps", NONE); DO_TEST("machine-aeskeywrap-off-cap", QEMU_CAPS_AES_KEY_WRAP, @@ -3188,7 +3185,6 @@ mymain(void) DO_TEST_FAILURE("machine-aeskeywrap-off-cap", QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390); - DO_TEST_FAILURE("machine-aeskeywrap-off-cap", NONE); DO_TEST("machine-deakeywrap-on-caps", QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP, @@ -3197,7 +3193,6 @@ mymain(void) DO_TEST_FAILURE("machine-deakeywrap-on-caps", QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390); - DO_TEST_FAILURE("machine-deakeywrap-on-caps", NONE); DO_TEST("machine-deakeywrap-on-cap", QEMU_CAPS_DEA_KEY_WRAP, @@ -3206,7 +3201,6 @@ mymain(void) DO_TEST_FAILURE("machine-deakeywrap-on-cap", QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390); - DO_TEST_FAILURE("machine-deakeywrap-on-cap", NONE); DO_TEST("machine-deakeywrap-off-caps", QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP, @@ -3215,7 +3209,6 @@ mymain(void) DO_TEST_FAILURE("machine-deakeywrap-off-caps", QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390); - DO_TEST_FAILURE("machine-deakeywrap-off-caps", NONE); DO_TEST("machine-deakeywrap-off-cap", QEMU_CAPS_DEA_KEY_WRAP, @@ -3224,7 +3217,6 @@ mymain(void) DO_TEST_FAILURE("machine-deakeywrap-off-cap", QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390); - DO_TEST_FAILURE("machine-deakeywrap-off-cap", NONE); DO_TEST("machine-keywrap-none-caps", QEMU_CAPS_AES_KEY_WRAP, QEMU_CAPS_DEA_KEY_WRAP, --=20 2.31.1 From nobody Fri May 17 06:07:55 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1621601297; cv=none; d=zohomail.com; s=zohoarc; b=iD73lHFts7m5M1hHArFfs0g9j1pw0PGAD5+w/NTY2fsJc4u5VzXD1AXaYsqScO9UbNhjVXjXuecWUULzlpYAQ7CK5x83B0hwacr2J/OZVHhfYhxulyrLCWgw95HrTU7SzO4MYsR0VE/dnjlbxpbGJ5+Dv3WlJqpuD1HO8BdS32M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601297; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=N83mJlUok1fHH3Yt3XU0cMFhZGCmDjNNXE5Vt94D0iI=; b=lf/K5bC6zXfkKxJeFoziVGZ29KNPs2NJGjB37RcgV7qT4MP6Xj9/u4DI2qakhO/gcld2tsLslwDijgF5Qxzo2iHb136H0EaAbdhFf9J1ZxHgJiaEZI0jbcaHmnu/dm6N8qu2f/NPGNB0bnvSmU3u4nJp2hF58OM7uobq72nPpXE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass 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 1621601297444328.590979764332; Fri, 21 May 2021 05:48:17 -0700 (PDT) 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-515-UccTmQVwNMyTBcnZ8ZNkPQ-1; Fri, 21 May 2021 08:48:13 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BC7F7805741; Fri, 21 May 2021 12:48:06 +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 99F045C3DF; Fri, 21 May 2021 12:48:06 +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 5E38444A64; Fri, 21 May 2021 12:48:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LCm3X7031081 for ; Fri, 21 May 2021 08:48:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id ACA1669FB4; Fri, 21 May 2021 12:48:03 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 02CA0421F for ; Fri, 21 May 2021 12:48:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601296; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=N83mJlUok1fHH3Yt3XU0cMFhZGCmDjNNXE5Vt94D0iI=; b=ZVDBy/3ALOx+uiIn9JiPsf/k1h/vdIQYo/bZ5HlivQABmGj6y8pcBoZKznLZOGZgsLSlSs tgie17KLJl2FWw2NP1c9SXXoyphBtHr4ZjGS0PEgTn0bwpKXOTisLz1brreUSmnUm2iy+q I6LgSx0HNdspGhYY4vrrwjfNkijVUfg= X-MC-Unique: UccTmQVwNMyTBcnZ8ZNkPQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/35] qemu: Move iothread and s390 address validation for disk devices into the validator Date: Fri, 21 May 2021 14:47:12 +0200 Message-Id: <4b2a209ac3c6698eacc7039b38a01f1a099be2d9.1621601160.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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.79 on 10.5.11.16 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The "machine-loadparm-multiple-disks-nets-s390" case now requires the QEMU_CAPS_CCW feature to pass validation. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 50 ---------------------------------------- src/qemu/qemu_validate.c | 49 +++++++++++++++++++++++++++++++++++++++ tests/qemuxml2xmltest.c | 2 +- 3 files changed, 50 insertions(+), 51 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 200f9a04b1..9c32fd16b5 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1583,50 +1583,6 @@ qemuBuildDriveStr(virDomainDiskDef *disk, } -static bool -qemuCheckIOThreads(const virDomainDef *def, - virDomainDiskDef *disk) -{ - /* Right "type" of disk" */ - switch ((virDomainDiskBus)disk->bus) { - case VIR_DOMAIN_DISK_BUS_VIRTIO: - if (disk->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI && - disk->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("IOThreads only available for virtio pci and= " - "virtio ccw disk")); - return false; - } - break; - - case VIR_DOMAIN_DISK_BUS_IDE: - case VIR_DOMAIN_DISK_BUS_FDC: - case VIR_DOMAIN_DISK_BUS_SCSI: - case VIR_DOMAIN_DISK_BUS_XEN: - case VIR_DOMAIN_DISK_BUS_USB: - case VIR_DOMAIN_DISK_BUS_UML: - case VIR_DOMAIN_DISK_BUS_SATA: - case VIR_DOMAIN_DISK_BUS_SD: - case VIR_DOMAIN_DISK_BUS_NONE: - case VIR_DOMAIN_DISK_BUS_LAST: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("IOThreads not available for bus %s target %s"), - virDomainDiskBusTypeToString(disk->bus), disk->dst); - return false; - } - - /* Can we find the disk iothread in the iothreadid list? */ - if (!virDomainIOThreadIDFind(def, disk->iothread)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Disk iothread '%u' not defined in iothreadid"), - disk->iothread); - return false; - } - - return true; -} - - static int qemuBuildDriveDevCacheStr(virDomainDiskDef *disk, virBuffer *buf, @@ -1668,12 +1624,6 @@ qemuBuildDiskDeviceStr(const virDomainDef *def, g_autofree char *scsiVPDDeviceId =3D NULL; int controllerModel; - if (!qemuDomainCheckCCWS390AddressSupport(def, &disk->info, qemuCaps, = disk->dst)) - return NULL; - - if (disk->iothread && !qemuCheckIOThreads(def, disk)) - return NULL; - switch ((virDomainDiskBus) disk->bus) { case VIR_DOMAIN_DISK_BUS_IDE: if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_CDROM) diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index e6ddb43113..9c74092f23 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2404,6 +2404,50 @@ qemuValidateDomainDeviceDefDiskSerial(const char *va= lue) } +static bool +qemuvalidateDomainDeviceDefDiskIOThreads(const virDomainDef *def, + const virDomainDiskDef *disk) +{ + /* Right "type" of disk" */ + switch ((virDomainDiskBus)disk->bus) { + case VIR_DOMAIN_DISK_BUS_VIRTIO: + if (disk->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI && + disk->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("IOThreads only available for virtio pci and= " + "virtio ccw disk")); + return false; + } + break; + + case VIR_DOMAIN_DISK_BUS_IDE: + case VIR_DOMAIN_DISK_BUS_FDC: + case VIR_DOMAIN_DISK_BUS_SCSI: + case VIR_DOMAIN_DISK_BUS_XEN: + case VIR_DOMAIN_DISK_BUS_USB: + case VIR_DOMAIN_DISK_BUS_UML: + case VIR_DOMAIN_DISK_BUS_SATA: + case VIR_DOMAIN_DISK_BUS_SD: + case VIR_DOMAIN_DISK_BUS_NONE: + case VIR_DOMAIN_DISK_BUS_LAST: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("IOThreads not available for bus %s target %s"), + virDomainDiskBusTypeToString(disk->bus), disk->dst); + return false; + } + + /* Can we find the disk iothread in the iothreadid list? */ + if (!virDomainIOThreadIDFind(def, disk->iothread)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Disk iothread '%u' not defined in iothreadid"), + disk->iothread); + return false; + } + + return true; +} + + static int qemuValidateDomainDeviceDefDiskFrontend(const virDomainDiskDef *disk, const virDomainDef *def, @@ -2789,6 +2833,11 @@ qemuValidateDomainDeviceDefDiskFrontend(const virDom= ainDiskDef *disk, qemuValidateDomainDeviceDefDiskSerial(disk->serial) < 0) return -1; + if (!qemuDomainCheckCCWS390AddressSupport(def, &disk->info, qemuCaps, = disk->dst)) + return -1; + + if (disk->iothread && !qemuvalidateDomainDeviceDefDiskIOThreads(def, d= isk)) + return -1; return 0; } diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 7af6f90aee..b2bf792743 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -220,7 +220,7 @@ mymain(void) DO_TEST_CAPS_LATEST("genid-auto"); DO_TEST("machine-core-on", NONE); DO_TEST("machine-core-off", NONE); - DO_TEST("machine-loadparm-multiple-disks-nets-s390", NONE); + DO_TEST("machine-loadparm-multiple-disks-nets-s390", QEMU_CAPS_CCW); DO_TEST("default-kvm-host-arch", NONE); DO_TEST("default-qemu-host-arch", NONE); DO_TEST("boot-cdrom", NONE); --=20 2.31.1 From nobody Fri May 17 06:07:55 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1621601404; cv=none; d=zohomail.com; s=zohoarc; b=j+FH/LG5eyuInIBAF/CEuZwwCPzR91xYc8EQOfvap07KmscPrZxFpJGAyAJEZd/J/d3qQAsYeoI2TbkG3f9iMLHTMvPAgMxEw0GdQK4tnu2M8cY4OiwjrvxnTD6xc+/w0LXDsT8uFWp/N5bxHiAgMQincF+HoN0oazvrCd9YUfk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601404; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZF+5u1+u26zoo9ZWawl1h7C9/wxRc5xr0OBzHKRPpKs=; b=aYvYUK5JV1U4KCqavvYH7zgoo0LRQvl/gB3S+HNf2gm3zN9OeeClprV3H3E6lmqFkzHStS0/OG7JglUdofqnubgFgak8t/etN8t0MC8lVNuDhkzUHxdmzAHNntfp/XXehAsKaoa6u0x4n5EE5ee36Lv2ppwuNeaUyFAsE+/Vff4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass 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 1621601404265539.390752954722; Fri, 21 May 2021 05:50:04 -0700 (PDT) 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-335-k4ruOwU5NdWKJQtEZfyCOg-1; Fri, 21 May 2021 08:48:14 -0400 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 957BE102C803; Fri, 21 May 2021 12:48:06 +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 C3FCA1007625; Fri, 21 May 2021 12:48: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 728DC44A60; Fri, 21 May 2021 12:48:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LCm42A031092 for ; Fri, 21 May 2021 08:48:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id B9D0B69FB4; Fri, 21 May 2021 12:48:04 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 28662421F for ; Fri, 21 May 2021 12:48:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601403; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ZF+5u1+u26zoo9ZWawl1h7C9/wxRc5xr0OBzHKRPpKs=; b=U4MmfsQ6eHGCMqsNiJ8cb9thPVxxxh9lnhQx7c67cXvZgpVe33cMjtVgbdQ8R31q3AIoXV VF+O6CROgkEw7u8Jk3os/LU0URpxRRgi7eOGflsGm1gXUwbwGWjqJQ52sx8c4iW9TYu0zC wHatLwfoU8QWqNpg+TfSfUfmUrthqQY= X-MC-Unique: k4ruOwU5NdWKJQtEZfyCOg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 13/35] Replace virDomainDiskInsertPreAlloced by virDomainDiskInsert Date: Fri, 21 May 2021 14:47:13 +0200 Message-Id: <6ef6f87783bc742c81e382db29a27d20d414e773.1621601160.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Pre-extending the disk array size is pointless nowadays since we've switched to memory APIs which don't return failure. Switch all uses of reallocation of the array followed by 'virDomainDiskInsertPreAlloced' with direct virDomainDiskInsert. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/libxl/libxl_driver.c | 4 +--- src/lxc/lxc_driver.c | 6 +----- src/qemu/qemu_hotplug.c | 3 +-- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index d54cd41785..e305f64f9c 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -3048,8 +3048,6 @@ libxlDomainAttachDeviceDiskLive(virDomainObj *vm, vir= DomainDeviceDef *dev) goto cleanup; } - VIR_REALLOC_N(vm->def->disks, vm->def->ndisks+1); - if (libxlMakeDisk(l_disk, &x_disk) < 0) goto cleanup; @@ -3072,7 +3070,7 @@ libxlDomainAttachDeviceDiskLive(virDomainObj *vm, vir= DomainDeviceDef *dev) } libxlUpdateDiskDef(l_disk, &x_disk); - virDomainDiskInsertPreAlloced(vm->def, l_disk); + virDomainDiskInsert(vm->def, l_disk); } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 07aeb56b0c..8f2ca19f44 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -3401,10 +3401,6 @@ lxcDomainAttachDeviceDiskLive(virLXCDriver *driver, perms) < 0) goto cleanup; - vm->def->disks =3D g_renew(virDomainDiskDef *, - vm->def->disks, - vm->def->ndisks + 1); - file =3D g_strdup_printf("/dev/%s", def->dst); if (lxcDomainAttachDeviceMknod(driver, @@ -3423,7 +3419,7 @@ lxcDomainAttachDeviceDiskLive(virLXCDriver *driver, goto cleanup; } - virDomainDiskInsertPreAlloced(vm->def, def); + virDomainDiskInsert(vm->def, def); ret =3D 0; diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 7a1b413be0..ee72762d0d 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -737,7 +737,6 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, if (!(devstr =3D qemuBuildDiskDeviceStr(vm->def, disk, priv->qemuCaps)= )) goto cleanup; - VIR_REALLOC_N(vm->def->disks, vm->def->ndisks + 1); if (qemuHotplugAttachManagedPR(driver, vm, disk->src, QEMU_ASYNC_JOB_N= ONE) < 0) goto cleanup; @@ -784,7 +783,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, virDomainAuditDisk(vm, NULL, disk->src, "attach", true); - virDomainDiskInsertPreAlloced(vm->def, disk); + virDomainDiskInsert(vm->def, disk); ret =3D 0; cleanup: --=20 2.31.1 From nobody Fri May 17 06:07:55 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1621601300; cv=none; d=zohomail.com; s=zohoarc; b=C14TTghRifa/zY3FEZgppYR/IzHcF6behRDXQ2vcInqvijLTOkMjL28Z7d/ZKoaIOPCGjrk7Xm9xTkcjUPVl1yYVhW2MlaT3OrLK+1j3YEv4T1kn0jDHuERYrzYgeuihxYBplI2XoujyCDNgDCTBt+4RPRZmrBao545tZiINoiQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601300; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MBo9R+dc8LmakPWIewh6YeDbV0Zi/Ka0TJEu3CGuJaM=; b=GyjDiA2cpJcm4Rgv1IeXp0DVrEfAPPKE/I1OoQmW7drY6qt//N1ij9GJNaN+6XW87nWmkSYqTBC9ypw1q/MTI++VuqkY9ujdY6WutQjf0fxk9FkoBnsajQ8MufqDlaTQ1QygGuWvct2ocfgU7MkF6NnkGGODk+6NqvUlBolqyoM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass 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 1621601300944171.0495627247991; Fri, 21 May 2021 05:48:20 -0700 (PDT) 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-231-IJfoe_VZMY-AM2HQcBRRZQ-1; Fri, 21 May 2021 08:48:16 -0400 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 3BB44189828C; Fri, 21 May 2021 12:48:09 +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 BCE80100EBAD; Fri, 21 May 2021 12:48:08 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 81B751801264; Fri, 21 May 2021 12:48:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LCm5he031104 for ; Fri, 21 May 2021 08:48:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id C621C69FB4; Fri, 21 May 2021 12:48:05 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 26903421F for ; Fri, 21 May 2021 12:48:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601299; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=MBo9R+dc8LmakPWIewh6YeDbV0Zi/Ka0TJEu3CGuJaM=; b=gC8bW9U1m2G3Ea6qzX80K5jsGBie9YeYjNl+QtzLqZ7k4WsVkMMxxxlAdcd2CNtrPzs/J4 RlWfUIwVOuV+RpMVNbAbHod7jFkd4NksFIomiPfKhxIrG2ck0Gxh1q9LJz1gT2MCt9hHIe 2UnFL9LdlmscQCAy6YBebSKx79p96lE= X-MC-Unique: IJfoe_VZMY-AM2HQcBRRZQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 14/35] conf: remove virDomainDiskInsertPreAlloced Date: Fri, 21 May 2021 14:47:14 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace the last use of the function by virDomainDiskInsert and remove the unused helper. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 16 ++-------------- src/conf/domain_conf.h | 2 -- src/libvirt_private.syms | 1 - 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e35c38caa3..4ec6484b78 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15488,13 +15488,6 @@ virDomainDiskByTarget(virDomainDef *def, void virDomainDiskInsert(virDomainDef *def, virDomainDiskDef *disk) -{ - def->disks =3D g_renew(virDomainDiskDef *, def->disks, def->ndisks + 1= ); - virDomainDiskInsertPreAlloced(def, disk); -} - -void virDomainDiskInsertPreAlloced(virDomainDef *def, - virDomainDiskDef *disk) { int idx; /* Tentatively plan to insert disk at the end. */ @@ -15521,9 +15514,7 @@ void virDomainDiskInsertPreAlloced(virDomainDef *de= f, } } - /* VIR_INSERT_ELEMENT_INPLACE will never return an error here. */ - ignore_value(VIR_INSERT_ELEMENT_INPLACE(def->disks, insertAt, - def->ndisks, disk)); + ignore_value(VIR_INSERT_ELEMENT(def->disks, insertAt, def->ndisks, dis= k)); } @@ -19539,9 +19530,6 @@ virDomainDefParseXML(xmlDocPtr xml, if ((n =3D virXPathNodeSet("./devices/disk", ctxt, &nodes)) < 0) goto error; - if (n) - def->disks =3D g_new0(virDomainDiskDef *, n); - for (i =3D 0; i < n; i++) { virDomainDiskDef *disk =3D virDomainDiskDefParseXML(xmlopt, nodes[i], @@ -19550,7 +19538,7 @@ virDomainDefParseXML(xmlDocPtr xml, if (!disk) goto error; - virDomainDiskInsertPreAlloced(def, disk); + virDomainDiskInsert(def, disk); } VIR_FREE(nodes); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index fab856a5c7..a0855d816e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3548,8 +3548,6 @@ virDomainDiskByTarget(virDomainDef *def, const char *dst); void virDomainDiskInsert(virDomainDef *def, virDomainDiskDef *disk); -void virDomainDiskInsertPreAlloced(virDomainDef *def, - virDomainDiskDef *disk); int virDomainStorageNetworkParseHost(xmlNodePtr hostnode, virStorageNetHostDef *host); int virDomainDiskDefAssignAddress(virDomainXMLOption *xmlopt, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6fbdee4124..e6b4ce5bea 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -389,7 +389,6 @@ virDomainDiskGetType; virDomainDiskIndexByAddress; virDomainDiskIndexByName; virDomainDiskInsert; -virDomainDiskInsertPreAlloced; virDomainDiskIoTypeFromString; virDomainDiskIoTypeToString; virDomainDiskMirrorStateTypeFromString; --=20 2.31.1 From nobody Fri May 17 06:07:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1621601299; cv=none; d=zohomail.com; s=zohoarc; b=VsaAad1TSoSKHMlH6JR6yfZ8pWtbzmUBFOOvo/IRqWNTOposuQv1yHtRHfGGkjlEVzAgOGjglV7VOsGJVP3g2HArH3KPqrKGNbw0NUHWebFi8WL9+AI9uuRmTplafV/z1aK5r7IdOhsw/niRbVFXv9KZFs7Vmvsl4HeKNkyFaOQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601299; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hU9o9BGd80VWtHbu8WQs057ftu9DVo5adhkwAtBdzpE=; b=VqBEMjZS9GKIqumWrOGja+UlLw3qf97zpZXBASpmJSlOd/n+B5YHBx49iXuJvN/3YZX6VbBGtCtOFXii+zsgZiqfxcziFqYnlMDBlK+H+UvdNQmSRgPQx+NXB9OghifgrdN9dIB9muTJHX5cLZniu8jmBTRaNEedE/2SvgNNBcw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1621601299851586.8643680601859; Fri, 21 May 2021 05:48:19 -0700 (PDT) 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-360-UcXysyuCMdOt9U5_73rDrw-1; Fri, 21 May 2021 08:48:15 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7BFCF101C8D4; Fri, 21 May 2021 12:48:08 +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 5EFAE69FCE; Fri, 21 May 2021 12:48:08 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 0B20544A67; Fri, 21 May 2021 12:48:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LCm6uF031144 for ; Fri, 21 May 2021 08:48:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id D79C0421F; Fri, 21 May 2021 12:48:06 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4AD6169FB4 for ; Fri, 21 May 2021 12:48:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601298; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=hU9o9BGd80VWtHbu8WQs057ftu9DVo5adhkwAtBdzpE=; b=TVhgMncvbJSzy1n8kN6KUeKI9Ls0hj/dxe+6QfwBBcqKxBoc0pXTYjlKZqkf4M9Ma6MNYA 0ZOxOnIXomcymm4vVY/0MYs4lCO9DNyEyF4jjO812j1/YLYF2r/7q29dcj4I0bEnFXrA7M 9kOUbnHpLVaVWkL1Jwcwhdk+pfvZ3zM= X-MC-Unique: UcXysyuCMdOt9U5_73rDrw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 15/35] qemuBlockStorageSourceChainData: Add handling of 'copy-on-read' filter layer Date: Fri, 21 May 2021 14:47:15 +0200 Message-Id: <409e837c8d1fb81d55b01cde679128f83c127051.1621601161.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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.79 on 10.5.11.11 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" qemuBlockStorageSourceChainData encapsulates the backend of the disk for startup and hotplug operations. Add the handling for the copy-on-read filter so that the hotplug code doesn't need to have separate cleanup. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_block.c | 12 ++++++++++++ src/qemu/qemu_block.h | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 89f20eb1d2..6627d044cd 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1947,6 +1947,9 @@ qemuBlockStorageSourceChainDataFree(qemuBlockStorageS= ourceChainData *data) for (i =3D 0; i < data->nsrcdata; i++) qemuBlockStorageSourceAttachDataFree(data->srcdata[i]); + virJSONValueFree(data->copyOnReadProps); + g_free(data->copyOnReadNodename); + g_free(data->srcdata); g_free(data); } @@ -2054,6 +2057,11 @@ qemuBlockStorageSourceChainAttach(qemuMonitor *mon, return -1; } + if (data->copyOnReadProps) { + if (qemuMonitorBlockdevAdd(mon, &data->copyOnReadProps) < 0) + return -1; + } + return 0; } @@ -2072,6 +2080,10 @@ qemuBlockStorageSourceChainDetach(qemuMonitor *mon, { size_t i; + if (data->copyOnReadAttached) + ignore_value(qemuMonitorBlockdevDel(mon, data->copyOnReadNodename)= ); + + for (i =3D 0; i < data->nsrcdata; i++) qemuBlockStorageSourceAttachRollback(mon, data->srcdata[i]); } diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index 28ccca97a8..ff7048eb6c 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -150,6 +150,10 @@ qemuBlockStorageSourceDetachOneBlockdev(virQEMUDriver = *driver, struct _qemuBlockStorageSourceChainData { qemuBlockStorageSourceAttachData **srcdata; size_t nsrcdata; + + virJSONValue *copyOnReadProps; + char *copyOnReadNodename; + bool copyOnReadAttached; }; typedef struct _qemuBlockStorageSourceChainData qemuBlockStorageSourceChai= nData; --=20 2.31.1 From nobody Fri May 17 06:07:55 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1621601302; cv=none; d=zohomail.com; s=zohoarc; b=L3K8JyqQT8zrvWlyohoNOJ+lX6F9x36lZ9PSiIpkbNNIU/nsfymYXiwxASO/B0CMXPRYPOdlivtqlDJRH5CNS4YL7l5b4oRA96XUyKeStxgn8KXhEIkuCQMYH0diWcS6T2tifX4uJmsmW532Am+uwPA0lqf2o2d3OFi59lP65Yk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601302; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wxxULADm1u4Sq/K/n/GprItMFegRDWo375/DIglVqVc=; b=GjJS2Xr8roXyOGk2jG2vg2507PKtOcJSFfM+LbQjLPhzld+D1tdgzMGmmmdxa8tstrlHrM0umdtIQsfpnqvBjosoTh3oSFmxPo4WjXnAQQmG9n5QDYnOeqCBvaQ/Nfra+iuYZ0tUoUqEkhlsb7E/d/Owh/sxNmTFjxV5XQaf7XE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass 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 1621601302332264.96229685190303; Fri, 21 May 2021 05:48:22 -0700 (PDT) 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-15--Z8WoiSePMW5g9bMR-4oZg-1; Fri, 21 May 2021 08:48:18 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id AA04791271; Fri, 21 May 2021 12:48:11 +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 8311769324; Fri, 21 May 2021 12:48:11 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 091771801268; Fri, 21 May 2021 12:48:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LCm7ti031162 for ; Fri, 21 May 2021 08:48:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id E95C41964B; Fri, 21 May 2021 12:48:07 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46781421F for ; Fri, 21 May 2021 12:48:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601301; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=wxxULADm1u4Sq/K/n/GprItMFegRDWo375/DIglVqVc=; b=cKLz5YrVdTEhQJTHP4vWZ+vx/2MsrEbEgrBt0XqF7fUHBMhO+kpYoUNSYndhs5s6WM4+5H Hzg2dGEDxiyFT4LQMqnIx/9Ve4t42Abb3p920BbnWiVZNskb4b5RCneJ8H0RNNNVqY8Ajf 8erViQQ0jPAO3TKDiOfvTTMtGPx7ZXg= X-MC-Unique: -Z8WoiSePMW5g9bMR-4oZg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 16/35] qemuDomainAttachDiskGeneric: Move 'copy-on-read' handling to qemuBlockStorageSourceChainData Date: Fri, 21 May 2021 14:47:16 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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.79 on 10.5.11.15 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Fill in the required fields in qemuBlockStorageSourceChainData to handle the hotplug so that we can simplify the cleanup code. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index ee72762d0d..31dc9a43b2 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -700,9 +700,6 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, qemuDomainObjPrivate *priv =3D vm->privateData; g_autofree char *devstr =3D NULL; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); - g_autoptr(virJSONValue) corProps =3D NULL; - g_autofree char *corAlias =3D NULL; - bool corAdded =3D false; bool blockdev =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); if (qemuDomainStorageSourceChainAccessAllow(driver, vm, disk->src) < 0) @@ -718,16 +715,17 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, if (!(data =3D qemuBuildStorageSourceChainAttachPrepareChardev(dis= k))) goto cleanup; } else if (blockdev) { + if (!(data =3D qemuBuildStorageSourceChainAttachPrepareBlockdev(di= sk->src, + priv= ->qemuCaps))) + goto cleanup; + if (disk->copy_on_read =3D=3D VIR_TRISTATE_SWITCH_ON) { - if (!(corProps =3D qemuBlockStorageGetCopyOnReadProps(disk))) + if (!(data->copyOnReadProps =3D qemuBlockStorageGetCopyOnReadP= rops(disk))) goto cleanup; - corAlias =3D g_strdup(QEMU_DOMAIN_DISK_PRIVATE(disk)->nodeCopy= OnRead); + data->copyOnReadNodename =3D g_strdup(QEMU_DOMAIN_DISK_PRIVATE= (disk)->nodeCopyOnRead); } - if (!(data =3D qemuBuildStorageSourceChainAttachPrepareBlockdev(di= sk->src, - priv= ->qemuCaps))) - goto cleanup; } else { if (!(data =3D qemuBuildStorageSourceChainAttachPrepareDrive(disk, priv->q= emuCaps))) @@ -746,13 +744,6 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, if (qemuBlockStorageSourceChainAttach(priv->mon, data) < 0) goto exit_monitor; - if (corProps) { - if (qemuMonitorBlockdevAdd(priv->mon, &corProps) < 0) - goto exit_monitor; - - corAdded =3D true; - } - if (qemuDomainAttachExtensionDevice(priv->mon, &disk->info) < 0) goto exit_monitor; @@ -793,8 +784,6 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, return ret; exit_monitor: - if (corAdded) - ignore_value(qemuMonitorBlockdevDel(priv->mon, corAlias)); qemuBlockStorageSourceChainDetach(priv->mon, data); if (qemuDomainObjExitMonitor(driver, vm) < 0) --=20 2.31.1 From nobody Fri May 17 06:07:55 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1621601306; cv=none; d=zohomail.com; s=zohoarc; b=C92kA68XuyAwNFfSmNNKYK/oqgqXWDNonf1RRR0u6LvIjIKXS6DtDgw3UL05ASvyhhONYE2U8vbfE9uINhUM4DN1VrH/EenQC3+tJaTZkGnE0QKF1NYOgpM7OsQdV7HmGoMa/4jEMnnHgMC0bYPb9/HvRTxRpfCQpiXkz3Srgj4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601306; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cD2ru2QPTenkVNui9uAw4ZhMkU1PNhfF+bCKf3rv0JU=; b=F0369YC3VJM1p22H0jj++z5ll2txedELITmlMjjar/uh7r/ZBLA/nL3Cbcr/4Wy8UnsF2h03YaSXT/c5pBQlQi1/jOrVab9FXm0XKXiKdnhs3fcW7fVWeD5PfH0BB+ueUao/LrcFjTbz+PsjImURXGI/3bHXJBAkTy5WDRRQ+OQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass 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 1621601306345411.54964111305264; Fri, 21 May 2021 05:48:26 -0700 (PDT) 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-233-Z_F4ljupP1CgQ_wYWpDmgA-1; Fri, 21 May 2021 08:48:21 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id D1C5418BA280; Fri, 21 May 2021 12:48: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 AF84B5D9D5; Fri, 21 May 2021 12:48:13 +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 809ED1801264; Fri, 21 May 2021 12:48:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LCm942031197 for ; Fri, 21 May 2021 08:48:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 066B259472; Fri, 21 May 2021 12:48:09 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F672421F for ; Fri, 21 May 2021 12:48:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601305; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=cD2ru2QPTenkVNui9uAw4ZhMkU1PNhfF+bCKf3rv0JU=; b=ZJhRFQBJ82aHrDiv1Scjd4b2Nt988Oc2qMzthA5R04G6u1aAwIr3kaiRoN+nrc5hQoY0+F Iecman1eTC5tvbNnle/K44H1VwmjvBN8a0G4ka+XcYcUwKZESOe7QQxq7/Vj7rAbFL6O+k EkXT1isxwDmzYNi7oU97x9uEXGNvC5E= X-MC-Unique: Z_F4ljupP1CgQ_wYWpDmgA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 17/35] qemuDomainRemoveDiskDevice: Move 'copy-on-read' handling to qemuBlockStorageSourceChainData Date: Fri, 21 May 2021 14:47:17 +0200 Message-Id: <904afccf36c0fbefd1a72d4d1a4f2f835266e5ce.1621601161.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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.79 on 10.5.11.14 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Unify the handling of the copy-on-read filter by changing the handling to use qemuBlockStorageSourceChainData. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 31dc9a43b2..86b2027be7 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -4288,7 +4288,6 @@ qemuDomainRemoveDiskDevice(virQEMUDriver *driver, virDomainDeviceDef dev; size_t i; qemuDomainObjPrivate *priv =3D vm->privateData; - g_autofree char *corAlias =3D NULL; bool blockdev =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); int ret =3D -1; @@ -4301,10 +4300,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriver *driver, if (!(diskBackend =3D qemuBlockStorageSourceChainDetachPrepareChar= dev(chardevAlias))) goto cleanup; - } else if (blockdev && - !qemuDiskBusIsSD(disk->bus)) { - corAlias =3D g_strdup(diskPriv->nodeCopyOnRead); - + } else if (blockdev && !qemuDiskBusIsSD(disk->bus)) { if (diskPriv->blockjob) { /* the block job keeps reference to the disk chain */ diskPriv->blockjob->disk =3D NULL; @@ -4314,6 +4310,13 @@ qemuDomainRemoveDiskDevice(virQEMUDriver *driver, if (!(diskBackend =3D qemuBlockStorageSourceChainDetachPrepare= Blockdev(disk->src))) goto cleanup; } + + if (diskPriv->nodeCopyOnRead) { + if (!diskBackend) + diskBackend =3D g_new0(qemuBlockStorageSourceChainData, 1); + diskBackend->copyOnReadNodename =3D g_strdup(diskPriv->nodeCop= yOnRead); + diskBackend->copyOnReadAttached =3D true; + } } else { char *driveAlias; @@ -4333,9 +4336,6 @@ qemuDomainRemoveDiskDevice(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); - if (corAlias) - ignore_value(qemuMonitorBlockdevDel(priv->mon, corAlias)); - if (diskBackend) qemuBlockStorageSourceChainDetach(priv->mon, diskBackend); --=20 2.31.1 From nobody Fri May 17 06:07:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1621601414; cv=none; d=zohomail.com; s=zohoarc; b=N+FkkUZ2HzbJEL75Q/Dj6zt10xzaMsiuQiJ3CEKN0bZg65auCZJn3rVJiM5zYcp0nmRSUZf4i/mMGnx/CyIUhd72OM6p8L/142yn93xvG3B+G2RG3dUd7lX3enWT8oZ8/aZSyJpsKL/xcwDUM8SjqRu+xyx+ucaOIlttp9Mv27E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601414; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XKn6e4Ct484lD1+7NqBtSnkmN1m/pI2b5TgP5+tGSNw=; b=lY0X7IFjXg/jqA1gXEpbz3lntjlctWLVFV48XJfDnB6ih77AtUI/Hqg2i7d/1AfnCNebcRZJwef9meZk77Uadco2po+opHLp7BnUy+7J5zft/6qY7HHN7fPBz2Pcp2jdYmtm/ZJtYVeYxKC28ql5FGpij9ooyGTZbHmsC91ixOk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 162160141470481.47637091035006; Fri, 21 May 2021 05:50:14 -0700 (PDT) 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-187-Znljq9p_MWaq-QI3nIIxgg-1; Fri, 21 May 2021 08:48:21 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id A0B0118B9F78; Fri, 21 May 2021 12:48:12 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7F4505D9D5; Fri, 21 May 2021 12:48: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 4606B44A61; Fri, 21 May 2021 12:48:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LCmA4B031207 for ; Fri, 21 May 2021 08:48:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0F71C1964B; Fri, 21 May 2021 12:48:10 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 679DB421F for ; Fri, 21 May 2021 12:48:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601413; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=XKn6e4Ct484lD1+7NqBtSnkmN1m/pI2b5TgP5+tGSNw=; b=SBJvBkORIVR1Ec+szBalLm/kDei2OVHNjGVun73/NA9jAv2+j1TSexi5+Pqivei/uz03Yu 0d8qPvPk0XWKadVnUG5rOLrfUUyMQdwcix88ZS2m8gmg0f6mGkuvplUxAiddLW1zk7CAnU /7aYKQL+IwZI8GePznbcmaIZzx1m5C0= X-MC-Unique: Znljq9p_MWaq-QI3nIIxgg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 18/35] qemuDomainAttachDeviceDiskLiveInternal: Absorb qemuDomainAttachUSBMassStorageDevice Date: Fri, 21 May 2021 14:47:18 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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.79 on 10.5.11.14 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Move the specific device setup and address reservation code into the main hotplug helper as it's just one extra function call. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 86b2027be7..0e3d256fbb 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -995,32 +995,16 @@ qemuDomainAttachSCSIDisk(virQEMUDriver *driver, } -static int -qemuDomainAttachUSBMassStorageDevice(virQEMUDriver *driver, - virDomainObj *vm, - virDomainDiskDef *disk) -{ - qemuDomainObjPrivate *priv =3D vm->privateData; - - if (virDomainUSBAddressEnsure(priv->usbaddrs, &disk->info) < 0) - return -1; - - if (qemuDomainAttachDiskGeneric(driver, vm, disk) < 0) { - virDomainUSBAddressRelease(priv->usbaddrs, &disk->info); - return -1; - } - - return 0; -} - static int qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *driver, virDomainObj *vm, virDomainDeviceDef *dev) { + qemuDomainObjPrivate *priv =3D vm->privateData; size_t i; virDomainDiskDef *disk =3D dev->data.disk; + bool releaseUSB =3D false; int ret =3D -1; if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_CDROM || @@ -1060,7 +1044,13 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver= *driver, _("disk device=3D'lun' is not supported for usb= bus")); break; } - ret =3D qemuDomainAttachUSBMassStorageDevice(driver, vm, disk); + + if (virDomainUSBAddressEnsure(priv->usbaddrs, &disk->info) < 0) + goto cleanup; + + releaseUSB =3D true; + + ret =3D qemuDomainAttachDiskGeneric(driver, vm, disk); break; case VIR_DOMAIN_DISK_BUS_VIRTIO: @@ -1088,8 +1078,13 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver= *driver, } cleanup: - if (ret !=3D 0) + if (ret < 0) { ignore_value(qemuRemoveSharedDevice(driver, dev, vm->def->name)); + + if (releaseUSB) + virDomainUSBAddressRelease(priv->usbaddrs, &disk->info); + } + return ret; } --=20 2.31.1 From nobody Fri May 17 06:07:55 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1621601304; cv=none; d=zohomail.com; s=zohoarc; b=lA1VfkQk/JJdmtickS15OVv8qVaOQnwRxnwC5MBodDSaRnnUrOCkbYITSF6LJSYzB1YCfTHC6/DPjHtvnLMotVHRv3KJULjOECj6lOQk502o7DouuVvS8B6VHddc6bPyZ8538hud2YMUkyKqyGWTHFGaFJ70sscW2mWXAfOxLm0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601304; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fUYuMPWdFqfqF/YDgkDMadg2pZyKrxzrw+gr5roOrVM=; b=Q44zoevXevV8otoeG7Coi7FUacV+dv1k9JF1c4hkvgcu9uj/QifPok6uOp1qUhBfzpCRKQfYs9OJiJ0qs3ADKwqWTNsJws44EYY9vS0qHcbVhjbIz2zM7MYDdkBVmqVCkwiOQrUy3Nrcj6iDMHRsIgPiXGls7zqIrXai7SipaJY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass 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 1621601304910302.7730715452909; Fri, 21 May 2021 05:48:24 -0700 (PDT) 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-191-KGnVd0fkOT2eYOcsvtAxNg-1; Fri, 21 May 2021 08:48:21 -0400 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 BBA949127D; Fri, 21 May 2021 12:48:13 +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 73D33100AE43; Fri, 21 May 2021 12:48:13 +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 395D444A62; Fri, 21 May 2021 12:48:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LCmBTK031232 for ; Fri, 21 May 2021 08:48:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 17207421F; Fri, 21 May 2021 12:48:11 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7955559472 for ; Fri, 21 May 2021 12:48:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601303; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=fUYuMPWdFqfqF/YDgkDMadg2pZyKrxzrw+gr5roOrVM=; b=a9bNpNNUy7VEJkLbd80l1O7dELXdbA1iHXcyQTLMwMJ6SZALi1fcJSzde1Q/c8VIKIVbAb tSSPRUxaKERE2UkD0yU4ggAWHZ7AfoDluNU4yehy17pvtAmuEbhcJwGSF0riUXOnVj9XNp VHGKiw2qSosQGAQ8oioaif+It6uj4VU= X-MC-Unique: KGnVd0fkOT2eYOcsvtAxNg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 19/35] qemuDomainAttachDeviceDiskLiveInternal: Absorb qemuDomainAttachVirtioDiskDevice Date: Fri, 21 May 2021 14:47:19 +0200 Message-Id: <8c9da2daf97945a78d87417e89c7f9a5e50e8405.1621601161.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Move the specific device setup and address reservation code into the main hotplug helper as it's just one extra function call. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 0e3d256fbb..da13d84d56 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -798,29 +798,6 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, } -static int -qemuDomainAttachVirtioDiskDevice(virQEMUDriver *driver, - virDomainObj *vm, - virDomainDiskDef *disk) -{ - virDomainDeviceDef dev =3D { VIR_DOMAIN_DEVICE_DISK, { .disk =3D disk = } }; - bool releaseaddr =3D false; - int rv; - - if (qemuDomainEnsureVirtioAddress(&releaseaddr, vm, &dev, disk->dst) <= 0) - return -1; - - if ((rv =3D qemuDomainAttachDiskGeneric(driver, vm, disk)) < 0) { - if (rv =3D=3D -1 && releaseaddr) - qemuDomainReleaseDeviceAddress(vm, &disk->info); - - return -1; - } - - return 0; -} - - int qemuDomainAttachControllerDevice(virQEMUDriver *driver, virDomainObj *vm, virDomainControllerDef *controller) @@ -1005,6 +982,7 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *= driver, size_t i; virDomainDiskDef *disk =3D dev->data.disk; bool releaseUSB =3D false; + bool releaseVirtio =3D false; int ret =3D -1; if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_CDROM || @@ -1054,7 +1032,10 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver= *driver, break; case VIR_DOMAIN_DISK_BUS_VIRTIO: - ret =3D qemuDomainAttachVirtioDiskDevice(driver, vm, disk); + if (qemuDomainEnsureVirtioAddress(&releaseVirtio, vm, dev, disk->d= st) < 0) + goto cleanup; + + ret =3D qemuDomainAttachDiskGeneric(driver, vm, disk); break; case VIR_DOMAIN_DISK_BUS_SCSI: @@ -1083,6 +1064,9 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver = *driver, if (releaseUSB) virDomainUSBAddressRelease(priv->usbaddrs, &disk->info); + + if (releaseVirtio && ret =3D=3D -1) + qemuDomainReleaseDeviceAddress(vm, &disk->info); } return ret; --=20 2.31.1 From nobody Fri May 17 06:07:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1621601307; cv=none; d=zohomail.com; s=zohoarc; b=Y0wcGSi0ZwEltSz2odXZywkorHRgBhSJJ61h4whKxbFWNTTkp6h7P1K7527ZfSZQqdQplviDGuXNKrRdEV5TYwwDfh5RJtzhUBPZzez4eemhoM9A87pTVfCvcCJ4xiiMOY9Br0BxeFouNL1EsRX5+LnPkNGE0XAiYgowSbWsRwE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601307; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dbgWZa89wcjJlKkv/R+34k3tipesd1huJ/pp6GztcZA=; b=WVLPLfx1vje+iOKImHnHw7Xu3aOslTEzQUohhiNWQoWDOHkJ8H2U4opymROOLAbdmt+kodtnGcbpExwLU5M+YhE2IJ6a3bI9/fU7xcjMWmJqTjYc5tr9DadCDikHnOTat32knCkqw41T4ZE6f9zNv4tIL6wnGnFZmRVNUpscuKk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1621601307824259.6552834671479; Fri, 21 May 2021 05:48:27 -0700 (PDT) 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-38-tYMRBo4xMne31tKkyIG_ww-1; Fri, 21 May 2021 08:48:23 -0400 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 37FC718D6A2F; Fri, 21 May 2021 12:48:17 +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 B01C810027A5; Fri, 21 May 2021 12:48:16 +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 732181801028; Fri, 21 May 2021 12:48:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LCmChc031254 for ; Fri, 21 May 2021 08:48:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2B6F21964B; Fri, 21 May 2021 12:48:12 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C799421F for ; Fri, 21 May 2021 12:48:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601305; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=dbgWZa89wcjJlKkv/R+34k3tipesd1huJ/pp6GztcZA=; b=RQcv0apPTw4PgjUiVD+rmQwc6c44V9eJ6lk9MWvRSVkH89BkoEidnmX7T3Z0yHUXkeAWOG hEwkd+pL+f9HFmfVVsFq5tTOiDt2hKmHJrVyQm4f7qomhV7FSsyxFyFcriIrwoJehiNge4 AQYaXsHpboaHRCpAKwSpUtzZMQP2Kiw= X-MC-Unique: tYMRBo4xMne31tKkyIG_ww-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 20/35] qemuDomainAttachDeviceDiskLiveInternal: Absorb qemuDomainAttachSCSIDisk Date: Fri, 21 May 2021 14:47:20 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Move the validation of the SCSI device address and the attachment of the controller into qemuDomainAttachDeviceDiskLiveInternal as there's no specific need for a special helper. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 69 ++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 42 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index da13d84d56..8d0ee1c659 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -932,47 +932,6 @@ qemuDomainFindOrCreateSCSIDiskController(virQEMUDriver= *driver, } -static int -qemuDomainAttachSCSIDisk(virQEMUDriver *driver, - virDomainObj *vm, - virDomainDiskDef *disk) -{ - size_t i; - - /* We should have an address already, so make sure */ - if (disk->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected disk address type %s"), - virDomainDeviceAddressTypeToString(disk->info.type)= ); - return -1; - } - - if (virDomainSCSIDriveAddressIsUsed(vm->def, &disk->info.addr.drive)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("Domain already contains a disk with that address= ")); - return -1; - } - - /* Let's make sure the disk has a controller defined and loaded before - * trying to add it. The controller used by the disk must exist before= a - * qemu command line string is generated. - * - * Ensure that the given controller and all controllers with a smaller= index - * exist; there must not be any missing index in between. - */ - for (i =3D 0; i <=3D disk->info.addr.drive.controller; i++) { - if (!qemuDomainFindOrCreateSCSIDiskController(driver, vm, i)) - return -1; - } - - if (qemuDomainAttachDiskGeneric(driver, vm, disk) < 0) - return -1; - - return 0; -} - - - static int qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *driver, virDomainObj *vm, @@ -1039,7 +998,33 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver = *driver, break; case VIR_DOMAIN_DISK_BUS_SCSI: - ret =3D qemuDomainAttachSCSIDisk(driver, vm, disk); + /* We should have an address already, so make sure */ + if (disk->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected disk address type %s"), + virDomainDeviceAddressTypeToString(disk->info.t= ype)); + goto cleanup; + } + + if (virDomainSCSIDriveAddressIsUsed(vm->def, &disk->info.addr.driv= e)) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("Domain already contains a disk with that add= ress")); + goto cleanup; + } + + /* Let's make sure the disk has a controller defined and loaded be= fore + * trying to add it. The controller used by the disk must exist be= fore a + * qemu command line string is generated. + * + * Ensure that the given controller and all controllers with a sma= ller index + * exist; there must not be any missing index in between. + */ + for (i =3D 0; i <=3D disk->info.addr.drive.controller; i++) { + if (!qemuDomainFindOrCreateSCSIDiskController(driver, vm, i)) + goto cleanup; + } + + ret =3D qemuDomainAttachDiskGeneric(driver, vm, disk); break; case VIR_DOMAIN_DISK_BUS_IDE: --=20 2.31.1 From nobody Fri May 17 06:07:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1621601415; cv=none; d=zohomail.com; s=zohoarc; b=eImlZ1NeSa9emsyHUfu7G3xbhynERHWEp3j5JFt3h2OkjwpYwC3s32ek54gq9OJzfcQJfT3q8u3sQOirRGhXn8cfF6KzsHHZZ7AZRR6FMDFG+mXTaG6kRfVB12ygY46iR0qPi5UqH06/hAVm/pULE9QDdqhErAW18OIkYtG/ggU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601415; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aLrW546v7e1fEdSC815hYj8L/Pm5GleP/wvfaqaNoMQ=; b=UF75vHHA/J0RwaqGqWsa9cuXI+13GcC0K5kEyC3yAz6n4xP7gbQNU/NzThkupAtA5AZc2IclPGKn/jWqPqW+DrHX0KjqsHT9rY17x+CDVKwAoutdSop+JjxN5RJuUUlU2Abj/S73EMIrxaLowE8ezIJsVxPEfkuv8hD9foRUvnk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1621601415988478.0485094750826; Fri, 21 May 2021 05:50:15 -0700 (PDT) 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-28-y4QRYk7pNwyvS68JaGDXrg-1; Fri, 21 May 2021 08:48:23 -0400 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 5A843802B4F; Fri, 21 May 2021 12:48:17 +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 F0F7D100AE4E; Fri, 21 May 2021 12:48:16 +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 AF8ED180B465; Fri, 21 May 2021 12:48:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LCmD4I031268 for ; Fri, 21 May 2021 08:48:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 44EB7421F; Fri, 21 May 2021 12:48:13 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9004B6E6F9 for ; Fri, 21 May 2021 12:48:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601415; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=aLrW546v7e1fEdSC815hYj8L/Pm5GleP/wvfaqaNoMQ=; b=h7igdSLjGGw7VrdT7iy01rlf6hHqBpDkf8sbPTqdBBlsJZi8fnYiNQD2WMBds+nlesvE0M YtxxCv8YDHuwucSpuj8hPHxGssIcyKsxU+uF3K/DEvp2BYyhi/oMXPIOl64n9bS8lLeitx TkzXNWfSfeS58pkSylvHXd6HWY57h/M= X-MC-Unique: y4QRYk7pNwyvS68JaGDXrg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 21/35] qemuDomainAttachDeviceDiskLiveInternal: Simplify call to qemuDomainAttachDiskGeneric Date: Fri, 21 May 2021 14:47:21 +0200 Message-Id: <2ceccf8f7e3ec52b03bcc8cd8a4fef74ee170584.1621601161.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" We can call it in one place as all per-device-type subcases use the same code. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 8d0ee1c659..33c6feea3e 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -986,15 +986,11 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver = *driver, goto cleanup; releaseUSB =3D true; - - ret =3D qemuDomainAttachDiskGeneric(driver, vm, disk); break; case VIR_DOMAIN_DISK_BUS_VIRTIO: if (qemuDomainEnsureVirtioAddress(&releaseVirtio, vm, dev, disk->d= st) < 0) goto cleanup; - - ret =3D qemuDomainAttachDiskGeneric(driver, vm, disk); break; case VIR_DOMAIN_DISK_BUS_SCSI: @@ -1023,8 +1019,6 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver = *driver, if (!qemuDomainFindOrCreateSCSIDiskController(driver, vm, i)) goto cleanup; } - - ret =3D qemuDomainAttachDiskGeneric(driver, vm, disk); break; case VIR_DOMAIN_DISK_BUS_IDE: @@ -1043,6 +1037,8 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver = *driver, virDomainDiskBusTypeToString(disk->bus)); } + ret =3D qemuDomainAttachDiskGeneric(driver, vm, disk); + cleanup: if (ret < 0) { ignore_value(qemuRemoveSharedDevice(driver, dev, vm->def->name)); --=20 2.31.1 From nobody Fri May 17 06:07:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1621601308; cv=none; d=zohomail.com; s=zohoarc; b=Kumav0fTQTw2weQkQe3fw76xLA1XMls+a5k7+epxqagwWH72E3R6msASMpPj7tVvg20xs7q1wtTfrw5GERpHtd+6OVIHQNf4cCTGwLJcP2MrdTPw+Z2F/U491T81dARlgN7wWtVHO0IOOuNrHDmdPl7iPFsvPbYvpIa4Y1uCTjI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601308; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9kkskaP6IDN8NwG7YZo3rUedF7+7U5Ar3DPM1C1Q5J8=; b=TEDGHqbhzazu9nubQvqR3X19PcJlVtpBi5ugY0eHpbEGACNbgfzpOnbjJlsMJe80tbx24gg7ue6VGnFOJRPwm+kvh5kS0UdKdW9m/m5csE6CXP+BuFffREvRQBl4b618X6UPp0zEjsa682qV2kwsnhMl79HuKd1Z9/js2+sSNkY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1621601308416543.6276072404256; Fri, 21 May 2021 05:48:28 -0700 (PDT) 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-40-CZRzmrOvPQihOM71xQckSg-1; Fri, 21 May 2021 08:48:24 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8DC3B9F7F7; Fri, 21 May 2021 12:48:17 +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 6A630610B0; Fri, 21 May 2021 12:48:17 +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 30A6E44A61; Fri, 21 May 2021 12:48:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LCmEQa031292 for ; Fri, 21 May 2021 08:48:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4BC021964B; Fri, 21 May 2021 12:48:14 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id B1D53421F for ; Fri, 21 May 2021 12:48:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601306; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=9kkskaP6IDN8NwG7YZo3rUedF7+7U5Ar3DPM1C1Q5J8=; b=FvoWFbtKUenOAYJA8zIFBxOSWlD6AmUDCJN77/DiZatxeC18Ekdst17to2ddHNzNXS+f0a t1Je+Dm0pCfYlTpzOnXuNDrJ+WLxJAndPEEM6663Uhw88AII2KmQKSFR5gSCRHUaKmekqB BzAKi8mGCvN/osWnzeAUNy/WYcPKMlw= X-MC-Unique: CZRzmrOvPQihOM71xQckSg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 22/35] qemuDomainAttachDiskGeneric: Move setup of disk into qemuDomainAttachDeviceDiskLiveInternal Date: Fri, 21 May 2021 14:47:22 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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.79 on 10.5.11.12 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" qemuDomainAttachDeviceDiskLiveInternal already sets up certain pieces of the disk definition so it's better suited to move the setup of the virStorageSource structs, granting access to the storage and allocation of the alias from qemuDomainAttachDiskGeneric which will be just handling the qemu interaction. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 33c6feea3e..fbf4a85c23 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -699,17 +699,8 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, int ret =3D -1; qemuDomainObjPrivate *priv =3D vm->privateData; g_autofree char *devstr =3D NULL; - g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); bool blockdev =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); - if (qemuDomainStorageSourceChainAccessAllow(driver, vm, disk->src) < 0) - return -1; - - if (qemuAssignDeviceDiskAlias(vm->def, disk, priv->qemuCaps) < 0) - goto cleanup; - - if (qemuDomainPrepareDiskSource(disk, priv, cfg) < 0) - goto cleanup; if (virStorageSourceGetActualType(disk->src) =3D=3D VIR_STORAGE_TYPE_V= HOST_USER) { if (!(data =3D qemuBuildStorageSourceChainAttachPrepareChardev(dis= k))) @@ -778,9 +769,6 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, ret =3D 0; cleanup: - if (ret < 0) - ignore_value(qemuDomainStorageSourceChainAccessRevoke(driver, vm, = disk->src)); - qemuDomainSecretDiskDestroy(disk); return ret; exit_monitor: @@ -937,11 +925,13 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver = *driver, virDomainObj *vm, virDomainDeviceDef *dev) { + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); qemuDomainObjPrivate *priv =3D vm->privateData; size_t i; virDomainDiskDef *disk =3D dev->data.disk; bool releaseUSB =3D false; bool releaseVirtio =3D false; + bool releaseSeclabel =3D false; int ret =3D -1; if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_CDROM || @@ -1037,6 +1027,17 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver= *driver, virDomainDiskBusTypeToString(disk->bus)); } + if (qemuDomainStorageSourceChainAccessAllow(driver, vm, disk->src) < 0) + goto cleanup; + + releaseSeclabel =3D true; + + if (qemuAssignDeviceDiskAlias(vm->def, disk, priv->qemuCaps) < 0) + goto cleanup; + + if (qemuDomainPrepareDiskSource(disk, priv, cfg) < 0) + goto cleanup; + ret =3D qemuDomainAttachDiskGeneric(driver, vm, disk); cleanup: @@ -1048,7 +1049,11 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver= *driver, if (releaseVirtio && ret =3D=3D -1) qemuDomainReleaseDeviceAddress(vm, &disk->info); + + if (releaseSeclabel) + ignore_value(qemuDomainStorageSourceChainAccessRevoke(driver, = vm, disk->src)); } + qemuDomainSecretDiskDestroy(disk); return ret; } --=20 2.31.1 From nobody Fri May 17 06:07:55 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1621601353; cv=none; d=zohomail.com; s=zohoarc; b=I9+kPQAOAEqXkoRXQyqjpIFOHbOy7zW0NF0F2z8SgwoiCuT3Hv/nNILDCeZ0caF9DLHpBrdg15uwAYYOhFh1c/wrN5Hf8s2wrYoMeAxBGTeRmN7B6p5kbzmjhtN47TifhxGSO+C6wcfCPnYC9ck7l5bnMlM2SA09ePiVD8nww3A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601353; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PT23X4F3KwyssOpwUkLiZHxOvdQmhn+LHEJ/jDg9/MM=; b=MXM4IyfFhBCGC0tWgFnOFuq9gdtZbDNOzRXk+3UBeT0HCsPwWmLIsG86+5G9RVAREV8ed0tMBoI0niM4Sy8GK00njcgDHRXm1IZnhXbYQNbUgXQxkHOHAgWalJ20ed8zrxjP22ufVU9jXyIDf/cVk7mmYfWWMeYrESjOgERkmzM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass 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 1621601353011720.2053508195572; Fri, 21 May 2021 05:49:13 -0700 (PDT) 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-507-_ocTiX-nNDOSWBlrMxg65A-1; Fri, 21 May 2021 08:48:27 -0400 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 E192D873017; Fri, 21 May 2021 12:48:19 +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 7926C105B216; Fri, 21 May 2021 12:48:19 +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 08FB044A5D; Fri, 21 May 2021 12:48:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LCmFOw031308 for ; Fri, 21 May 2021 08:48:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5CC5A1964B; Fri, 21 May 2021 12:48:15 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id B4BDD421F for ; Fri, 21 May 2021 12:48:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601352; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=PT23X4F3KwyssOpwUkLiZHxOvdQmhn+LHEJ/jDg9/MM=; b=ESqTCtb6UZB7qy2ZkHPXL4uN/rB04QsYVQ89ybKu3Rvwmzk4NwFwSmrp2vFyXz41PbCVq7 k9PVxz+Xw3P9ZldclG6kBq5bfwnvF8+Ret4Pku5hbDV54HaaWumEHCOeiJ1FIrdxHpoCdk xaMUFwC2O4ozYkSRE8b+K4GPg3h5P8c= X-MC-Unique: _ocTiX-nNDOSWBlrMxg65A-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 23/35] qemu: hotplug: Move post-insertion steps of disk hotplug to qemuDomainAttachDeviceDiskLiveInternal Date: Fri, 21 May 2021 14:47:23 +0200 Message-Id: <77a92d11168e4dd57c496c75e6504d4c2ddbc2ba.1621601161.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Move the auditing entry and insertion into the disk definition from the function which deals with qemu to 'qemuDomainAttachDeviceDiskLiveInternal' which deals with the hotplug related specifics. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index fbf4a85c23..9b7067110e 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -763,9 +763,6 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, goto cleanup; } - virDomainAuditDisk(vm, NULL, disk->src, "attach", true); - - virDomainDiskInsert(vm->def, disk); ret =3D 0; cleanup: @@ -781,7 +778,6 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, qemuHotplugRemoveManagedPR(driver, vm, QEMU_ASYNC_JOB_NONE) < 0) ret =3D -2; - virDomainAuditDisk(vm, NULL, disk->src, "attach", false); goto cleanup; } @@ -1040,6 +1036,13 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver= *driver, ret =3D qemuDomainAttachDiskGeneric(driver, vm, disk); + virDomainAuditDisk(vm, NULL, disk->src, "attach", ret =3D=3D 0); + + if (ret < 0) + goto cleanup; + + virDomainDiskInsert(vm->def, disk); + cleanup: if (ret < 0) { ignore_value(qemuRemoveSharedDevice(driver, dev, vm->def->name)); --=20 2.31.1 From nobody Fri May 17 06:07:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1621601310; cv=none; d=zohomail.com; s=zohoarc; b=ij/JaGzAq2F9Sd9jv0XYQpwhxJLDqsWBxS1iwa8jfa/UZAk/NsPc/ScXSqzqh4c3hvaOcWP4hzxt1q2aBX+mGjXUEYXvFJcQloR/V/Wiy4Dq9b/mgV6ltUJYJb0+dqVY1wDFK7tidbGssW5jUkMaN1GQGjz3aSfA+Vc6+prSA9I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601310; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2s+2/9FneceO+0Ptoym/vIawsW6+KJF0m9r5grSYQSM=; b=ASRVFFk5+i3p+fjHDJqNapZz1rh6n07zdOJUXx1SkOt+QpIuBEVL1+orEjRsbgBIgsQiKW5ctEafxHDYMK0n+k/7w0m6NWUZUCbWa8fWGYHvBFtTL+uhFb5WMabaxLzncq3RA1gI7yHM9+7iwu1d3wwaInv2d791CRsDwVmNKVc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1621601310560105.5220642167053; Fri, 21 May 2021 05:48:30 -0700 (PDT) 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-248-r-Ov6ZAMMFyXCUeeMAn9rQ-1; Fri, 21 May 2021 08:48:26 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id B0D208042C8; Fri, 21 May 2021 12:48:20 +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 8E09A5D9D5; Fri, 21 May 2021 12:48:20 +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 4FACC44A66; Fri, 21 May 2021 12:48:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LCmGjG031323 for ; Fri, 21 May 2021 08:48:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7629D50F89; Fri, 21 May 2021 12:48:16 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id CCBDB421F for ; Fri, 21 May 2021 12:48:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601309; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=2s+2/9FneceO+0Ptoym/vIawsW6+KJF0m9r5grSYQSM=; b=hJ7YoxurWhzE2ActCOGdd6t5o8an2QzL48b0vG+tDCZ90wITdDy3gq+jv+tb+O3XOHiicf iY/+2/4XExEAHs4a97F6Pggaz7oJz2J/3tnQY/nep/y3MTrZjCfO0RSMsJT+h5yALcs4QI L5txRYmy0+ZAbUoUlzWg2nONFHHXVCI= X-MC-Unique: r-Ov6ZAMMFyXCUeeMAn9rQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 24/35] qemuDomainAttachDiskGeneric: Fix whitespace Date: Fri, 21 May 2021 14:47:24 +0200 Message-Id: <58f0760e50777ba7cd647c08654b044825ec2ea0.1621601161.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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.79 on 10.5.11.14 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Remove two empty lines. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 9b7067110e..b1d3ee8e7a 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -701,7 +701,6 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, g_autofree char *devstr =3D NULL; bool blockdev =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); - if (virStorageSourceGetActualType(disk->src) =3D=3D VIR_STORAGE_TYPE_V= HOST_USER) { if (!(data =3D qemuBuildStorageSourceChainAttachPrepareChardev(dis= k))) goto cleanup; @@ -726,7 +725,6 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, if (!(devstr =3D qemuBuildDiskDeviceStr(vm->def, disk, priv->qemuCaps)= )) goto cleanup; - if (qemuHotplugAttachManagedPR(driver, vm, disk->src, QEMU_ASYNC_JOB_N= ONE) < 0) goto cleanup; --=20 2.31.1 From nobody Fri May 17 06:07:55 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1621601467; cv=none; d=zohomail.com; s=zohoarc; b=m/X2hNM8286pfsIfsYGOjHhK9EOIKeVZNhjPJFwMaKa/t8UYd0qOZ3miZqZtJrrZLdbysAcv7D5BJIf9/t8WDyIQvsOfcV11Rg8izNGWC6YQ4yDPrNh16xTLMZPQsIwn4mcq/nJbBpYKzCuN4TPBMoCIvYP8WPQ7NPv6r+qoq8M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601467; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QLXSkg++ubEPJe5p3A6xDWDMPkWISwb1dafXzPgRfM0=; b=drW1Gz2YtDbqmMbR/DndoVI/RoKnIVfDQ6Mzwn5pfhOT5ppP9lN5KKFYCAzkB44dRslUrd5YV7+MWuR0BKdILtbyaT8xpVevvCUqXNUK1V4XAyB+RGWRk4KrxTDKYU9NraDiLk4BlNn2SyICmw6ZcAkZV+cD6FUo5rUx7sodi98= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass 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 1621601467181399.8316734214609; Fri, 21 May 2021 05:51:07 -0700 (PDT) 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-315-LSOZPABGN1edTG5Js2NBTg-1; Fri, 21 May 2021 08:48:29 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 095EBA40DD; Fri, 21 May 2021 12:48:23 +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 D8DED50415; Fri, 21 May 2021 12:48:22 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id AA174180B464; Fri, 21 May 2021 12:48:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LCmLSV031409 for ; Fri, 21 May 2021 08:48:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 45A98421F; Fri, 21 May 2021 12:48:21 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id ADD5969FB4 for ; Fri, 21 May 2021 12:48:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601466; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=QLXSkg++ubEPJe5p3A6xDWDMPkWISwb1dafXzPgRfM0=; b=Lq9DhO/phAZ5ZqErz8iA0bdzEn5lcQHMj/UapskGaCzy65jgR71T7UYR3ZQvWEnA4bTW76 oAyPiEa+2Ve+F6FF4XOHFLu1XPCOusjlvbkciZYNS3GsFfsieWOhjyp7evMyvarBBSdFDx pB0rrxDQ6IWmgkLOe1/i+1ls7BW8x80= X-MC-Unique: LSOZPABGN1edTG5Js2NBTg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 25/35] qemuDomainAttachDiskGeneric: Refactor cleanup Date: Fri, 21 May 2021 14:47:25 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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.79 on 10.5.11.12 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Remove the 'ret' variable and 'cleanup' label in favor of directly returning the value since we don't have anything under the 'cleanup:' label. Signed-off-by: Peter Krempa --- src/qemu/qemu_hotplug.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index b1d3ee8e7a..25e845dc83 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -696,22 +696,21 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, virDomainDiskDef *disk) { g_autoptr(qemuBlockStorageSourceChainData) data =3D NULL; - int ret =3D -1; qemuDomainObjPrivate *priv =3D vm->privateData; g_autofree char *devstr =3D NULL; bool blockdev =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); if (virStorageSourceGetActualType(disk->src) =3D=3D VIR_STORAGE_TYPE_V= HOST_USER) { if (!(data =3D qemuBuildStorageSourceChainAttachPrepareChardev(dis= k))) - goto cleanup; + return -1; } else if (blockdev) { if (!(data =3D qemuBuildStorageSourceChainAttachPrepareBlockdev(di= sk->src, priv= ->qemuCaps))) - goto cleanup; + return -1; if (disk->copy_on_read =3D=3D VIR_TRISTATE_SWITCH_ON) { if (!(data->copyOnReadProps =3D qemuBlockStorageGetCopyOnReadP= rops(disk))) - goto cleanup; + return -1; data->copyOnReadNodename =3D g_strdup(QEMU_DOMAIN_DISK_PRIVATE= (disk)->nodeCopyOnRead); } @@ -719,14 +718,14 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, } else { if (!(data =3D qemuBuildStorageSourceChainAttachPrepareDrive(disk, priv->q= emuCaps))) - goto cleanup; + return -1; } if (!(devstr =3D qemuBuildDiskDeviceStr(vm->def, disk, priv->qemuCaps)= )) - goto cleanup; + return -1; if (qemuHotplugAttachManagedPR(driver, vm, disk->src, QEMU_ASYNC_JOB_N= ONE) < 0) - goto cleanup; + return -1; qemuDomainObjEnterMonitor(driver, vm); @@ -756,27 +755,22 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, VIR_WARN("failed to set blkdeviotune for '%s' of '%s'", disk->= dst, vm->def->name); } - if (qemuDomainObjExitMonitor(driver, vm) < 0) { - ret =3D -2; - goto cleanup; - } - - ret =3D 0; + if (qemuDomainObjExitMonitor(driver, vm) < 0) + return -2; - cleanup: - return ret; + return 0; exit_monitor: qemuBlockStorageSourceChainDetach(priv->mon, data); if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret =3D -2; + return -2; if (virStorageSourceChainHasManagedPR(disk->src) && qemuHotplugRemoveManagedPR(driver, vm, QEMU_ASYNC_JOB_NONE) < 0) - ret =3D -2; + return -2; - goto cleanup; + return -1; } --=20 2.31.1 From nobody Fri May 17 06:07:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1621601313; cv=none; d=zohomail.com; s=zohoarc; b=DTTpf6rd/hs9a3NZdtZ+jDJpCDIAUvLItGHfLKFbddNlY9sJp3oATMhkXyW3SCS2Whb35kbqhi3+dOkyP4XYhjy2pyrHiXzAX8G74doFOCiPy7ZGn7oza4As21bYiKYNM3JoDWkbvvGPQ3wL3gKDZOD06gWl2UeYvh2Zt8Nwco8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601313; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FQ7kT1H3Ce1PjKvOFdp+0K9rg0zGOhLhyhAazyqcS/Q=; b=cfk7qtYcl0bmgEx8yEpH655DCVnxGT6jsWk8T3iL3AkUOVU4gyWkzI0aEcKAurm5YPG4SwWjWCqzcnZquyi5QJObQKG+YEqUclbnNIcCRJcDCbmIpkg0buYNDSpWtQGCz1nLcTrZno3aS+Ozhjm5MLFutyunyb6QD2Ic3DhsG+E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1621601313696387.2752133033032; Fri, 21 May 2021 05:48:33 -0700 (PDT) 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-552-42zEitAnNTytsIo0jlLPtA-1; Fri, 21 May 2021 08:48:30 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id CE16A101373A; Fri, 21 May 2021 12:48:25 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 88B765E26A; Fri, 21 May 2021 12:48:25 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 498CC44A62; Fri, 21 May 2021 12:48:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LCmMv4031425 for ; Fri, 21 May 2021 08:48:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6D6415945B; Fri, 21 May 2021 12:48:22 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id A8A3E421F for ; Fri, 21 May 2021 12:48:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601312; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=FQ7kT1H3Ce1PjKvOFdp+0K9rg0zGOhLhyhAazyqcS/Q=; b=bO8jtJxn3txTBs44Y2v1JRkOmztN3MEcCzXK8a4IKch26ZsMPtjDjzNMNyWhnGE+f9xTpq sFFy76SGu03OqO0VVUlPgIGLPksqqQcUoPcuzJFtFhY7hSQlq0k2MM9LC9HcTxTZ+hkxyl o+IQ+JsBSS0hzDThRsPd5evVA++Vlo8= X-MC-Unique: 42zEitAnNTytsIo0jlLPtA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 26/35] qemuDomainAttachDiskGeneric: Move PR helper attach into qemuDomainAttachDeviceDiskLiveInternal Date: Fri, 21 May 2021 14:47:26 +0200 Message-Id: <8c6605b9f30d2f421b412c6d549eb3b85455c84d.1621601161.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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.79 on 10.5.11.14 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Similarly to previous refactors we want to move all hotplug related setup which isn't strictly relevant to attaching the disk into qemuDomainAttachDeviceDiskLiveInternal. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 25e845dc83..f8c741c683 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -724,9 +724,6 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, if (!(devstr =3D qemuBuildDiskDeviceStr(vm->def, disk, priv->qemuCaps)= )) return -1; - if (qemuHotplugAttachManagedPR(driver, vm, disk->src, QEMU_ASYNC_JOB_N= ONE) < 0) - return -1; - qemuDomainObjEnterMonitor(driver, vm); if (qemuBlockStorageSourceChainAttach(priv->mon, data) < 0) @@ -766,10 +763,6 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, if (qemuDomainObjExitMonitor(driver, vm) < 0) return -2; - if (virStorageSourceChainHasManagedPR(disk->src) && - qemuHotplugRemoveManagedPR(driver, vm, QEMU_ASYNC_JOB_NONE) < 0) - return -2; - return -1; } @@ -1026,6 +1019,9 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver = *driver, if (qemuDomainPrepareDiskSource(disk, priv, cfg) < 0) goto cleanup; + if (qemuHotplugAttachManagedPR(driver, vm, disk->src, QEMU_ASYNC_JOB_N= ONE) < 0) + goto cleanup; + ret =3D qemuDomainAttachDiskGeneric(driver, vm, disk); virDomainAuditDisk(vm, NULL, disk->src, "attach", ret =3D=3D 0); @@ -1047,6 +1043,9 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver = *driver, if (releaseSeclabel) ignore_value(qemuDomainStorageSourceChainAccessRevoke(driver, = vm, disk->src)); + + if (virStorageSourceChainHasManagedPR(disk->src)) + ignore_value(qemuHotplugRemoveManagedPR(driver, vm, QEMU_ASYNC= _JOB_NONE)); } qemuDomainSecretDiskDestroy(disk); --=20 2.31.1 From nobody Fri May 17 06:07:55 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1621601346; cv=none; d=zohomail.com; s=zohoarc; b=DSGCEgtpfiV8hFg7HGnphSZ3yHQq+Khrsl5qUq+uZLUQOFCX+pzCDJ6fhFsl88xFm/mbAJmaodhIAyiaVPZZ58oCY3i+YECdADAMuJ+xsfCgUzyW0p0xGnVY6cdo/2PuNUmirNSS78k6I/WPsGoIa1jChsP6eidSLKVBIjAdWp8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601346; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4dlddTlFYBvg1GiZTGXdZVrS6spUfGUnltMSuel6nt8=; b=Gunxy65TOsuDmNmvCy8t4gEWUCYy2ay1xJsUq2cq8kWhR/9kgD/Du0py58nRLTe8cpwTkYSgQJBkQql/euwChy+S7HoRsbCpPUep8wdz9XZqg08XsKQZhAoQA5P3NIdXhkP3rehgkhLQ2GTuAOXhnE3C9BUOFf3MCQnLCCAZEaE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass 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 1621601346777563.3147790381538; Fri, 21 May 2021 05:49:06 -0700 (PDT) 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-537-3C83iDPPNFeaJcJadIScVA-1; Fri, 21 May 2021 08:48:31 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id BD6B6A40DE; Fri, 21 May 2021 12:48:25 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6A7F518351; Fri, 21 May 2021 12:48:25 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 240EB44A61; Fri, 21 May 2021 12:48:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LCmNds031442 for ; Fri, 21 May 2021 08:48:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id A8E68421F; Fri, 21 May 2021 12:48:23 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 009F669FCE for ; Fri, 21 May 2021 12:48:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601345; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=4dlddTlFYBvg1GiZTGXdZVrS6spUfGUnltMSuel6nt8=; b=JlfbM1MwnV8ld+GZoaQo29NBbXDd4zxQGgja+h5+na32QzOOHeu5pvYjFk7/rixnCvLVM1 lP4cojc5bf1yIdNeUBH23yxJBmu2vMmCvKXT60HP3r4GcNvycpr1gAqH+y71h8zpsYoOB8 RjIXWZxqMoH6Mj8/SYI9P60dk7Ndkn8= X-MC-Unique: 3C83iDPPNFeaJcJadIScVA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 27/35] qemuDomainAttachDiskGeneric: Refactor rollback handling Date: Fri, 21 May 2021 14:47:27 +0200 Message-Id: <3de943d3b6f9ac8cae0ae0dfa03f945ecd90d6a4.1621601161.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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.79 on 10.5.11.14 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Modify the rollback section to use it's own monitor context so that we can later split up the hotplug into multiple steps and move the detachment of the extension device into the rollback section rather than doing it inline. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index f8c741c683..3772c5b4b8 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -699,6 +699,8 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, qemuDomainObjPrivate *priv =3D vm->privateData; g_autofree char *devstr =3D NULL; bool blockdev =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); + bool extensionDeviceAttached =3D false; + int rc; if (virStorageSourceGetActualType(disk->src) =3D=3D VIR_STORAGE_TYPE_V= HOST_USER) { if (!(data =3D qemuBuildStorageSourceChainAttachPrepareChardev(dis= k))) @@ -726,16 +728,14 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); - if (qemuBlockStorageSourceChainAttach(priv->mon, data) < 0) - goto exit_monitor; + rc =3D qemuBlockStorageSourceChainAttach(priv->mon, data); - if (qemuDomainAttachExtensionDevice(priv->mon, &disk->info) < 0) - goto exit_monitor; + if (rc =3D=3D 0 && + (rc =3D qemuDomainAttachExtensionDevice(priv->mon, &disk->info)) = =3D=3D 0) + extensionDeviceAttached =3D true; - if (qemuMonitorAddDevice(priv->mon, devstr) < 0) { - ignore_value(qemuDomainDetachExtensionDevice(priv->mon, &disk->inf= o)); - goto exit_monitor; - } + if (rc =3D=3D 0) + rc =3D qemuMonitorAddDevice(priv->mon, devstr); /* Setup throttling of disk via block_set_io_throttle QMP command. This * is a hack until the 'throttle' blockdev driver will support modific= ation @@ -743,7 +743,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, * As there isn't anything sane to do if this fails, let's just return * success. */ - if (blockdev && + if (blockdev && rc =3D=3D 0 && qemuDiskConfigBlkdeviotuneEnabled(disk)) { qemuDomainDiskPrivate *diskPriv =3D QEMU_DOMAIN_DISK_PRIVATE(disk); if (qemuMonitorSetBlockIoThrottle(priv->mon, NULL, diskPriv->qomNa= me, @@ -755,9 +755,17 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, if (qemuDomainObjExitMonitor(driver, vm) < 0) return -2; + if (rc < 0) + goto rollback; + return 0; - exit_monitor: + rollback: + qemuDomainObjEnterMonitor(driver, vm); + + if (extensionDeviceAttached) + ignore_value(qemuDomainDetachExtensionDevice(priv->mon, &disk->inf= o)); + qemuBlockStorageSourceChainDetach(priv->mon, data); if (qemuDomainObjExitMonitor(driver, vm) < 0) --=20 2.31.1 From nobody Fri May 17 06:07:55 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1621601397; cv=none; d=zohomail.com; s=zohoarc; b=LCWMCaCMNwrGBkUlJM55nU1lGM16dNc2KhhI0OdiOMl1aEUQ4ZQRGdLH8aHwEDp5CYvy+/cMyiGLFZoLsajnSWqJLR6JwBWEwFOIrcck8U12Tydcc9v++U9KfBxS6IxjblaYPCcYAmSKnzsFVUDJ52HHd79pLzQJB201QCcssaw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601397; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eUvC+RnqQpC4EgKvW6jFZCkcKtm9mVpHZ/wFyjnR7tY=; b=YPzN5nWK3LoRT638y4hvQ1oQRwrqz/2uaIBKG5QjQ1Q7TNUzOcc3XuhreRtyKvZR421N0OwPRGy3/T5CJQprbG/VU9z3LgNaEQDYvcvz+jkpRraowxKe7WgwQjuHzCBb73KrVQYNUxkAqucWOEBJiYg4ieNwr4KjWfIry6OuOY8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass 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 1621601397848192.94211077203067; Fri, 21 May 2021 05:49:57 -0700 (PDT) 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-286-kLDNLckRNiCYtTKG4e6yUQ-1; Fri, 21 May 2021 08:48:33 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 71AA3107ACE6; Fri, 21 May 2021 12:48:28 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 50C4E5D9D5; Fri, 21 May 2021 12:48:28 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1A1E344A64; Fri, 21 May 2021 12:48:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LCmOCY031469 for ; Fri, 21 May 2021 08:48:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id B62155945B; Fri, 21 May 2021 12:48:24 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C0A0421F for ; Fri, 21 May 2021 12:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601396; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=eUvC+RnqQpC4EgKvW6jFZCkcKtm9mVpHZ/wFyjnR7tY=; b=UM/RYYS8ajz0IxcLKdf03yQqxDsPhBe4Hz4RHNHXQq8U2/EogqgtqDcxlTF3LTAZYd4VWR jnuX4TLXBtRYS3neA+41uwZ2bIAjQbWB2DECQMkGopOIlM/gJOeCe4DeMC27YuHdse9UNF 2VDHI5Il2BIpjVP3X7Bs2YOQ60kzPvU= X-MC-Unique: kLDNLckRNiCYtTKG4e6yUQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 28/35] qemuDomainAttachDiskGeneric: Split up frontend and backend attachment Date: Fri, 21 May 2021 14:47:28 +0200 Message-Id: <18ea7d57b548b7fa8eff74ae08729ff3eb84c35b.1621601161.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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.79 on 10.5.11.14 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Split up the monitor contexts to attach the backend of the disk and the frontend device in preparation for hotplugging transient disks where we'll need to add the code for adding the transient overlay between these two steps. Signed-off-by: Peter Krempa --- src/qemu/qemu_hotplug.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 3772c5b4b8..e13a739ade 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -723,15 +723,22 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, return -1; } - if (!(devstr =3D qemuBuildDiskDeviceStr(vm->def, disk, priv->qemuCaps)= )) - return -1; - qemuDomainObjEnterMonitor(driver, vm); rc =3D qemuBlockStorageSourceChainAttach(priv->mon, data); - if (rc =3D=3D 0 && - (rc =3D qemuDomainAttachExtensionDevice(priv->mon, &disk->info)) = =3D=3D 0) + if (qemuDomainObjExitMonitor(driver, vm) < 0) + return -2; + + if (rc < 0) + goto rollback; + + if (!(devstr =3D qemuBuildDiskDeviceStr(vm->def, disk, priv->qemuCaps)= )) + goto rollback; + + qemuDomainObjEnterMonitor(driver, vm); + + if ((rc =3D qemuDomainAttachExtensionDevice(priv->mon, &disk->info)) = =3D=3D 0) extensionDeviceAttached =3D true; if (rc =3D=3D 0) --=20 2.31.1 From nobody Fri May 17 06:07:55 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1621601322; cv=none; d=zohomail.com; s=zohoarc; b=L1fUo/YFumDWpa/jQWEEJoXvy0KyXxZmgYxTP6unhWYk88wTEu8/LxFl3MaKAQgxbhiPwYRvlo9vok5yRW/QmqSGdlIemigXSja3VhsdU6B9lrU7tb0+k2KxZjCeYfEeghOxA3O/T/IPh9mIpDYGsH5Ox7dZDthU/Ep3z5zrxtA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601322; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MrugLro1NazELu8mCc7L9mKzVNsrq2GNAGg6ciTXk2U=; b=BrcrzptMz3t1Yqx2NIAoLy46e0iweWX4BWqnQ0eyPTUrqiB1v0AdB6EFJjdP/ZQFmsCNZfpzZgdYbhUcEzZeB5iX7uLC8Rj9NAiA5G9jofHeV7xjgfRlmRIGNR2gsAQfzYorJ0I4Ul0joBXWq4zoau3QS2RJmLZl4ga4MskRers= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass 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 1621601322044968.2339878057219; Fri, 21 May 2021 05:48:42 -0700 (PDT) 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-559-lGxN2fAbPzyVcT3Pg9HuAg-1; Fri, 21 May 2021 08:48:38 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 78444107ACFE; Fri, 21 May 2021 12:48: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 59AB262467; Fri, 21 May 2021 12:48: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 292F91801028; Fri, 21 May 2021 12:48:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LCmPRL031504 for ; Fri, 21 May 2021 08:48:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id BBF6F421F; Fri, 21 May 2021 12:48:25 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2C32E5945B for ; Fri, 21 May 2021 12:48:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601321; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=MrugLro1NazELu8mCc7L9mKzVNsrq2GNAGg6ciTXk2U=; b=Uib1DmC5jvP4JFakHu30kiesX77iX6JQ8gZixpXBcHwv2uRXHa8XmOWuXgj6YbF6zRdv2K V4EqayUyG/h5CWOR4kk53Rz+JssOw2tqs1YxnFBAUPGBwE6gcHJD0JpbnMoeC1Db/zByOw kOkjTWQRaUXRgMK4ob6UL8h1M3nHfXU= X-MC-Unique: lGxN2fAbPzyVcT3Pg9HuAg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 29/35] qemu: Track creation of disk overlay individually Date: Fri, 21 May 2021 14:47:29 +0200 Message-Id: <35b543f458310716399efe98fdaca55b91660ff0.1621601161.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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.79 on 10.5.11.15 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" In preparation for hotplug of disks we'll need to track whether the overlay file was created individually per-disk. Add 'transientOverlayCreated' to 'struct _qemuDomainDiskPrivate' and remove 'inhibitDiskTransientDelete' from 'qemuDomainObjPrivate' and adjust the code for the change. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 2 -- src/qemu/qemu_domain.h | 7 +++---- src/qemu/qemu_process.c | 33 +++++++++++++++++++-------------- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 10641846b3..c5f994c4a5 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1880,8 +1880,6 @@ qemuDomainObjPrivateDataClear(qemuDomainObjPrivate *p= riv) g_slist_free_full(g_steal_pointer(&priv->dbusVMStateIds), g_free); priv->dbusVMState =3D false; - - priv->inhibitDiskTransientDelete =3D false; } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 4fc1969d9e..9cebf9e426 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -258,10 +258,6 @@ struct _qemuDomainObjPrivate { GSList *dbusVMStateIds; /* true if -object dbus-vmstate was added */ bool dbusVMState; - - /* prevent deletion of disk overlay files between startup = and - * successful setup of the overlays */ - bool inhibitDiskTransientDelete; }; #define QEMU_DOMAIN_PRIVATE(vm) \ @@ -292,6 +288,9 @@ struct _qemuDomainDiskPrivate { unsigned int effectiveBootindex; /* boot index of the disk based on one of the two ways we use to select a= boot device */ + + bool transientOverlayCreated; /* the overlay image of a transient disk= was + created and the definition was update= d */ }; #define QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src) \ diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 7fe051505b..9302180403 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5709,9 +5709,6 @@ qemuProcessInit(virQEMUDriver *driver, if (virDomainObjSetDefTransient(driver->xmlopt, vm, priv->qemuCaps) < = 0) goto cleanup; - /* don't clean up files for disks until we set them up */ - priv->inhibitDiskTransientDelete =3D true; - if (flags & VIR_QEMU_PROCESS_START_PRETEND) { if (qemuDomainSetPrivatePaths(driver, vm) < 0) { virDomainObjRemoveTransientDef(vm); @@ -7007,7 +7004,6 @@ static int qemuProcessSetupDisksTransientSnapshot(virDomainObj *vm, qemuDomainAsyncJob asyncJob) { - qemuDomainObjPrivate *priv =3D vm->privateData; g_autoptr(qemuSnapshotDiskContext) snapctxt =3D NULL; g_autoptr(GHashTable) blockNamedNodeData =3D NULL; size_t i; @@ -7039,8 +7035,14 @@ qemuProcessSetupDisksTransientSnapshot(virDomainObj = *vm, if (qemuSnapshotDiskCreate(snapctxt) < 0) return -1; - /* the overlays are established, so they can be deleted on shutdown */ - priv->inhibitDiskTransientDelete =3D false; + for (i =3D 0; i < vm->def->ndisks; i++) { + virDomainDiskDef *domdisk =3D vm->def->disks[i]; + + if (!domdisk->transient) + continue; + + QEMU_DOMAIN_DISK_PRIVATE(domdisk)->transientOverlayCreated =3D tru= e; + } return 0; } @@ -8077,7 +8079,7 @@ void qemuProcessStop(virQEMUDriver *driver, /* for now transient disks are forbidden with migration so they * can be handled here */ if (disk->transient && - !priv->inhibitDiskTransientDelete) { + QEMU_DOMAIN_DISK_PRIVATE(disk)->transientOverlayCreated) { VIR_DEBUG("Removing transient overlay '%s' of disk '%s'", disk->src->path, disk->dst); if (qemuDomainStorageFileInit(driver, vm, disk->src, NULL)= >=3D 0) { @@ -8505,10 +8507,6 @@ qemuProcessReconnect(void *opaque) if (oldjob.asyncJob =3D=3D QEMU_ASYNC_JOB_BACKUP && priv->backup) priv->backup->apiFlags =3D oldjob.apiFlags; - /* expect that libvirt might have crashed during VM start, so prevent - * cleanup of transient disks */ - priv->inhibitDiskTransientDelete =3D true; - if (qemuDomainObjBeginJob(driver, obj, QEMU_JOB_MODIFY) < 0) goto error; jobStarted =3D true; @@ -8611,9 +8609,6 @@ qemuProcessReconnect(void *opaque) goto error; } - /* vm startup complete, we can remove transient disks if required */ - priv->inhibitDiskTransientDelete =3D false; - /* In case the domain shutdown while we were not running, * we need to finish the shutdown process. And we need to do it after * we have virQEMUCaps filled in. @@ -8662,6 +8657,16 @@ qemuProcessReconnect(void *opaque) if (qemuProcessRefreshDisks(driver, obj, QEMU_ASYNC_JOB_NONE) < 0) goto error; + /* At this point we've already checked that the startup of the VM was + * completed successfully before, thus that also implies that all tran= sient + * disk overlays were created. */ + for (i =3D 0; i < obj->def->ndisks; i++) { + virDomainDiskDef *disk =3D obj->def->disks[i]; + + if (disk->transient) + QEMU_DOMAIN_DISK_PRIVATE(disk)->transientOverlayCreated =3D tr= ue; + } + if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV) && qemuBlockNodeNamesDetect(driver, obj, QEMU_ASYNC_JOB_NONE) < 0) goto error; --=20 2.31.1 From nobody Fri May 17 06:07:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1621601425; cv=none; d=zohomail.com; s=zohoarc; b=i/jJLXsOPM1OlplPPDhJvMZOXL+5cXRRptlJYx9V09ly6tzBbX39FTyQdju87eDKWhuawjLMUToEb8z45Ctpt4arBIDbfbW9sUlZALbo7Qh/LNeNeY/BR0QGd67CSHNjU0/vbyXxaxCcdGY2x4deLnXFXJiaJlUwlcBWe2XORMU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601425; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=h89YmQSYNMpMKSGJWmGzFDkDHrq7bC+i5+LyWi8INJQ=; b=MaB00/TAvhAi4Nr1/i8vfoe99Bi3llfZlirAUlV2BE1PJOcsj8POnM+A8Ka6/iwnABBCN+Th3mAjLx1H/E7AyeizopT3fXtI9rC6OmyreC0wE1KjdJ4uSSHiXQErpt6jwc5Irze5Jg/EDH2LSyMr7AEzB/0Cegog6LAjLeLoNlg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 162160142568191.58599920094571; Fri, 21 May 2021 05:50:25 -0700 (PDT) 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-547-SyxbtEsZOyi6i6jmR9QbCw-1; Fri, 21 May 2021 08:48:36 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id BEB498A9F51; Fri, 21 May 2021 12:48:29 +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 961D75D9D5; Fri, 21 May 2021 12:48:29 +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 2EADE1804480; Fri, 21 May 2021 12:48:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LCmQwc031548 for ; Fri, 21 May 2021 08:48:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id C12B95945B; Fri, 21 May 2021 12:48:26 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 276AE421F for ; Fri, 21 May 2021 12:48:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601424; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=h89YmQSYNMpMKSGJWmGzFDkDHrq7bC+i5+LyWi8INJQ=; b=HEtB9VerhSsNpTVB/s2alzNHmKPXvfCNNKJvAqTO1eEOSZHdwIdDQ1ddlAqzXR7cHjfFkj sudOSUTcDkbbCEQVXUoINBgs5BkV3j+LKKIsNTToH4bSMZ2PGOXpW3S9qx6ECuDx8TqFPb iMjDjLC/BTV0xbhJpJ+YLTHUzrA/h0s= X-MC-Unique: SyxbtEsZOyi6i6jmR9QbCw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 30/35] qemuDomainAttachDiskGeneric: Implement hotplug of disk Date: Fri, 21 May 2021 14:47:30 +0200 Message-Id: <9178c5c24feed0d03e79035420f44fcdbf283918.1621601161.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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.79 on 10.5.11.14 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Add code which creates the transient overlay after hotplugging the disk backend before attaching the disk frontend. The state of the topmost image is modified to be already read-only to prevent the need to open the image in read-write mode. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 52 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index e13a739ade..59832ea2b3 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -34,6 +34,7 @@ #include "qemu_process.h" #include "qemu_security.h" #include "qemu_block.h" +#include "qemu_snapshot.h" #include "domain_audit.h" #include "netdev_bandwidth_conf.h" #include "domain_nwfilter.h" @@ -685,6 +686,25 @@ qemuDomainChangeEjectableMedia(virQEMUDriver *driver, } +static qemuSnapshotDiskContext * +qemuDomainAttachDiskGenericTransient(virDomainObj *vm, + virDomainDiskDef *disk, + GHashTable *blockNamedNodeData) +{ + g_autoptr(qemuSnapshotDiskContext) snapctxt =3D NULL; + g_autoptr(virDomainSnapshotDiskDef) snapdiskdef =3D NULL; + + snapdiskdef =3D qemuSnapshotGetTransientDiskDef(disk, vm->def->name); + snapctxt =3D qemuSnapshotDiskContextNew(1, vm, QEMU_ASYNC_JOB_NONE); + + if (qemuSnapshotDiskPrepareOne(snapctxt, disk, snapdiskdef, + blockNamedNodeData, false, false) < 0) + return NULL; + + return g_steal_pointer(&snapctxt); +} + + /** * qemuDomainAttachDiskGeneric: * @@ -701,6 +721,11 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, bool blockdev =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); bool extensionDeviceAttached =3D false; int rc; + g_autoptr(qemuSnapshotDiskContext) transientDiskSnapshotCtxt =3D NULL; + bool origReadonly =3D disk->src->readonly; + + if (disk->transient) + disk->src->readonly =3D true; if (virStorageSourceGetActualType(disk->src) =3D=3D VIR_STORAGE_TYPE_V= HOST_USER) { if (!(data =3D qemuBuildStorageSourceChainAttachPrepareChardev(dis= k))) @@ -723,6 +748,8 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, return -1; } + disk->src->readonly =3D origReadonly; + qemuDomainObjEnterMonitor(driver, vm); rc =3D qemuBlockStorageSourceChainAttach(priv->mon, data); @@ -733,6 +760,25 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, if (rc < 0) goto rollback; + if (disk->transient) { + g_autoptr(qemuBlockStorageSourceAttachData) backend =3D NULL; + g_autoptr(GHashTable) blockNamedNodeData =3D NULL; + + if (!(blockNamedNodeData =3D qemuBlockGetNamedNodeData(vm, QEMU_AS= YNC_JOB_NONE))) + goto rollback; + + if (!(transientDiskSnapshotCtxt =3D qemuDomainAttachDiskGenericTra= nsient(vm, disk, blockNamedNodeData))) + goto rollback; + + + if (qemuSnapshotDiskCreate(transientDiskSnapshotCtxt) < 0) + goto rollback; + + QEMU_DOMAIN_DISK_PRIVATE(disk)->transientOverlayCreated =3D true; + backend =3D qemuBlockStorageSourceDetachPrepare(disk->src, NULL); + ignore_value(VIR_INSERT_ELEMENT(data->srcdata, 0, data->nsrcdata, = backend)); + } + if (!(devstr =3D qemuBuildDiskDeviceStr(vm->def, disk, priv->qemuCaps)= )) goto rollback; @@ -937,12 +983,6 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *= driver, return -1; } - if (disk->transient) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("transient disk hotplug isn't supported")); - return -1; - } - if (virDomainDiskTranslateSourcePool(disk) < 0) goto cleanup; --=20 2.31.1 From nobody Fri May 17 06:07:55 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1621601463; cv=none; d=zohomail.com; s=zohoarc; b=IPpwvtLwBy2CLJnwJ/MHIGCGQzgrzhgAgooFDBWDxh/l/Tblkp9pCHH5Cy3EeSl0lMUOky0Kbrci7qNE7xpbLAJcf80TnzthwQhHc2DON6RuPEZpiBmsMTpSSgsdL658gcJkyolgcTaj/5utainZaUwdivl9BwiH569jtiG7ViM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601463; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=oGFxr0Jr6VMyGSg0T9wFgum/EfZpyeigrELPrA93LB4=; b=YptZgQD40ipUxL29gwqyR8Rg6mxd938kevNnwV3aNUDyCgqTdsvxQp+dNRKr0bCrXa+hwPfgv1P5m/T/R2o+h6zc69mgi/MoN2hdWuBA01vpDQNz1b5GQHZR/T2mYyUbodENvG14JsXqLXRSk8FwBuA+he8FQ11BQwBRdYw2kVw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass 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 1621601463644687.0698965595038; Fri, 21 May 2021 05:51:03 -0700 (PDT) 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-579-er6_NBP4OlGUYBaNiyW04A-1; Fri, 21 May 2021 08:48:39 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 42EE9A40EC; Fri, 21 May 2021 12:48:32 +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 26F8362677; Fri, 21 May 2021 12:48:32 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E4EED44A64; Fri, 21 May 2021 12:48:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LCmR0i031570 for ; Fri, 21 May 2021 08:48:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id C637C5945B; Fri, 21 May 2021 12:48:27 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2CDB4421F for ; Fri, 21 May 2021 12:48:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601462; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=oGFxr0Jr6VMyGSg0T9wFgum/EfZpyeigrELPrA93LB4=; b=Ns1a99M6tpOM9meL+HiC55Zaxvdi9tseyqPNuSptWffmSv6UX9//4TFDS3AnbkIBKT9NLD EHkox7/EI6AavdSjXUtdclyuglF/G8h19BHbZ4hx0hz68E9BOn/eNJgCFSuBxFGUpkzzCW LA6PMnXrvQJZFHRaC1FKoRNlOgpYGnw= X-MC-Unique: er6_NBP4OlGUYBaNiyW04A-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 31/35] qemuDomainAttachDiskGeneric: Pass the qemu async job type Date: Fri, 21 May 2021 14:47:31 +0200 Message-Id: <163e1e26816a26e9970e9c6aca1cf05d953e1f75.1621601161.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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.79 on 10.5.11.15 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The qemuDomainAttachDiskGeneric will also be used on startup for transient disks which share the overlay. The VM startup code passes the asyncJob around so we need to pass it into qemuDomainAttachDiskGeneric. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 59832ea2b3..03649634c5 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -689,13 +689,14 @@ qemuDomainChangeEjectableMedia(virQEMUDriver *driver, static qemuSnapshotDiskContext * qemuDomainAttachDiskGenericTransient(virDomainObj *vm, virDomainDiskDef *disk, - GHashTable *blockNamedNodeData) + GHashTable *blockNamedNodeData, + qemuDomainAsyncJob asyncJob) { g_autoptr(qemuSnapshotDiskContext) snapctxt =3D NULL; g_autoptr(virDomainSnapshotDiskDef) snapdiskdef =3D NULL; snapdiskdef =3D qemuSnapshotGetTransientDiskDef(disk, vm->def->name); - snapctxt =3D qemuSnapshotDiskContextNew(1, vm, QEMU_ASYNC_JOB_NONE); + snapctxt =3D qemuSnapshotDiskContextNew(1, vm, asyncJob); if (qemuSnapshotDiskPrepareOne(snapctxt, disk, snapdiskdef, blockNamedNodeData, false, false) < 0) @@ -713,7 +714,8 @@ qemuDomainAttachDiskGenericTransient(virDomainObj *vm, static int qemuDomainAttachDiskGeneric(virQEMUDriver *driver, virDomainObj *vm, - virDomainDiskDef *disk) + virDomainDiskDef *disk, + qemuDomainAsyncJob asyncJob) { g_autoptr(qemuBlockStorageSourceChainData) data =3D NULL; qemuDomainObjPrivate *priv =3D vm->privateData; @@ -750,7 +752,8 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, disk->src->readonly =3D origReadonly; - qemuDomainObjEnterMonitor(driver, vm); + if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) + return -1; rc =3D qemuBlockStorageSourceChainAttach(priv->mon, data); @@ -764,10 +767,10 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, g_autoptr(qemuBlockStorageSourceAttachData) backend =3D NULL; g_autoptr(GHashTable) blockNamedNodeData =3D NULL; - if (!(blockNamedNodeData =3D qemuBlockGetNamedNodeData(vm, QEMU_AS= YNC_JOB_NONE))) + if (!(blockNamedNodeData =3D qemuBlockGetNamedNodeData(vm, asyncJo= b))) goto rollback; - if (!(transientDiskSnapshotCtxt =3D qemuDomainAttachDiskGenericTra= nsient(vm, disk, blockNamedNodeData))) + if (!(transientDiskSnapshotCtxt =3D qemuDomainAttachDiskGenericTra= nsient(vm, disk, blockNamedNodeData, asyncJob))) goto rollback; @@ -782,7 +785,8 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, if (!(devstr =3D qemuBuildDiskDeviceStr(vm->def, disk, priv->qemuCaps)= )) goto rollback; - qemuDomainObjEnterMonitor(driver, vm); + if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) + goto rollback; if ((rc =3D qemuDomainAttachExtensionDevice(priv->mon, &disk->info)) = =3D=3D 0) extensionDeviceAttached =3D true; @@ -814,7 +818,8 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, return 0; rollback: - qemuDomainObjEnterMonitor(driver, vm); + if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) + return -1; if (extensionDeviceAttached) ignore_value(qemuDomainDetachExtensionDevice(priv->mon, &disk->inf= o)); @@ -1077,7 +1082,7 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver = *driver, if (qemuHotplugAttachManagedPR(driver, vm, disk->src, QEMU_ASYNC_JOB_N= ONE) < 0) goto cleanup; - ret =3D qemuDomainAttachDiskGeneric(driver, vm, disk); + ret =3D qemuDomainAttachDiskGeneric(driver, vm, disk, QEMU_ASYNC_JOB_N= ONE); virDomainAuditDisk(vm, NULL, disk->src, "attach", ret =3D=3D 0); --=20 2.31.1 From nobody Fri May 17 06:07:55 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1621601414; cv=none; d=zohomail.com; s=zohoarc; b=WQiQuuiPWznbg7PbAy/LpXhqOck//F8WAexdrV8xk4ISqG9gtg8dblnZIMLOgf0kjXxQVA1xgJuvNF+ccPmnly/YsdwcuY0ZbFRVWveRZb+8ch3gJpn2gk7KmSTrke0t9M9sV8/GKzoPmh9sGsqYOm6SSqeEjcTEyKQhCngb9Ho= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601414; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IQeew1wonIxAvpSsLruhHiO8SN/Qpa7ws49aIw+SIRw=; b=NvWhq5nOozOs0BfyZZ+mVz8ok3df+AWp6+gsME6k7izCOkLuroExycSnG4JXO205j2GDZxm+Eo9im12mBkTZ8Z2OR06IItIvoLs92vQLTKJB/ASb7tsAVCi02b44j+8tTPOXGBuDMjmW09URi99GTxAqh5z4CcYnM/4NWnu8l7g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass 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 1621601414205301.2097513573798; Fri, 21 May 2021 05:50:14 -0700 (PDT) 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-294-5HUsBPJ8Ol2iwR1oDdcFnw-1; Fri, 21 May 2021 08:48:40 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id D97A08A9F65; Fri, 21 May 2021 12:48:33 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B91E3610B0; Fri, 21 May 2021 12:48:33 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8216D44A66; Fri, 21 May 2021 12:48:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LCmSGF031611 for ; Fri, 21 May 2021 08:48:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id D090F5945B; Fri, 21 May 2021 12:48:28 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F9A1421F for ; Fri, 21 May 2021 12:48:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601413; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=IQeew1wonIxAvpSsLruhHiO8SN/Qpa7ws49aIw+SIRw=; b=OHX/8+as69jGyVXiSwy2+HS5o5b3bErEzNemyPSbzrZIcfrzJnwBQXVoJZbRx0Opicyfe9 7rGFiHd3aif95WwviKzC5ub+eL1ScI9bsaabsAzxunWNQn1/Ap6t9lCswEDxjWk1EW3Ppv VuuElAszHE14mMtI2S4OAFZogCtPzuE= X-MC-Unique: 5HUsBPJ8Ol2iwR1oDdcFnw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 32/35] qemuDomainAttachDiskGeneric: Export Date: Fri, 21 May 2021 14:47:32 +0200 Message-Id: <1441abd59f058ab70730f197147dd2488b6581ac.1621601161.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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.79 on 10.5.11.12 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 2 +- src/qemu/qemu_hotplug.h | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 03649634c5..b91cab08ac 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -711,7 +711,7 @@ qemuDomainAttachDiskGenericTransient(virDomainObj *vm, * * Attaches disk to a VM. This function aggregates common code for all bus= types. * In cases when the VM crashed while adding the disk, -2 is returned. */ -static int +int qemuDomainAttachDiskGeneric(virQEMUDriver *driver, virDomainObj *vm, virDomainDiskDef *disk, diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h index df8f76f8d6..b5f7afb076 100644 --- a/src/qemu/qemu_hotplug.h +++ b/src/qemu/qemu_hotplug.h @@ -58,6 +58,12 @@ int qemuDomainAttachControllerDevice(virQEMUDriver *driv= er, int qemuDomainAttachDeviceDiskLive(virQEMUDriver *driver, virDomainObj *vm, virDomainDeviceDef *dev); + +int qemuDomainAttachDiskGeneric(virQEMUDriver *driver, + virDomainObj *vm, + virDomainDiskDef *disk, + qemuDomainAsyncJob asyncJob); + int qemuDomainAttachNetDevice(virQEMUDriver *driver, virDomainObj *vm, virDomainNetDef *net); --=20 2.31.1 From nobody Fri May 17 06:07:55 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; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1621601361; cv=none; d=zohomail.com; s=zohoarc; b=mBLv+B6qP4cPfbLWMyeAtAtdZbNFld9LvbJkHJQBJubRaSa+Q2L88RgHd4AA3iFTdTxU0WGn92t43hKBEpaerGzR1yk1D8A5mErXUFx4zgti8dXTrdauRI51m8qd4BhL8myGYjBqJCwhy1NBKKaK7H6X+A6NNhjqElPFeI0Bm34= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601361; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yikEl7dRkusD8MLyD6FFNQqYyRLu9pkndEOOPXc3nzs=; b=AEWeMZoi4bXDicv+8KofOGlcB0EvIjgQfE0G4HWS/30kK//DsqikyScnOVcawUnXqSGJjLG7UHkm9RxRN+WZchkeXYl6WqXqCgewxUwYd2uO/J0mUII53j3uUkXVJNSzJuXfmToe1cJAx2Xx0oW8/GjKoW3SrAEYQUWOukJpq5w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass 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 1621601361028285.09306782973067; Fri, 21 May 2021 05:49:21 -0700 (PDT) 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-589-3XuZR_H_PjanP6iqocHaYQ-1; Fri, 21 May 2021 08:48:38 -0400 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 52215102621D; Fri, 21 May 2021 12:48:32 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CB3471037F21; Fri, 21 May 2021 12:48: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 8341C1801264; Fri, 21 May 2021 12:48:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LCmTMH031629 for ; Fri, 21 May 2021 08:48:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id DF5EF421F; Fri, 21 May 2021 12:48:29 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E5D469FB4 for ; Fri, 21 May 2021 12:48:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601360; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=yikEl7dRkusD8MLyD6FFNQqYyRLu9pkndEOOPXc3nzs=; b=Q5n+OzeYgQ7jdAUiybict1bgEyoibeSxhWkRaIjKDMPggcQClDRH46e7/bXxds9Xu+7Tx2 s8JRkbd09Jt18JbROtaGuTb+qhh57K63oPrGyQKXdBfcdreEyKitGwMmaHn3kjeOUe8zub M57Zos0Bx98GNGR8mAr21OcUoMUEHcA= X-MC-Unique: 3XuZR_H_PjanP6iqocHaYQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 33/35] conf: Introduce 'shareBacking' for disks Date: Fri, 21 May 2021 14:47:33 +0200 Message-Id: <0056798b29b9f8a49c0cc2c57c1033ea24673bda.1621601161.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" In case the user wants to share the disk image between multiple VMs the qemu driver needs to hotplug such disks to instantiate the backends. Since that doesn't work for all disk configs add a switch to force this behaviour. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- docs/formatdomain.rst | 6 ++++++ docs/schemas/domaincommon.rng | 5 +++++ src/conf/domain_conf.c | 17 ++++++++++++++--- src/conf/domain_conf.h | 1 + 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index fa5c14febc..61fa520965 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -3135,6 +3135,12 @@ paravirtualized driver is specified via the ``disk``= element. disk transient prevents the domain from participating in migration, snapshots, or blockjobs. Only supported in vmx hypervisor (:since:`Since 0.9.5`) and ``qemu`` hypervisor (:since:`Since 6.9.0`). + + In cases where the source image of the ```` disk is suppose= d to + be shared between multiple concurrently running VMs the optional + ``shareBacking`` attribute should be set to ``yes``. Note that hypervis= or + drivers may need to hotplug such disk and thus it works only with + configurations supporting hotplug. :since:`Since 7.4.0` ``serial`` If present, this specify serial number of virtual hard drive. For examp= le, it may look like ``WD-WMAP9A966149``. Not supported for diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index a2e5c50c1d..e476eca250 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1429,6 +1429,11 @@ + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4ec6484b78..749c07b2c1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9038,6 +9038,7 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, xmlNodePtr blockioNode; xmlNodePtr driverNode; xmlNodePtr mirrorNode; + xmlNodePtr transientNode; g_autoptr(virStorageSource) src =3D NULL; if (!(src =3D virDomainDiskDefParseSourceXML(xmlopt, node, ctxt, flags= ))) @@ -9146,9 +9147,15 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, } } - if (virXPathNode("./transient", ctxt)) + if ((transientNode =3D virXPathNode("./transient", ctxt))) { def->transient =3D true; + if (virXMLPropTristateBool(transientNode, "shareBacking", + VIR_XML_PROP_NONE, + &def->transientShareBacking) < 0) + return NULL; + } + if (virDomainDiskDefIotuneParse(def, ctxt) < 0) return NULL; @@ -23540,8 +23547,12 @@ virDomainDiskDefFormat(virBuffer *buf, virBufferAddLit(buf, "\n"); if (def->src->shared) virBufferAddLit(buf, "\n"); - if (def->transient) - virBufferAddLit(buf, "\n"); + if (def->transient) { + virBufferAddLit(buf, "transientShareBacking =3D=3D VIR_TRISTATE_BOOL_YES) + virBufferAddLit(buf, " shareBacking=3D'yes'"); + virBufferAddLit(buf, "/>\n"); + } virBufferEscapeString(buf, "%s\n", def->serial); virBufferEscapeString(buf, "%s\n", def->wwn); virBufferEscapeString(buf, "%s\n", def->vendor); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index a0855d816e..34420f0a10 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -575,6 +575,7 @@ struct _virDomainDiskDef { unsigned int snapshot; /* virDomainSnapshotLocation, snapshot_conf.h */ virDomainStartupPolicy startupPolicy; bool transient; + virTristateBool transientShareBacking; virDomainDeviceInfo info; virTristateBool rawio; virDomainDeviceSGIO sgio; --=20 2.31.1 From nobody Fri May 17 06:07:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1621601323; cv=none; d=zohomail.com; s=zohoarc; b=XRTZW9xmMrtnXxMytAtu8lF6FUNaMFliOVo2hSqcL7AmRHqKVNPFzuofAQ54QME70S7hN3QfonAzcK68z/fcZ+RanG75fbFvNUVDH/1RQxD+ju2NdrMJHb7kWp09cGUYM7jCNzJy9BlWgjGRpU7e73MKbaXJCv8NSi0E9NS83pY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601323; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8arLAWkecMQTJ/68qjj881hIrAOGWrXTAkkC7GhUuwI=; b=ISCBi3INrRM29w3jf3Pc4FmdpNRnw6J+4W14Jx7gDljfdCog8Lawjogyaa+ijZMrlhaCI27TC0F78diiBCuTJws45Mln8TBeFFgprqdYBS8rZLTQttY/dOcI7nf90bg0qmo9UJplfU4mhzY0wVcpjP82UWQ8z0NvvTK5Rmiyj40= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1621601323156899.3119940177666; Fri, 21 May 2021 05:48:43 -0700 (PDT) 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-518-HTUHjKkdOrG6vzoG5tFEsA-1; Fri, 21 May 2021 08:48:40 -0400 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 9D09319253C5; Fri, 21 May 2021 12:48:34 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2AE9110027A5; Fri, 21 May 2021 12:48:34 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E9F0E1801263; Fri, 21 May 2021 12:48:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LCmUMS031648 for ; Fri, 21 May 2021 08:48:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id E866C5945B; Fri, 21 May 2021 12:48:30 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 57399421F for ; Fri, 21 May 2021 12:48:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601322; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=8arLAWkecMQTJ/68qjj881hIrAOGWrXTAkkC7GhUuwI=; b=RZlklh42QtdkBI5BDOZ90e1tVXYbd3NiEGcD/OWlKXVjgs9CqHnckKQWeu1He8lO/1g3cY dkSREGcaR7NoWaTcT0AuEghSJLLHVnMz0A2LIQO1Uo4Bw7hZnyQ8fiv2e63c5QbJIs7lcY rYcczvOJbPSFUut1IWwraY49wzR0h7s= X-MC-Unique: HTUHjKkdOrG6vzoG5tFEsA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 34/35] qemu: Allow disks with images shared accross VMs Date: Fri, 21 May 2021 14:47:34 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Implement this behaviour by skipping the disks on traditional commandline and hotplug them before resuming CPUs. That allows to use the support for hotplugging of transient disks which inherently allows sharing of the backing image as we open it read-only. This commit implements the validation code to allow it only with buses supporting hotplug and the hotplug code while starting up the VM. When we have such disk we need to issue a system-reset so that firmware tables are regenerated to allow booting from such device. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 6 ++++++ src/qemu/qemu_process.c | 45 +++++++++++++++++++++++++++++++++++++++- src/qemu/qemu_validate.c | 24 +++++++++++++++++++++ 3 files changed, 74 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 9c32fd16b5..697324eea5 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2164,6 +2164,12 @@ qemuBuildDisksCommandLine(virCommand *cmd, for (i =3D 0; i < def->ndisks; i++) { virDomainDiskDef *disk =3D def->disks[i]; + /* transient disks with shared backing image will be hotplugged af= ter + * the VM is started */ + if (disk->transient && + disk->transientShareBacking =3D=3D VIR_TRISTATE_BOOL_YES) + continue; + if (qemuBuildDiskCommandLine(cmd, def, disk, qemuCaps) < 0) return -1; } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 9302180403..c0b4f3530f 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7017,7 +7017,8 @@ qemuProcessSetupDisksTransientSnapshot(virDomainObj *= vm, virDomainDiskDef *domdisk =3D vm->def->disks[i]; g_autoptr(virDomainSnapshotDiskDef) snapdisk =3D NULL; - if (!domdisk->transient) + if (!domdisk->transient || + domdisk->transientShareBacking =3D=3D VIR_TRISTATE_BOOL_YES) continue; /* validation code makes sure that we do this only for local disks @@ -7048,6 +7049,45 @@ qemuProcessSetupDisksTransientSnapshot(virDomainObj = *vm, } +static int +qemuProcessSetupDisksTransientHotplug(virDomainObj *vm, + qemuDomainAsyncJob asyncJob) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + bool hasHotpluggedDisk =3D false; + size_t i; + + for (i =3D 0; i < vm->def->ndisks; i++) { + virDomainDiskDef *domdisk =3D vm->def->disks[i]; + + if (!domdisk->transient || + domdisk->transientShareBacking !=3D VIR_TRISTATE_BOOL_YES) + continue; + + if (qemuDomainAttachDiskGeneric(priv->driver, vm, domdisk, asyncJo= b) < 0) + return -1; + + hasHotpluggedDisk =3D true; + } + + /* in order to allow booting from such disks we need to issue a system= -reset + * so that the firmware tables recording bootable devices are regerate= d */ + if (hasHotpluggedDisk) { + int rc; + + if (qemuDomainObjEnterMonitorAsync(priv->driver, vm, asyncJob) < 0) + return -1; + + rc =3D qemuMonitorSystemReset(priv->mon); + + if (qemuDomainObjExitMonitor(priv->driver, vm) < 0 || rc < 0) + return -1; + } + + return 0; +} + + static int qemuProcessSetupDisksTransient(virDomainObj *vm, qemuDomainAsyncJob asyncJob) @@ -7060,6 +7100,9 @@ qemuProcessSetupDisksTransient(virDomainObj *vm, if (qemuProcessSetupDisksTransientSnapshot(vm, asyncJob) < 0) return -1; + if (qemuProcessSetupDisksTransientHotplug(vm, asyncJob) < 0) + return -1; + return 0; } diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 9c74092f23..6d6bca859b 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2980,6 +2980,30 @@ qemuValidateDomainDeviceDefDiskTransient(const virDo= mainDiskDef *disk, return -1; } + if (disk->transientShareBacking =3D=3D VIR_TRISTATE_BOOL_YES) { + /* sharing the backing file requires hotplug of the disk in the qe= mu driver */ + switch (disk->bus) { + case VIR_DOMAIN_DISK_BUS_USB: + case VIR_DOMAIN_DISK_BUS_VIRTIO: + case VIR_DOMAIN_DISK_BUS_SCSI: + break; + + case VIR_DOMAIN_DISK_BUS_IDE: + case VIR_DOMAIN_DISK_BUS_FDC: + case VIR_DOMAIN_DISK_BUS_XEN: + case VIR_DOMAIN_DISK_BUS_UML: + case VIR_DOMAIN_DISK_BUS_SATA: + case VIR_DOMAIN_DISK_BUS_SD: + case VIR_DOMAIN_DISK_BUS_NONE: + case VIR_DOMAIN_DISK_BUS_LAST: + default: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("disk bus '%s' doesn't support transiend disk= backing image sharing"), + virDomainDiskBusTypeToString(disk->bus)); + return -1; + } + } + return 0; } --=20 2.31.1 From nobody Fri May 17 06:07:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1621601325; cv=none; d=zohomail.com; s=zohoarc; b=KyfJ/+XO1GKQcxUvApLyBlxv88gneY3O2TMzuDB5DdjfaPFEx9ygyEaxc69fqWyap7+eceokEfn0rQ8uitoJKocEhDgX1duGuUx0APKuYuxuPIRRZZmOmBJuKjauqm7wXUShBbVNLsqgSPgWG/1ICS21TBwcw1/GsMBKK17eOko= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621601325; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=z917S2L/ygbAYRAasJFKfc1t4WauRVuVz62aef12AB4=; b=SGtHn+WAzAXCmAB60d9gxjzBH3b8+JyR+B++aKdJQIzqP8ro/PSUxoygkJAOn9nwxFMRWn66wjw/5xaAWZWYw7v/jVUDaQH/C7iYpqvRVXioE5L0d1Fh3x4d9FbHYoL8wlU849emGeeDT0DWiTeiti5IBLxNtyt334YQ11CIeio= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1621601325385656.9460151509913; Fri, 21 May 2021 05:48:45 -0700 (PDT) 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-568-CEq5mIBMPseHCxfCkIc31A-1; Fri, 21 May 2021 08:48:42 -0400 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 2B698BBEFD; Fri, 21 May 2021 12:48:35 +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 E6F9D10027A5; Fri, 21 May 2021 12:48:34 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id AC3CE18095C4; Fri, 21 May 2021 12:48:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14LCmWbL031689 for ; Fri, 21 May 2021 08:48:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id F3D765945B; Fri, 21 May 2021 12:48:31 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A035421F for ; Fri, 21 May 2021 12:48:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621601324; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=z917S2L/ygbAYRAasJFKfc1t4WauRVuVz62aef12AB4=; b=LMfwbq/MKuDABWaXcmw638XtB+sUpFdRir0mVi/QNF1rHFsSP+FSoVE6ONRw9LeV7g/CIA YF9StME0AsSJnom+XrWs3INPEYeFEzkcLKdPUO0ei4XMiMn70WR53hEkLA+iuC8mIqKwUh BB5xbedUezP5BXI/Q339xjqeKTwp8es= X-MC-Unique: CEq5mIBMPseHCxfCkIc31A-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 35/35] tests: Add qemuxml2argv and qemuxml2xml test for Date: Fri, 21 May 2021 14:47:35 +0200 Message-Id: <1f980efd46192531128e0bc8a892654480489cf3.1621601161.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- .../disk-transient.x86_64-4.1.0.err | 2 +- .../disk-transient.x86_64-latest.args | 4 +- tests/qemuxml2argvdata/disk-transient.xml | 6 +++ .../disk-transient.x86_64-latest.xml | 48 +++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 5 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 tests/qemuxml2xmloutdata/disk-transient.x86_64-latest.x= ml diff --git a/tests/qemuxml2argvdata/disk-transient.x86_64-4.1.0.err b/tests= /qemuxml2argvdata/disk-transient.x86_64-4.1.0.err index eb5af4762d..493da051e3 100644 --- a/tests/qemuxml2argvdata/disk-transient.x86_64-4.1.0.err +++ b/tests/qemuxml2argvdata/disk-transient.x86_64-4.1.0.err @@ -1 +1 @@ -unsupported configuration: transient disk not supported by this QEMU binar= y (hda) +unsupported configuration: transient disk not supported by this QEMU binar= y (vda) diff --git a/tests/qemuxml2argvdata/disk-transient.x86_64-latest.args b/tes= ts/qemuxml2argvdata/disk-transient.x86_64-latest.args index 41f6400891..18f16c3489 100644 --- a/tests/qemuxml2argvdata/disk-transient.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-transient.x86_64-latest.args @@ -29,8 +29,8 @@ XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ -device piix3-usb-uhci,id=3Dusb,bus=3Dpci.0,addr=3D0x1.0x2 \ -blockdev '{"driver":"file","filename":"/tmp/QEMUGuest1.img","node-name":"= libvirt-1-storage","cache":{"direct":true,"no-flush":false},"auto-read-only= ":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"cache":{"dir= ect":true,"no-flush":false},"driver":"qcow2","file":"libvirt-1-storage"}' \ --device ide-hd,bus=3Dide.0,unit=3D0,drive=3Dlibvirt-1-format,id=3Dide0-0-0= ,bootindex=3D1,write-cache=3Don \ +-device ide-hd,bus=3Dide.0,unit=3D0,drive=3Dlibvirt-1-format,id=3Dide0-0-0= ,write-cache=3Don \ -audiodev id=3Daudio1,driver=3Dnone \ --device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x2 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ -msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/disk-transient.xml b/tests/qemuxml2argv= data/disk-transient.xml index cffb325336..49613a88b2 100644 --- a/tests/qemuxml2argvdata/disk-transient.xml +++ b/tests/qemuxml2argvdata/disk-transient.xml @@ -14,6 +14,12 @@ destroy /usr/bin/qemu-system-i386 + + + + + + diff --git a/tests/qemuxml2xmloutdata/disk-transient.x86_64-latest.xml b/te= sts/qemuxml2xmloutdata/disk-transient.x86_64-latest.xml new file mode 100644 index 0000000000..988706002d --- /dev/null +++ b/tests/qemuxml2xmloutdata/disk-transient.x86_64-latest.xml @@ -0,0 +1,48 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + qemu64 + + + destroy + restart + destroy + + /usr/bin/qemu-system-i386 + + + + + +
+ + + + + + +
+ + +
+ + +
+ + + + +