Statistics
| Branch: | Revision:

root / blockdev.c @ 95b5edcd

History | View | Annotate | Download (21 kB)

# Date Author Comment
95b5edcd 05/19/2011 11:26 am Markus Armbruster

blockdev: Store -drive option media in DriveInfo

DriveInfo is closely tied to -drive, and like -drive, it mixes
information about host and guest part of the block device. Unlike
DriveInfo, BlockDriverState should be about the host part only.

One of the remaining guest bits there is the "type hint". -drive...

d22b2f41 04/07/2011 02:51 pm Ryan Harper

Do not delete BlockDriverState when deleting the drive

When removing a drive from the host-side via drive_del we currently have
the following path:

drive_del
qemu_aio_flush()
bdrv_close() // zaps bs->drv, which makes any subsequent I/O get
// dropped. Works as designed...

29f82b37 04/04/2011 01:34 am Alexander Graf

virtio: use generic name when possible

We have two different virtio buses: pci and s390. The abstraction path
taken in qemu is to have generic aliases for each device type in the
architecture specific qdev devices.

So let's make use of these aliases whenever we can and define them...

52f9a172 03/15/2011 02:21 pm Jes Sorensen

Improve error handling in do_snapshot_blkdev()

In case we cannot open the newly created snapshot image, try to fall
back to the original image file and continue running on that, which
should prevent the guest from aborting.

This is a corner case which can happen if the admin by mistake...

2753d4a5 02/10/2011 02:24 pm Markus Armbruster

blockdev: Plug memory leak in drive_uninit()

Started leaking in commit 1dae12e6.

Signed-off-by: Markus Armbruster <>
Signed-off-by: Kevin Wolf <>

a9ae2bff 02/10/2011 02:24 pm Markus Armbruster

blockdev: Plug memory leak in drive_init() error paths

Should have spotted this when doing commit 319ae529.

Signed-off-by: Markus Armbruster <>
Signed-off-by: Kevin Wolf <>

84fb3925 02/07/2011 01:51 pm Marcelo Tosatti

blockdev: add refcount to DriveInfo

The host part of a block device can be deleted with in progress
block migration.

To fix this, add a reference count to DriveInfo, freeing resources
on last reference.

Signed-off-by: Marcelo Tosatti <>...

8591675f 02/07/2011 01:51 pm Marcelo Tosatti

block: enable in_use flag

Set block device in use during block migration, disallow drive_del and
bdrv_truncate for in use devices.

Signed-off-by: Marcelo Tosatti <>
Signed-off-by: Kevin Wolf <>

319ae529 01/31/2011 12:59 pm Markus Armbruster

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...

5645b0f4 01/31/2011 12:57 pm Markus Armbruster

blockdev: Replace drive_add()'s fmt, ... by optstr parameter

Let the callers build the optstr. Only one wants to. All the others
become simpler, because they don't have to worry about escaping '%'.

Signed-off-by: Markus Armbruster <>
Signed-off-by: Kevin Wolf <>

4e5d9b57 01/31/2011 12:22 pm Markus Armbruster

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...
f1bd51ac 01/31/2011 12:17 pm Markus Armbruster

blockdev: New drive_get_by_index()

Signed-off-by: Markus Armbruster <>
Signed-off-by: Kevin Wolf <>

505a7fb1 01/31/2011 12:16 pm Markus Armbruster

blockdev: Factor drive_index_to_{bus,unit}_id out of drive_init()

Signed-off-by: Markus Armbruster <>
Signed-off-by: Kevin Wolf <>

2292ddae 01/31/2011 11:59 am Markus Armbruster

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 for
uses later in this series.

New IF_DEFAULT to ask for the machine's default interface. Before,...

27d6bf40 01/31/2011 11:42 am Markus Armbruster

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, but
not the guest device. That's because the controllers we use with
if=scsi drives (lsi53c895a and esp) support only 7 units, and...

1960966d 01/31/2011 11:28 am Markus Armbruster

blockdev: Put BlockInterfaceType names and max_devs in tables

Turns drive_init()'s lengthy conditional into a concise loop, and
makes the data available elsewhere.

Signed-off-by: Markus Armbruster <>
Signed-off-by: Kevin Wolf <>

13839974 01/31/2011 11:24 am Markus Armbruster

blockdev: New drive_get_next(), replacing qdev_init_bdrv()

qdev_init_bdrv() doesn't belong into qdev.c; it's about drives, not
qdevs. Rename to drive_get_next, move to blockdev.c, drop the bogus
DeviceState argument, and return DriveInfo instead of
BlockDriverState....

6d4a2b3a 01/31/2011 11:03 am Christoph Hellwig

block: add block_resize monitor command

Add a monitor command that allows resizing of block devices while
qemu is running. It uses the existing bdrv_truncate method already
used by qemu-img to do it's work. Compared to qemu-img the size
parsing is very simplicistic, but I think having a properly numering...

