From nobody Mon Feb 9 16:01:58 2026 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