summaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2011-01-28 11:21:41 +0100
committerKevin Wolf <kwolf@redhat.com>2011-01-31 10:59:09 +0100
commit2292ddaeab3467c68efd9e07e17ca0c9fc510fdc (patch)
tree7977bb2762dc972c8bbf4e2f20d0c034a6772839 /vl.c
parent27d6bf40edc346a61ade6d4c5d4f27f6b40acc81 (diff)
blockdev: Make drive_add() take explicit type, index parameters
Before, type & index were hidden in printf-like fmt, ... parameters, which get expanded into an option string. Rather inconvenient for uses later in this series. New IF_DEFAULT to ask for the machine's default interface. Before, that was done by having no option "if" in the option string. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/vl.c b/vl.c
index 14255c4948..5399e33791 100644
--- a/vl.c
+++ b/vl.c
@@ -621,12 +621,13 @@ static int bt_parse(const char *opt)
/***********************************************************/
/* QEMU Block devices */
-#define HD_ALIAS "index=%d,media=disk"
-#define CDROM_ALIAS "index=2,media=cdrom"
-#define FD_ALIAS "index=%d,if=floppy"
-#define PFLASH_ALIAS "if=pflash"
-#define MTD_ALIAS "if=mtd"
-#define SD_ALIAS "index=0,if=sd"
+/* Any % in the following strings must be escaped as %% */
+#define HD_OPTS "media=disk"
+#define CDROM_OPTS "media=cdrom"
+#define FD_OPTS ""
+#define PFLASH_OPTS ""
+#define MTD_OPTS ""
+#define SD_OPTS ""
static int drive_init_func(QemuOpts *opts, void *opaque)
{
@@ -1987,7 +1988,7 @@ int main(int argc, char **argv, char **envp)
if (optind >= argc)
break;
if (argv[optind][0] != '-') {
- hda_opts = drive_add(argv[optind++], HD_ALIAS, 0);
+ hda_opts = drive_add(IF_DEFAULT, 0, argv[optind++], HD_OPTS);
} else {
const QEMUOption *popt;
@@ -2027,11 +2028,11 @@ int main(int argc, char **argv, char **envp)
break;
case QEMU_OPTION_hda:
if (cyls == 0)
- hda_opts = drive_add(optarg, HD_ALIAS, 0);
+ hda_opts = drive_add(IF_DEFAULT, 0, optarg, HD_OPTS);
else
- hda_opts = drive_add(optarg, HD_ALIAS
+ hda_opts = drive_add(IF_DEFAULT, 0, optarg, HD_OPTS
",cyls=%d,heads=%d,secs=%d%s",
- 0, cyls, heads, secs,
+ cyls, heads, secs,
translation == BIOS_ATA_TRANSLATION_LBA ?
",trans=lba" :
translation == BIOS_ATA_TRANSLATION_NONE ?
@@ -2040,10 +2041,11 @@ int main(int argc, char **argv, char **envp)
case QEMU_OPTION_hdb:
case QEMU_OPTION_hdc:
case QEMU_OPTION_hdd:
- drive_add(optarg, HD_ALIAS, popt->index - QEMU_OPTION_hda);
+ drive_add(IF_DEFAULT, popt->index - QEMU_OPTION_hda, optarg,
+ HD_OPTS);
break;
case QEMU_OPTION_drive:
- drive_add(NULL, "%s", optarg);
+ drive_def(optarg);
break;
case QEMU_OPTION_set:
if (qemu_set_option(optarg) != 0)
@@ -2054,13 +2056,13 @@ int main(int argc, char **argv, char **envp)
exit(1);
break;
case QEMU_OPTION_mtdblock:
- drive_add(optarg, MTD_ALIAS);
+ drive_add(IF_MTD, -1, optarg, MTD_OPTS);
break;
case QEMU_OPTION_sd:
- drive_add(optarg, SD_ALIAS);
+ drive_add(IF_SD, 0, optarg, SD_OPTS);
break;
case QEMU_OPTION_pflash:
- drive_add(optarg, PFLASH_ALIAS);
+ drive_add(IF_PFLASH, -1, optarg, PFLASH_OPTS);
break;
case QEMU_OPTION_snapshot:
snapshot = 1;
@@ -2139,7 +2141,7 @@ int main(int argc, char **argv, char **envp)
kernel_cmdline = optarg;
break;
case QEMU_OPTION_cdrom:
- drive_add(optarg, CDROM_ALIAS);
+ drive_add(IF_DEFAULT, 2, optarg, CDROM_OPTS);
break;
case QEMU_OPTION_boot:
{
@@ -2192,7 +2194,8 @@ int main(int argc, char **argv, char **envp)
break;
case QEMU_OPTION_fda:
case QEMU_OPTION_fdb:
- drive_add(optarg, FD_ALIAS, popt->index - QEMU_OPTION_fda);
+ drive_add(IF_FLOPPY, popt->index - QEMU_OPTION_fda,
+ optarg, FD_OPTS);
break;
case QEMU_OPTION_no_fd_bootchk:
fd_bootchk = 0;
@@ -2892,17 +2895,17 @@ int main(int argc, char **argv, char **envp)
if (default_cdrom) {
/* we always create the cdrom drive, even if no disk is there */
- drive_add(NULL, CDROM_ALIAS);
+ drive_add(IF_DEFAULT, 2, NULL, CDROM_OPTS);
}
if (default_floppy) {
/* we always create at least one floppy */
- drive_add(NULL, FD_ALIAS, 0);
+ drive_add(IF_FLOPPY, 0, NULL, FD_OPTS);
}
if (default_sdcard) {
/* we always create one sd slot, even if no card is in it */
- drive_add(NULL, SD_ALIAS);
+ drive_add(IF_SD, 0, NULL, SD_OPTS);
}
/* open the virtual block devices */