From nobody Sun Apr 28 22:10:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1503330109640124.90223823915039; Mon, 21 Aug 2017 08:41:49 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id D5C30C047B82; Mon, 21 Aug 2017 15:41: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 B2CCA60C20; Mon, 21 Aug 2017 15:41:47 +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 771E43FC72; Mon, 21 Aug 2017 15:41:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7LFfk1Z009579 for ; Mon, 21 Aug 2017 11:41:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0940477D55; Mon, 21 Aug 2017 15:41:46 +0000 (UTC) Received: from dnr.brq.redhat.com (unknown [10.34.247.176]) by smtp.corp.redhat.com (Postfix) with ESMTP id 58B6F7E8F2 for ; Mon, 21 Aug 2017 15:41:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D5C30C047B82 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Mon, 21 Aug 2017 17:41:41 +0200 Message-Id: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] vmx: do not treat controllers as implicit devices 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 21 Aug 2017 15:41:48 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When parsing the config, we look for the SCSI controllers one by one, remembering their models, then let virDomainDefAddImplicitDevices add them if any SCSI disk is using them. Since these controllers are not really implicit (they are present in the source config), add them explicitly. This patch maintains the behavior of not adding a controller if it was present in the config, but no disk was using it. This also resolves the memory leak of virVMXParseConfig overwriting the video device added by calling virDomainDefAddImplicitDevices before the parsing is finished. Reported-by: Michal Privoznik Reviewed-by: John Ferlan --- src/vmx/vmx.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 3e2f4c3e1..849cfc6b1 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -1650,6 +1650,18 @@ virVMXParseConfig(virVMXContext *ctx, if (def->disks[def->ndisks] !=3D NULL) ++def->ndisks; } + + } + + /* add all the SCSI controllers we've seen, up until the last one that= is + * currently used by a disk */ + if (def->ndisks !=3D 0) { + virDomainDeviceInfoPtr info =3D &def->disks[def->ndisks - 1]->info; + for (controller =3D 0; controller <=3D info->addr.drive.controller= ; controller++) { + if (virDomainDefAddController(def, VIR_DOMAIN_CONTROLLER_TYPE_= SCSI, + controller, scsi_virtualDev[cont= roller]) < 0) + goto cleanup; + } } =20 /* def:disks (ide) */ @@ -1689,26 +1701,6 @@ virVMXParseConfig(virVMXContext *ctx, ++def->ndisks; } =20 - /* def:controllers */ - if (virDomainDefAddImplicitDevices(def) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not add cont= rollers")); - goto cleanup; - } - - for (controller =3D 0; controller < def->ncontrollers; ++controller) { - if (def->controllers[controller]->type =3D=3D VIR_DOMAIN_CONTROLLE= R_TYPE_SCSI) { - if (def->controllers[controller]->idx > 3) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("SCSI controller index %d out of [0..3] r= ange"), - def->controllers[controller]->idx); - goto cleanup; - } - - def->controllers[controller]->model =3D - scsi_virtualDev[def->controllers[controller]->idx]; - } - } - /* def:fss */ if (virVMXGetConfigBoolean(conf, "isolation.tools.hgfs.disable", &hgfs_disabled, true, true) < 0) { --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list