s390x: fix s390 virtio aliases

Some of the virtio devices have the same frontend name, but actually
implement different devices behind the scenes through aliases.

The indicator which device type to use is the architecture. On s390, we
want s390 virtio devices. On everything else, we want PCI devices.

Reflect this in the alias selection code. This way we fix commands like
-device virtio-blk on s390x which with this patch applied select the
correct virtio-blk-s390 device rather than virtio-blk-pci.

Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
This commit is contained in:
Alexander Graf 2012-05-18 02:36:26 +02:00
parent eb2aeacf98
commit 5f629d943c

View File

@ -20,6 +20,7 @@
#include "qdev.h" #include "qdev.h"
#include "monitor.h" #include "monitor.h"
#include "qmp-commands.h" #include "qmp-commands.h"
#include "arch_init.h"
/* /*
* Aliases were a bad idea from the start. Let's keep them * Aliases were a bad idea from the start. Let's keep them
@ -29,16 +30,18 @@ typedef struct QDevAlias
{ {
const char *typename; const char *typename;
const char *alias; const char *alias;
uint32_t arch_mask;
} QDevAlias; } QDevAlias;
static const QDevAlias qdev_alias_table[] = { static const QDevAlias qdev_alias_table[] = {
{ "virtio-blk-pci", "virtio-blk" }, { "virtio-blk-pci", "virtio-blk", QEMU_ARCH_ALL & ~QEMU_ARCH_S390X },
{ "virtio-net-pci", "virtio-net" }, { "virtio-net-pci", "virtio-net", QEMU_ARCH_ALL & ~QEMU_ARCH_S390X },
{ "virtio-serial-pci", "virtio-serial" }, { "virtio-serial-pci", "virtio-serial", QEMU_ARCH_ALL & ~QEMU_ARCH_S390X },
{ "virtio-balloon-pci", "virtio-balloon" }, { "virtio-balloon-pci", "virtio-balloon",
{ "virtio-blk-s390", "virtio-blk" }, QEMU_ARCH_ALL & ~QEMU_ARCH_S390X },
{ "virtio-net-s390", "virtio-net" }, { "virtio-blk-s390", "virtio-blk", QEMU_ARCH_S390X },
{ "virtio-serial-s390", "virtio-serial" }, { "virtio-net-s390", "virtio-net", QEMU_ARCH_S390X },
{ "virtio-serial-s390", "virtio-serial", QEMU_ARCH_S390X },
{ "lsi53c895a", "lsi" }, { "lsi53c895a", "lsi" },
{ "ich9-ahci", "ahci" }, { "ich9-ahci", "ahci" },
{ } { }
@ -50,6 +53,11 @@ static const char *qdev_class_get_alias(DeviceClass *dc)
int i; int i;
for (i = 0; qdev_alias_table[i].typename; i++) { for (i = 0; qdev_alias_table[i].typename; i++) {
if (qdev_alias_table[i].arch_mask &&
!(qdev_alias_table[i].arch_mask & arch_type)) {
continue;
}
if (strcmp(qdev_alias_table[i].typename, typename) == 0) { if (strcmp(qdev_alias_table[i].typename, typename) == 0) {
return qdev_alias_table[i].alias; return qdev_alias_table[i].alias;
} }
@ -110,6 +118,11 @@ static const char *find_typename_by_alias(const char *alias)
int i; int i;
for (i = 0; qdev_alias_table[i].alias; i++) { for (i = 0; qdev_alias_table[i].alias; i++) {
if (qdev_alias_table[i].arch_mask &&
!(qdev_alias_table[i].arch_mask & arch_type)) {
continue;
}
if (strcmp(qdev_alias_table[i].alias, alias) == 0) { if (strcmp(qdev_alias_table[i].alias, alias) == 0) {
return qdev_alias_table[i].typename; return qdev_alias_table[i].typename;
} }