qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: qemu-devel@nongnu.org
Cc: Glauber Costa <glommer@redhat.com>,
	Anthony Liguori <aliguori@us.ibm.com>
Subject: [Qemu-devel] [PATCH 14/22] machine: replace QEMUMachine.use_scsi with -machine default_drive
Date: Mon,  7 Jun 2010 18:52:02 -0500	[thread overview]
Message-ID: <1275954730-8196-15-git-send-email-aliguori@us.ibm.com> (raw)
In-Reply-To: <1275954730-8196-1-git-send-email-aliguori@us.ibm.com>

Some boards only support scsi and there's some ugliness to accomodate this.

This patch removes that and introduces a default_drive common option for
machines.  The absence of this option assumes ide.  It can be explicitly set
to scsi and this is used to replace all current occurrances of use_scsi.

As fall out to this patch, current_machine disappears because it's actually
not needed since we no longer access the machine state to check for use_scsi.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>

diff --git a/hw/boards.h b/hw/boards.h
index f33c44b..887487e 100644
--- a/hw/boards.h
+++ b/hw/boards.h
@@ -14,7 +14,6 @@ struct QEMUMachine {
     const char *alias;
     const char *desc;
     QEMUMachineInitFunc *init;
-    int use_scsi;
     int max_cpus;
     int is_default;
     QemuOptDesc *opts_desc;
@@ -75,6 +74,9 @@ extern QEMUMachine *current_machine;
     },{                                 \
         .name = "sdcard",               \
         .type = QEMU_OPT_BOOL,          \
+    },{                                 \
+        .name = "default_drive",        \
+        .type = QEMU_OPT_STRING,        \
     }
 
 
diff --git a/hw/device-hotplug.c b/hw/device-hotplug.c
index 9cc8376..feb8aa3 100644
--- a/hw/device-hotplug.c
+++ b/hw/device-hotplug.c
@@ -38,7 +38,7 @@ DriveInfo *add_init_drive(const char *optstr)
     if (!opts)
         return NULL;
 
