vhost: Pass device path to vhost_dev_init()
The path to /dev/vhost-net is currently hardcoded in vhost_dev_init(). This needs to be changed so that /dev/vhost-scsi can be used. Pass in the device path instead of hardcoding it. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
a96ed02fc7
commit
1241ed94c3
@ -747,14 +747,15 @@ static void vhost_eventfd_del(MemoryListener *listener,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int vhost_dev_init(struct vhost_dev *hdev, int devfd, bool force)
|
int vhost_dev_init(struct vhost_dev *hdev, int devfd, const char *devpath,
|
||||||
|
bool force)
|
||||||
{
|
{
|
||||||
uint64_t features;
|
uint64_t features;
|
||||||
int r;
|
int r;
|
||||||
if (devfd >= 0) {
|
if (devfd >= 0) {
|
||||||
hdev->control = devfd;
|
hdev->control = devfd;
|
||||||
} else {
|
} else {
|
||||||
hdev->control = open("/dev/vhost-net", O_RDWR);
|
hdev->control = open(devpath, O_RDWR);
|
||||||
if (hdev->control < 0) {
|
if (hdev->control < 0) {
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,8 @@ struct vhost_dev {
|
|||||||
bool force;
|
bool force;
|
||||||
};
|
};
|
||||||
|
|
||||||
int vhost_dev_init(struct vhost_dev *hdev, int devfd, bool force);
|
int vhost_dev_init(struct vhost_dev *hdev, int devfd, const char *devpath,
|
||||||
|
bool force);
|
||||||
void vhost_dev_cleanup(struct vhost_dev *hdev);
|
void vhost_dev_cleanup(struct vhost_dev *hdev);
|
||||||
bool vhost_dev_query(struct vhost_dev *hdev, VirtIODevice *vdev);
|
bool vhost_dev_query(struct vhost_dev *hdev, VirtIODevice *vdev);
|
||||||
int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev);
|
int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev);
|
||||||
|
@ -109,7 +109,7 @@ struct vhost_net *vhost_net_init(NetClientState *backend, int devfd,
|
|||||||
(1 << VHOST_NET_F_VIRTIO_NET_HDR);
|
(1 << VHOST_NET_F_VIRTIO_NET_HDR);
|
||||||
net->backend = r;
|
net->backend = r;
|
||||||
|
|
||||||
r = vhost_dev_init(&net->dev, devfd, force);
|
r = vhost_dev_init(&net->dev, devfd, "/dev/vhost-net", force);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user