Make the 'name' parameter optional and return all processors from the
host if name is not specified.
---
 src/hyperv/hyperv_driver.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index 1031076a28..7cd83e7565 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -56,15 +56,20 @@ VIR_LOG_INIT("hyperv.hyperv_driver");
  */
 
 static int
-hypervGetProcessorsByName(hypervPrivate *priv, const char *name,
-                          Win32_Processor **processorList)
+hypervGetProcessorList(hypervPrivate *priv, const char *computer_name,
+                       Win32_Processor **processorList)
 {
     g_auto(virBuffer) query = VIR_BUFFER_INITIALIZER;
-    virBufferEscapeSQL(&query,
-                       "ASSOCIATORS OF {Win32_ComputerSystem.Name='%s'} "
-                       "WHERE AssocClass = Win32_ComputerSystemProcessor "
-                       "ResultClass = Win32_Processor",
-                       name);
+    if (computer_name) {
+        virBufferEscapeSQL(&query,
+                           "ASSOCIATORS OF {Win32_ComputerSystem.Name='%s'} "
+                           "WHERE AssocClass = Win32_ComputerSystemProcessor "
+                           "ResultClass = Win32_Processor",
+                           computer_name);
+
+    } else {
+        virBufferAddLit(&query, WIN32_PROCESSOR_WQL_SELECT);
+    }
 
     if (hypervGetWmiClass(Win32_Processor, processorList) < 0)
         return -1;
@@ -72,7 +77,7 @@ hypervGetProcessorsByName(hypervPrivate *priv, const char 
*name,
     if (!*processorList) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Could not look up processor(s) on '%1$s'"),
-                       name);
+                       computer_name);
         return -1;
     }
 
@@ -1933,7 +1938,7 @@ hypervNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info)
     if (hypervGetPhysicalSystemList(priv, &computerSystem) < 0)
         return -1;
 
-    if (hypervGetProcessorsByName(priv, computerSystem->data->Name, 
&processorList) < 0) {
+    if (hypervGetProcessorList(priv, computerSystem->data->Name, 
&processorList) < 0) {
         return -1;
     }
 
-- 
2.54.0

Reply via email to