From patchwork Fri Jun 4 16:33:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 54654 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id F4095B7D43 for ; Sat, 5 Jun 2010 03:49:39 +1000 (EST) Received: from localhost ([127.0.0.1]:53237 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OKayL-0007Nm-Az for incoming@patchwork.ozlabs.org; Fri, 04 Jun 2010 13:46:21 -0400 Received: from [140.186.70.92] (port=52848 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OKapl-0005ZE-Pa for qemu-devel@nongnu.org; Fri, 04 Jun 2010 13:37:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OKape-0002m3-Jb for qemu-devel@nongnu.org; Fri, 04 Jun 2010 13:37:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:18201) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OKape-0002lq-CF for qemu-devel@nongnu.org; Fri, 04 Jun 2010 13:37:22 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o54HbIVc010162 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 4 Jun 2010 13:37:20 -0400 Received: from localhost.localdomain (vpn2-9-144.ams2.redhat.com [10.36.9.144]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o54GXWT7032074; Fri, 4 Jun 2010 12:40:32 -0400 From: Kevin Wolf To: anthony@codemonkey.ws Date: Fri, 4 Jun 2010 18:33:12 +0200 Message-Id: <1275669195-28312-25-git-send-email-kwolf@redhat.com> In-Reply-To: <1275669195-28312-1-git-send-email-kwolf@redhat.com> References: <1275669195-28312-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 24/27] blockdev: Hide QEMUMachine from drive_init() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Markus Armbruster To pave the way for moving it out of vl.c. Signed-off-by: Markus Armbruster Signed-off-by: Kevin Wolf --- hw/device-hotplug.c | 2 +- hw/usb-msd.c | 2 +- sysemu.h | 3 ++- vl.c | 12 +++++------- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/hw/device-hotplug.c b/hw/device-hotplug.c index 9cc8376..a3fe99e 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, current_machine->use_scsi, &fatal_error); if (!dinfo) { qemu_opts_del(opts); return NULL; diff --git a/hw/usb-msd.c b/hw/usb-msd.c index c1c2537..0ba4a64 100644 --- a/hw/usb-msd.c +++ b/hw/usb-msd.c @@ -584,7 +584,7 @@ static USBDevice *usb_msd_init(const char *filename) qemu_opt_set(opts, "if", "none"); /* create host drive */ - dinfo = drive_init(opts, NULL, &fatal_error); + dinfo = drive_init(opts, 0, &fatal_error); if (!dinfo) { qemu_opts_del(opts); return NULL; diff --git a/sysemu.h b/sysemu.h index fd83b7d..46a1b2f 100644 --- a/sysemu.h +++ b/sysemu.h @@ -191,7 +191,8 @@ extern BlockInterfaceErrorAction drive_get_on_error( BlockDriverState *qdev_init_bdrv(DeviceState *dev, BlockInterfaceType type); extern QemuOpts *drive_add(const char *file, const char *fmt, ...); -extern DriveInfo *drive_init(QemuOpts *arg, void *machine, int *fatal_error); +extern DriveInfo *drive_init(QemuOpts *arg, int default_to_scsi, + int *fatal_error); /* device-hotplug */ diff --git a/vl.c b/vl.c index 551138f..db1fefd 100644 --- a/vl.c +++ b/vl.c @@ -767,8 +767,7 @@ static int parse_block_error_action(const char *buf, int is_read) } } -DriveInfo *drive_init(QemuOpts *opts, void *opaque, - int *fatal_error) +DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi, int *fatal_error) { const char *buf; const char *file = NULL; @@ -780,7 +779,6 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque, int bus_id, unit_id; int cyls, heads, secs, translation; BlockDriver *drv = NULL; - QEMUMachine *machine = opaque; int max_devs; int index; int ro = 0; @@ -795,7 +793,7 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque, translation = BIOS_ATA_TRANSLATION_AUTO; - if (machine && machine->use_scsi) { + if (default_to_scsi) { type = IF_SCSI; max_devs = MAX_SCSI_DEVS; pstrcpy(devname, sizeof(devname), "scsi"); @@ -1135,10 +1133,10 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque, static int drive_init_func(QemuOpts *opts, void *opaque) { - QEMUMachine *machine = opaque; + int *use_scsi = opaque; int fatal_error = 0; - if (drive_init(opts, machine, &fatal_error) == NULL) { + if (drive_init(opts, *use_scsi, &fatal_error) == NULL) { if (fatal_error) return 1; } @@ -3641,7 +3639,7 @@ 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) + if (qemu_opts_foreach(&qemu_drive_opts, drive_init_func, &machine->use_scsi, 1) != 0) exit(1); register_savevm_live("ram", 0, 3, NULL, ram_save_live, NULL,