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 <jferlan(a)redhat.com>
---
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 | 17 ++++++++++-------
src/qemu/test_libvirtd_qemu.aug.in | 1 +
6 files changed, 39 insertions(+), 7 deletions(-)
diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug
index de723b2..d011f2c 100644
--- a/src/qemu/libvirtd_qemu.aug
+++ b/src/qemu/libvirtd_qemu.aug
@@ -92,6 +92,7 @@ module Libvirtd_qemu =
let device_entry = bool_entry "mac_filter"
| bool_entry "relaxed_acs_check"
| bool_entry "allow_disk_format_probing"
+ | bool_entry "nodedev_enumeration"
| str_entry "lock_manager"
let rpc_entry = int_entry "max_queued"
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index a8cd369..c726bc9 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -531,6 +531,25 @@
#allow_disk_format_probing = 1
+# 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 Storage
+# Pool NPIV vHBA's to define LUNs in the domain XML.
+#
+# Defaults to 0.
+#
+#nodedev_enumeration = 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 f88c7f3..cfe0f84 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -347,6 +347,8 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged)
goto error;
#endif
+ cfg->nodeDeviceEnumeration = false;
+
return cfg;
error:
@@ -707,6 +709,9 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
goto cleanup;
if (virConfGetValueBool(conf, "allow_disk_format_probing",
&cfg->allowDiskFormatProbing) < 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 7d514a9..9e5d9ad 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -196,6 +196,9 @@ struct _virQEMUDriverConfig {
virFirmwarePtr *firmwares;
size_t nfirmwares;
unsigned int glusterDebugLevel;
+
+ /* Node device enumeration enabled */
+ bool nodeDeviceEnumeration;
};
/* Main driver state */
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 758a7f5..023bb30 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -798,14 +798,17 @@ qemuStateInitialize(bool privileged,
if (!(qemu_driver->sharedDevices = virHashCreate(30, qemuSharedDeviceEntryFree)))
goto error;
- /* Create a hash table to keep track of node device's by name */
- if (!(qemu_driver->nodeDevices = 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 = virHashCreate(100, NULL)))
+ goto error;
- /* Set up a callback mechanism with the node device conf code to get
- * called whenever a node device is added or removed. */
- if (virNodeDeviceRegisterCallbackDriver(&qemuNodedevCallbackDriver) < 0)
- goto error;
+ if (virNodeDeviceRegisterCallbackDriver(&qemuNodedevCallbackDriver) < 0)
+ goto error;
+ }
if (qemuMigrationErrorInit(qemu_driver) < 0)
goto error;
diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qemu.aug.in
index a749f09..4c46e36 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 =
{ "mac_filter" = "1" }
{ "relaxed_acs_check" = "1" }
{ "allow_disk_format_probing" = "1" }
+{ "nodedev_enumeration" = "1" }
{ "lock_manager" = "lockd" }
{ "max_queued" = "0" }
{ "keepalive_interval" = "5" }
--
2.7.4