RFC: Small cleanup to legacy drive option parsing
Currently, the old-style options for specifying drives (-hd[abcd], -cdrom, etc.) are equivalent to more longer new-style (-drive) options. However, in the code which handles these, the equivalency is not directly obvious, since it's handled via the drive_add() function which somewhat awkwardly translates an interface type enum into a string option, so that drive_def() can change it back again.
This patch cleanups up this handling, by abolishing drive_add() and replacing it with drive_def_print(), a convenience wrapper around drive_def() which should make the equivalency between the leagcy options and longer -drive strings more obvious to C programmers.
This also slighly reduces code size:
blockdev.c | 22 ------------------- vl.c | 68 +++++++++++++++++++++++++++++++++++++------------------------ 2 files changed, 42 insertions(+), 48 deletions(-)
blockdev.c +0 -22
@@ -92,28 +92,6 @@ QemuOpts *drive_def(const char *optstr)return qemu_opts_parse (qemu_find_opts ("drive" ), optstr,0 ); } -QemuOpts *drive_add (BlockInterfaceType type,int index,const char *file, -const char *optstr) -{ -QemuOpts *opts; -char buf[32 ]; - - opts =drive_def (optstr); -if (!opts) { -return NULL ; - } -if (type !=IF_DEFAULT ) { -qemu_opt_set (opts,"if" , if_name[type]); - } -if (index >=0 ) { -snprintf (buf,sizeof (buf),"%d" , index); -qemu_opt_set (opts,"index" , buf); - } -if (file) -qemu_opt_set (opts,"file" , file); -return opts; -} -DriveInfo *drive_get (BlockInterfaceType type,int bus,int unit) {DriveInfo *dinfo;
vl.c +42 -26
139 lines not on this page · raw message
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson