From nobody Fri May 10 16:14:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1698326130; cv=none; d=zohomail.com; s=zohoarc; b=bXqyCgbTCjw4j/Y6uhvuqb1BlXz6rIXUE2ukMc9xMkd6WC7JC6nMGVIeiqv2XCi+0WQJlR5prCjmz/uGNMIB6lIJWoyvF0BAO75+3AJCSvbf4OX42dtUXRuPZ0UY5mQJ0aiygoYGDfuyLndULMWTgJqyyICbe+tVfKgYdcF7Qag= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698326130; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=sbVUlLyiOscBwDEQM8BDjMPzsQwz9z0q0ISUfiegXNM=; b=lEWNfhw4TDrH6cbQHSU0e/5eCaIiUx1yNFbMzmNiexC9UVUZSxgFJumvNgZT6p8mM+OfT2smpS57lJOVb6YOddntBfcPK0ffJgoVlO9UyPA02aA9H+dv+P3IuJQU+/Q+NGC4MvZ5wEH1lhcOcjNVcQw4SP3Auer7aK4GCmwUe1Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 16983261306581005.3059386266319; Thu, 26 Oct 2023 06:15:30 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-111-amcLA5fcOrO2kyD8_W1liA-1; Thu, 26 Oct 2023 09:15:25 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B245C857CE9; Thu, 26 Oct 2023 13:15:22 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3271E492BE7; Thu, 26 Oct 2023 13:15:22 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DA51B19465BC; Thu, 26 Oct 2023 13:15:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 95536194658C for ; Thu, 26 Oct 2023 13:15:19 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 78B4C2166B29; Thu, 26 Oct 2023 13:15:19 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id E901E2166B26 for ; Thu, 26 Oct 2023 13:15:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698326129; 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=sbVUlLyiOscBwDEQM8BDjMPzsQwz9z0q0ISUfiegXNM=; b=FNxkwwmbzz0fhX7IEAUFt+qmP6o3vGyflj3JpCrTs6BQJX4fGiQCR+CVG5ufNw1Y5xkb0g yTL2ow0bqQfag7yiIfaS7mWQEErN5u1UUY8VSkCqEShR6kytSNWEFbO2b49b39DLeOJihy l44i6yFS/ncMpP9NcwOkOJHXeIxsUsM= X-MC-Unique: amcLA5fcOrO2kyD8_W1liA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/2] qemu: process: Extract host setup of disk device into a helper Date: Thu, 26 Oct 2023 15:15:16 +0200 Message-ID: <588cdb1475a0e2988e589a4487c3961053cfdc9b.1698326094.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1698326131353100002 Content-Type: text/plain; charset="utf-8" Currently the code sets up only VDPA backends but will be used later in hotplug code too. This patch also uses normal forward iteration in the loop in qemuProcessPrepareHostStorage as we don't need to remove disks from the disk list at that point. Signed-off-by: Peter Krempa --- src/qemu/qemu_process.c | 42 ++++++++++++++++++++++++++++++++--------- src/qemu/qemu_process.h | 3 +++ 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 63c0c62a46..b420ec283d 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6777,6 +6777,35 @@ qemuProcessPrepareHostStorageSourceVDPA(virStorageSo= urce *src, } +/** + * qemuProcessPrepareHostStorageDisk: + * + * @vm: domain object + * @disk: disk definition object + * + * Prepare the host side of a disk for use with the VM. Note that this fun= ction + * accesses host resources. + * + * Note that this function does not call qemuDomainDetermineDiskChain as t= hat is + * needed in qemuProcessPrepareHostStorage to remove disks based on the st= artup + * policy, thus other callers need to call it explicitly. + */ +int +qemuProcessPrepareHostStorageDisk(virDomainObj *vm, + virDomainDiskDef *disk) +{ + virStorageSource *n; + + for (n =3D disk->src; virStorageSourceIsBacking(n); n =3D n->backingSt= ore) { + /* connect to any necessary vdpa block devices */ + if (qemuProcessPrepareHostStorageSourceVDPA(n, vm->privateData) < = 0) + return -1; + } + + return 0; +} + + static int qemuProcessPrepareHostStorage(virQEMUDriver *driver, virDomainObj *vm, @@ -6813,16 +6842,11 @@ qemuProcessPrepareHostStorage(virQEMUDriver *driver, return -1; } - /* connect to any necessary vdpa block devices */ - for (i =3D vm->def->ndisks; i > 0; i--) { - size_t idx =3D i - 1; - virDomainDiskDef *disk =3D vm->def->disks[idx]; - virStorageSource *src; + for (i =3D 0; i < vm->def->ndisks; i++) { + virDomainDiskDef *disk =3D vm->def->disks[i]; - for (src =3D disk->src; virStorageSourceIsBacking(src); src =3D sr= c->backingStore) { - if (qemuProcessPrepareHostStorageSourceVDPA(src, vm->privateDa= ta) < 0) - return -1; - } + if (qemuProcessPrepareHostStorageDisk(vm, disk) < 0) + return -1; } return 0; diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index ef05b46892..7b974259d3 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -133,6 +133,9 @@ int qemuProcessPrepareHost(virQEMUDriver *driver, virDomainObj *vm, unsigned int flags); +int qemuProcessPrepareHostStorageDisk(virDomainObj *vm, + virDomainDiskDef *disk); + int qemuProcessDeleteThreadContext(virDomainObj *vm); int qemuProcessLaunch(virConnectPtr conn, --=20 2.41.0 From nobody Fri May 10 16:14:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1698326131; cv=none; d=zohomail.com; s=zohoarc; b=Dkp5UKc4KS36eajCR5wSMEQEU3KOd/wF+wlBhmzjWoUWdFCp9ENXjOFMOJlmajv+nl9SP3a+8wm6Imu00nLzFHSD/XbX5E4a5kd6aWr66zxsemx7WXHqM9PVtPGwseMc49q5+7K7hpkoicQ9U2h54kiHKyIm7EmeYzrp6s/c8u4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698326131; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=CCNRA6Q+EBYACFGtT7L7nbUO7rH7m6Kbt0FmOsdMQKs=; b=kPLyg5HP4JJdTP13eBsKxNDfV3aw+Hwos8ClKJyAjpzTAQGBwCHC+xiKuausIf/wsMWbCjv8C47SJeE0b10n2+BcEIKuLEb5tI3sxiBr3weFQ8dH1U4QdeqeeInCRBq+4dIlnAr9FxBVQutUP96TDv2L6h7e0IpDadD+xFnjm50= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1698326131139678.8653260774322; Thu, 26 Oct 2023 06:15:31 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-155-lbPsUqKQNpa7hXEqDxTwYg-1; Thu, 26 Oct 2023 09:15:26 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1FED428040C1; Thu, 26 Oct 2023 13:15:23 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0284B2027047; Thu, 26 Oct 2023 13:15:23 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1C5B219465A0; Thu, 26 Oct 2023 13:15:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 76B4D194658C for ; Thu, 26 Oct 2023 13:15:20 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5716B2166B28; Thu, 26 Oct 2023 13:15:20 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id C60F72166B26 for ; Thu, 26 Oct 2023 13:15:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698326130; 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=CCNRA6Q+EBYACFGtT7L7nbUO7rH7m6Kbt0FmOsdMQKs=; b=hROPSIlqmaaQKAhXDoiOz1CQQ0wDMxo8qgKQm4+d4zQ38weiBCDKRsyzQ81uXzE6Ssy8gB ZE+mJzHM0/QheD+EQtUKlvhccJdHVI2MDPUXbgYPfu5BhqPN0jKo29VGb27xSw9KReq7dE WplFCGe2A9OZDP9byGtgEqbTOnmBmm0= X-MC-Unique: lbPsUqKQNpa7hXEqDxTwYg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/2] qemu: hotplug: Setup host side of VDPA device for disk hotplug Date: Thu, 26 Oct 2023 15:15:17 +0200 Message-ID: <9d927b1d97057235b012fe59bd08515b50960a18.1698326094.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1698326133425100001 Content-Type: text/plain; charset="utf-8" The code which opens the VDPA device and prepares it for FD passing was not called in the hotplug code path, preventing hotplug of VDPA disks with: error: internal error: argument key 'path' must not have null value Use the new helper qemuProcessPrepareHostStorageDisk to setup the VDPA definition. Closes: https://gitlab.com/libvirt/libvirt/-/issues/539 Signed-off-by: Peter Krempa --- src/qemu/qemu_hotplug.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 1f7f5bdd26..fec7c4be4e 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1007,6 +1007,9 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver = *driver, if (qemuDomainDetermineDiskChain(driver, vm, disk, NULL) < 0) goto cleanup; + if (qemuProcessPrepareHostStorageDisk(vm, disk) < 0) + goto cleanup; + if (qemuHotplugAttachManagedPR(vm, disk->src, VIR_ASYNC_JOB_NONE) < 0) goto cleanup; --=20 2.41.0