All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/4] block: Improve warnings for doubly-connected drives
@ 2015-06-12 13:26 Peter Maydell
  2015-06-12 13:26 ` [Qemu-devel] [PATCH 1/4] block: Warn if an if=<something> drive was also connected manually Peter Maydell
                   ` (4 more replies)
  0 siblings, 5 replies; 17+ messages in thread
From: Peter Maydell @ 2015-06-12 13:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Markus Armbruster, qemu-block, patches

This patchset attempts to improve the warning and error messages for
bad user command lines that attempt to connect a drive up to two
devices. The motivation here is patch #4, which changes the default
interface for the virt board to virtio. That will break some existing
command lines which forgot to specify if=none, and so I would like
us to at least diagnose that user error in a helpful way that points
the user towards adding the missing if=none.

The patchset improves some error messages, and makes some previously
undiagnosed mistakes into warnings. The changes (with sample x86
command lines to provoke them) are:

(1) Drive specified as to be auto-connected and also manually connected
(and the board does handle this if= type):

  qemu-system-x86_64 -nodefaults -display none -drive if=scsi,file=tmp.qcow2,id=foo -device ide-hd,drive=foo

Previously: an error:
  qemu-system-x86_64: -device ide-hd,drive=foo: Property 'ide-hd.drive'
  can't take value 'foo', it's in use

Now: a better error:
  qemu-system-x86_64: -device ide-hd,drive=foo: Property 'ide-hd.drive'
  can't be set to drive ID 'foo'; that drive has been automatically
  connected to another device. Use if=none if you do not want that
  automatic connection.

(2) As 1, but the board does not handle this if= type:

Previously: not diagnosed at all

