From nobody Mon Feb 9 10:39:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1594391715; cv=none; d=zohomail.com; s=zohoarc; b=kOORRjceOnBck/YvdmbKswUxLMGr+IZsLYdZGrhPhuOe6G2LH4gh4WY6od188PcK+RCLgccX1ysuJ1V4ooM3b70n3Rhv736C8beyJtTreZZMoKTieXzuv7j2M6cITXDAqCsfzwteFw7s1cQlB3PK+aU3kwoDTxKIJEcookAS6yc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594391715; 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=Z6pzY4MnTvRDLsW2yzaK1nUdlM7FVHWpnfSh1ivSucI=; b=mq3KYnkQRYrzQKYuFxWF+yjLXtUYlTnDU0Ij31kazj+fGLLsORGBlLvkgsVA82C5+GqT4KtHC5U/CFsGEwYBMGJU7++8LESXGOP6zF2+yX7EznDRTEjEWfZOuBmmLPMYp7gH+CEL182Q5O6NJ2FD2q45LBwV/rm33phyOQydMio= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1594391715697347.3677458461601; Fri, 10 Jul 2020 07:35: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-25-lHx2-GgPOEmVMlqTnkKAOw-1; Fri, 10 Jul 2020 10:34:33 -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 9536B80BCAF; Fri, 10 Jul 2020 14:34:16 +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 774945C1D3; Fri, 10 Jul 2020 14:34: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 234A2180530C; Fri, 10 Jul 2020 14:34:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06AEY3ui007216 for ; Fri, 10 Jul 2020 10:34:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7FC4778A44; Fri, 10 Jul 2020 14:34:03 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id D827C78A41 for ; Fri, 10 Jul 2020 14:33:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594391714; 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=Z6pzY4MnTvRDLsW2yzaK1nUdlM7FVHWpnfSh1ivSucI=; b=RzAicpcqQm0eMHAaUs6erx73qv0etGXXu4ia9QPtQ1q2wJj4vHSRBWmjBdzTQJYKZfj8Dn ixVEthnbbhtdqkfoi3hKSFlIHqRI5TuPrivG1ivJBrbPWfdagIh9GY2478iwk4ayxzslAm fsNqpmZ63uDS7AtBBjHCWqMqcjmSTY0= X-MC-Unique: lHx2-GgPOEmVMlqTnkKAOw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 15/18] qemuDomainAttachHostSCSIDevice: Use new infrastructure Date: Fri, 10 Jul 2020 16:33:36 +0200 Message-Id: <1e7f061622b33bf49423b6e3b83934044da46b78.1594391524.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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" Similarly to command line creation, use the blockdev helpers when hotplugging an (i)SCSI hostdev. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 45 +++++++---------------------------------- 1 file changed, 7 insertions(+), 38 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index fbbd6a533c..06b3b94ff2 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2566,17 +2566,12 @@ qemuDomainAttachHostSCSIDevice(virQEMUDriverPtr dri= ver, int ret =3D -1; qemuDomainObjPrivatePtr priv =3D vm->privateData; virErrorPtr orig_err; + g_autoptr(qemuBlockStorageSourceAttachData) data =3D NULL; + const char *backendalias =3D NULL; g_autofree char *devstr =3D NULL; - g_autofree char *drvstr =3D NULL; - g_autofree char *drivealias =3D NULL; - g_autofree char *secobjAlias =3D NULL; bool teardowncgroup =3D false; bool teardownlabel =3D false; bool teardowndevice =3D false; - bool driveAdded =3D false; - virJSONValuePtr secobjProps =3D NULL; - virDomainHostdevSubsysSCSIPtr scsisrc =3D &hostdev->source.subsys.u.sc= si; - qemuDomainSecretInfoPtr secinfo =3D NULL; /* 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 @@ -2611,25 +2606,11 @@ qemuDomainAttachHostSCSIDevice(virQEMUDriverPtr dri= ver, if (qemuDomainSecretHostdevPrepare(priv, hostdev) < 0) goto cleanup; - if (scsisrc->protocol =3D=3D VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISC= SI) { - qemuDomainStorageSourcePrivatePtr srcPriv =3D - QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(scsisrc->u.iscsi.src); - if (srcPriv) - secinfo =3D srcPriv->secinfo; - } - - if (secinfo && secinfo->type =3D=3D VIR_DOMAIN_SECRET_INFO_TYPE_AES) { - if (qemuBuildSecretInfoProps(secinfo, &secobjProps) < 0) - goto cleanup; - } - - if (!(drvstr =3D qemuBuildSCSIHostdevDrvStr(hostdev, priv->qemuCaps))) - goto cleanup; - - if (!(drivealias =3D qemuAliasFromHostdev(hostdev))) + if (!(data =3D qemuBuildHostdevSCSIAttachPrepare(hostdev, &backendalia= s, + priv->qemuCaps))) goto cleanup; - if (!(devstr =3D qemuBuildSCSIHostdevDevStr(vm->def, hostdev, driveali= as))) + if (!(devstr =3D qemuBuildSCSIHostdevDevStr(vm->def, hostdev, backenda= lias))) goto cleanup; if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0) @@ -2637,14 +2618,9 @@ qemuDomainAttachHostSCSIDevice(virQEMUDriverPtr driv= er, qemuDomainObjEnterMonitor(driver, vm); - if (secobjProps && - qemuMonitorAddObject(priv->mon, &secobjProps, &secobjAlias) < 0) + if (qemuBlockStorageSourceAttachApply(priv->mon, data) < 0) goto exit_monitor; - if (qemuMonitorAddDrive(priv->mon, drvstr) < 0) - goto exit_monitor; - driveAdded =3D true; - if (qemuMonitorAddDevice(priv->mon, devstr) < 0) goto exit_monitor; @@ -2670,18 +2646,11 @@ qemuDomainAttachHostSCSIDevice(virQEMUDriverPtr dri= ver, VIR_WARN("Unable to remove host device from /dev"); } qemuDomainSecretHostdevDestroy(hostdev); - virJSONValueFree(secobjProps); return ret; exit_monitor: virErrorPreserveLast(&orig_err); - if (driveAdded && qemuMonitorDriveDel(priv->mon, drivealias) < 0) { - VIR_WARN("Unable to remove drive %s (%s) after failed " - "qemuMonitorAddDevice", - drvstr, devstr); - } - if (secobjAlias) - ignore_value(qemuMonitorDelObject(priv->mon, secobjAlias, false)); + qemuBlockStorageSourceAttachRollback(priv->mon, data); ignore_value(qemuDomainObjExitMonitor(driver, vm)); virErrorRestore(&orig_err); --=20 2.26.2