Skip to contentSkip to conversation

KVM test: kvm_vm.py: don't require pci_assignable to be defined

PATCH In review Michael Goldish 2 participants 3 messages Jun 6, 2010 – Jun 7, 2010 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM test: kvm_vm.py: don't require pci_assignable to be defined

Currently to disable PCI device assignment pci_assignable must be explicitly set to "no". This patch allows it to remain undefined (and adds a warning message and a comment).

---
 client/tests/kvm/kvm_vm.py |   47 +++++++++++++++++++++----------------------
 1 files changed, 23 insertions(+), 24 deletions(-)
client/tests/kvm/kvm_vm.py +23 -24
index af45a81..78cbb16 100755
@@ -502,49 +502,48 @@ class VM:
                 self.uuid = f.read().strip()
                 f.close()
 
-            if not params.get("pci_assignable") == "no":
-                pa_type = params.get("pci_assignable")
+            # Assign a PCI assignable device
+            self.pci_assignable = None
+            pa_type = params.get("pci_assignable")
+            if pa_type in ["vf", "pf", "mixed"]:
                 pa_devices_requested = params.get("devices_requested")
 
                 # Virtual Functions (VF) assignable devices
                 if pa_type == "vf":
-                    pa_driver = params.get("driver")
-                    pa_driver_option = params.get("driver_option")
-                    self.pci_assignable = kvm_utils.PciAssignable(type=pa_type,
-                                        driver=pa_driver,
-                                        driver_option=pa_driver_option,
-                                        devices_requested=pa_devices_requested)
+                    self.pci_assignable = kvm_utils.PciAssignable(
+                        type=pa_type,
+                        driver=params.get("driver"),
+                        driver_option=params.get("driver_option"),
+                        devices_requested=pa_devices_requested)
                 # Physical NIC (PF) assignable devices
                 elif pa_type == "pf":
-                    pa_device_names = params.get("device_names")
-                    self.pci_assignable = kvm_utils.PciAssignable(type=pa_type,
-                                         names=pa_device_names,
-                                         devices_requested=pa_devices_requested)
+                    self.pci_assignable = kvm_utils.PciAssignable(
+                        type=pa_type,
+                        names=params.get("device_names"),
+                        devices_requested=pa_devices_requested)
                 # Working with both VF and PF
                 elif pa_type == "mixed":
-                    pa_device_names = params.get("device_names")
-                    pa_driver = params.get("driver")
-                    pa_driver_option = params.get("driver_option")
-                    self.pci_assignable = kvm_utils.PciAssignable(type=pa_type,
-                                        driver=pa_driver,
-                                        driver_option=pa_driver_option,
-                                        names=pa_device_names,
-                                        devices_requested=pa_devices_requested)
+                    self.pci_assignable = kvm_utils.PciAssignable(
+                        type=pa_type,
+                        driver=params.get("driver"),
+                        driver_option=params.get("driver_option"),
+                        names=params.get("device_names"),
+                        devices_requested=pa_devices_requested)
 
                 self.pa_pci_ids = self.pci_assignable.request_devs()
 
                 if self.pa_pci_ids:
-                    logging.debug("Successfuly assigned devices: %s" %
+                    logging.debug("Successfuly assigned devices: %s",
                                   self.pa_pci_ids)
                 else:
                     logging.error("No PCI assignable devices were assigned "
                                   "and 'pci_assignable' is defined to %s "
-                                  "on your config file. Aborting VM creation." %
+                                  "on your config file. Aborting VM creation.",
                                   pa_type)
                     return False
 
-            else:
-                self.pci_assignable = None
+            elif pa_type and pa_type != "no":
+                logging.warn("Unsupported pci_assignable type: %s", pa_type)
 
             # Make qemu command
             qemu_command = self.make_qemu_command()
Signature · 1 line
1.5.4.1
#1 lore raw
Quoted 3 lines · Michael Goldish

Currently to disable PCI device assignment pci_assignable must be explicitly set to "no". This patch allows it to remain undefined (and adds a warning message and a comment).

I have noticed this on Friday, while I was testing the patches for RHEL6 style unit tests. Thanks for your fix! :)

By the way, I have the original flat files sent by Naphtali on his initial patch, have you checked with Avi which ones are good to be checked in? Copying Avi on the message.

Quoted 83 lines
---
 client/tests/kvm/kvm_vm.py |   47 +++++++++++++++++++++----------------------
 1 files changed, 23 insertions(+), 24 deletions(-)
client/tests/kvm/kvm_vm.py +23 -24
index af45a81..78cbb16 100755
@@ -502,49 +502,48 @@ class VM:
                 self.uuid = f.read().strip()
                 f.close()
 
-            if not params.get("pci_assignable") == "no":
-                pa_type = params.get("pci_assignable")
+            # Assign a PCI assignable device
+            self.pci_assignable = None
+            pa_type = params.get("pci_assignable")
+            if pa_type in ["vf", "pf", "mixed"]:
                 pa_devices_requested = params.get("devices_requested")
 
                 # Virtual Functions (VF) assignable devices
                 if pa_type == "vf":
-                    pa_driver = params.get("driver")
-                    pa_driver_option = params.get("driver_option")
-                    self.pci_assignable = kvm_utils.PciAssignable(type=pa_type,
-                                        driver=pa_driver,
-                                        driver_option=pa_driver_option,
-                                        devices_requested=pa_devices_requested)
+                    self.pci_assignable = kvm_utils.PciAssignable(
+                        type=pa_type,
+                        driver=params.get("driver"),
+                        driver_option=params.get("driver_option"),
+                        devices_requested=pa_devices_requested)
                 # Physical NIC (PF) assignable devices
                 elif pa_type == "pf":
-                    pa_device_names = params.get("device_names")
-                    self.pci_assignable = kvm_utils.PciAssignable(type=pa_type,
-                                         names=pa_device_names,
-                                         devices_requested=pa_devices_requested)
+                    self.pci_assignable = kvm_utils.PciAssignable(
+                        type=pa_type,
+                        names=params.get("device_names"),
+                        devices_requested=pa_devices_requested)
                 # Working with both VF and PF
                 elif pa_type == "mixed":
-                    pa_device_names = params.get("device_names")
-                    pa_driver = params.get("driver")
-                    pa_driver_option = params.get("driver_option")
-                    self.pci_assignable = kvm_utils.PciAssignable(type=pa_type,
-                                        driver=pa_driver,
-                                        driver_option=pa_driver_option,
-                                        names=pa_device_names,
-                                        devices_requested=pa_devices_requested)
+                    self.pci_assignable = kvm_utils.PciAssignable(
+                        type=pa_type,
+                        driver=params.get("driver"),
+                        driver_option=params.get("driver_option"),
+                        names=params.get("device_names"),
+                        devices_requested=pa_devices_requested)
 
                 self.pa_pci_ids = self.pci_assignable.request_devs()
 
                 if self.pa_pci_ids:
-                    logging.debug("Successfuly assigned devices: %s" %
+                    logging.debug("Successfuly assigned devices: %s",
                                   self.pa_pci_ids)
                 else:
                     logging.error("No PCI assignable devices were assigned "
                                   "and 'pci_assignable' is defined to %s "
-                                  "on your config file. Aborting VM creation." %
+                                  "on your config file. Aborting VM creation.",
                                   pa_type)
                     return False
 
-            else:
-                self.pci_assignable = None
+            elif pa_type and pa_type != "no":
+                logging.warn("Unsupported pci_assignable type: %s", pa_type)
 
             # Make qemu command
             qemu_command = self.make_qemu_command()
#2 lore raw
Quoted 11 lines · Lucas Meneghel Rodrigues
Quoted 3 lines · Michael Goldish

Currently to disable PCI device assignment pci_assignable must be explicitly set to "no". This patch allows it to remain undefined (and adds a warning message and a comment).

I have noticed this on Friday, while I was testing the patches for RHEL6 style unit tests. Thanks for your fix! :)

By the way, I have the original flat files sent by Naphtali on his initial patch, have you checked with Avi which ones are good to be checked in? Copying Avi on the message.

Nevermind, just talked to Avi, we'll have to modify the whole test. Will keep you posted.

Quoted 90 lines
Quoted 74 lines
---
 client/tests/kvm/kvm_vm.py |   47 +++++++++++++++++++++----------------------
 1 files changed, 23 insertions(+), 24 deletions(-)
client/tests/kvm/kvm_vm.py +21 -22
index af45a81..78cbb16 100755
@@ -502,49 +502,48 @@ class VM:
                 self.uuid = f.read().strip()
                 f.close()
 
-            if not params.get("pci_assignable") == "no":
-                pa_type = params.get("pci_assignable")
+            # Assign a PCI assignable device
+            self.pci_assignable = None
+            pa_type = params.get("pci_assignable")
+            if pa_type in ["vf", "pf", "mixed"]:
                 pa_devices_requested = params.get("devices_requested")
 
                 # Virtual Functions (VF) assignable devices
                 if pa_type == "vf":
-                    pa_driver = params.get("driver")
-                    pa_driver_option = params.get("driver_option")
-                    self.pci_assignable = kvm_utils.PciAssignable(type=pa_type,
-                                        driver=pa_driver,
-                                        driver_option=pa_driver_option,
-                                        devices_requested=pa_devices_requested)
+                    self.pci_assignable = kvm_utils.PciAssignable(
+                        type=pa_type,
+                        driver=params.get("driver"),
+                        driver_option=params.get("driver_option"),
+                        devices_requested=pa_devices_requested)
                 # Physical NIC (PF) assignable devices
                 elif pa_type == "pf":
-                    pa_device_names = params.get("device_names")
-                    self.pci_assignable = kvm_utils.PciAssignable(type=pa_type,
-                                         names=pa_device_names,
-                                         devices_requested=pa_devices_requested)
+                    self.pci_assignable = kvm_utils.PciAssignable(
+                        type=pa_type,
+                        names=params.get("device_names"),
+                        devices_requested=pa_devices_requested)
                 # Working with both VF and PF
                 elif pa_type == "mixed":
-                    pa_device_names = params.get("device_names")
-                    pa_driver = params.get("driver")
-                    pa_driver_option = params.get("driver_option")
-                    self.pci_assignable = kvm_utils.PciAssignable(type=pa_type,
-                                        driver=pa_driver,
-                                        driver_option=pa_driver_option,
-                                        names=pa_device_names,
-                                        devices_requested=pa_devices_requested)
+                    self.pci_assignable = kvm_utils.PciAssignable(
+                        type=pa_type,
+                        driver=params.get("driver"),
+                        driver_option=params.get("driver_option"),
+                        names=params.get("device_names"),
+                        devices_requested=pa_devices_requested)
 
                 self.pa_pci_ids = self.pci_assignable.request_devs()
 
                 if self.pa_pci_ids:
-                    logging.debug("Successfuly assigned devices: %s" %
+                    logging.debug("Successfuly assigned devices: %s",
                                   self.pa_pci_ids)
                 else:
                     logging.error("No PCI assignable devices were assigned "
                                   "and 'pci_assignable' is defined to %s "
-                                  "on your config file. Aborting VM creation." %
+                                  "on your config file. Aborting VM creation.",

client/tests/kvm/kvm_vm.py class VM: · line 549

Quoted 10 lines
client/tests/kvm/kvm_vm.py +2 -2
                                   pa_type)
                     return False
 
-            else:
-                self.pci_assignable = None
+            elif pa_type and pa_type != "no":
+                logging.warn("Unsupported pci_assignable type: %s", pa_type)
 
             # Make qemu command
             qemu_command = self.make_qemu_command()

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