@@ -99,8 +99,9 @@ int create_vm(struct vm_description *vm_desc, struct vm **rtn_vm)
99
99
}
100
100
101
101
for (id = 0U ; id < (size_t )(sizeof (long ) * 8U ); id ++ ) {
102
- if (!bitmap_test_and_set (id , & vmid_bitmap ))
102
+ if (!bitmap_test_and_set (id , & vmid_bitmap )) {
103
103
break ;
104
+ }
104
105
}
105
106
vm -> attr .id = id ;
106
107
vm -> attr .boot_idx = id ;
@@ -113,12 +114,14 @@ int create_vm(struct vm_description *vm_desc, struct vm **rtn_vm)
113
114
/* For UOS: This VM software information is configure in DM */
114
115
if (is_vm0 (vm )) {
115
116
status = prepare_vm0_memmap_and_e820 (vm );
116
- if (status != 0 )
117
+ if (status != 0 ) {
117
118
goto err2 ;
119
+ }
118
120
#ifndef CONFIG_EFI_STUB
119
121
status = init_vm0_boot_info (vm );
120
- if (status != 0 )
122
+ if (status != 0 ) {
121
123
goto err2 ;
124
+ }
122
125
#endif
123
126
} else {
124
127
/* populate UOS vm fields according to vm_desc */
@@ -143,8 +146,9 @@ int create_vm(struct vm_description *vm_desc, struct vm **rtn_vm)
143
146
144
147
if (is_vm0 (vm )) {
145
148
/* Load pm S state data */
146
- if (vm_load_pm_s_state (vm ) == 0 )
149
+ if (vm_load_pm_s_state (vm ) == 0 ) {
147
150
register_pm1ab_handler (vm );
151
+ }
148
152
149
153
/* Create virtual uart */
150
154
vm -> vuart = vuart_init (vm );
@@ -166,8 +170,9 @@ int create_vm(struct vm_description *vm_desc, struct vm **rtn_vm)
166
170
vm -> sw .io_shared_page = NULL ;
167
171
168
172
status = set_vcpuid_entries (vm );
169
- if (status != 0 )
173
+ if (status != 0 ) {
170
174
goto err4 ;
175
+ }
171
176
172
177
vm -> state = VM_CREATED ;
173
178
@@ -190,14 +195,16 @@ int shutdown_vm(struct vm *vm)
190
195
uint16_t i ;
191
196
struct vcpu * vcpu = NULL ;
192
197
193
- if (vm == NULL )
198
+ if (vm == NULL ) {
194
199
return - EINVAL ;
200
+ }
195
201
196
202
pause_vm (vm );
197
203
198
204
/* Only allow shutdown paused vm */
199
- if (vm -> state != VM_PAUSED )
205
+ if (vm -> state != VM_PAUSED ) {
200
206
return - EINVAL ;
207
+ }
201
208
202
209
foreach_vcpu (i , vm , vcpu ) {
203
210
reset_vcpu (vcpu );
@@ -226,13 +233,15 @@ int shutdown_vm(struct vm *vm)
226
233
free_io_emulation_resource (vm );
227
234
228
235
/* Free iommu_domain */
229
- if (vm -> iommu_domain != NULL )
236
+ if (vm -> iommu_domain != NULL ) {
230
237
destroy_iommu_domain (vm -> iommu_domain );
238
+ }
231
239
232
240
bitmap_clear (vm -> attr .id , & vmid_bitmap );
233
241
234
- if (vm -> vpic != NULL )
242
+ if (vm -> vpic != NULL ) {
235
243
vpic_cleanup (vm );
244
+ }
236
245
237
246
free (vm -> hw .vcpu_array );
238
247
@@ -267,8 +276,9 @@ void pause_vm(struct vm *vm)
267
276
uint16_t i ;
268
277
struct vcpu * vcpu = NULL ;
269
278
270
- if (vm -> state == VM_PAUSED )
279
+ if (vm -> state == VM_PAUSED ) {
271
280
return ;
281
+ }
272
282
273
283
vm -> state = VM_PAUSED ;
274
284
@@ -320,14 +330,16 @@ int prepare_vm0(void)
320
330
struct vm_description * vm_desc = & vm0_desc ;
321
331
322
332
err = create_vm (vm_desc , & vm );
323
- if (err != 0 )
333
+ if (err != 0 ) {
324
334
return err ;
335
+ }
325
336
326
337
/* Allocate all cpus to vm0 at the beginning */
327
338
for (i = 0U ; i < phys_cpu_num ; i ++ ) {
328
339
err = prepare_vcpu (vm , i );
329
- if (err != 0 )
340
+ if (err != 0 ) {
330
341
return err ;
342
+ }
331
343
}
332
344
333
345
/* start vm0 BSP automatically */
@@ -344,8 +356,9 @@ static inline bool vcpu_in_vm_desc(struct vcpu *vcpu,
344
356
int i ;
345
357
346
358
for (i = 0 ; i < vm_desc -> vm_hw_num_cores ; i ++ ) {
347
- if (vcpu -> pcpu_id == vm_desc -> vm_hw_logical_core_ids [i ])
359
+ if (vcpu -> pcpu_id == vm_desc -> vm_hw_logical_core_ids [i ]) {
348
360
return true;
361
+ }
349
362
}
350
363
351
364
return false;
0 commit comments