From 8aab031fc66c4cedc1c08ed346fe39a2ea2aaba7 Mon Sep 17 00:00:00 2001 From: Max Filippov Date: Fri, 8 Jun 2012 13:50:34 +0400 Subject: xtensa_lx60: add missing #include "blockdev.h" This should fix the following build failure: /home/buildbot/slave-public/block_mingw32/build/hw/xtensa_lx60.c: In function 'lx_init': /home/buildbot/slave-public/block_mingw32/build/hw/xtensa_lx60.c:212: warning: implicit declaration of function 'drive_get' /home/buildbot/slave-public/block_mingw32/build/hw/xtensa_lx60.c:212: warning: nested extern declaration of 'drive_get' /home/buildbot/slave-public/block_mingw32/build/hw/xtensa_lx60.c:212: error: 'IF_PFLASH' undeclared (first use in this function) /home/buildbot/slave-public/block_mingw32/build/hw/xtensa_lx60.c:212: error: (Each undeclared identifier is reported only once /home/buildbot/slave-public/block_mingw32/build/hw/xtensa_lx60.c:212: error: for each function it appears in.) /home/buildbot/slave-public/block_mingw32/build/hw/xtensa_lx60.c:216: error: dereferencing pointer to incomplete type Signed-off-by: Max Filippov Signed-off-by: Kevin Wolf --- hw/xtensa_lx60.c | 1 + 1 file changed, 1 insertion(+) (limited to 'hw') diff --git a/hw/xtensa_lx60.c b/hw/xtensa_lx60.c index b153bfdddf..152eed95d8 100644 --- a/hw/xtensa_lx60.c +++ b/hw/xtensa_lx60.c @@ -34,6 +34,7 @@ #include "pc.h" #include "sysbus.h" #include "flash.h" +#include "blockdev.h" #include "xtensa_bootparam.h" typedef struct LxBoardDesc { -- cgit v1.2.3 From dfc65f1f780622d852ca8b9fb1421735ee56c48b Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 11 May 2012 17:22:19 +0200 Subject: Un-inline fdctrl_init_isa() Signed-off-by: Markus Armbruster Reviewed-by: Anthony Liguori Signed-off-by: Kevin Wolf --- hw/fdc.c | 20 ++++++++++++++++++++ hw/fdc.h | 24 ++---------------------- hw/ide/piix.c | 3 ++- hw/isa.h | 2 -- hw/pc_sysfw.c | 1 + 5 files changed, 25 insertions(+), 25 deletions(-) (limited to 'hw') diff --git a/hw/fdc.c b/hw/fdc.c index 30d34e3f1d..bfa4e686fa 100644 --- a/hw/fdc.c +++ b/hw/fdc.c @@ -1888,6 +1888,26 @@ static int fdctrl_connect_drives(FDCtrl *fdctrl) return 0; } +ISADevice *fdctrl_init_isa(ISABus *bus, DriveInfo **fds) +{ + ISADevice *dev; + + dev = isa_try_create(bus, "isa-fdc"); + if (!dev) { + return NULL; + } + + if (fds[0]) { + qdev_prop_set_drive_nofail(&dev->qdev, "driveA", fds[0]->bdrv); + } + if (fds[1]) { + qdev_prop_set_drive_nofail(&dev->qdev, "driveB", fds[1]->bdrv); + } + qdev_init_nofail(&dev->qdev); + + return dev; +} + void fdctrl_init_sysbus(qemu_irq irq, int dma_chann, target_phys_addr_t mmio_base, DriveInfo **fds) { diff --git a/hw/fdc.h b/hw/fdc.h index 55a8d732c1..1b32b17bef 100644 --- a/hw/fdc.h +++ b/hw/fdc.h @@ -1,32 +1,12 @@ #ifndef HW_FDC_H #define HW_FDC_H -#include "isa.h" -#include "blockdev.h" +#include "qemu-common.h" /* fdc.c */ #define MAX_FD 2 -static inline ISADevice *fdctrl_init_isa(ISABus *bus, DriveInfo **fds) -{ - ISADevice *dev; - - dev = isa_try_create(bus, "isa-fdc"); - if (!dev) { - return NULL; - } - - if (fds[0]) { - qdev_prop_set_drive_nofail(&dev->qdev, "driveA", fds[0]->bdrv); - } - if (fds[1]) { - qdev_prop_set_drive_nofail(&dev->qdev, "driveB", fds[1]->bdrv); - } - qdev_init_nofail(&dev->qdev); - - return dev; -} - +ISADevice *fdctrl_init_isa(ISABus *bus, DriveInfo **fds); void fdctrl_init_sysbus(qemu_irq irq, int dma_chann, target_phys_addr_t mmio_base, DriveInfo **fds); void sun4m_fdctrl_init(qemu_irq irq, target_phys_addr_t io_base, diff --git a/hw/ide/piix.c b/hw/ide/piix.c index bcaa400e2d..f5a74c293a 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -22,11 +22,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ + #include #include #include #include -#include "block.h" +#include "blockdev.h" #include "sysemu.h" #include "dma.h" diff --git a/hw/isa.h b/hw/isa.h index f7bc4b5a95..6c6fd7fac9 100644 --- a/hw/isa.h +++ b/hw/isa.h @@ -9,8 +9,6 @@ #define ISA_NUM_IRQS 16 -typedef struct ISADevice ISADevice; - #define TYPE_ISA_DEVICE "isa-device" #define ISA_DEVICE(obj) \ OBJECT_CHECK(ISADevice, (obj), TYPE_ISA_DEVICE) diff --git a/hw/pc_sysfw.c b/hw/pc_sysfw.c index f0d7c21b5c..b45f0acc7d 100644 --- a/hw/pc_sysfw.c +++ b/hw/pc_sysfw.c @@ -23,6 +23,7 @@ * THE SOFTWARE. */ +#include "blockdev.h" #include "sysbus.h" #include "hw.h" #include "pc.h" -- cgit v1.2.3 From 137745c5c60f083ec982fe9e861e8c16ebca1ba8 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Tue, 5 Jun 2012 16:49:25 +0200 Subject: scsi-disk: Don't peek behind the BlockDriverState abstraction Use the appropriate interface instead. Signed-off-by: Markus Armbruster Acked-by: Paolo Bonzini Signed-off-by: Kevin Wolf --- hw/scsi-disk.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'hw') diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index 1691491c03..9197b08d84 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -34,7 +34,6 @@ do { printf("scsi-disk: " fmt , ## __VA_ARGS__); } while (0) #include "scsi-defs.h" #include "sysemu.h" #include "blockdev.h" -#include "block_int.h" #include "dma.h" #ifdef __linux @@ -1889,7 +1888,7 @@ static SCSIRequest *scsi_block_new_request(SCSIDevice *d, uint32_t tag, * ones (such as WRITE SAME or EXTENDED COPY, etc.). So, without * O_DIRECT everything must go through SG_IO. */ - if (!(s->qdev.conf.bs->open_flags & BDRV_O_NOCACHE)) { + if (bdrv_get_flags(s->qdev.conf.bs) & BDRV_O_NOCACHE) { break; } -- cgit v1.2.3 From 7cdd481cdf15d610f83e38f15c7e7979420c6ac0 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 6 Jun 2012 00:04:54 +0200 Subject: ide: support enable/disable write cache Enabling or disabling the write cache is done with the SET FEATURES command. The command can be issued with sg_sat_set_features from sg3-utils. Signed-off-by: Paolo Bonzini Signed-off-by: Kevin Wolf --- hw/ide/core.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'hw') diff --git a/hw/ide/core.c b/hw/ide/core.c index 9785d5f713..f28229a193 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -1047,6 +1047,7 @@ static bool ide_cmd_permitted(IDEState *s, uint32_t cmd) void ide_exec_cmd(IDEBus *bus, uint32_t val) { + uint16_t *identify_data; IDEState *s; int n; int lba48 = 0; @@ -1231,10 +1232,21 @@ void ide_exec_cmd(IDEBus *bus, uint32_t val) goto abort_cmd; /* XXX: valid for CDROM ? */ switch(s->feature) { - case 0xcc: /* reverting to power-on defaults enable */ - case 0x66: /* reverting to power-on defaults disable */ case 0x02: /* write cache enable */ + bdrv_set_enable_write_cache(s->bs, true); + identify_data = (uint16_t *)s->identify_data; + put_le16(identify_data + 85, (1 << 14) | (1 << 5) | 1); + s->status = READY_STAT | SEEK_STAT; + ide_set_irq(s->bus); + break; case 0x82: /* write cache disable */ + bdrv_set_enable_write_cache(s->bs, false); + identify_data = (uint16_t *)s->identify_data; + put_le16(identify_data + 85, (1 << 14) | 1); + ide_flush_cache(s); + break; + case 0xcc: /* reverting to power-on defaults enable */ + case 0x66: /* reverting to power-on defaults disable */ case 0xaa: /* read look-ahead enable */ case 0x55: /* read look-ahead disable */ case 0x05: /* set advanced power management mode */ @@ -1250,7 +1262,7 @@ void ide_exec_cmd(IDEBus *bus, uint32_t val) break; case 0x03: { /* set transfer mode */ uint8_t val = s->nsector & 0x07; - uint16_t *identify_data = (uint16_t *)s->identify_data; + identify_data = (uint16_t *)s->identify_data; switch (s->nsector >> 3) { case 0x00: /* pio default */ @@ -2146,6 +2158,9 @@ static int ide_drive_post_load(void *opaque, int version_id) s->cdrom_changed = 1; } } + if (s->identify_set) { + bdrv_set_enable_write_cache(s->bs, !!(s->identify_data[85] & (1 << 5))); + } return 0; } -- cgit v1.2.3 From 8814a05112632ec30f0b5b41d7b2cc639199c7f9 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 13 Jun 2012 10:11:49 +0200 Subject: xen: Don't change -drive if=xen device name during machine init A "top" BlockDriverState has a non-empty device_name. If the user doesn't specify one with -drive parameter id, the system supplies a default name. xen_config_dev_blk() changes this name, during machine initialization. Naughty. Don't do that. Signed-off-by: Markus Armbruster Acked-by: Stefano Stabellini Signed-off-by: Kevin Wolf --- hw/xen_devconfig.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'hw') diff --git a/hw/xen_devconfig.c b/hw/xen_devconfig.c index 41accbbfa9..7b7b0a2bf0 100644 --- a/hw/xen_devconfig.c +++ b/hw/xen_devconfig.c @@ -94,16 +94,15 @@ static int xen_config_dev_all(char *fe, char *be) int xen_config_dev_blk(DriveInfo *disk) { - char fe[256], be[256]; + char fe[256], be[256], device_name[32]; int vdev = 202 * 256 + 16 * disk->unit; int cdrom = disk->media_cd; const char *devtype = cdrom ? "cdrom" : "disk"; const char *mode = cdrom ? "r" : "w"; - snprintf(disk->bdrv->device_name, sizeof(disk->bdrv->device_name), - "xvd%c", 'a' + disk->unit); + snprintf(device_name, sizeof(device_name), "xvd%c", 'a' + disk->unit); xen_be_printf(NULL, 1, "config disk %d [%s]: %s\n", - disk->unit, disk->bdrv->device_name, disk->bdrv->filename); + disk->unit, device_name, disk->bdrv->filename); xen_config_dev_dirs("vbd", "qdisk", vdev, fe, be, sizeof(fe)); /* frontend */ @@ -111,7 +110,7 @@ int xen_config_dev_blk(DriveInfo *disk) xenstore_write_str(fe, "device-type", devtype); /* backend */ - xenstore_write_str(be, "dev", disk->bdrv->device_name); + xenstore_write_str(be, "dev", device_name); xenstore_write_str(be, "type", "file"); xenstore_write_str(be, "params", disk->bdrv->filename); xenstore_write_str(be, "mode", mode); -- cgit v1.2.3 From 093003b1d3d7453d65bcbe8ad7e911950fc076f5 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 13 Jun 2012 10:11:50 +0200 Subject: xen: Don't peek behind the BlockDriverState abstraction First offender is xen_config_dev_blk()'s use of disk->bdrv->filename. Get the filename from disk->opts instead. Same result, except for snapshots: there, we now get the filename specified by the user instead of the name of the temporary image created by bdrv_open(). Should be an improvement. Second offender is blk_init()'s use of blkdev->bs->drv->format_name. Simply use the appropriate interface to get the format name. Signed-off-by: Markus Armbruster Acked-by: Stefano Stabellini Signed-off-by: Kevin Wolf --- hw/xen_devconfig.c | 6 +++--- hw/xen_disk.c | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'hw') diff --git a/hw/xen_devconfig.c b/hw/xen_devconfig.c index 7b7b0a2bf0..0928613b55 100644 --- a/hw/xen_devconfig.c +++ b/hw/xen_devconfig.c @@ -1,6 +1,5 @@ #include "xen_backend.h" #include "blockdev.h" -#include "block_int.h" /* XXX */ /* ------------------------------------------------------------- */ @@ -99,10 +98,11 @@ int xen_config_dev_blk(DriveInfo *disk) int cdrom = disk->media_cd; const char *devtype = cdrom ? "cdrom" : "disk"; const char *mode = cdrom ? "r" : "w"; + const char *filename = qemu_opt_get(disk->opts, "file"); snprintf(device_name, sizeof(device_name), "xvd%c", 'a' + disk->unit); xen_be_printf(NULL, 1, "config disk %d [%s]: %s\n", - disk->unit, device_name, disk->bdrv->filename); + disk->unit, device_name, filename); xen_config_dev_dirs("vbd", "qdisk", vdev, fe, be, sizeof(fe)); /* frontend */ @@ -112,7 +112,7 @@ int xen_config_dev_blk(DriveInfo *disk) /* backend */ xenstore_write_str(be, "dev", device_name); xenstore_write_str(be, "type", "file"); - xenstore_write_str(be, "params", disk->bdrv->filename); + xenstore_write_str(be, "params", filename); xenstore_write_str(be, "mode", mode); /* common stuff */ diff --git a/hw/xen_disk.c b/hw/xen_disk.c index de7e8a4a5c..fb68ed9bbf 100644 --- a/hw/xen_disk.c +++ b/hw/xen_disk.c @@ -40,7 +40,6 @@ #include #include "hw.h" -#include "block_int.h" #include "qemu-char.h" #include "xen_blkif.h" #include "xen_backend.h" @@ -650,7 +649,7 @@ static int blk_init(struct XenDevice *xendev) if (blkdev->file_size < 0) { xen_be_printf(&blkdev->xendev, 1, "bdrv_getlength: %d (%s) | drv %s\n", (int)blkdev->file_size, strerror(-blkdev->file_size), - blkdev->bs->drv ? blkdev->bs->drv->format_name : "-"); + bdrv_get_format_name(blkdev->bs) ?: "-"); blkdev->file_size = 0; } -- cgit v1.2.3 From c52acf60b6c12ff5eb58eb6ac568c159ae0c8737 Mon Sep 17 00:00:00 2001 From: Pavel Hrdina Date: Wed, 13 Jun 2012 15:43:11 +0200 Subject: fdc: fix implied seek while there is no media in drive The Windows uses 'READ' command at the start of an instalation without checking the 'dir' register. We have to abort the transfer with an abnormal termination if there is no media in the drive. Signed-off-by: Pavel Hrdina Signed-off-by: Kevin Wolf --- hw/fdc.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'hw') diff --git a/hw/fdc.c b/hw/fdc.c index bfa4e686fa..78b4e3309c 100644 --- a/hw/fdc.c +++ b/hw/fdc.c @@ -159,6 +159,10 @@ static int fd_seek(FDrive *drv, uint8_t head, uint8_t track, uint8_t sect, drv->sect = sect; } + if (drv->bs == NULL || !bdrv_is_inserted(drv->bs)) { + ret = 2; + } + return ret; } -- cgit v1.2.3