All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Jason Wang <jasowang@redhat.com>, Alexander Graf <agraf@suse.de>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Cornelia Huck <cornelia.huck@de.ibm.com>,
	Richard Henderson <rth@twiddle.net>
Subject: [Qemu-devel] [PULL v2 32/60] virtio: device_plugged() can fail
Date: Mon, 1 Jun 2015 14:24:05 +0200	[thread overview]
Message-ID: <1433161230-29421-33-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1433161230-29421-1-git-send-email-mst@redhat.com>

From: Jason Wang <jasowang@redhat.com>

This patch passes error pointer to transport specific device_plugged()
callback. Through this way, device_plugged() can do some transport
specific check and fail. This will be uesd by following patches that
check the number of virtqueues against the transport limitation.

Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Alexander Graf <agraf@suse.de>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 include/hw/virtio/virtio-bus.h | 4 ++--
 hw/s390x/virtio-ccw.c          | 2 +-
 hw/virtio/virtio-bus.c         | 5 ++---
 hw/virtio/virtio-pci.c         | 2 +-
 hw/virtio/virtio.c             | 7 ++++++-
 5 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/include/hw/virtio/virtio-bus.h b/include/hw/virtio/virtio-bus.h
index d4ccdf2..8811415 100644
--- a/include/hw/virtio/virtio-bus.h
+++ b/include/hw/virtio/virtio-bus.h
@@ -55,7 +55,7 @@ typedef struct VirtioBusClass {
      * transport independent init function.
      * This is called by virtio-bus just after the device is plugged.
      */
-    void (*device_plugged)(DeviceState *d);
+    void (*device_plugged)(DeviceState *d, Error **errp);
     /*
      * transport independent exit function.
      * This is called by virtio-bus just before the device is unplugged.
@@ -74,7 +74,7 @@ struct VirtioBusState {
     BusState parent_obj;
 };
 
-int virtio_bus_device_plugged(VirtIODevice *vdev);
+void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp);
 void virtio_bus_reset(VirtioBusState *bus);
 void virtio_bus_device_unplugged(VirtIODevice *bus);
 /* Get the device id of the plugged device. */
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index e772265..965b03a 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -1378,7 +1378,7 @@ static int virtio_ccw_load_config(DeviceState *d, QEMUFile *f)
 }
 
 /* This is called by virtio-bus just after the device is plugged. */
-static void virtio_ccw_device_plugged(DeviceState *d)
+static void virtio_ccw_device_plugged(DeviceState *d, Error **errp)
 {
     VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
     SubchDev *sch = dev->sch;
diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c
index fac452b..3926f7e 100644
--- a/hw/virtio/virtio-bus.c
+++ b/hw/virtio/virtio-bus.c
@@ -38,7 +38,7 @@ do { printf("virtio_bus: " fmt , ## __VA_ARGS__); } while (0)
 #endif
 
 /* A VirtIODevice is being plugged */
-int virtio_bus_device_plugged(VirtIODevice *vdev)
+void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp)
 {
     DeviceState *qdev = DEVICE(vdev);
     BusState *qbus = BUS(qdev_get_parent_bus(qdev));
@@ -49,13 +49,12 @@ int virtio_bus_device_plugged(VirtIODevice *vdev)
     DPRINTF("%s: plug device.\n", qbus->name);
 
     if (klass->device_plugged != NULL) {
-        klass->device_plugged(qbus->parent);
+        klass->device_plugged(qbus->parent, errp);
     }
 
     /* Get the features of the plugged device. */
     assert(vdc->get_features != NULL);
     vdev->host_features = vdc->get_features(vdev, vdev->host_features);
-    return 0;
 }
 
 /* Reset the virtio_bus */
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 8923ba8..0cc249c 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -912,7 +912,7 @@ static int virtio_pci_query_nvectors(DeviceState *d)
 }
 
 /* This is called by virtio-bus just after the device is plugged. */
-static void virtio_pci_device_plugged(DeviceState *d)
+static void virtio_pci_device_plugged(DeviceState *d, Error **errp)
 {
     VirtIOPCIProxy *proxy = VIRTIO_PCI(d);
     VirtioBusState *bus = &proxy->bus;
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 96d9c6a..b50cbef 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -1323,7 +1323,12 @@ static void virtio_device_realize(DeviceState *dev, Error **errp)
             return;
         }
     }
-    virtio_bus_device_plugged(vdev);
+
+    virtio_bus_device_plugged(vdev, &err);
+    if (err != NULL) {
+        error_propagate(errp, err);
+        return;
+    }
 }
 
 static void virtio_device_unrealize(DeviceState *dev, Error **errp)
-- 
MST

  parent reply	other threads:[~2015-06-01 12:24 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-01 12:22 [Qemu-devel] [PULL v2 00/60] pc, pci, tpm, virtio, vhost enhancements and fixes Michael S. Tsirkin
2015-06-01 12:22 ` [Qemu-devel] [PULL v2 01/60] hw/virtio/virtio-balloon: move adding property to virtio_balloon_instance_init Michael S. Tsirkin
2015-06-01 12:22 ` [Qemu-devel] [PULL v2 02/60] hw/virtio/virtio-pci: use alias property for virtio-balloon-pci Michael S. Tsirkin
2015-06-01 12:22 ` [Qemu-devel] [PULL v2 03/60] hw/s390x/virtio-ccw: use alias property for virtio-balloon-ccw Michael S. Tsirkin
2015-06-01 12:22 ` [Qemu-devel] [PULL v2 04/60] pc: Replace tab with spaces Michael S. Tsirkin
2015-06-01 12:22 ` [Qemu-devel] [PULL v2 05/60] hw: Move commas inside HW_COMPAT_2_1 macro Michael S. Tsirkin
2015-06-01 12:22 ` [Qemu-devel] [PULL v2 06/60] pc: Move commas inside PC_COMPAT_* macros Michael S. Tsirkin
2015-06-01 12:22 ` [Qemu-devel] [PULL v2 07/60] spapr: Move commas inside SPAPR_COMPAT_* macros Michael S. Tsirkin
2015-06-01 12:22 ` [Qemu-devel] [PULL v2 08/60] hw: Define empty HW_COMPAT_2_[23] macros Michael S. Tsirkin
2015-06-01 12:22 ` [Qemu-devel] [PULL v2 09/60] pc: Define PC_COMPAT_2_[123] macros Michael S. Tsirkin
2015-06-01 12:22 ` [Qemu-devel] [PULL v2 10/60] spapr: Use HW_COMPAT_* inside SPAPR_COMPAT_* macros Michael S. Tsirkin
2015-06-01 12:22 ` [Qemu-devel] [PULL v2 11/60] spapr: define SPAPR_COMPAT_2_3 Michael S. Tsirkin
2015-06-01 12:23 ` [Qemu-devel] [PULL v2 12/60] piix: Move pc-0.14 qxl compat properties to PC_COMPAT_0_14 Michael S. Tsirkin
2015-06-01 12:23 ` [Qemu-devel] [PULL v2 13/60] piix: Move pc-0.11 drive version compat props to PC_COMPAT_0_11 Michael S. Tsirkin
2015-06-01 12:23 ` [Qemu-devel] [PULL v2 14/60] piix: Move pc-0.13 virtio-9p-pci compat to PC_COMPAT_0_13 Michael S. Tsirkin
2015-06-01 12:23 ` [Qemu-devel] [PULL v2 15/60] piix: Move pc-0.1[23] rombar compat props " Michael S. Tsirkin
2015-06-01 12:23 ` [Qemu-devel] [PULL v2 16/60] piix: Define PC_COMPAT_0_10 Michael S. Tsirkin
2015-06-01 12:23 ` [Qemu-devel] [PULL v2 17/60] pc: Define MACHINE_OPTIONS macros consistently for all machines Michael S. Tsirkin
2015-06-01 12:23 ` [Qemu-devel] [PULL v2 18/60] pc: Define machines using a DEFINE_PC_MACHINE macro Michael S. Tsirkin
2015-06-01 12:23 ` [Qemu-devel] [PULL v2 19/60] pc: Convert *_MACHINE_OPTIONS macros into functions Michael S. Tsirkin
2015-06-01 12:23 ` [Qemu-devel] [PULL v2 20/60] pc: Move compat_props setting inside *_machine_options() functions Michael S. Tsirkin
2015-06-01 12:23 ` [Qemu-devel] [PULL v2 21/60] pc: Don't use QEMUMachine anymore Michael S. Tsirkin
2015-06-01 12:23 ` [Qemu-devel] [PULL v2 22/60] pc: Remove qemu_register_pc_machine() function Michael S. Tsirkin
2015-06-01 12:23 ` [Qemu-devel] [PULL v2 23/60] machine: Remove unused fields from QEMUMachine Michael S. Tsirkin
2015-06-01 12:23 ` [Qemu-devel] [PULL v2 24/60] piix: Add kvmclock_enabled, pci_enabled globals Michael S. Tsirkin
2015-06-01 12:23 ` [Qemu-devel] [PULL v2 25/60] piix: Eliminate pc_init_pci() Michael S. Tsirkin
2015-06-01 12:23 ` [Qemu-devel] [PULL v2 26/60] pc: Generate init functions with a macro Michael S. Tsirkin
2015-06-01 12:23 ` [Qemu-devel] [PULL v2 27/60] pc: acpi: fix pvpanic for buggy guests Michael S. Tsirkin
2015-06-01 12:23 ` [Qemu-devel] [PULL v2 28/60] virtio: move host_features Michael S. Tsirkin
2015-06-01 12:23 ` [Qemu-devel] [PULL v2 29/60] virtio-ccw: Don't advertise VIRTIO_F_BAD_FEATURE Michael S. Tsirkin
2015-06-01 12:23 ` [Qemu-devel] [PULL v2 30/60] virtio: move VIRTIO_F_NOTIFY_ON_EMPTY into core Michael S. Tsirkin
2015-06-01 12:24 ` [Qemu-devel] [PULL v2 31/60] virtio-net: adding all queues in .realize() Michael S. Tsirkin
2015-06-01 12:24 ` Michael S. Tsirkin [this message]
2015-06-01 12:24 ` [Qemu-devel] [PULL v2 33/60] virtio: introduce virtio_get_num_queues() Michael S. Tsirkin
2015-06-01 12:24 ` [Qemu-devel] [PULL v2 34/60] virtio-ccw: introduce ccw specific queue limit Michael S. Tsirkin
2015-06-01 12:24 ` [Qemu-devel] [PULL v2 35/60] virtio-ccw: validate the number of queues against bus limitation Michael S. Tsirkin
2015-06-01 12:24 ` [Qemu-devel] [PULL v2 36/60] virtio-s390: introduce virito s390 queue limit Michael S. Tsirkin
2015-06-01 12:24 ` [Qemu-devel] [PULL v2 37/60] virtio-s390: introduce virtio_s390_device_plugged() Michael S. Tsirkin
2015-06-01 12:24 ` [Qemu-devel] [PULL v2 38/60] virtio: rename VIRTIO_PCI_QUEUE_MAX to VIRTIO_QUEUE_MAX Michael S. Tsirkin
2015-06-01 12:24 ` [Qemu-devel] [PULL v2 39/60] virtio: increase the queue limit to 1024 Michael S. Tsirkin
2015-06-01 12:24 ` [Qemu-devel] [PULL v2 40/60] i386/pc: pc_basic_device_init(): delegate FDC creation request Michael S. Tsirkin
2015-06-01 12:24 ` [Qemu-devel] [PULL v2 41/60] i386/pc: '-drive if=floppy' should imply a board-default FDC Michael S. Tsirkin
2015-06-01 12:24 ` [Qemu-devel] [PULL v2 42/60] i386/pc_q35: don't insist on board FDC if there's no default floppy Michael S. Tsirkin
2015-06-01 12:24 ` [Qemu-devel] [PULL v2 43/60] i386: drop FDC in pc-q35-2.4+ if neither it nor floppy drives are wanted Michael S. Tsirkin
2015-06-19  7:01   ` Markus Armbruster
2015-06-19 12:52     ` Laszlo Ersek
2015-06-19 13:32       ` Michael S. Tsirkin
2015-06-01 12:25 ` [Qemu-devel] [PULL v2 44/60] acpi: Simplify printing to dynamic string Michael S. Tsirkin
2015-06-01 12:25 ` [Qemu-devel] [PULL v2 45/60] Add stream ID to MSI write Michael S. Tsirkin
2015-06-01 12:25 ` [Qemu-devel] [PULL v2 46/60] Extend TPM TIS interface to support TPM 2 Michael S. Tsirkin
2015-06-01 12:25 ` [Qemu-devel] [PULL v2 47/60] tpm: Probe for connected TPM 1.2 or " Michael S. Tsirkin
2015-06-01 12:25 ` [Qemu-devel] [PULL v2 48/60] TPM2 ACPI table support Michael S. Tsirkin
2015-06-01 12:25 ` [Qemu-devel] [PULL v2 49/60] acpi: add aml_add() term Michael S. Tsirkin
2015-06-01 12:25 ` [Qemu-devel] [PULL v2 50/60] acpi: add aml_lless() term Michael S. Tsirkin
2015-06-01 12:25 ` [Qemu-devel] [PULL v2 51/60] acpi: add aml_index() term Michael S. Tsirkin
2015-06-01 12:25 ` [Qemu-devel] [PULL v2 52/60] acpi: add aml_shiftleft() term Michael S. Tsirkin
2015-06-01 12:25 ` [Qemu-devel] [PULL v2 53/60] acpi: add aml_shiftright() term Michael S. Tsirkin
2015-06-01 12:25 ` [Qemu-devel] [PULL v2 54/60] acpi: add aml_increment() term Michael S. Tsirkin
2015-06-01 12:25 ` [Qemu-devel] [PULL v2 55/60] acpi: add aml_while() term Michael S. Tsirkin
2015-06-01 12:25 ` [Qemu-devel] [PULL v2 56/60] hw/acpi/aml-build: Fix memory leak Michael S. Tsirkin
2015-06-01 12:25 ` [Qemu-devel] [PULL v2 57/60] virtio-mmio: ioeventfd support Michael S. Tsirkin
2015-06-01 12:25 ` [Qemu-devel] [PULL v2 58/60] qdev: add 64bit properties Michael S. Tsirkin
2015-06-20 21:10   ` Paolo Bonzini
2015-06-23  1:36     ` Gonglei
2015-06-23  6:55       ` Markus Armbruster
2015-06-23  7:04         ` Gonglei
2015-06-01 12:25 ` [Qemu-devel] [PULL v2 59/60] virtio: make features 64bit wide Michael S. Tsirkin
2015-06-01 12:25 ` [Qemu-devel] [PULL v2 60/60] vhost-user: add multi queue support Michael S. Tsirkin
2015-06-01 16:33 ` [Qemu-devel] [PULL v2 00/60] pc, pci, tpm, virtio, vhost enhancements and fixes Peter Maydell
2015-06-01 17:39   ` Daniel P. Berrange
2015-06-01 23:42     ` Stefan Berger
2015-06-02 14:53       ` Igor Mammedov
2015-06-02 14:59         ` Stefan Berger
2015-06-02 15:04         ` Michael S. Tsirkin
2015-06-02  8:06     ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1433161230-29421-33-git-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=agraf@suse.de \
    --cc=borntraeger@de.ibm.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=jasowang@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.