Now: a warning:
  Warning: automatic connection of this drive requested (because if=sd
  was specified) but it was also connected manually to a device:
  id=foo,file=tmp.qcow2,if=sd,bus=0,unit=0
  (If you don't want this drive auto-connected, use if=none.)

[This means we now will always warn one way or another about drives which
have an if= auto-connect specified but which the board didn't pick up: either
they're also manually connected and get this warning, or they're not manually
connected, and get the orphan-drive warning. If the if= was due to the
board default rather than the user typing it specifically, the error message
text is slightly different to reflect that.]

(3) Drive specified to be manually connected in two different ways:

  qemu-system-x86_64 -nodefaults -display none -drive if=sd,file=tmp.qcow2,id=foo -device ide-hd,drive=foo -device ide-hd,drive=foo

Previously: an error:
  qemu-system-x86_64: -device ide-hd,drive=foo: Property 'ide-hd.drive'
  can't take value 'foo', it's in use

Now: a better error:
  qemu-system-x86_64: -device ide-hd,drive=foo: Property 'ide-hd.drive'
  can't be set to drive ID 'foo'; that drive has already been connected
  to another device.



In order to detect when a drive was auto-connected, we need to set a
flag in the DriveInfo when this happens.  we do this by assuming that
all calls to blk_by_legacy_dinfo() imply that we're about to assign
the drive to a device.  This is a slightly ugly place to make the
test, but simpler than trying to locate and change every place in the
code that does automatic drive handling, and the worst case is that
we might print out a spurious warning.


I include patch #4 as the motivation/context but in fact it doesn't
depend on the first 3, so if you want to take the first 3 via
block and have me put the 4th one in target-arm that's OK.

thanks
-- PMM


Peter Maydell (4):
  block: Warn if an if=<something> drive was also connected manually
  qdev-properties-system: Change set_pointer's parse callback to use
    Error
  qdev-properties-system: Improve error message for drive assignment
    conflict
  hw/arm/virt: Make block devices default to virtio

 block/block-backend.c            |  4 ++++
 blockdev.c                       | 39 ++++++++++++++++++++++++++++++++++
 hw/arm/virt.c                    |  2 ++
 hw/core/qdev-properties-system.c | 45 ++++++++++++++++++++++++++++------------
 include/sysemu/blockdev.h        |  2 ++
 5 files changed, 79 insertions(+), 13 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 17+ messages in thread
* [Qemu-devel] [PATCH 0/4] blockdev: Defer creation of implicit PCI devices for IF_VIRTIO drives
@ 2015-06-04 16:20 Peter Maydell
  2015-06-04 16:20 ` [Qemu-devel] [PATCH 4/4] hw/arm/virt: Make block devices default to virtio Peter Maydell
  0 siblings, 1 reply; 17+ messages in thread
From: Peter Maydell @ 2015-06-04 16:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, qemu-block, patches, Markus Armbruster,
	Alexander Graf, Christian Borntraeger, Cornelia Huck

blockdev.c will create implicit virtio-blk-* devices for IF_VIRTIO
drives. I want to turn this on for the ARM virt board (now it has PCI),
so that users can use shorter and more comprehensible command lines.

Unfortunately, the code as it stands will always create an implicit
device, which means that setting the virt block_default_type to IF_VIRTIO
would break existing command lines like:

  -drive file=arm-wheezy.qcow2,id=foo
  -device virtio-blk-pci,drive=foo

because the creation of the drive causes us to create an implied
virtio-blk-pci which steals the drive, and then the explicit
device creation fails because 'foo' is already in use.

This patchset fixes this problem by deferring the creation of the
implicit devices to drive_check_orphaned(), which means we can do
it only for the drives which haven't been explicitly connected to
a device by the user.

The slight downside of deferral is that it is effectively rearranging
the order in which the devices are created, which means they will
end up in different PCI slots, etc. We can get away with this for PCI,
because at the moment the only machines which set their block_default_type
to IF_VIRTIO are the S390X ones. I have special-cased S390X to retain
the old behaviour, which is a bit ugly but functional. If S390X doesn't
care about cross-version migration we can probably drop that and
just have everything defer. S390X people?

The code in master didn't seem to take much account of the possibility
of hotplug -- if the user created a drive via the monitor we would
apparently try to create the implicit drive, but in fact not do so
because vl.c had already done device creation long before. I've included
a patch that makes it more explicit that hotplug does not get you the
magic implicit devices.

The last patch is the oneliner to enable the default for virt once
the underlying stuff lets us do this without breaking existing user
command lines.


Peter Maydell (4):
  blockdev: Factor out create_implicit_virtio_device
  blockdev: Don't call create_implicit_virtio_device() when it has no
    effect
  blockdev: Defer creation of implicit PCI devices for IF_VIRTIO drives
  hw/arm/virt: Make block devices default to virtio

 blockdev.c    | 72 +++++++++++++++++++++++++++++++++++++++++++++++------------
 hw/arm/virt.c |  1 +
 2 files changed, 59 insertions(+), 14 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2015-06-22 15:20 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-12 13:26 [Qemu-devel] [PATCH 0/4] block: Improve warnings for doubly-connected drives Peter Maydell
2015-06-12 13:26 ` [Qemu-devel] [PATCH 1/4] block: Warn if an if=<something> drive was also connected manually Peter Maydell
2015-06-22  9:59   ` Markus Armbruster
2015-06-22 13:39     ` Peter Maydell
2015-06-22 14:44       ` Markus Armbruster
2015-06-22 15:20     ` Peter Maydell
2015-06-12 13:26 ` [Qemu-devel] [PATCH 2/4] qdev-properties-system: Change set_pointer's parse callback to use Error Peter Maydell
2015-06-22  9:39   ` Markus Armbruster
2015-06-22 10:11     ` Peter Maydell
2015-06-22 11:18       ` Markus Armbruster
2015-06-12 13:26 ` [Qemu-devel] [PATCH 3/4] qdev-properties-system: Improve error message for drive assignment conflict Peter Maydell
2015-06-22  9:12   ` Markus Armbruster
2015-06-22 10:13     ` Peter Maydell
2015-06-22 11:11       ` Markus Armbruster
2015-06-12 13:26 ` [Qemu-devel] [PATCH 4/4] hw/arm/virt: Make block devices default to virtio Peter Maydell
2015-06-19 11:08 ` [Qemu-devel] [PATCH 0/4] block: Improve warnings for doubly-connected drives Peter Maydell
  -- strict thread matches above, loose matches on Subject: below --
2015-06-04 16:20 [Qemu-devel] [PATCH 0/4] blockdev: Defer creation of implicit PCI devices for IF_VIRTIO drives Peter Maydell
2015-06-04 16:20 ` [Qemu-devel] [PATCH 4/4] hw/arm/virt: Make block devices default to virtio Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.