vhost-scsi: expose the TYPE_FW_PATH_PROVIDER interface
In the way, we can make the bootindex property take effect. At the meanwhile, the firmware path name of vhost-scsi is "channel@channel/vhost-scsi@target,lun". Signed-off-by: Gonglei <arei.gonglei@huawei.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
d4433f3211
commit
1956cf6fa1
@ -24,6 +24,7 @@
|
|||||||
#include "hw/virtio/virtio-scsi.h"
|
#include "hw/virtio/virtio-scsi.h"
|
||||||
#include "hw/virtio/virtio-bus.h"
|
#include "hw/virtio/virtio-bus.h"
|
||||||
#include "hw/virtio/virtio-access.h"
|
#include "hw/virtio/virtio-access.h"
|
||||||
|
#include "hw/fw-path-provider.h"
|
||||||
|
|
||||||
/* Features supported by host kernel. */
|
/* Features supported by host kernel. */
|
||||||
static const int kernel_feature_bits[] = {
|
static const int kernel_feature_bits[] = {
|
||||||
@ -271,6 +272,19 @@ static void vhost_scsi_unrealize(DeviceState *dev, Error **errp)
|
|||||||
virtio_scsi_common_unrealize(dev, errp);
|
virtio_scsi_common_unrealize(dev, errp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Implementation of an interface to adjust firmware path
|
||||||
|
* for the bootindex property handling.
|
||||||
|
*/
|
||||||
|
static char *vhost_scsi_get_fw_dev_path(FWPathProvider *p, BusState *bus,
|
||||||
|
DeviceState *dev)
|
||||||
|
{
|
||||||
|
VHostSCSI *s = VHOST_SCSI(dev);
|
||||||
|
/* format: channel@channel/vhost-scsi@target,lun */
|
||||||
|
return g_strdup_printf("channel@%x/%s@%x,%x", s->channel,
|
||||||
|
qdev_fw_name(dev), s->target, s->lun);
|
||||||
|
}
|
||||||
|
|
||||||
static Property vhost_scsi_properties[] = {
|
static Property vhost_scsi_properties[] = {
|
||||||
DEFINE_VHOST_SCSI_PROPERTIES(VHostSCSI, parent_obj.conf),
|
DEFINE_VHOST_SCSI_PROPERTIES(VHostSCSI, parent_obj.conf),
|
||||||
DEFINE_PROP_END_OF_LIST(),
|
DEFINE_PROP_END_OF_LIST(),
|
||||||
@ -280,6 +294,7 @@ static void vhost_scsi_class_init(ObjectClass *klass, void *data)
|
|||||||
{
|
{
|
||||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||||
VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
|
VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
|
||||||
|
FWPathProviderClass *fwc = FW_PATH_PROVIDER_CLASS(klass);
|
||||||
|
|
||||||
dc->props = vhost_scsi_properties;
|
dc->props = vhost_scsi_properties;
|
||||||
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
|
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
|
||||||
@ -288,6 +303,7 @@ static void vhost_scsi_class_init(ObjectClass *klass, void *data)
|
|||||||
vdc->get_features = vhost_scsi_get_features;
|
vdc->get_features = vhost_scsi_get_features;
|
||||||
vdc->set_config = vhost_scsi_set_config;
|
vdc->set_config = vhost_scsi_set_config;
|
||||||
vdc->set_status = vhost_scsi_set_status;
|
vdc->set_status = vhost_scsi_set_status;
|
||||||
|
fwc->get_dev_path = vhost_scsi_get_fw_dev_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vhost_scsi_instance_init(Object *obj)
|
static void vhost_scsi_instance_init(Object *obj)
|
||||||
@ -304,6 +320,10 @@ static const TypeInfo vhost_scsi_info = {
|
|||||||
.instance_size = sizeof(VHostSCSI),
|
.instance_size = sizeof(VHostSCSI),
|
||||||
.class_init = vhost_scsi_class_init,
|
.class_init = vhost_scsi_class_init,
|
||||||
.instance_init = vhost_scsi_instance_init,
|
.instance_init = vhost_scsi_instance_init,
|
||||||
|
.interfaces = (InterfaceInfo[]) {
|
||||||
|
{ TYPE_FW_PATH_PROVIDER },
|
||||||
|
{ }
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static void virtio_register_types(void)
|
static void virtio_register_types(void)
|
||||||
|
@ -61,6 +61,9 @@ typedef struct VHostSCSI {
|
|||||||
|
|
||||||
struct vhost_dev dev;
|
struct vhost_dev dev;
|
||||||
int32_t bootindex;
|
int32_t bootindex;
|
||||||
|
int channel;
|
||||||
|
int target;
|
||||||
|
int lun;
|
||||||
} VHostSCSI;
|
} VHostSCSI;
|
||||||
|
|
||||||
#define DEFINE_VHOST_SCSI_PROPERTIES(_state, _conf_field) \
|
#define DEFINE_VHOST_SCSI_PROPERTIES(_state, _conf_field) \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user