Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tools/lkl/cptofs.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,8 @@ int main(int argc, char **argv)
goto out;
}

disk.ops = NULL;

ret = lkl_disk_add(&disk);
if (ret < 0) {
fprintf(stderr, "can't add disk: %s\n", lkl_strerror(ret));
Expand Down
2 changes: 2 additions & 0 deletions tools/lkl/fs2tar.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ int main(int argc, char **argv)
goto out;
}

disk.ops = NULL;

ret = lkl_disk_add(&disk);
if (ret < 0) {
fprintf(stderr, "can't add disk: %s\n", lkl_strerror(ret));
Expand Down
6 changes: 6 additions & 0 deletions tools/lkl/include/lkl.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ const char *lkl_strerror(int err);
*/
void lkl_perror(char *msg, int err);

/**
* struct lkl_dev_blk_ops - block device host operations, defined in lkl_host.h.
*/
struct lkl_dev_blk_ops;

/**
* lkl_disk - host disk handle
*
Expand All @@ -97,6 +102,7 @@ struct lkl_disk {
int fd;
void *handle;
};
struct lkl_dev_blk_ops *ops;
};

/**
Expand Down
5 changes: 4 additions & 1 deletion tools/lkl/lib/virtio_blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ int lkl_disk_add(struct lkl_disk *disk)
dev->dev.config_data = &dev->config;
dev->dev.config_len = sizeof(dev->config);
dev->dev.ops = &blk_ops;
dev->ops = &lkl_dev_blk_ops;
if (disk->ops)
dev->ops = disk->ops;
else
dev->ops = &lkl_dev_blk_ops;
dev->disk = *disk;

ret = dev->ops->get_capacity(*disk, &capacity);
Expand Down
2 changes: 2 additions & 0 deletions tools/lkl/tests/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ int test_disk_add(char *str, int len)
#endif
goto out_unlink;

disk.ops = NULL;

disk_id = lkl_disk_add(&disk);
if (disk_id < 0)
goto out_close;
Expand Down