-    dinfo = drive_init(opts, current_machine, &fatal_error);
+    dinfo = drive_init(opts, NULL, &fatal_error);
     if (!dinfo) {
         qemu_opts_del(opts);
         return NULL;
diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c
index 1ba9475..7e1e119 100644
--- a/hw/mips_jazz.c
+++ b/hw/mips_jazz.c
@@ -319,14 +319,20 @@ static QEMUMachine mips_magnum_machine = {
     .name = "magnum",
     .desc = "MIPS Magnum",
     .init = mips_magnum_init,
-    .use_scsi = 1,
+    .opts_default = (QemuOptValue[]) {
+        QOPT_VALUE("default_drive", "scsi"),
+        { /* end of list */ }
+    },
 };
 
 static QEMUMachine mips_pica61_machine = {
     .name = "pica61",
     .desc = "Acer Pica 61",
     .init = mips_pica61_init,
-    .use_scsi = 1,
+    .opts_default = (QemuOptValue[]) {
+        QOPT_VALUE("default_drive", "scsi"),
+        { /* end of list */ }
+    },
 };
 
 static void mips_jazz_machine_init(void)
diff --git a/hw/realview.c b/hw/realview.c
index 4364b7b..a36bdbe 100644
--- a/hw/realview.c
+++ b/hw/realview.c
@@ -432,14 +432,20 @@ static QEMUMachine realview_eb_machine = {
     .name = "realview-eb",
     .desc = "ARM RealView Emulation Baseboard (ARM926EJ-S)",
     .init = realview_eb_init,
-    .use_scsi = 1,
+    .opts_default = (QemuOptValue[]) {
+        QOPT_VALUE("default_drive", "scsi"),
+        { /* end of list */ }
+    },
 };
 
 static QEMUMachine realview_eb_mpcore_machine = {
     .name = "realview-eb-mpcore",
     .desc = "ARM RealView Emulation Baseboard (ARM11MPCore)",
     .init = realview_eb_mpcore_init,
-    .use_scsi = 1,
+    .opts_default = (QemuOptValue[]) {
+        QOPT_VALUE("default_drive", "scsi"),
+        { /* end of list */ }
+    },
     .max_cpus = 4,
 };
 
@@ -453,7 +459,10 @@ static QEMUMachine realview_pbx_a9_machine = {
     .name = "realview-pbx-a9",
     .desc = "ARM RealView Platform Baseboard Explore for Cortex-A9",
     .init = realview_pbx_a9_init,
-    .use_scsi = 1,
+    .opts_default = (QemuOptValue[]) {
+        QOPT_VALUE("default_drive", "scsi"),
+        { /* end of list */ }
+    },
     .max_cpus = 4,
 };
 
diff --git a/hw/sun4m.c b/hw/sun4m.c
index 5aa3de1..a400530 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -1319,7 +1319,10 @@ static QEMUMachine ss5_machine = {
     .name = "SS-5",
     .desc = "Sun4m platform, SPARCstation 5",
     .init = ss5_init,
-    .use_scsi = 1,
+    .opts_default = (QemuOptValue[]) {
+        QOPT_VALUE("default_drive", "scsi"),
+        { /* end of list */ }
+    },
     .is_default = 1,
 };
 
@@ -1327,7 +1330,10 @@ static QEMUMachine ss10_machine = {
     .name = "SS-10",
     .desc = "Sun4m platform, SPARCstation 10",
     .init = ss10_init,
-    .use_scsi = 1,
+    .opts_default = (QemuOptValue[]) {
+        QOPT_VALUE("default_drive", "scsi"),
+        { /* end of list */ }
+    },
     .max_cpus = 4,
 };
 
@@ -1335,7 +1341,10 @@ static QEMUMachine ss600mp_machine = {
     .name = "SS-600MP",
     .desc = "Sun4m platform, SPARCserver 600MP",
     .init = ss600mp_init,
-    .use_scsi = 1,
+    .opts_default = (QemuOptValue[]) {
+        QOPT_VALUE("default_drive", "scsi"),
+        { /* end of list */ }
+    },
     .max_cpus = 4,
 };
 
@@ -1343,7 +1352,10 @@ static QEMUMachine ss20_machine = {
     .name = "SS-20",
     .desc = "Sun4m platform, SPARCstation 20",
     .init = ss20_init,
-    .use_scsi = 1,
+    .opts_default = (QemuOptValue[]) {
+        QOPT_VALUE("default_drive", "scsi"),
+        { /* end of list */ }
+    },
     .max_cpus = 4,
 };
 
@@ -1351,35 +1363,50 @@ static QEMUMachine voyager_machine = {
     .name = "Voyager",
     .desc = "Sun4m platform, SPARCstation Voyager",
     .init = vger_init,
-    .use_scsi = 1,
+    .opts_default = (QemuOptValue[]) {
+        QOPT_VALUE("default_drive", "scsi"),
+        { /* end of list */ }
+    },
 };
 
 static QEMUMachine ss_lx_machine = {
     .name = "LX",
     .desc = "Sun4m platform, SPARCstation LX",
     .init = ss_lx_init,
-    .use_scsi = 1,
+    .opts_default = (QemuOptValue[]) {
+        QOPT_VALUE("default_drive", "scsi"),
+        { /* end of list */ }
+    },
 };
 
 static QEMUMachine ss4_machine = {
     .name = "SS-4",
     .desc = "Sun4m platform, SPARCstation 4",
     .init = ss4_init,
-    .use_scsi = 1,
+    .opts_default = (QemuOptValue[]) {
+        QOPT_VALUE("default_drive", "scsi"),
+        { /* end of list */ }
+    },
 };
 
 static QEMUMachine scls_machine = {
     .name = "SPARCClassic",
     .desc = "Sun4m platform, SPARCClassic",
     .init = scls_init,
-    .use_scsi = 1,
+    .opts_default = (QemuOptValue[]) {
+        QOPT_VALUE("default_drive", "scsi"),
+        { /* end of list */ }
+    },
 };
 
 static QEMUMachine sbook_machine = {
     .name = "SPARCbook",
     .desc = "Sun4m platform, SPARCbook",
     .init = sbook_init,
-    .use_scsi = 1,
+    .opts_default = (QemuOptValue[]) {
+        QOPT_VALUE("default_drive", "scsi"),
+        { /* end of list */ }
+    },
 };
 
 static const struct sun4d_hwdef sun4d_hwdefs[] = {
@@ -1599,7 +1626,10 @@ static QEMUMachine ss1000_machine = {
     .name = "SS-1000",
     .desc = "Sun4d platform, SPARCserver 1000",
     .init = ss1000_init,
-    .use_scsi = 1,
+    .opts_default = (QemuOptValue[]) {
+        QOPT_VALUE("default_drive", "scsi"),
+        { /* end of list */ }
+    },
     .max_cpus = 8,
 };
 
@@ -1607,7 +1637,10 @@ static QEMUMachine ss2000_machine = {
     .name = "SS-2000",
     .desc = "Sun4d platform, SPARCcenter 2000",
     .init = ss2000_init,
-    .use_scsi = 1,
+    .opts_default = (QemuOptValue[]) {
+        QOPT_VALUE("default_drive", "scsi"),
+        { /* end of list */ }
+    },
     .max_cpus = 20,
 };
 
@@ -1782,7 +1815,10 @@ static QEMUMachine ss2_machine = {
     .name = "SS-2",
     .desc = "Sun4c platform, SPARCstation 2",
     .init = ss2_init,
-    .use_scsi = 1,
+    .opts_default = (QemuOptValue[]) {
+        QOPT_VALUE("default_drive", "scsi"),
+        { /* end of list */ }
+    },
 };
 
 static void ss2_machine_init(void)
diff --git a/hw/versatilepb.c b/hw/versatilepb.c
index 59b66d7..f407669 100644
--- a/hw/versatilepb.c
+++ b/hw/versatilepb.c
@@ -321,14 +321,20 @@ static QEMUMachine versatilepb_machine = {
     .name = "versatilepb",
     .desc = "ARM Versatile/PB (ARM926EJ-S)",
     .init = vpb_init,
-    .use_scsi = 1,
+    .opts_default = (QemuOptValue[]) {
+        QOPT_VALUE("default_drive", "scsi"),
+        { /* end of list */ }
+    },
 };
 
 static QEMUMachine versatileab_machine = {
     .name = "versatileab",
     .desc = "ARM Versatile/AB (ARM926EJ-S)",
     .init = vab_init,
-    .use_scsi = 1,
+    .opts_default = (QemuOptValue[]) {
+        QOPT_VALUE("default_drive", "scsi"),
+        { /* end of list */ }
+    },
 };
 
 static void versatile_machine_init(void)
diff --git a/vl.c b/vl.c
index 553da4d..1065233 100644
--- a/vl.c
+++ b/vl.c
@@ -783,7 +783,7 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque,
     int bus_id, unit_id;
     int cyls, heads, secs, translation;
     BlockDriver *drv = NULL;
-    QEMUMachine *machine = opaque;
+    const char *default_drive = opaque;
     int max_devs;
     int index;
     int ro = 0;
@@ -797,10 +797,14 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque,
 
     translation = BIOS_ATA_TRANSLATION_AUTO;
 
-    if (machine && machine->use_scsi) {
+    if (default_drive && strcmp(default_drive, "scsi") == 0) {
         type = IF_SCSI;
         max_devs = MAX_SCSI_DEVS;
         pstrcpy(devname, sizeof(devname), "scsi");
+    } else if (default_drive && strcmp(default_drive, "virtio") == 0) {
+        type = IF_VIRTIO;
+        max_devs = MAX_DRIVES;
+        pstrcpy(devname, sizeof(devname), "virtio");
     } else {
         type = IF_IDE;
         max_devs = MAX_IDE_DEVS;
@@ -1136,10 +1140,10 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque,
 
 static int drive_init_func(QemuOpts *opts, void *opaque)
 {
-    QEMUMachine *machine = opaque;
+    const char *default_drive = opaque;
     int fatal_error = 0;
 
-    if (drive_init(opts, machine, &fatal_error) == NULL) {
+    if (drive_init(opts, (void *)default_drive, &fatal_error) == NULL) {
         if (fatal_error)
             return 1;
     }
@@ -1582,7 +1586,6 @@ void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque)
 /* machine registration */
 
 static QEMUMachine *first_machine = NULL;
-QEMUMachine *current_machine = NULL;
 
 int qemu_register_machine(QEMUMachine *m)
 {
@@ -3709,8 +3712,18 @@ int main(int argc, char **argv, char **envp)
     /* open the virtual block devices */
     if (snapshot)
         qemu_opts_foreach(&qemu_drive_opts, drive_enable_snapshot, NULL, 0);
-    if (qemu_opts_foreach(&qemu_drive_opts, drive_init_func, machine, 1) != 0)
-        exit(1);
+
+    {
+        int ret;
+        const char *default_drive;
+
+        default_drive = qemu_opt_get(machine_opts, "default_drive");
+        ret = qemu_opts_foreach(&qemu_drive_opts, drive_init_func,
+                                (void *)default_drive, 1);
+        if (ret != 0) {
+            exit(1);
+        }
+    }
 
     register_savevm_live("ram", 0, 3, NULL, ram_save_live, NULL, 
                          ram_load, NULL);
@@ -3813,8 +3826,6 @@ int main(int argc, char **argv, char **envp)
 
     set_numa_modes();
 
-    current_machine = machine;
-
     /* init USB devices */
     if (usb_enabled) {
         if (foreach_device_config(DEV_USB, usb_parse) < 0)
-- 
1.7.0.4

  parent reply	other threads:[~2010-06-07 23:52 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-07 23:51 [Qemu-devel] [PATCH 0/22] Refactor machine support Anthony Liguori
2010-06-07 23:51 ` [Qemu-devel] [PATCH 01/22] QemuOpts: fix a bug in QemuOpts when setting an option twice Anthony Liguori
2010-06-08  7:51   ` Gerd Hoffmann
2010-06-08 10:32     ` [Qemu-devel] " Paolo Bonzini
2010-06-08 13:07       ` Anthony Liguori
2010-06-08 13:44         ` Gerd Hoffmann
2010-06-08 15:17           ` Anthony Liguori
2010-06-08 15:37             ` Gerd Hoffmann
2010-06-08 16:04               ` Anthony Liguori
2010-06-09  7:01                 ` Gerd Hoffmann
2010-06-08 14:38         ` Paul Brook
2010-06-08 15:14           ` Anthony Liguori
2010-06-07 23:51 ` [Qemu-devel] [PATCH 02/22] QemuOpts: make qemu_opts_validate() store the description list for later use Anthony Liguori
2010-06-07 23:51 ` [Qemu-devel] [PATCH 03/22] QemuOpts: add function to set QemuOpts from defaults Anthony Liguori
2010-06-07 23:51 ` [Qemu-devel] [PATCH 04/22] machine: package all init arguments into a QemuOpts (v2) Anthony Liguori
2010-06-07 23:51 ` [Qemu-devel] [PATCH 05/22] machine: pass all init options as a single QemuOpts Anthony Liguori
2010-06-08  7:58   ` Gerd Hoffmann
2010-06-07 23:51 ` [Qemu-devel] [PATCH 06/22] Make -acpi-enable a machine specific option Anthony Liguori
2010-06-07 23:51 ` [Qemu-devel] [PATCH 07/22] machine: introduce -machine option Anthony Liguori
2010-06-07 23:51 ` [Qemu-devel] [PATCH 08/22] machine: implement -kernel/-append/-initrd options in term of -machine Anthony Liguori
2010-06-07 23:51 ` [Qemu-devel] [PATCH 09/22] machine: implement -m in terms " Anthony Liguori
2010-06-07 23:51 ` [Qemu-devel] [PATCH 10/22] machine: allow boards to specify default values and use it in isapc Anthony Liguori
2010-06-08  8:03   ` Gerd Hoffmann
2010-06-08 13:09     ` Anthony Liguori
2010-06-08 13:29       ` Gerd Hoffmann
2010-06-07 23:51 ` [Qemu-devel] [PATCH 11/22] machine: replace compat_props with opts_default Anthony Liguori
2010-06-07 23:52 ` [Qemu-devel] [PATCH 12/22] machine: some sugary macros to simplify machine default options Anthony Liguori
2010-06-07 23:52 ` [Qemu-devel] [PATCH 13/22] machine: get rid of global default QEMUMachine members Anthony Liguori
2010-06-07 23:52 ` Anthony Liguori [this message]
2010-06-07 23:52 ` [Qemu-devel] [PATCH 15/22] machine: make max_cpus a -machine option Anthony Liguori
2010-06-08  1:01   ` Paul Brook
2010-06-08  1:56     ` Anthony Liguori
2010-06-08  2:56       ` Paul Brook
2010-06-09  7:44       ` Jes Sorensen
2010-06-09  7:47   ` Jes Sorensen
2010-06-07 23:52 ` [Qemu-devel] [PATCH 16/22] machine: move default machine out of machine definitions Anthony Liguori
2010-06-07 23:52 ` [Qemu-devel] [PATCH 17/22] machine: kill machine->alias Anthony Liguori
2010-06-07 23:52 ` [Qemu-devel] [PATCH 18/22] machine: final conversion to pure QemuOpts Anthony Liguori
2010-06-07 23:52 ` [Qemu-devel] [PATCH 19/22] machine: introduce accel option to allow selection of kvm or tcg Anthony Liguori
2010-06-07 23:52 ` [Qemu-devel] [PATCH 20/22] machine: introduce machine core and split qemu_register_machine Anthony Liguori
2010-06-07 23:52 ` [Qemu-devel] [PATCH 21/22] machine: convert pc machines to split core vs machine API Anthony Liguori
2010-06-09  7:51   ` Jes Sorensen
2010-06-07 23:52 ` [Qemu-devel] [PATCH 22/22] machine: introduce -machine-def option to define a machine via config Anthony Liguori
2010-06-08  0:50   ` Anthony Liguori
2010-06-10 17:48     ` Daniel P. Berrange
2010-06-11 13:03       ` Daniel P. Berrange
2010-06-08  3:12 ` [Qemu-devel] [PATCH 0/22] Refactor machine support Paul Brook
2010-06-08 10:24   ` [Qemu-devel] " Paolo Bonzini
2010-06-08 14:30     ` Paul Brook
2010-06-08 15:28       ` Anthony Liguori
2010-06-08 15:36         ` Paul Brook
2010-06-08 15:58           ` Paolo Bonzini
2010-06-08 16:15             ` Anthony Liguori
2010-06-08 21:05               ` Alexander Graf
2010-06-08 21:16                 ` Anthony Liguori
2010-06-08 17:23             ` Anthony Liguori
2010-06-09  2:11             ` Paul Brook
2010-06-09 13:55               ` Anthony Liguori
2010-06-09 14:30                 ` Paul Brook
2010-06-09 20:47                   ` Blue Swirl
2010-06-09 20:52                     ` Anthony Liguori
2010-06-09 21:09                       ` Blue Swirl
2010-06-09 22:26                       ` Paul Brook
2010-06-08 14:04   ` [Qemu-devel] " Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1275954730-8196-15-git-send-email-aliguori@us.ibm.com \
    --to=aliguori@us.ibm.com \
    --cc=glommer@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).