diff options
author | Anthony Liguori <aliguori@us.ibm.com> | 2012-06-18 10:34:59 -0500 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2012-06-18 10:34:59 -0500 |
commit | 0b0cb9d310edfe2b2d108f18be4f013a1e552cfd (patch) | |
tree | 895e26169ccbcbeb7e7c40eaecb353dadd7afb21 /hw | |
parent | df6606f4556a752d30a4eab26c626b6c34717ea8 (diff) | |
parent | d551cd50a43b9998c7aa562db7c567f557fb58fd (diff) |
Merge remote-tracking branch 'kwolf/for-anthony' into staging
* kwolf/for-anthony: (39 commits)
qemu-iotests: add 036 autoclear feature bit test
qemu-iotests: add qcow2.py set-feature-bit command
fdc-test: introduced qtest read_without_media
fdc: fix implied seek while there is no media in drive
qcow2: fix autoclear image header update
xen: Don't peek behind the BlockDriverState abstraction
xen: Don't change -drive if=xen device name during machine init
block: Replace bdrv_get_format() by bdrv_get_format_name()
qemu-img: document qed format on qemu-img man page
qemu-iotests: COW with many AIO requests on the same cluster
qemu-iotests: Some backing file COW tests
qcow2: Fix avail_sectors in cluster allocation code
qcow2: Simplify calculation for COW area at the end
qcow2: always operate caches in writeback mode
ide: support enable/disable write cache
block: always open drivers in writeback mode
block: add bdrv_set_enable_write_cache
block: copy enable_write_cache in bdrv_append
savevm: flush after saving vm state
block: flush in writethrough mode after writes
...
Diffstat (limited to 'hw')
-rw-r--r-- | hw/fdc.c | 24 | ||||
-rw-r--r-- | hw/fdc.h | 24 | ||||
-rw-r--r-- | hw/ide/core.c | 21 | ||||
-rw-r--r-- | hw/ide/piix.c | 3 | ||||
-rw-r--r-- | hw/isa.h | 2 | ||||
-rw-r--r-- | hw/pc_sysfw.c | 1 | ||||
-rw-r--r-- | hw/scsi-disk.c | 3 | ||||
-rw-r--r-- | hw/xen_devconfig.c | 13 | ||||
-rw-r--r-- | hw/xen_disk.c | 3 | ||||
-rw-r--r-- | hw/xtensa_lx60.c | 1 |
10 files changed, 56 insertions, 39 deletions
@@ -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; } @@ -1888,6 +1892,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) { @@ -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/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; } 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 <hw/hw.h> #include <hw/pc.h> #include <hw/pci.h> #include <hw/isa.h> -#include "block.h" +#include "blockdev.h" #include "sysemu.h" #include "dma.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" 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; } diff --git a/hw/xen_devconfig.c b/hw/xen_devconfig.c index 41accbbfa9..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 */ /* ------------------------------------------------------------- */ @@ -94,16 +93,16 @@ 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"; + const char *filename = qemu_opt_get(disk->opts, "file"); - 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, filename); xen_config_dev_dirs("vbd", "qdisk", vdev, fe, be, sizeof(fe)); /* frontend */ @@ -111,9 +110,9 @@ 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, "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 <xen/io/xenbus.h> #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; } 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 { |