Skip to contentSkip to conversation

libxl: only add PCI entries to xenstore if there is at least one PCI device

PATCH New Roger Pau Monne 1 participant 1 message Jul 22, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxl: only add PCI entries to xenstore if there is at least one PCI device

# HG changeset patch
# User royger
# Date 1311355474 -7200
# Node ID bb2568713604f2eef45326c271132b06a0bff1cc
# Parent e298ce67777eb45187d6581a0c51c2dbe7161000
libxl: only add PCI entries to xenstore if there is at least one PCI device.

tools/libxl/libxl_create.c +9 -7
diff -r e298ce67777e -r bb2568713604 tools/libxl/libxl_create.c
@@ -528,15 +528,17 @@ static int do_domain_create(libxl__gc *g
         }
     }
 
-    for (i = 0; i < d_config->num_pcidevs; i++)
-        libxl__device_pci_add(gc, domid, &d_config->pcidevs[i], 1);
+    if (d_config->num_pcidevs > 0) {
+        for (i = 0; i < d_config->num_pcidevs; i++) 
+            libxl__device_pci_add(gc, domid, &d_config->pcidevs[i], 1);
 
-    ret = libxl__create_pci_backend(gc, domid, d_config->pcidevs,
+        ret = libxl__create_pci_backend(gc, domid, d_config->pcidevs,
                                     d_config->num_pcidevs);
-    if (ret < 0) {
-        LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
-                   "libxl_create_pci_backend failed: %d", ret);
-        goto error_out;
+        if (ret < 0) {
+            LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
+                "libxl_create_pci_backend failed: %d", ret);
+            goto error_out;
+        }
     }
 
     if (!d_config->c_info.hvm && d_config->b_info.u.pv.e820_host) {