From nobody Sat Apr 20 01:58:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1486742176283942.968611933366; Fri, 10 Feb 2017 07:56:16 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1AFqqTb017129; Fri, 10 Feb 2017 10:52:52 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1AFqZHH015585 for ; Fri, 10 Feb 2017 10:52:35 -0500 Received: from localhost.localdomain.com (ovpn-116-36.phx2.redhat.com [10.3.116.36]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1AFqXT5031428 for ; Fri, 10 Feb 2017 10:52:34 -0500 From: John Ferlan To: libvir-list@redhat.com Date: Fri, 10 Feb 2017 10:52:30 -0500 Message-Id: <1486741950-21363-4-git-send-email-jferlan@redhat.com> In-Reply-To: <1486741950-21363-1-git-send-email-jferlan@redhat.com> References: <1486741950-21363-1-git-send-email-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 3/3] qemu: Add configuration variable to control nodedev enumeration 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add an 'enumerate_nodedev' qemu configuration variable to control whether the node device enumeration and add/remove event notification mechanism is enabled. This ensures only those environments that desire to utilize a domain vHBA need to have the (slight) overhead of adding the device hash table to qemu and managing add/remove events for specific scsi_host and scsi_target events. Signed-off-by: John Ferlan --- src/qemu/libvirtd_qemu.aug | 1 + src/qemu/qemu.conf | 19 +++++++++++++++++++ src/qemu/qemu_conf.c | 5 +++++ src/qemu/qemu_conf.h | 3 +++ src/qemu/qemu_driver.c | 33 +++++++++++++++++++-------------- src/qemu/test_libvirtd_qemu.aug.in | 1 + 6 files changed, 48 insertions(+), 14 deletions(-) diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug index 82bae9e..ef759ce 100644 --- a/src/qemu/libvirtd_qemu.aug +++ b/src/qemu/libvirtd_qemu.aug @@ -92,6 +92,7 @@ module Libvirtd_qemu =3D let device_entry =3D bool_entry "mac_filter" | bool_entry "relaxed_acs_check" | bool_entry "allow_disk_format_probing" + | bool_entry "nodedev_enumeration" | str_entry "lock_manager" =20 let rpc_entry =3D int_entry "max_queued" diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf index 97d769d..fe70a96 100644 --- a/src/qemu/qemu.conf +++ b/src/qemu/qemu.conf @@ -531,6 +531,25 @@ #allow_disk_format_probing =3D 1 =20 =20 +# In order for a properly configured qemu domain to be able to passthrough +# NPIV vHBA LUN's to the guest qemu will need to enumerate all the node +# device's and then handle the add and remove events. In order to enable +# qemu to handle this, set this parameter to 1 and restart libvirtd. This +# enables communication between qemu and udev node device event management +# to provide the functionality. When a domain is started or reconnected +# with a vHBA controller configured in the domain XML or when a vHBA +# controller is hot-plugged, the qemu driver will handle the "scsi_hostN" +# device creation and removal events by hot-(un)plugging "scsi_targetB_T_L" +# (Bus, Target, Lun) Direct-Access LUNs to/from the guest. +# +# This is not required for qemu domain environments that utilize the Stora= ge +# Pool NPIV vHBA's to define LUNs in the domain XML. +# +# Defaults to 0. +# +#nodedev_enumeration =3D 1 + + # In order to prevent accidentally starting two domains that # share one writable disk, libvirt offers two approaches for # locking files. The first one is sanlock, the other one, diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 527c1bc..c6296c7 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -351,6 +351,8 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool priv= ileged) goto error; #endif =20 + cfg->nodeDeviceEnumeration =3D false; + return cfg; =20 error: @@ -713,6 +715,9 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr = cfg, goto cleanup; if (virConfGetValueBool(conf, "allow_disk_format_probing", &cfg->allow= DiskFormatProbing) < 0) goto cleanup; + if (virConfGetValueBool(conf, "nodedev_enumeration", + &cfg->nodeDeviceEnumeration) < 0) + goto cleanup; if (virConfGetValueBool(conf, "set_process_name", &cfg->setProcessName= ) < 0) goto cleanup; if (virConfGetValueUInt(conf, "max_processes", &cfg->maxProcesses) < 0) diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index b8af74b..202585f 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -198,6 +198,9 @@ struct _virQEMUDriverConfig { unsigned int glusterDebugLevel; =20 char *memoryBackingDir; + + /* Node device enumeration enabled */ + bool nodeDeviceEnumeration; }; =20 /* Main driver state */ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c05914b..5e02da0 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -799,22 +799,27 @@ qemuStateInitialize(bool privileged, if (!(qemu_driver->sharedDevices =3D virHashCreate(30, qemuSharedDevic= eEntryFree))) goto error; =20 - /* Create a hash table to keep track of node device's by name */ - if (!(qemu_driver->nodeDevices =3D virHashCreate(100, NULL))) - goto error; + /* If node device enumeration is enabled, create a hash table to + * keep track of node device's by name and set up a callback mechanism + * with the node device conf code to get called whenever a node device + * is added or removed. */ + if (cfg->nodeDeviceEnumeration) { + if (!(qemu_driver->nodeDevices =3D virHashCreate(100, NULL))) + goto error; =20 - /* Set up a callback mechanism with the node device conf code to get - * called whenever a node device is added or removed. */ - if (!(nodedevEnumCb =3D - virNodeDeviceRegisterCallbackDriver(&qemuNodedevCallbackDriver))) - goto error; + /* Set up a callback mechanism with the node device conf code to g= et + * called whenever a node device is added or removed. */ + if (!(nodedevEnumCb =3D + virNodeDeviceRegisterCallbackDriver(&qemuNodedevCallbackDriv= er))) + goto error; =20 - /* Setting the add/remove callback first ensures that there is no - * window of opportunity for a device to be added after enumeration - * is complete, but before the callback is in place. So, set the - * callback first, then do the enumeration. */ - if (nodedevEnumCb(qemuNodeDeviceAdd) < 0) - goto error; + /* Setting the add/remove callback first ensures that there is no + * window of opportunity for a device to be added after enumeration + * is complete, but before the callback is in place. So, set the + * callback first, then do the enumeration. */ + if (nodedevEnumCb(qemuNodeDeviceAdd) < 0) + goto error; + } =20 if (qemuMigrationErrorInit(qemu_driver) < 0) goto error; diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qe= mu.aug.in index bd25235..f1c98a2 100644 --- a/src/qemu/test_libvirtd_qemu.aug.in +++ b/src/qemu/test_libvirtd_qemu.aug.in @@ -74,6 +74,7 @@ module Test_libvirtd_qemu =3D { "mac_filter" =3D "1" } { "relaxed_acs_check" =3D "1" } { "allow_disk_format_probing" =3D "1" } +{ "nodedev_enumeration" =3D "1" } { "lock_manager" =3D "lockd" } { "max_queued" =3D "0" } { "keepalive_interval" =3D "5" } --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list