struct kvm_cpu **kvm_cpus;
__thread struct kvm_cpu *current_kvm_cpu;
+static struct disk_image_params disk_image[MAX_DISK_IMAGES];
static u64 ram_size;
static u8 image_count;
static u8 num_net_devices;
static const char *vmlinux_filename;
static const char *initrd_filename;
static const char *firmware_filename;
-static const char *image_filename[MAX_DISK_IMAGES];
static const char *console;
static const char *dev;
static const char *network;
static const char *custom_rootfs_name = "default";
static struct virtio_net_params *net_params;
static bool single_step;
-static bool readonly_image[MAX_DISK_IMAGES];
static bool vnc;
static bool sdl;
static bool balloon;
if (image_count >= MAX_DISK_IMAGES)
die("Currently only 4 images are supported");
- image_filename[image_count] = arg;
+ disk_image[image_count].filename = arg;
sep = strstr(arg, ",");
if (sep) {
if (strcmp(sep + 1, "ro") == 0)
- readonly_image[image_count] = 1;
+ disk_image[image_count].readonly = true;
*sep = 0;
}
if (kernel_cmdline)
strlcat(real_cmdline, kernel_cmdline, sizeof(real_cmdline));
- if (!using_rootfs && !image_filename[0] && !initrd_filename) {
+ if (!using_rootfs && !disk_image[0].filename && !initrd_filename) {
char tmp[PATH_MAX];
kvm_setup_create_new(custom_rootfs_name);
if (image_count) {
kvm->nr_disks = image_count;
- kvm->disks = disk_image__open_all(image_filename, readonly_image, image_count);
+ kvm->disks = disk_image__open_all((struct disk_image_params *)&disk_image, image_count);
if (IS_ERR(kvm->disks)) {
r = PTR_ERR(kvm->disks);
pr_err("disk_image__open_all() failed with error %ld\n",
return ERR_PTR(-ENOSYS);
}
-struct disk_image **disk_image__open_all(const char **filenames,
- bool *readonly, int count)
+struct disk_image **disk_image__open_all(struct disk_image_params *params, int count)
{
struct disk_image **disks;
- int i;
+ const char *filename;
+ bool readonly;
void *err;
+ int i;
if (!count)
return ERR_PTR(-EINVAL);
return ERR_PTR(-ENOMEM);
for (i = 0; i < count; i++) {
- if (!filenames[i])
+ filename = params[i].filename;
+ readonly = params[i].readonly;
+ if (!filename)
continue;
- disks[i] = disk_image__open(filenames[i], readonly[i]);
+ disks[i] = disk_image__open(filename, readonly);
if (IS_ERR_OR_NULL(disks[i])) {
- pr_err("Loading disk image '%s' failed", filenames[i]);
+ pr_err("Loading disk image '%s' failed", filename);
err = disks[i];
goto error;
}
int (*close)(struct disk_image *disk);
};
+struct disk_image_params {
+ const char *filename;
+ bool readonly;
+};
+
struct disk_image {
int fd;
u64 size;
};
struct disk_image *disk_image__open(const char *filename, bool readonly);
-struct disk_image **disk_image__open_all(const char **filenames, bool *readonly, int count);
+struct disk_image **disk_image__open_all(struct disk_image_params *params, int count);
struct disk_image *disk_image__new(int fd, u64 size, struct disk_image_operations *ops, int mmap);
int disk_image__close(struct disk_image *disk);
int disk_image__close_all(struct disk_image **disks, int count);