Skip to content
This repository was archived by the owner on Mar 28, 2018. It is now read-only.

Commit 50b6d6f

Browse files
authored
Merge pull request #997 from amshinde/devicemapper-storage
Devicemapper storage
2 parents 0117048 + 271223a commit 50b6d6f

22 files changed

+911
-146
lines changed

data/hypervisor.args.in

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ memory-backend-file,id=mem0,mem-path=@IMAGE@,size=@SIZE@
1313
@KERNEL@
1414
-append
1515
@KERNEL_PARAMS@ @KERNEL_NET_PARAMS@
16-
-device
17-
virtio-9p-pci,fsdev=workload9p,mount_tag=rootfs
18-
-fsdev
19-
local,id=workload9p,path=@WORKLOAD_DIR@,security_model=none
2016
-smp
2117
2,sockets=1,cores=2,threads=1
2218
-cpu

src/hypervisor.c

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,46 @@ cc_oci_append_network_args(struct cc_oci_config *config,
139139
}
140140
}
141141

142+
static gboolean
143+
cc_oci_append_storage_args(struct cc_oci_config *config,
144+
GPtrArray *additional_args)
145+
{
146+
gchar *workload_dir;
147+
148+
if (! (config && additional_args)) {
149+
return false;
150+
}
151+
152+
if (config->device_name) {
153+
g_ptr_array_add(additional_args, g_strdup("-device"));
154+
g_ptr_array_add(additional_args, g_strdup_printf("virtio-blk,drive=drive-%d,scsi=off,config-wce=off",
155+
config->state.block_index));
156+
g_ptr_array_add(additional_args, g_strdup_printf("-drive\nid=drive-%d,file=%s,aio=threads,format=raw,if=none",
157+
config->state.block_index,
158+
config->device_name));
159+
}
160+
161+
workload_dir = cc_oci_get_workload_dir(config);
162+
if (! workload_dir) {
163+
g_critical ("No workload");
164+
return false;
165+
}
166+
167+
if (!(workload_dir[0]
168+
&& g_file_test (workload_dir, G_FILE_TEST_IS_DIR))) {
169+
g_critical ("workload directory: %s does not exist",
170+
workload_dir);
171+
return false;
172+
}
173+
174+
g_ptr_array_add(additional_args, g_strdup("-device"));
175+
g_ptr_array_add(additional_args, g_strdup("virtio-9p-pci,fsdev=workload9p,mount_tag=rootfs"));
176+
g_ptr_array_add(additional_args, g_strdup("-fsdev"));
177+
g_ptr_array_add(additional_args, g_strdup_printf("local,id=workload9p,path=%s,security_model=none", workload_dir));
178+
179+
return true;
180+
}
181+
142182
/*!
143183
* Replace any special tokens found in \p args with their expanded
144184
* values.
@@ -158,7 +198,6 @@ cc_oci_expand_cmdline (struct cc_oci_config *config,
158198
gchar **arg;
159199
gchar *bytes = NULL;
160200
gchar *console_device = NULL;
161-
gchar *workload_dir;
162201
gchar *hypervisor_console = NULL;
163202
g_autofree gchar *procsock_device = NULL;
164203

@@ -194,11 +233,6 @@ cc_oci_expand_cmdline (struct cc_oci_config *config,
194233

195234
/* We're about to launch the hypervisor so validate paths.*/
196235

197-
workload_dir = cc_oci_get_workload_dir(config);
198-
if (! workload_dir) {
199-
g_critical ("No workload");
200-
goto out;
201-
}
202236

203237
if ((!config->vm->image_path[0])
204238
|| stat (config->vm->image_path, &st) < 0) {
@@ -214,13 +248,6 @@ cc_oci_expand_cmdline (struct cc_oci_config *config,
214248
return false;
215249
}
216250

217-
if (!(workload_dir[0]
218-
&& g_file_test (workload_dir, G_FILE_TEST_IS_DIR))) {
219-
g_critical ("workload directory: %s does not exist",
220-
workload_dir);
221-
return false;
222-
}
223-
224251
uuid_generate_random(uuid);
225252
for(size_t i=0; i<sizeof(uuid_t) && uuid_index < sizeof(uuid_pattern); ++i) {
226253
/* hex to char */
@@ -266,7 +293,6 @@ cc_oci_expand_cmdline (struct cc_oci_config *config,
266293
const gchar* name;
267294
const gchar* value;
268295
} special_tags[] = {
269-
{ "@WORKLOAD_DIR@" , workload_dir },
270296
{ "@KERNEL@" , config->vm->kernel_path },
271297
{ "@KERNEL_PARAMS@" , config->vm->kernel_params },
272298
{ "@KERNEL_NET_PARAMS@" , kernel_net_params },
@@ -497,6 +523,7 @@ cc_oci_populate_extra_args(struct cc_oci_config *config ,
497523
//g_ptr_array_add(additional_args, g_strdup("-device testdevice"));
498524

499525
cc_oci_append_network_args(config, additional_args);
526+
cc_oci_append_storage_args(config, additional_args);
500527

501528
return;
502529
}

0 commit comments

Comments
 (0)