Message ID | 1277484812-22012-5-git-send-email-armbru@redhat.com |
---|---|
State | New |
Headers | show |
> +DriveInfo *drive_of_blockdev(BlockDriverState *bs)
I'd call this find_drive_by_blockdev.
Christoph Hellwig <hch@lst.de> writes: >> +DriveInfo *drive_of_blockdev(BlockDriverState *bs) > > I'd call this find_drive_by_blockdev. For what it's worth, all externally visible functions dealing with drives start with "drive_".
On Sat, Jun 26, 2010 at 07:32:09AM +0200, Markus Armbruster wrote: > Christoph Hellwig <hch@lst.de> writes: > > >> +DriveInfo *drive_of_blockdev(BlockDriverState *bs) > > > > I'd call this find_drive_by_blockdev. > > For what it's worth, all externally visible functions dealing with > drives start with "drive_". Ok. How about drive_get_by_blockdev, matching the drive_get_by_id we have around?
Christoph Hellwig <hch@lst.de> writes: > On Sat, Jun 26, 2010 at 07:32:09AM +0200, Markus Armbruster wrote: >> Christoph Hellwig <hch@lst.de> writes: >> >> >> +DriveInfo *drive_of_blockdev(BlockDriverState *bs) >> > >> > I'd call this find_drive_by_blockdev. >> >> For what it's worth, all externally visible functions dealing with >> drives start with "drive_". > > Ok. How about drive_get_by_blockdev, matching the drive_get_by_id we > have around? drive_get_by_id() gets removed by 07/12. But there's still drive_get(). drive_get_by_blockdev()? blockdev_to_drive()?
On Sat, Jun 26, 2010 at 04:46:28PM +0200, Markus Armbruster wrote: > drive_get_by_id() gets removed by 07/12. But there's still drive_get(). > > drive_get_by_blockdev()? blockdev_to_drive()? Oh well, just keep any name - it's not that important aftet all.
On 06/26/2010 04:46 PM, Markus Armbruster wrote:
> drive_get_by_blockdev()? blockdev_to_drive()?
I like drive_find_by_blockdev or drive_get_by_blockdev, in any case I'll
make sure my own cpu_get_by_id is named in the same style that you choose.
Paolo
Paolo Bonzini <pbonzini@redhat.com> writes: > On 06/26/2010 04:46 PM, Markus Armbruster wrote: >> drive_get_by_blockdev()? blockdev_to_drive()? > > I like drive_find_by_blockdev or drive_get_by_blockdev, in any case > I'll make sure my own cpu_get_by_id is named in the same style that > you choose. drive_get_by_blockdev() it is. As long as this is the only change, I don't think another post to the list is necessary. Instead, I'll push to my tree and let Kevin pick it up from there.
diff --git a/blockdev.c b/blockdev.c index e0495e5..8023cfd 100644 --- a/blockdev.c +++ b/blockdev.c @@ -78,6 +78,18 @@ int drive_get_max_bus(BlockInterfaceType type) return max_bus; } +DriveInfo *drive_of_blockdev(BlockDriverState *bs) +{ + DriveInfo *dinfo; + + QTAILQ_FOREACH(dinfo, &drives, next) { + if (dinfo->bdrv == bs) { + return dinfo; + } + } + return NULL; +} + static void bdrv_format_print(void *opaque, const char *name) { fprintf(stderr, " %s", name); diff --git a/blockdev.h b/blockdev.h index a936785..4bf75b1 100644 --- a/blockdev.h +++ b/blockdev.h @@ -40,6 +40,7 @@ extern DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit); extern DriveInfo *drive_get_by_id(const char *id); extern int drive_get_max_bus(BlockInterfaceType type); extern void drive_uninit(DriveInfo *dinfo); +extern DriveInfo *drive_of_blockdev(BlockDriverState *bs); extern QemuOpts *drive_add(const char *file, const char *fmt, ...); extern DriveInfo *drive_init(QemuOpts *arg, int default_to_scsi,
Signed-off-by: Markus Armbruster <armbru@redhat.com> --- blockdev.c | 12 ++++++++++++ blockdev.h | 1 + 2 files changed, 13 insertions(+), 0 deletions(-)