History | View | Annotate | Download (28.5 kB)
qmp: add block_job_cancel command
Add block_job_cancel, which stops an active block streaming operation.When the operation has been cancelled the new BLOCK_JOB_CANCELLED eventis emitted.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>Acked-by: Luiz Capitulino <lcapitulino@redhat.com>...
qmp: add query-block-jobs
Add query-block-jobs, which shows the progress of ongoing block deviceoperations.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>Acked-by: Luiz Capitulino <lcapitulino@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
blockdev: make image streaming safe across hotplug
Unplugging a storage interface like virtio-blk causes the host blockdevice to be deleted too. Long-running operations like block migrationmust take a DriveInfo reference to prevent the BlockDriverState from...
block: add support for partial streaming
Add support for streaming data from an intermediate section of theimage chain (see patch and documentation for details).
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>...
qmp: add block_job_set_speed command
Add block_job_set_speed, which sets the maximum speed for a backgroundblock operation.
qmp: add block_stream command
Add the block_stream command, which starts copy backing file contentsinto the image file. Also add the BLOCK_JOB_COMPLETED QMP event whichis emitted when image streaming completes. Later patches add controlover the background copy speed, cancelation, and querying running...
block: check bdrv_in_use() before blockdev operations
Long-running block operations like block migration and image streamingmust have continual access to their block device. It is not safe toperform operations like hotplug, eject, change, resize, commit, or...
block: eject_device(): Use error_set()
Also drops the leftover 'mon' argument.
This is a preparation for the next commits which will port theeject and change commands to the QAPI.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
qapi: Convert eject
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
qapi: Convert change
qapi: Convert block_set_io_throttle
block: use proper qerrors in qmp_block_resize
Let's report specific errors so that management tools and users canidentify the problem.
Two new qerrors are needed: * QERR_DEVICE_HAS_NO_MEDIUM for ENOMEDIUM * QERR_DEVICE_IS_READ_ONLY for EACCES
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>...
qapi: Convert block_passwd
qapi: Convert block_resize
qapi: Convert blockdev_snapshot_sync
Unfortunately, this conversion required an additional change.
In the old QMP command, the 'snapshot-file' argument is specified asoptional. The idea is to take the snapshot internally if 'snapshot-file'is not passed. However, internal snapshots are not supported yet so...
block: convert qemu_aio_flush() calls to bdrv_drain_all()
Many places in QEMU call qemu_aio_flush() to complete all pendingasynchronous I/O. Most of these places actually want to drain all blockrequests but there is no block layer API to do so.
This patch introduces the bdrv_drain_all() API to wait for requests...
block: add -drive copy-on-read=on|off
This patch adds the -drive copy-on-read=on|off command-line option:
copy-on-read=on|off copy-on-read is "on" or "off" and enables whether to copy read backing file sectors into the image file. Copy-on-read avoids accessing the...
block: add the blockio limits command line support
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
hmp/qmp: add block_set_io_throttle
block: add eject request callback
Recent versions of udev always keep the tray locked so that the kernelcan observe "eject request" events (aka tray button presses) even ondiscs that aren't mounted. Add support for these events in the ATAPIand SCSI cd drive device models....
ide/atapi scsi-disk: Make monitor eject -f, then change work
change fails while the tray is locked by the guest. eject -f forcesit open and removes any media. Unfortunately, the tray closes againinstantly. Since the lock remains as it is, there is no way to insert...
block: Clean up remaining users of "removable"
BlockDriverState member removable is a confused mess. It is true whenan ide-cd, scsi-cd or floppy qdev is attached, or when theBlockDriverState was created with -drive if={floppy,sd} or -driveif={ide,scsi,xen,none},media=cdrom ("created removable"), except when...
block: Drop BlockDriverState member removable
It's a confused mess (see previous commit). No users remain.
Signed-off-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: Drop medium lock tracking, ask device models instead
Requires new BlockDevOps member is_medium_locked(). Implement for IDEand SCSI CD-ROMs.
block: Attach non-qdev devices as well
For now, this just protects against programming errors like having thesame drive back multiple non-qdev devices, or untimely bdrv_delete().Later commits will add other interesting uses.
While there, rename BlockDriverState member peer to dev, bdrv_attach()...
block: parse cache mode flags in a single place
This patch introduces bdrv_parse_cache_flags() which sets open flagsgiven a cache mode. Previously this was duplicated in blockdev.c andqemu-img.c.
Use glib memory allocation and free functions
qemu_malloc/qemu_free no longer exist after this commit.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
blockdev: Make eject fail for non-removable drives even with -f
Ejecting hard disk platters can only end in tears.
If you need to revoke access to an image, use drive_del, not eject -f.
QMP: add snapshot-blkdev-sync command
Add QMP bits for snapshot_blkdev command. This is the same assnapshot_blkdev in the human monitor. The command is synchronous.
In the future async commands and or a break down of the functionalityinto multiple commands might be added....
block: drive_init(): Simplify interface type setting
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Reviewed-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: drive_init(): Improve CHS setting error message
The current message doesn't clearly communicate the error cause.
blockdev: Put space after comma in error message
Signed-off-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
block: clarify the meaning of BDRV_O_NOCACHE
Change BDRV_O_NOCACHE to only imply bypassing the host OS file cache,but no writeback semantics. All existing callers are changed to alsospecify BDRV_O_CACHE_WB to give them writeback semantics.
Signed-off-by: Christoph Hellwig <hch@lst.de>...
block: Remove type hint, it's guest matter, doesn't belong here
No users of bdrv_get_type_hint() left. bdrv_set_type_hint() can makethe media removable by side effect. Make that explicit.
blockdev: Store -drive option media in DriveInfo
DriveInfo is closely tied to -drive, and like -drive, it mixesinformation about host and guest part of the block device. UnlikeDriveInfo, BlockDriverState should be about the host part only.
One of the remaining guest bits there is the "type hint". -drive...
Do not delete BlockDriverState when deleting the drive
When removing a drive from the host-side via drive_del we currently havethe following path:
drive_delqemu_aio_flush()bdrv_close() // zaps bs->drv, which makes any subsequent I/O get // dropped. Works as designed...
virtio: use generic name when possible
We have two different virtio buses: pci and s390. The abstraction pathtaken in qemu is to have generic aliases for each device type in thearchitecture specific qdev devices.
So let's make use of these aliases whenever we can and define them...
Improve error handling in do_snapshot_blkdev()
In case we cannot open the newly created snapshot image, try to fallback to the original image file and continue running on that, whichshould prevent the guest from aborting.
This is a corner case which can happen if the admin by mistake...
blockdev: Plug memory leak in drive_uninit()
Started leaking in commit 1dae12e6.
blockdev: Plug memory leak in drive_init() error paths
Should have spotted this when doing commit 319ae529.
blockdev: add refcount to DriveInfo
The host part of a block device can be deleted with in progressblock migration.
To fix this, add a reference count to DriveInfo, freeing resourceson last reference.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>...
block: enable in_use flag
Set block device in use during block migration, disallow drive_del andbdrv_truncate for in use devices.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
blockdev: Fix drive_add for drives without media
Watch this:
(qemu) drive_add 0 if=none (qemu) info block none0: type=hd removable=0 [not inserted] (qemu) drive_del none0 Segmentation fault (core dumped)
add_init_drive() is confused about drive_init()'s failure modes, and...
blockdev: Replace drive_add()'s fmt, ... by optstr parameter
Let the callers build the optstr. Only one wants to. All the othersbecome simpler, because they don't have to worry about escaping '%'.
blockdev: Reject multiple definitions for the same drive
We silently ignore multiple definitions for the same drive:
$ qemu-system-x86_64 -nodefaults -vnc :1 -S -monitor stdio -drive if=ide,index=1,file=tmp.qcow2 -drive if=ide,index=1,file=nonexistant...
blockdev: New drive_get_by_index()
blockdev: Factor drive_index_to_{bus,unit}_id out of drive_init()
blockdev: Make drive_add() take explicit type, index parameters
Before, type & index were hidden in printf-like fmt, ... parameters,which get expanded into an option string. Rather inconvenient foruses later in this series.
New IF_DEFAULT to ask for the machine's default interface. Before,...
blockdev: Fix regression in -drive if=scsi,index=N
Before commit 622b520f, index=12 meant bus=1,unit=5.
Since the commit, it means bus=0,unit=12. The drive is created, butnot the guest device. That's because the controllers we use withif=scsi drives (lsi53c895a and esp) support only 7 units, and...
blockdev: Put BlockInterfaceType names and max_devs in tables
Turns drive_init()'s lengthy conditional into a concise loop, andmakes the data available elsewhere.
blockdev: New drive_get_next(), replacing qdev_init_bdrv()
qdev_init_bdrv() doesn't belong into qdev.c; it's about drives, notqdevs. Rename to drive_get_next, move to blockdev.c, drop the bogusDeviceState argument, and return DriveInfo instead ofBlockDriverState....
block: add block_resize monitor command
Add a monitor command that allows resizing of block devices whileqemu is running. It uses the existing bdrv_truncate method alreadyused by qemu-img to do it's work. Compared to qemu-img the sizeparsing is very simplicistic, but I think having a properly numering...
blockdev: Make drive_init() use error_report()
This makes the errors point to the error location, and fixes drive_addto report errors in the monitor instead of stderr.
While there, tweak a few error messages for consistency.
Signed-off-by: Markus Armbruster <armbru@redhat.com>...
blockdev: Fix drive_del not to crash when drive is not in use
(qemu) drive_add 0 if=none,file=tmp.img OK (qemu) info block none0: type=hd removable=0 file=tmp.img ro=0 drv=raw encrypted=0 (qemu) drive_del none0 Segmentation fault (core dumped)...
blockdev: Fix error message for invalid -drive CHS
When cyls, heads or secs are out of range, the error message printsbuf, which points to the value of option "if". Bogus, may even benull. Drop that.
do_snapshot_blkdev() error on missing snapshot_file argument
Current code does not support snapshot internally to the runningimage. Error in case no snapshot_file is specified.
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Introduce do_snapshot_blkdev() and monitor command to handle it.
The monitor command is:snapshot_blkdev <device> [snapshot-file] [format]
Default format is qcow2. For now snapshots without a snapshot-file, eginternal snapshots, are not supported.
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>...
blockdev: check dinfo ptr before using
If a user decides to punish a guest by revoking its block device viadrive_del, and subsequently also attempts to remove the pci devicebacking it, and the device is using blockdev_auto_del() then we get asegfault when we attempt to access dinfo->auto_del.[1]...
Implement drive_del to decouple block removal from device removal
Currently device hotplug removal code is tied to device removal viaACPI. All pci devices that are removable via device_del() require theguest to respond to the request. In some cases the guest may not...
scsi-disk: Implement rerror option
This implements the rerror option for SCSI disks.
It also includes minor changes to the write path where the same code is usedthat was criticized in the review for the changes to the read path required forrerror support....
QemuOpts: make most qemu_*_opts static
Switch tree to lookup-by-name using qemu_find_opts().Also hook up virtfs options so qemu_find_opts works for them too.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Fix -snapshot deleting images on disk change
Block device change command did not copy BDRV_O_SNAPSHOT flag. Thusthe new image did not have this flag and the file got deleted duringopening.
Fix by copying BDRV_O_SNAPSHOT flag.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>...
blockdev: Clean up how readonly persists across virtual media change
Since commit cb4e5f8e, monitor command change makes the new mediareadonly iff the type hint is BDRV_TYPE_CDROM, i.e. the drive wascreated with media=cdrom. The intention is to avoid changing a block...
Merge remote branch 'kwolf/for-anthony' into staging
blockdev: drive_get_by_id() is no longer used, remove
blockdev: Remove drive_get_serial()
Unused since commit 6ced55a5.
blockdev: New drive_get_by_blockdev()
blockdev: Clean up automatic drive deletion
We automatically delete blockdev host parts on unplug of the guestdevice. Too much magic, but we can't change that now.
The delete happens early in the guest device teardown, before theconnection to the host part is severed. Thus, the guest part's...
Monitor: handle optional '-' arg as a bool
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'thave a boolean type at the very beginning of QMP. Today we have it...
monitor: allow device to be ejected if no disk is inserted
This changes the monitor eject_device() function to not check forbdrv_is_inserted().
Example run where the bug manifests itself:
(output of 'info block' is stripped to include only the CD-ROM device)...
block: Move error actions from DriveInfo to BlockDriverState
That's where they belong semantically (block device host part), eventhough the actions are actually executed by guest device code.
block: Decouple block device "commit all" from DriveInfo
do_commit() and mux_proc_byte() iterate over the list of drivesdefined with drive_init(). This misses host block devices defined byother means. Such means don't exist now, but will be introduced later...
monitor: Make "commit FOO" complain when FOO doesn't exist
blockdev: Give drives internal linkage
This is the list of drives defined with drive_init(). Hide it, so itdoesn't get abused.
Fix regression for "-drive file="
Empty file used to create an empty drive (no media). Since commit9dfd7c7a, it's an error: "qemu: could not open disk image : No suchfile or directory". Older versions of libvirt can choke on this.
block: Fix serial number assignment
We should use 'dinfo->serial' length, 'serial' is a pointer, sothe serial number length is currently limited to the pointer size.
This fixes https://bugs.launchpad.net/qemu/+bug/584143 and is alsovalid for stable.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>...
blockdev: Collect block device code in new blockdev.c
Anything that moves hundreds of lines out of vl.c can't be all bad.