summaryrefslogtreecommitdiff
path: root/blockdev.c
AgeCommit message (Collapse)AuthorFilesLines
2010-08-02Merge remote branch 'upstream' into nextAvi Kivity1-0/+1
* upstream: (43 commits) Initialize a variable in all cases Fix uint8_t comparison with negative value Fix a warning on OpenSolaris Correctly identify multiple cpus in SMP systems Remove unused constant jazz led: Fix debug prints xilinx-s3adsp: Add support for loading u-boot images. xilinx-s3adsp: Fix loading of raw binaries. Remove unused eventfd.h migration: Accept 'cont' only after successful incoming migration mips64el: fulong: PCI_DEVFN() clean up. remove pointless if from vl.c fix variable type in qemu-io.c remove dead code from hw/loader.c savevm: Fix memory leak of compat struct virtio-serial: Check if more max_ports specified than we can handle linux-user: fix build on hosts not using guest base linux-user: Protect against allocation failure in load_symbols. cris: Correct settls1 testcase. cris: Correct ADDO and ADDOQ testcases. ... Signed-off-by: Avi Kivity <avi@redhat.com>
2010-07-26Fix -snapshot deleting images on disk changeBlue Swirl1-0/+1
Block device change command did not copy BDRV_O_SNAPSHOT flag. Thus the new image did not have this flag and the file got deleted during opening. Fix by copying BDRV_O_SNAPSHOT flag. Signed-off-by: Blue Swirl <blauwirbel@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-07-13Merge commit '498238687fd3a2bf3efb32694732f88ceac72e99' into upstream-mergeMarcelo Tosatti1-1/+1
* commit '498238687fd3a2bf3efb32694732f88ceac72e99': (28 commits) pci: introduce multifunction property. qdev: implement qdev_prop_set_bit(). pci: remove PCIDeviceInfo::header_type pci: don't overwrite multi functio bit in pci header type. pci: insert assert that auto-assigned-address function is single function device. pci: use PCI_DEVFN() where appropriate. target-mips: add loongson 2E & 2F integer instructions Fix warning about uninitialized variable sheepdog: fix compile error on systems without TCP_CORK ramblocks: No more being lazy about duplicate names pci: Free the space allocated for the option rom on removal block: add sheepdog driver for distributed storage support ide: Reject invalid CHS geometry ide: Reject readonly drives unless CD-ROM ide: Make ide_init_drive() return success ide: Replace IDEState members is_cdrom, is_cf by drive_kind ide: Improve error messages scsi: Error locations for -drive if=scsi device initialization error: New qemu_opts_loc_restore() scsi: Reject unimplemented error actions ... Conflicts: hw/pci.c Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2010-07-13Merge commit 'd17b5288d91c935cc8795fa0620721da0a3865e1' into upstream-mergeMarcelo Tosatti1-18/+29
* commit 'd17b5288d91c935cc8795fa0620721da0a3865e1': (54 commits) Remove uses of ram.last_offset (aka last_ram_offset) make rtc alatm work scsi: Fix SCSI bus reset Fix io-thread build breakage of a88790a14f Include sys/mman.h before qemu-options.h cris: Avoid debug clobbering for both I & D MMU state. cris: Dont clobber the MMU state across calls to cpu_get_phys_page_debug. cris: Break out rand LFSR update into a separate func. block: Handle multiwrite errors only when all requests have completed block: Fix early failure in multiwrite qemu-img: avoid calling exit(1) to release resources properly pc: Fix CMOS info for drives defined with -device ide: Make PIIX and ISA IDE init functions return the qdev block: Fix virtual media change for if=none block: Clean up bdrv_snapshots() savevm: Survive hot-unplug of snapshot device blkdebug: Initialize state as 1 blkdebug: Free QemuOpts after having read the config blkdebug: Fix set_state_opts definition qemu-option: New qemu_opts_reset() ... Conflicts: exec.c Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2010-07-06blockdev: Clean up how readonly persists across virtual media changeMarkus Armbruster1-1/+1
Since commit cb4e5f8e, monitor command change makes the new media readonly iff the type hint is BDRV_TYPE_CDROM, i.e. the drive was created with media=cdrom. The intention is to avoid changing a block device's read-only-ness. However, BDRV_TYPE_CDROM is only a hint. It is currently sufficent for read-only. But it's not necessary, and it may not remain sufficient. Use bdrv_is_read_only() instead. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-07-06Merge remote branch 'kwolf/for-anthony' into stagingAnthony Liguori1-17/+28
2010-07-05block: Restore extboot functionality after mismergeStefan Hajnoczi1-0/+11
Extboot if=virtio,boot=on is broken due to a mismerge of: commit 666daa68234b5b1758652633cab07d5ca6046a5b Author: Markus Armbruster <armbru@redhat.com> Date: Wed Jun 2 18:48:27 2010 +0200 blockdev: Collect block device code in new blockdev.c in: commit 55cbee9e738bfe7434081967f884209f1a9c994c Merge: a854beb 666daa6 Author: Avi Kivity <avi@redhat.com> Date: Mon Jun 21 17:29:02 2010 +0300 Merge commit '666daa68234b5b1758652633cab07d5ca6046a5b' into upstream-merge The extboot_drive global is no longer being initialized in drive_init(). This patch restores the code to initialize extboot_drive. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Avi Kivity <avi@redhat.com>
2010-07-04Merge commit '758e8e38eb582e3dc87fd55a1d234c25108a7b7f' into upstream-mergeMarcelo Tosatti1-12/+10
* commit '758e8e38eb582e3dc87fd55a1d234c25108a7b7f': virtio-9p: Make infrastructure for the new security model. virtio-9p: Introduces an option to specify the security model. virtio-9p: Rearrange fileop structures Flush the debug message out to the log file. give some useful error messages when tap open Extra scan codes for missing keys qcow2: Don't try to check tables that couldn't be loaded qcow2: Fix qemu-img check segfault on corrupted images virtio-blk: fix the list operation in virtio_blk_load(). qemu-io: check registered fds in command_loop() vpc: Use bdrv_(p)write_sync for metadata writes vmdk: Use bdrv_(p)write_sync for metadata writes qcow2: Use bdrv_(p)write_sync for metadata writes qcow: Use bdrv_(p)write_sync for metadata writes cow: Use bdrv_(p)write_sync for metadata writes block: Add bdrv_(p)write_sync monitor: allow device to be ejected if no disk is inserted block: fix physical_block_size calculation scsi-bus: Add MAINTENANCE_IN and MAINTENANCE_OUT SCSIRequest xfer and mode assignments scsi-bus: Add PERSISTENT_RESERVE_OUT SCSIRequest->cmd.mode setup Conflicts: vl.c Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2010-07-02blockdev: drive_get_by_id() is no longer used, removeMarkus Armbruster1-12/+0
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-07-02blockdev: Clean up automatic drive deletionMarkus Armbruster1-0/+23
We automatically delete blockdev host parts on unplug of the guest device. Too much magic, but we can't change that now. The delete happens early in the guest device teardown, before the connection to the host part is severed. Thus, the guest part's pointer to the host part dangles for a brief time. No actual harm comes from this, but we'll catch such dangling pointers a few commits down the road. Clean up the dangling pointers by delaying the automatic deletion until the guest part's pointer is gone. Device usb-storage deliberately makes two qdev properties refer to the same drive, because it automatically creates a second device. Again, too much magic we can't change now. Multiple references worked okay before, but now free_drive() dies for the second one. Zap the extra reference. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-07-02blockdev: New drive_get_by_blockdev()Markus Armbruster1-0/+12
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-07-02blockdev: Remove drive_get_serial()Markus Armbruster1-12/+0
Unused since commit 6ced55a5. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-07-01Monitor: handle optional '-' arg as a boolLuiz Capitulino1-1/+1
Historically, user monitor arguments beginning with '-' (eg. '-f') were passed as integers down to handlers. I've maintained this behavior in the new monitor because we didn't have a boolean type at the very beginning of QMP. Today we have it and this behavior is causing trouble to QMP's argument checker. This commit fixes the problem by doing the following changes: 1. User Monitor Before: the optional arg was represented as a QInt, we'd pass 1 down to handlers if the user specified the argument or 0 otherwise This commit: the optional arg is represented as a QBool, we pass true down to handlers if the user specified the argument, otherwise _nothing_ is passed 2. QMP Before: the client was required to pass the arg as QBool, but we'd convert it to QInt internally. If the argument wasn't passed, we'd pass 0 down This commit: still require a QBool, but doesn't do any conversion and doesn't pass any default value 3. Convert existing handlers (do_eject()/do_migrate()) to the new way Before: Both handlers would expect a QInt value, either 0 or 1 This commit: Change the handlers to accept a QBool, they handle the following cases: A) true is passed: the option is enabled B) false is passed: the option is disabled C) nothing is passed: option not specified, use default behavior Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2010-06-22monitor: allow device to be ejected if no disk is insertedEduardo Habkost1-12/+10
This changes the monitor eject_device() function to not check for bdrv_is_inserted(). Example run where the bug manifests itself: (output of 'info block' is stripped to include only the CD-ROM device) (qemu) info block ide1-cd0: type=cdrom removable=1 locked=0 [not inserted] (qemu) change ide1-cd0 /dev/cdrom host_cdrom (qemu) info block ide1-cd0: type=cdrom removable=1 locked=0 file=/dev/cdrom ro=1 drv=host_cdrom encrypted=0 (qemu) eject ide1-cd0 (qemu) info block ide1-cd0: type=cdrom removable=1 locked=0 file=/dev/cdrom ro=1 drv=host_cdrom encrypted=0 # at this point, a disk was inserted on the host CD-ROM drive (qemu) info block ide1-cd0: type=cdrom removable=1 locked=0 file=/dev/cdrom ro=1 drv=host_cdrom encrypted=0 (qemu) eject ide1-cd0 (qemu) info block ide1-cd0: type=cdrom removable=1 locked=0 [not inserted] (qemu) The first eject command didn't work because the is_inserted() check failed. I have no clue why the code had the is_inserted() check, as it doesn't matter if there is a disk present at the host drive, when the user wants the virtual device to be disconnected from the host device. The is_inserted() check has another side effect: a memory leak if the "change" command is used multiple times, as do_change() calls eject_device() before re-opening the block device, but bdrv_close() is never called. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-06-21Merge commit 'c9b62a7ee14f51c9fa473a5bbefe264c904613ee' into upstream-mergeAvi Kivity1-25/+14
* commit 'c9b62a7ee14f51c9fa473a5bbefe264c904613ee': blockdev: Give drives internal linkage block: Decouple savevm from DriveInfo block: New bdrv_next() monitor: Make "commit FOO" complain when FOO doesn't exist block: Decouple block device "commit all" from DriveInfo block: Move error actions from DriveInfo to BlockDriverState cow: use qemu block API cow: stop using mmap cow: use pread/pwrite qcow2: Restore L1 entry on l2_allocate failure Fix regression for "-drive file=" savevm: Really verify if a drive supports snapshots qcow2: Return real error code in load_refcount_block qcow2: Allow alloc_clusters_noref to return errors qcow2: Allow get_refcount to return errors vpc: Read/write multiple sectors at once Conflicts: blockdev.c Signed-off-by: Avi Kivity <avi@redhat.com>
2010-06-21Merge commit 'a4673e276248ada38f40d39191a197e7e35d3f8b' into upstream-mergeAvi Kivity1-1/+1
* commit 'a4673e276248ada38f40d39191a197e7e35d3f8b': (24 commits) OHCI address decoding fix Move stdbool.h monitor/QMP: Drop info hpet / query-hpet hpet: Add MSI support hpet: Make number of timers configurable vmstate: Add VMSTATE_STRUCT_VARRAY_UINT8 hpet: Add support for level-triggered interrupts hpet: Drop static state hpet/rtc: Rework RTC IRQ replacement by HPET hpet: Start/stop timer when HPET_TN_ENABLE is modified hpet: Convert to qdev hpet: Move static timer field initialization hpet: Silence warning on write to running main counter hxtool: Fix line number reporting on SQMP/EQMP errors remove unnecessary lookaheads implement optional lookahead in json lexer add some tests for invalid JSON json-streamer: Don't use qdict_put_obj() json-lexer: Drop 'buf' check-qjson: Add more escape tests ... Conflicts: hw/hpet.c Signed-off-by: Avi Kivity <avi@redhat.com>
2010-06-21Merge commit '666daa68234b5b1758652633cab07d5ca6046a5b' into upstream-mergeAvi Kivity1-0/+602
* commit '666daa68234b5b1758652633cab07d5ca6046a5b': blockdev: Collect block device code in new blockdev.c qdev: Move declaration of qdev_init_bdrv() into qdev.h blockdev: Hide QEMUMachine from drive_init() block: call the snapshot handlers of the protocol drivers close all the block drivers before the qemu process exits block: Assume raw for drives without media Fix error message in drive_init scsi: Fix info qtree for scsi-disk.ver scsi: Turn drive serial into a qdev property scsi-disk.serial ide: Fix info qtree for ide-drive.ver ide: Turn drive serial into a qdev property ide-drive.serial qdev: Don't leak string property value on hot unplug qdev: New qdev_prop_set_string() ide: Split non-qdev code off ide_init2() ide: Change ide_init_drive() to require valid dinfo argument ide: Split ide_init1() off ide_init2() ide: Remove redundant IDEState member conf ide: Remove useless IDEDeviceInfo members unit, drive usb: Remove unused usb_device_add() parameter is_hotplug Conflicts: hw/pc.c sysemu.h vl.c Signed-off-by: Avi Kivity <avi@redhat.com>
2010-06-15blockdev: Give drives internal linkageMarkus Armbruster1-1/+1
This is the list of drives defined with drive_init(). Hide it, so it doesn't get abused. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-06-15monitor: Make "commit FOO" complain when FOO doesn't existMarkus Armbruster1-2/+4
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-06-15block: Decouple block device "commit all" from DriveInfoMarkus Armbruster1-8/+8
do_commit() and mux_proc_byte() iterate over the list of drives defined with drive_init(). This misses host block devices defined by other means. Such means don't exist now, but will be introduced later in this series. Change them to use new bdrv_commit_all(), which iterates over all host block devices. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-06-15block: Move error actions from DriveInfo to BlockDriverStateMarkus Armbruster1-15/+2
That's where they belong semantically (block device host part), even though the actions are actually executed by guest device code. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-06-15Fix regression for "-drive file="Markus Armbruster1-1/+1
Empty file used to create an empty drive (no media). Since commit 9dfd7c7a, it's an error: "qemu: could not open disk image : No such file or directory". Older versions of libvirt can choke on this. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-06-04block: Fix serial number assignmentLuiz Capitulino1-1/+1
We should use 'dinfo->serial' length, 'serial' is a pointer, so the serial number length is currently limited to the pointer size. This fixes https://bugs.launchpad.net/qemu/+bug/584143 and is also valid for stable. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-06-04blockdev: Collect block device code in new blockdev.cMarkus Armbruster1-0/+600
Anything that moves hundreds of lines out of vl.c can't be all bad. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>