807105a7 01/24/2011 05:49 pm Markus Armbruster

blockdev: Make drive_init() use error_report()

This makes the errors point to the error location, and fixes drive_add
to report errors in the monitor instead of stderr.

While there, tweak a few error messages for consistency.

Signed-off-by: Markus Armbruster <>...

850ec113 01/24/2011 05:49 pm Markus Armbruster

blockdev: Fix drive_del not to crash when drive is not in use

Watch this:

(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)...
48384854 01/24/2011 05:49 pm Markus Armbruster

blockdev: Fix error message for invalid -drive CHS

When cyls, heads or secs are out of range, the error message prints
buf, which points to the value of option "if". Bogus, may even be
null. Drop that.

Signed-off-by: Markus Armbruster <>...

c90f1b32 01/24/2011 12:08 pm Jes Sorensen

do_snapshot_blkdev() error on missing snapshot_file argument

Current code does not support snapshot internally to the running
image. Error in case no snapshot_file is specified.

Signed-off-by: Jes Sorensen <>
Signed-off-by: Kevin Wolf <>

f8882568 12/17/2010 05:11 pm Jes Sorensen

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, eg
internal snapshots, are not supported.

Signed-off-by: Jes Sorensen <>...

0fc0f1fa 12/17/2010 05:10 pm Ryan Harper

blockdev: check dinfo ptr before using

If a user decides to punish a guest by revoking its block device via
drive_del, and subsequently also attempts to remove the pci device
backing it, and the device is using blockdev_auto_del() then we get a
segfault when we attempt to access dinfo->auto_del.[1]...

9063f814 11/24/2010 06:30 pm Ryan Harper

Implement drive_del to decouple block removal from device removal

Currently device hotplug removal code is tied to device removal via
ACPI. All pci devices that are removable via device_del() require the
guest to respond to the request. In some cases the guest may not...

5dba48a8 11/04/2010 01:52 pm Kevin Wolf

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 used
that was criticized in the review for the changes to the read path required for
rerror support....

3329f07b 08/23/2010 01:11 am Gerd Hoffmann

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 <>
Signed-off-by: Anthony Liguori <>

199630b6 07/26/2010 02:39 pm Blue Swirl

Fix -snapshot deleting images on disk change

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 <>...

528f7663 07/06/2010 06:05 pm Markus Armbruster

blockdev: Clean up how readonly persists across virtual media change

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...

734003e6 07/06/2010 04:31 pm Anthony Liguori

Merge remote branch 'kwolf/for-anthony' into staging

dfb0acd8 07/02/2010 02:18 pm Markus Armbruster

blockdev: drive_get_by_id() is no longer used, remove

Signed-off-by: Markus Armbruster <>
Signed-off-by: Kevin Wolf <>

0c6f9c17 07/02/2010 02:18 pm Markus Armbruster

blockdev: Remove drive_get_serial()

Unused since commit 6ced55a5.

Signed-off-by: Markus Armbruster <>
Signed-off-by: Kevin Wolf <>

e4700e59 07/02/2010 02:18 pm Markus Armbruster

blockdev: New drive_get_by_blockdev()

Signed-off-by: Markus Armbruster <>
Signed-off-by: Kevin Wolf <>

14bafc54 07/02/2010 02:18 pm Markus Armbruster

blockdev: Clean up automatic drive deletion

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...

eb159d13 07/01/2010 08:27 pm Luiz Capitulino

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't
have a boolean type at the very beginning of QMP. Today we have it...

3b5276b5 06/22/2010 03:38 pm Eduardo Habkost

monitor: allow device to be ejected if no disk is inserted

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)...

abd7f68d 06/15/2010 10:41 am Markus Armbruster

block: Move error actions from DriveInfo to BlockDriverState

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 <>
Signed-off-by: Kevin Wolf <>

6ab4b5ab 06/15/2010 10:41 am Markus Armbruster

block: Decouple block device "commit all" from DriveInfo

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...

ac59eb95 06/15/2010 10:41 am Markus Armbruster

monitor: Make "commit FOO" complain when FOO doesn't exist

Signed-off-by: Markus Armbruster <>
Signed-off-by: Kevin Wolf <>

c9b62a7e 06/15/2010 10:41 am Markus Armbruster

blockdev: Give drives internal linkage

This is the list of drives defined with drive_init(). Hide it, so it
doesn't get abused.

Signed-off-by: Markus Armbruster <>
Signed-off-by: Kevin Wolf <>

dd5b0d71 06/15/2010 10:41 am Markus Armbruster

Fix regression for "-drive file="

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 <>...

653dbec7 06/04/2010 04:20 pm Luiz Capitulino

block: Fix serial number assignment

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 <>...

666daa68 06/04/2010 04:20 pm Markus Armbruster

blockdev: Collect block device code in new blockdev.c

Anything that moves hundreds of lines out of vl.c can't be all bad.

Signed-off-by: Markus Armbruster <>
Signed-off-by: Kevin Wolf <>