qemu versions that use the pci_add syntax return success information such as:

    (qemu) pci_add pci_addr=auto nic model=virtio
    OK domain 0, bus 0, slot 10, function 0

The added device pci address is specificed as base 10 integers. The pci_del
command, however, expects the pci address as base 16. Example on current:

    (qemu) pci_del pci_addr=10
    slot 16 empty

Correct usage:

    (qemu) pci_del pci_addr=a

or:

    (qemu) pci_del pci_addr=0:0:a

This patch also better identifies the device using the complete pci address
(domain, bus and slot).

Signed-off-by: Cleber Rosa <[email protected]>
---
 client/tests/kvm/tests/pci_hotplug.py |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/client/tests/kvm/tests/pci_hotplug.py 
b/client/tests/kvm/tests/pci_hotplug.py
index 3f07bda..727ee62 100644
--- a/client/tests/kvm/tests/pci_hotplug.py
+++ b/client/tests/kvm/tests/pci_hotplug.py
@@ -105,8 +105,12 @@ def run_pci_hotplug(test, params, env):
     # Define a helper function to delete the device
     def pci_del(ignore_failure=False):
         if cmd_type == "pci_add":
-            slot_id = "0" + add_output.split(",")[2].split()[1]
-            cmd = "pci_del pci_addr=%s" % slot_id
+            result_domain, bus, slot, function = add_output.split(',')
+            domain = int(result_domain.split()[2])
+            bus = int(bus.split()[1])
+            slot = int(slot.split()[1])
+            pci_addr = "%x:%x:%x" % (domain, bus, slot)
+            cmd = "pci_del pci_addr=%s" % pci_addr
         elif cmd_type == "device_add":
             cmd = "device_del %s" % id
         # This should be replaced by a proper monitor method call
-- 
1.7.1

_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to