mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
xl: track size of diskws with a dedicated counter
The num_disks field can change during guest lifetime. Don't use that as the size of diskws, use a dedicated counter instead. Also free diskws and reset diskws to NULL after disabling events so that it will be automatically re-created when the guest reboots. Reported-by: Fatih Acar <fatih.acar@gandi.net> Signed-off-by: Wei Liu <wei.liu2@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Tested-by: Fatih Acar <fatih.acar@gandi.net>
This commit is contained in:
1 parent
df4d268e35
commit
ffe2aae4b2
1 file changed
+7
-2
@@ -2811,6 +2811,7 @@ static int create_domain(struct domain_create *dom_info)
|
||||
int ret, rc;
|
||||
libxl_evgen_domain_death *deathw = NULL;
|
||||
libxl_evgen_disk_eject **diskws = NULL; /* one per disk */
|
||||
unsigned int num_diskws = 0;
|
||||
void *config_data = 0;
|
||||
int config_len = 0;
|
||||
int restore_fd = -1;
|
||||
@@ -3119,8 +3120,9 @@ start:
|
||||
diskws = xmalloc(sizeof(*diskws) * d_config.num_disks);
|
||||
for (i = 0; i < d_config.num_disks; i++)
|
||||
diskws[i] = NULL;
|
||||
num_diskws = d_config.num_disks;
|
||||
}
|
||||
for (i = 0; i < d_config.num_disks; i++) {
|
||||
for (i = 0; i < num_diskws; i++) {
|
||||
if (d_config.disks[i].removable) {
|
||||
ret = libxl_evenable_disk_eject(ctx, domid, d_config.disks[i].vdev,
|
||||
0, &diskws[i]);
|
||||
@@ -3157,7 +3159,10 @@ start:
|
||||
libxl_event_free(ctx, event);
|
||||
libxl_evdisable_domain_death(ctx, deathw);
|
||||
deathw = NULL;
|
||||
evdisable_disk_ejects(diskws, d_config.num_disks);
|
||||
evdisable_disk_ejects(diskws, num_diskws);
|
||||
free(diskws);
|
||||
diskws = NULL;
|
||||
num_diskws = 0;
|
||||
/* discard any other events which may have been generated */
|
||||
while (!(ret = libxl_event_check(ctx, &event,
|
||||
LIBXL_EVENTMASK_ALL, 0,0))) {
|
||||
|
||||