Stefano Stabellini
2009-May-21 16:31 UTC
[Xen-devel] [PATCH] qemu: fix cdrom handling issues
Hi all, this patch fixes few cdrom handling issues: - when a cdrom medium event occurs and the new filename is NULL, we should eject the emulated cdrom instead of just ignoring the event; - when a cdrom medium event occurs and we are in a stubdom, we have to pass the xenstore path of the frontend to bdrv_open instead of the filename; - when we try and fail to open a cdrom (or disk) in a stubdom we should not fall back to the usual "non-stubdom" code path because is useless and wrong. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> --- diff --git a/xenstore.c b/xenstore.c index 9360771..3db3531 100644 --- a/xenstore.c +++ b/xenstore.c @@ -476,9 +476,8 @@ void xenstore_parse_domain_config(int hvm_domid) continue; if (bdrv_open2(bs, danger_buf, BDRV_O_CACHE_WB /* snapshot and write-back */, &bdrv_raw) == 0) { pstrcpy(bs->filename, sizeof(bs->filename), params); - } else -#endif - + } +#else if (params[0]) { if (!format) { if (!drv) { @@ -504,6 +503,8 @@ void xenstore_parse_domain_config(int hvm_domid) fprintf(stderr, "qemu: could not open vbd ''%s'' or hard disk image ''%s'' (drv ''%s'' format ''%s'')\n", buf, params, drv ? drv : "?", format ? format->format_name : "0"); } +#endif + drives_table[nb_drives].bdrv = bs; drives_table[nb_drives].used = 1; nb_drives++; @@ -955,23 +956,22 @@ void xenstore_process_event(void *opaque) fprintf(stderr,"medium change watch on `%s'' (index: %d): %s\n", vec[XS_WATCH_TOKEN], hd_index, image ? image : "<none>"); - if (image == NULL) - goto out; /* gone */ - - /* Strip off blktap sub-type prefix */ - bpath = strdup(vec[XS_WATCH_PATH]); - if (bpath == NULL) - goto out; - if ((offset = strrchr(bpath, ''/'')) != NULL) - *offset = ''\0''; - if (pasprintf(&buf, "%s/type", bpath) == -1) - goto out; - drv = xs_read(xsh, XBT_NULL, buf, &len); - if (drv && !strcmp(drv, "tap") && ((offset = strchr(image, '':'')) != NULL)) - memmove(image, offset+1, strlen(offset+1)+1); + if (image != NULL) { + /* Strip off blktap sub-type prefix */ + bpath = strdup(vec[XS_WATCH_PATH]); + if (bpath == NULL) + goto out; + if ((offset = strrchr(bpath, ''/'')) != NULL) + *offset = ''\0''; + if (pasprintf(&buf, "%s/type", bpath) == -1) + goto out; + drv = xs_read(xsh, XBT_NULL, buf, &len); + if (drv && !strcmp(drv, "tap") && ((offset = strchr(image, '':'')) != NULL)) + memmove(image, offset+1, strlen(offset+1)+1); - if (!strcmp(image, drives_table[hd_index].bdrv->filename)) - goto out; /* identical */ + if (!strcmp(image, drives_table[hd_index].bdrv->filename)) + goto out; /* identical */ + } drives_table[hd_index].bdrv->filename[0] = ''\0''; bdrv_close(drives_table[hd_index].bdrv); @@ -980,8 +980,16 @@ void xenstore_process_event(void *opaque) media_filename[hd_index] = NULL; } - if (image[0]) { + if (image && image[0]) { +#ifdef CONFIG_STUBDOM + char path[strlen(vec[XS_WATCH_PATH]) - 6 + 8]; + path[0] = ''\0''; + strncat(path, vec[XS_WATCH_PATH], strlen(vec[XS_WATCH_PATH]) - 6); + strcat(path, "frontend"); + media_filename[hd_index] = xs_read(xsh, XBT_NULL, path, &len); +#else media_filename[hd_index] = strdup(image); +#endif xenstore_check_new_media_present(5000); } _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel