Commit bbfa18fc authored by Amos Kong's avatar Amos Kong Committed by Anthony Liguori
Browse files

qdev: fix get_fw_dev_path to support to add nothing to fw_dev_path



Recent virtio refactoring in QEMU made virtio-bus become the parent bus
of scsi-bus, and virtio-bus doesn't have get_fw_dev_path implementation,
typename will be added to fw_dev_path by default, the new fw_dev_path
could not be identified by seabios. It causes that bootindex parameter
of scsi device doesn't work.

This patch implements get_fw_dev_path() in BusClass, it will be called
if bus doesn't implement the method, tyename will be added to
fw_dev_path. If the implemented method returns NULL, nothing will be
added to fw_dev_path.

It also implements virtio_bus_get_fw_dev_path() to return NULL. Then
QEMU will still pass original style of fw_dev_path to seabios.

Signed-off-by: default avatarAmos Kong <akong@redhat.com>
Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Reviewed-by: default avatarLaszlo Ersek <lersek@redhat.com>
Message-id: 1369814202-10346-1-git-send-email-akong@redhat.com
--
v2: only add nothing to fw_dev_path when get_fw_dev_path() is
    implemented and returns NULL. then it will not effect other devices
    don't have get_fw_dev_path() implementation.
v3: implement default get_fw_dev_path() in BusClass
Signed-off-by: default avatarAnthony Liguori <aliguori@us.ibm.com>
parent 87d23f78
Loading
Loading
Loading
Loading
+9 −1
Original line number Original line Diff line number Diff line
@@ -515,7 +515,7 @@ static int qdev_get_fw_dev_path_helper(DeviceState *dev, char *p, int size)
            l += snprintf(p + l, size - l, "%s", d);
            l += snprintf(p + l, size - l, "%s", d);
            g_free(d);
            g_free(d);
        } else {
        } else {
            l += snprintf(p + l, size - l, "%s", object_get_typename(OBJECT(dev)));
            return l;
        }
        }
    }
    }
    l += snprintf(p + l , size - l, "/");
    l += snprintf(p + l , size - l, "/");
@@ -867,9 +867,17 @@ static void qbus_initfn(Object *obj)
    QTAILQ_INIT(&bus->children);
    QTAILQ_INIT(&bus->children);
}
}


static char *default_bus_get_fw_dev_path(DeviceState *dev)
{
    return g_strdup(object_get_typename(OBJECT(dev)));
}

static void bus_class_init(ObjectClass *class, void *data)
static void bus_class_init(ObjectClass *class, void *data)
{
{
    BusClass *bc = BUS_CLASS(class);

    class->unparent = bus_unparent;
    class->unparent = bus_unparent;
    bc->get_fw_dev_path = default_bus_get_fw_dev_path;
}
}


static void qbus_finalize(Object *obj)
static void qbus_finalize(Object *obj)
+6 −0
Original line number Original line Diff line number Diff line
@@ -161,10 +161,16 @@ static char *virtio_bus_get_dev_path(DeviceState *dev)
    return qdev_get_dev_path(proxy);
    return qdev_get_dev_path(proxy);
}
}


static char *virtio_bus_get_fw_dev_path(DeviceState *dev)
{
    return NULL;
}

static void virtio_bus_class_init(ObjectClass *klass, void *data)
static void virtio_bus_class_init(ObjectClass *klass, void *data)
{
{
    BusClass *bus_class = BUS_CLASS(klass);
    BusClass *bus_class = BUS_CLASS(klass);
    bus_class->get_dev_path = virtio_bus_get_dev_path;
    bus_class->get_dev_path = virtio_bus_get_dev_path;
    bus_class->get_fw_dev_path = virtio_bus_get_fw_dev_path;
}
}


static const TypeInfo virtio_bus_info = {
static const TypeInfo virtio_bus_info = {