Skip to contentSkip to conversation

qemu-xen: read default pci passthrough values

PATCH In review Stefano Stabellini 2 participants 4 messages Feb 2, 2011 – Feb 4, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu-xen: read default pci passthrough values

If there are no devices assigned to the domain at boot, we don't read the default pci passthrough parameters.
This patch fixes it.

xenstore.c +2 -3
index d364a5e..3fd69aa 100644
@@ -738,9 +738,8 @@ void xenstore_parse_domain_config(int hvm_domid)
 
     free(params);
     params = xs_read(xsh, XBT_NULL, buf, &len);
-    if (params == NULL)
-        goto out;
-    num = atoi(params);
+    if (params != NULL)
+        num = atoi(params);
 
     /* get the pci pass-through parameter */
     if (pasprintf(&buf, "/local/domain/0/backend/pci/%u/%u/msitranslate",
#1 lore raw

Stefano Stabellini writes ("[Xen-devel] [PATCH] qemu-xen: read default pci passthrough values"):

Quoted 3 lines

If there are no devices assigned to the domain at boot, we don't read the default pci passthrough parameters.
This patch fixes it.

The semantics you intend seem sensible, but:

The variable "num" seems completely unused after we went to all the effort of reading num_devs to get it. The code seems to read .../num_devs just to check that the key exists, and doesn't mind "0" as an answer. With your patch applied, we don't even care whether the key exists.

So why do we bother reading .../num_devs and converting it to an integer and assigning it to nums ?

Ian.

#2 lore raw
Quoted 7 lines · Ian Jackson

Stefano Stabellini writes ("[Xen-devel] [PATCH] qemu-xen: read default pci passthrough values"):

Quoted 3 lines

If there are no devices assigned to the domain at boot, we don't read the default pci passthrough parameters.
This patch fixes it.

The semantics you intend seem sensible, but:

Quoted 8 lines

The variable "num" seems completely unused after we went to all the effort of reading num_devs to get it. The code seems to read .../num_devs just to check that the key exists, and doesn't mind "0" as an answer. With your patch applied, we don't even care whether the key exists.

So why do we bother reading .../num_devs and converting it to an integer and assigning it to nums ?

That is a very good point. Reading num_devs is completely useless hence I am removing it.

---

xenstore.c +1 -12
index d364a5e..eed4955 100644
@@ -731,18 +731,7 @@ void xenstore_parse_domain_config(int hvm_domid)
      * hvm_domid is always equal to domid */
     hvm_domid = domid;
 
-    /* get the pci pass-through parameter */
-    if (pasprintf(&buf, "/local/domain/0/backend/pci/%u/%u/num_devs",
-                  hvm_domid, pci_devid) == -1)
-        goto out;
-
-    free(params);
-    params = xs_read(xsh, XBT_NULL, buf, &len);
-    if (params == NULL)
-        goto out;
-    num = atoi(params);
-
-    /* get the pci pass-through parameter */
+    /* get the pci pass-through parameters */
     if (pasprintf(&buf, "/local/domain/0/backend/pci/%u/%u/msitranslate",
                   hvm_domid, pci_devid) != -1)
     {
#3 lore raw

Stefano Stabellini writes ("Re: [Xen-devel] [PATCH] qemu-xen: read default pci passthrough values"):

Quoted 2 lines

That is a very good point. Reading num_devs is completely useless hence I am removing it.

Great, applied, thanks.

Ian.