[PATCH v2 3/3] qemu: Add configuration variable to control nodedev enumeration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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 =
    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 97d769d..fe70a96 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 527c1bc..c6296c7 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -351,6 +351,8 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged)
         goto error;
 #endif
 
+    cfg->nodeDeviceEnumeration = false;
+
     return cfg;
 
  error:
@@ -713,6 +715,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 b8af74b..202585f 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -198,6 +198,9 @@ struct _virQEMUDriverConfig {
     unsigned int glusterDebugLevel;
 
     char *memoryBackingDir;
+
+    /* Node device enumeration enabled */
+    bool nodeDeviceEnumeration;
 };
 
 /* 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 = 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 (!(nodedevEnumCb =
-          virNodeDeviceRegisterCallbackDriver(&qemuNodedevCallbackDriver)))
-        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 (!(nodedevEnumCb =
+              virNodeDeviceRegisterCallbackDriver(&qemuNodedevCallbackDriver)))
+            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;
+        /* 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;
+    }
 
     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 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 =
 { "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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux