Merge two copies of the same code and cleanup with no functional
changes.
Signed-off-by: Mark McLoughlin <[EMAIL PROTECTED]>
fix error messages
Signed-off-by: Mark McLoughlin <[EMAIL PROTECTED]>
---
qemu/hw/device-assignment.c | 32 +++++++++++++++++++++-----------
qemu/hw/device-assignment.h | 2 +-
qemu/hw/ipf.c | 16 ++--------------
qemu/hw/pc.c | 16 ++--------------
4 files changed, 26 insertions(+), 40 deletions(-)
diff --git a/qemu/hw/device-assignment.c b/qemu/hw/device-assignment.c
index 9a790c6..eb2a73a 100644
--- a/qemu/hw/device-assignment.c
+++ b/qemu/hw/device-assignment.c
@@ -554,17 +554,6 @@ struct PCIDevice *init_assigned_device(AssignedDevInfo
*adev, PCIBus *bus)
return &dev->dev;
}
-int init_all_assigned_devices(PCIBus *bus)
-{
- struct AssignedDevInfo *adev;
-
- LIST_FOREACH(adev, &adev_head, next)
- if (init_assigned_device(adev, bus) == NULL)
- return -1;
-
- return 0;
-}
-
/*
* Syntax to assign device:
*
@@ -619,3 +608,24 @@ bad:
qemu_free(adev);
return NULL;
}
+
+void add_assigned_devices(PCIBus *bus, const char **devices, int n_devices)
+{
+ int i;
+
+ for (i = 0; i < n_devices; i++) {
+ struct AssignedDevInfo *adev;
+
+ adev = add_assigned_device(devices[i]);
+ if (!adev) {
+ fprintf(stderr, "Could not add assigned device %s\n", devices[i]);
+ continue;
+ }
+
+ if (!init_assigned_device(adev, bus)) {
+ fprintf(stderr, "Failed to initialize assigned device %s\n",
+ devices[i]);
+ exit(1);
+ }
+ }
+}
diff --git a/qemu/hw/device-assignment.h b/qemu/hw/device-assignment.h
index d6caa67..5a01d98 100644
--- a/qemu/hw/device-assignment.h
+++ b/qemu/hw/device-assignment.h
@@ -96,7 +96,7 @@ struct AssignedDevInfo {
PCIDevice *init_assigned_device(AssignedDevInfo *adev, PCIBus *bus);
AssignedDevInfo *add_assigned_device(const char *arg);
-int init_all_assigned_devices(PCIBus *bus);
+void add_assigned_devices(PCIBus *bus, const char **devices, int n_devices);
#define MAX_DEV_ASSIGN_CMDLINE 8
diff --git a/qemu/hw/ipf.c b/qemu/hw/ipf.c
index c0ac9eb..3e24c98 100644
--- a/qemu/hw/ipf.c
+++ b/qemu/hw/ipf.c
@@ -647,20 +647,8 @@ static void ipf_init1(ram_addr_t ram_size, int
vga_ram_size,
}
#ifdef USE_KVM_DEVICE_ASSIGNMENT
- if (kvm_enabled()) {
- int i;
- for (i = 0; i < assigned_devices_index; i++) {
- if (!add_assigned_device(assigned_devices[i])) {
- fprintf(stderr, "Warning: could not add assigned device %s\n",
- assigned_devices[i]);
- }
- }
-
- if (init_all_assigned_devices(pci_bus)) {
- fprintf(stderr, "Failed to initialize assigned devices\n");
- exit (1);
- }
- }
+ if (kvm_enabled())
+ add_assigned_devices(pci_bus, assigned_devices, assigned_devices_index);
#endif /* USE_KVM_DEVICE_ASSIGNMENT */
}
diff --git a/qemu/hw/pc.c b/qemu/hw/pc.c
index 6f3339f..6de460c 100644
--- a/qemu/hw/pc.c
+++ b/qemu/hw/pc.c
@@ -1184,20 +1184,8 @@ static void pc_init1(ram_addr_t ram_size, int
vga_ram_size,
virtio_balloon_init(pci_bus);
#ifdef USE_KVM_DEVICE_ASSIGNMENT
- if (kvm_enabled()) {
- int i;
- for (i = 0; i < assigned_devices_index; i++) {
- if (!add_assigned_device(assigned_devices[i])) {
- fprintf(stderr, "Warning: could not add assigned device %s\n",
- assigned_devices[i]);
- }
- }
-
- if (init_all_assigned_devices(pci_bus)) {
- fprintf(stderr, "Failed to initialize assigned devices\n");
- exit (1);
- }
- }
+ if (kvm_enabled())
+ add_assigned_devices(pci_bus, assigned_devices, assigned_devices_index);
#endif /* USE_KVM_DEVICE_ASSIGNMENT */
}
--
1.5.4.3
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html