Skip to contentSkip to conversation

virtio-scsi: forward scsibus for virtio-scsi-pci.

PATCH RESEND In review [email protected] 3 participants 17 messages Jun 12, 2013 – Jun 20, 2013

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 virtio-scsi: forward scsibus for virtio-scsi-pci.

From: KONRAD Frederic <[email protected]>

This fix a bug with scsi hotplug on virtio-scsi-pci:

As virtio-scsi-pci doesn't have any scsi bus, we need to forward scsi-hot-add to the virtio-scsi-device plugged on the virtio-bus.

---
 hw/pci/pci-hotplug.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
hw/pci/pci-hotplug.c +17 -2
index 12287d1..c708752 100644
@@ -30,6 +30,8 @@
 #include "monitor/monitor.h"
 #include "hw/scsi/scsi.h"
 #include "hw/virtio/virtio-blk.h"
+#include "hw/virtio/virtio-scsi.h"
+#include "hw/virtio/virtio-pci.h"
 #include "qemu/config-file.h"
 #include "sysemu/blockdev.h"
 #include "qapi/error.h"
@@ -79,13 +81,26 @@ static int scsi_hot_add(Monitor *mon, DeviceState *adapter,
 {
     SCSIBus *scsibus;
     SCSIDevice *scsidev;
+    VirtIOPCIProxy *virtio_proxy;
 
     scsibus = (SCSIBus *)
         object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
                             TYPE_SCSI_BUS);
     if (!scsibus) {
-	error_report("Device is not a SCSI adapter");
-	return -1;
+        /*
+         * Check if the adapter is a virtio-scsi-pci, and forward scsi_hot_add
+         * to the virtio-scsi-device.
+         */
+        if (!object_dynamic_cast(OBJECT(adapter), TYPE_VIRTIO_SCSI_PCI)) {
+            error_report("Device is not a SCSI adapter");
+            return -1;
+        }
+        virtio_proxy = VIRTIO_PCI(adapter);
+        adapter = DEVICE(virtio_proxy->bus.vdev);
+        scsibus = (SCSIBus *)
+                  object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
+                            TYPE_SCSI_BUS);
+        assert(scsibus);
     }
 
     /*
Signature · 1 line
1.8.1.4
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · On Wed, Jun 12, 2013 at 08:15:17AM +0200, [email protected] wrote:

From: KONRAD Frederic <[email protected]>

This fix a bug with scsi hotplug on virtio-scsi-pci:

As virtio-scsi-pci doesn't have any scsi bus, we need to forward scsi-hot-add to the virtio-scsi-device plugged on the virtio-bus.

Note: we don't seem to have any decent way to add disks to devices: no QMP interface, pci address is required instead of using an id ...

Anyone can be bothered to fix this?

Quoted 48 lines
---
 hw/pci/pci-hotplug.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
hw/pci/pci-hotplug.c +17 -2
index 12287d1..c708752 100644
@@ -30,6 +30,8 @@
 #include "monitor/monitor.h"
 #include "hw/scsi/scsi.h"
 #include "hw/virtio/virtio-blk.h"
+#include "hw/virtio/virtio-scsi.h"
+#include "hw/virtio/virtio-pci.h"
 #include "qemu/config-file.h"
 #include "sysemu/blockdev.h"
 #include "qapi/error.h"
@@ -79,13 +81,26 @@ static int scsi_hot_add(Monitor *mon, DeviceState *adapter,
 {
     SCSIBus *scsibus;
     SCSIDevice *scsidev;
+    VirtIOPCIProxy *virtio_proxy;
 
     scsibus = (SCSIBus *)
         object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
                             TYPE_SCSI_BUS);
     if (!scsibus) {
-	error_report("Device is not a SCSI adapter");
-	return -1;
+        /*
+         * Check if the adapter is a virtio-scsi-pci, and forward scsi_hot_add
+         * to the virtio-scsi-device.
+         */
+        if (!object_dynamic_cast(OBJECT(adapter), TYPE_VIRTIO_SCSI_PCI)) {
+            error_report("Device is not a SCSI adapter");
+            return -1;
+        }
+        virtio_proxy = VIRTIO_PCI(adapter);
+        adapter = DEVICE(virtio_proxy->bus.vdev);
+        scsibus = (SCSIBus *)
+                  object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
+                            TYPE_SCSI_BUS);
+        assert(scsibus);
     }
 
     /*
Signature · 1 line
1.8.1.4
#2 lore raw
Quoted 13 lines · Michael S. Tsirkin
Quoted 11 lines · On Wed, Jun 12, 2013 at 08:15:17AM +0200, [email protected] wrote:

From: KONRAD Frederic <[email protected]>

This fix a bug with scsi hotplug on virtio-scsi-pci:

As virtio-scsi-pci doesn't have any scsi bus, we need to forward scsi-hot-add to the virtio-scsi-device plugged on the virtio-bus.

Quoted 7 lines

Note: we don't seem to have any decent way to add disks to devices: no QMP interface, pci address is required instead of using an id ...

Anyone can be bothered to fix this?

Actually PCI address is not always required, this field (we are talking about "drive_add"?) is ignored when "if=none".

Quoted 48 lines
Quoted 48 lines
---
 hw/pci/pci-hotplug.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
hw/pci/pci-hotplug.c +17 -2
index 12287d1..c708752 100644
@@ -30,6 +30,8 @@
 #include "monitor/monitor.h"
 #include "hw/scsi/scsi.h"
 #include "hw/virtio/virtio-blk.h"
+#include "hw/virtio/virtio-scsi.h"
+#include "hw/virtio/virtio-pci.h"
 #include "qemu/config-file.h"
 #include "sysemu/blockdev.h"
 #include "qapi/error.h"
@@ -79,13 +81,26 @@ static int scsi_hot_add(Monitor *mon, DeviceState *adapter,
 {
     SCSIBus *scsibus;
     SCSIDevice *scsidev;
+    VirtIOPCIProxy *virtio_proxy;
 
     scsibus = (SCSIBus *)
         object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
                             TYPE_SCSI_BUS);
     if (!scsibus) {
-	error_report("Device is not a SCSI adapter");
-	return -1;
+        /*
+         * Check if the adapter is a virtio-scsi-pci, and forward scsi_hot_add
+         * to the virtio-scsi-device.
+         */
+        if (!object_dynamic_cast(OBJECT(adapter), TYPE_VIRTIO_SCSI_PCI)) {
+            error_report("Device is not a SCSI adapter");
+            return -1;
+        }
+        virtio_proxy = VIRTIO_PCI(adapter);
+        adapter = DEVICE(virtio_proxy->bus.vdev);
+        scsibus = (SCSIBus *)
+                  object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
+                            TYPE_SCSI_BUS);
+        assert(scsibus);
     }
 
     /*
Signature · 1 line
1.8.1.4
Signature · 1 line
Alexey
#3 lore raw
Quoted 20 lines · Alexey Kardashevskiy
Quoted 19 lines · Michael S. Tsirkin
Quoted 11 lines · On Wed, Jun 12, 2013 at 08:15:17AM +0200, [email protected] wrote:

From: KONRAD Frederic <[email protected]>

This fix a bug with scsi hotplug on virtio-scsi-pci:

As virtio-scsi-pci doesn't have any scsi bus, we need to forward scsi-hot-add to the virtio-scsi-device plugged on the virtio-bus.

Note: we don't seem to have any decent way to add disks to devices: no QMP interface, pci address is required instead of using an id ...

Quoted 6 lines
Quoted 1 line

Anyone can be bothered to fix this?

Actually PCI address is not always required, this field (we are talking about "drive_add"?) is ignored when "if=none".

Then documentation in hmp-commands.hx is wrong, isn't it? Add that to the list.

if=none can't be actually used to hot-add
a disk to a device, can it? It creates a disc and assumes you will use it by a device created later.

Quoted 53 lines
Quoted 49 lines
Quoted 49 lines
---
 hw/pci/pci-hotplug.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
hw/pci/pci-hotplug.c +17 -2
index 12287d1..c708752 100644
@@ -30,6 +30,8 @@
 #include "monitor/monitor.h"
 #include "hw/scsi/scsi.h"
 #include "hw/virtio/virtio-blk.h"
+#include "hw/virtio/virtio-scsi.h"
+#include "hw/virtio/virtio-pci.h"
 #include "qemu/config-file.h"
 #include "sysemu/blockdev.h"
 #include "qapi/error.h"
@@ -79,13 +81,26 @@ static int scsi_hot_add(Monitor *mon, DeviceState *adapter,
 {
     SCSIBus *scsibus;
     SCSIDevice *scsidev;
+    VirtIOPCIProxy *virtio_proxy;
 
     scsibus = (SCSIBus *)
         object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
                             TYPE_SCSI_BUS);
     if (!scsibus) {
-	error_report("Device is not a SCSI adapter");
-	return -1;
+        /*
+         * Check if the adapter is a virtio-scsi-pci, and forward scsi_hot_add
+         * to the virtio-scsi-device.
+         */
+        if (!object_dynamic_cast(OBJECT(adapter), TYPE_VIRTIO_SCSI_PCI)) {
+            error_report("Device is not a SCSI adapter");
+            return -1;
+        }
+        virtio_proxy = VIRTIO_PCI(adapter);
+        adapter = DEVICE(virtio_proxy->bus.vdev);
+        scsibus = (SCSIBus *)
+                  object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
+                            TYPE_SCSI_BUS);
+        assert(scsibus);
     }
 
     /*
Signature · 1 line
1.8.1.4
Signature · 1 line
Alexey
#4 lore raw
Quoted 28 lines · Michael S. Tsirkin
Quoted 20 lines · Alexey Kardashevskiy
Quoted 19 lines · Michael S. Tsirkin
Quoted 11 lines · On Wed, Jun 12, 2013 at 08:15:17AM +0200, [email protected] wrote:

From: KONRAD Frederic <[email protected]>

This fix a bug with scsi hotplug on virtio-scsi-pci:

As virtio-scsi-pci doesn't have any scsi bus, we need to forward scsi-hot-add to the virtio-scsi-device plugged on the virtio-bus.

Note: we don't seem to have any decent way to add disks to devices: no QMP interface, pci address is required instead of using an id ...

Quoted 6 lines
Quoted 1 line

Anyone can be bothered to fix this?

Actually PCI address is not always required, this field (we are talking about "drive_add"?) is ignored when "if=none".

Quoted 6 lines

Then documentation in hmp-commands.hx is wrong, isn't it? Add that to the list.

if=none can't be actually used to hot-add
a disk to a device, can it? It creates a disc and assumes you will use it by a device created later.

Yep. I run QEMU with -device "virtio-scsi-pci,id=device0" and then do in console:
drive_add auto file=virtimg/fc18guest,if=none,id=bar1 device_add scsi-disk,bus=device0.0,drive=bar1

Pretty hot plug :)

Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines


---
 hw/pci/pci-hotplug.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
hw/pci/pci-hotplug.c +17 -2
index 12287d1..c708752 100644
@@ -30,6 +30,8 @@
 #include "monitor/monitor.h"
 #include "hw/scsi/scsi.h"
 #include "hw/virtio/virtio-blk.h"
+#include "hw/virtio/virtio-scsi.h"
+#include "hw/virtio/virtio-pci.h"
 #include "qemu/config-file.h"
 #include "sysemu/blockdev.h"
 #include "qapi/error.h"
@@ -79,13 +81,26 @@ static int scsi_hot_add(Monitor *mon, DeviceState *adapter,
 {
     SCSIBus *scsibus;
     SCSIDevice *scsidev;
+    VirtIOPCIProxy *virtio_proxy;
 
     scsibus = (SCSIBus *)
         object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
                             TYPE_SCSI_BUS);
     if (!scsibus) {
-	error_report("Device is not a SCSI adapter");
-	return -1;
+        /*
+         * Check if the adapter is a virtio-scsi-pci, and forward scsi_hot_add
+         * to the virtio-scsi-device.
+         */
+        if (!object_dynamic_cast(OBJECT(adapter), TYPE_VIRTIO_SCSI_PCI)) {
+            error_report("Device is not a SCSI adapter");
+            return -1;
+        }
+        virtio_proxy = VIRTIO_PCI(adapter);
+        adapter = DEVICE(virtio_proxy->bus.vdev);
+        scsibus = (SCSIBus *)
+                  object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
+                            TYPE_SCSI_BUS);
+        assert(scsibus);
     }
 
     /*
Signature · 1 line
Alexey
#5 lore raw
Quoted 37 lines · Alexey Kardashevskiy
Quoted 28 lines · Michael S. Tsirkin
Quoted 20 lines · Alexey Kardashevskiy
Quoted 19 lines · Michael S. Tsirkin
Quoted 11 lines · On Wed, Jun 12, 2013 at 08:15:17AM +0200, [email protected] wrote:

From: KONRAD Frederic <[email protected]>

This fix a bug with scsi hotplug on virtio-scsi-pci:

As virtio-scsi-pci doesn't have any scsi bus, we need to forward scsi-hot-add to the virtio-scsi-device plugged on the virtio-bus.

Note: we don't seem to have any decent way to add disks to devices: no QMP interface, pci address is required instead of using an id ...

Quoted 6 lines
Quoted 1 line

Anyone can be bothered to fix this?

Actually PCI address is not always required, this field (we are talking about "drive_add"?) is ignored when "if=none".

Quoted 6 lines

Then documentation in hmp-commands.hx is wrong, isn't it? Add that to the list.

if=none can't be actually used to hot-add
a disk to a device, can it? It creates a disc and assumes you will use it by a device created later.

Quoted 6 lines

Yep. I run QEMU with -device "virtio-scsi-pci,id=device0" and then do in console:
drive_add auto file=virtimg/fc18guest,if=none,id=bar1 device_add scsi-disk,bus=device0.0,drive=bar1

Pretty hot plug :)

I see. So you pass the device id of a patent as a bus option?

So the real problem is that there's no documentation and what is there in hmp-commands.hx, is wrong.

Quoted 54 lines
Quoted 50 lines
Quoted 50 lines
Quoted 50 lines
Quoted 50 lines



---
 hw/pci/pci-hotplug.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
hw/pci/pci-hotplug.c +17 -2
index 12287d1..c708752 100644
@@ -30,6 +30,8 @@
 #include "monitor/monitor.h"
 #include "hw/scsi/scsi.h"
 #include "hw/virtio/virtio-blk.h"
+#include "hw/virtio/virtio-scsi.h"
+#include "hw/virtio/virtio-pci.h"
 #include "qemu/config-file.h"
 #include "sysemu/blockdev.h"
 #include "qapi/error.h"
@@ -79,13 +81,26 @@ static int scsi_hot_add(Monitor *mon, DeviceState *adapter,
 {
     SCSIBus *scsibus;
     SCSIDevice *scsidev;
+    VirtIOPCIProxy *virtio_proxy;
 
     scsibus = (SCSIBus *)
         object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
                             TYPE_SCSI_BUS);
     if (!scsibus) {
-	error_report("Device is not a SCSI adapter");
-	return -1;
+        /*
+         * Check if the adapter is a virtio-scsi-pci, and forward scsi_hot_add
+         * to the virtio-scsi-device.
+         */
+        if (!object_dynamic_cast(OBJECT(adapter), TYPE_VIRTIO_SCSI_PCI)) {
+            error_report("Device is not a SCSI adapter");
+            return -1;
+        }
+        virtio_proxy = VIRTIO_PCI(adapter);
+        adapter = DEVICE(virtio_proxy->bus.vdev);
+        scsibus = (SCSIBus *)
+                  object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
+                            TYPE_SCSI_BUS);
+        assert(scsibus);
     }
 
     /*
Signature · 1 line
Alexey
#6 lore raw
Quoted 38 lines · Michael S. Tsirkin
Quoted 37 lines · Alexey Kardashevskiy
Quoted 34 lines · Michael S. Tsirkin
Quoted 20 lines · Alexey Kardashevskiy
Quoted 19 lines · Michael S. Tsirkin
Quoted 11 lines · On Wed, Jun 12, 2013 at 08:15:17AM +0200, [email protected] wrote:

From: KONRAD Frederic <[email protected]>

This fix a bug with scsi hotplug on virtio-scsi-pci:

As virtio-scsi-pci doesn't have any scsi bus, we need to forward scsi-hot-add to the virtio-scsi-device plugged on the virtio-bus.

Note: we don't seem to have any decent way to add disks to devices: no QMP interface, pci address is required instead of using an id ...

Quoted 6 lines
Quoted 1 line

Anyone can be bothered to fix this?

Actually PCI address is not always required, this field (we are talking about "drive_add"?) is ignored when "if=none".

Then documentation in hmp-commands.hx is wrong, isn't it? Add that to the list.

if=none can't be actually used to hot-add
a disk to a device, can it? It creates a disc and assumes you will use it by a device created later.

Quoted 8 lines
Quoted 6 lines

Yep. I run QEMU with -device "virtio-scsi-pci,id=device0" and then do in console:
drive_add auto file=virtimg/fc18guest,if=none,id=bar1 device_add scsi-disk,bus=device0.0,drive=bar1

Pretty hot plug :)

I see. So you pass the device id of a patent as a bus option?

Yes. Furthermore I can add many drive+scsi-disk to the same virtio-scsi-pci device/bus this way.

Quoted 2 lines

So the real problem is that there's no documentation and what is there in hmp-commands.hx, is wrong.

Yes, confusing.

Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines




---
 hw/pci/pci-hotplug.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
hw/pci/pci-hotplug.c +17 -2
index 12287d1..c708752 100644
@@ -30,6 +30,8 @@
 #include "monitor/monitor.h"
 #include "hw/scsi/scsi.h"
 #include "hw/virtio/virtio-blk.h"
+#include "hw/virtio/virtio-scsi.h"
+#include "hw/virtio/virtio-pci.h"
 #include "qemu/config-file.h"
 #include "sysemu/blockdev.h"
 #include "qapi/error.h"
@@ -79,13 +81,26 @@ static int scsi_hot_add(Monitor *mon, DeviceState *adapter,
 {
     SCSIBus *scsibus;
     SCSIDevice *scsidev;
+    VirtIOPCIProxy *virtio_proxy;
 
     scsibus = (SCSIBus *)
         object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
                             TYPE_SCSI_BUS);
     if (!scsibus) {
-	error_report("Device is not a SCSI adapter");
-	return -1;
+        /*
+         * Check if the adapter is a virtio-scsi-pci, and forward scsi_hot_add
+         * to the virtio-scsi-device.
+         */
+        if (!object_dynamic_cast(OBJECT(adapter), TYPE_VIRTIO_SCSI_PCI)) {
+            error_report("Device is not a SCSI adapter");
+            return -1;
+        }
+        virtio_proxy = VIRTIO_PCI(adapter);
+        adapter = DEVICE(virtio_proxy->bus.vdev);
+        scsibus = (SCSIBus *)
+                  object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
+                            TYPE_SCSI_BUS);
+        assert(scsibus);
     }
 
     /*
Signature · 1 line
Alexey
#7 lore raw
In reply to Alexey Kardashevskiy
Quoted 33 lines · Alexey Kardashevskiy
Quoted 25 lines · Michael S. Tsirkin
Quoted 15 lines · Alexey Kardashevskiy
Quoted 14 lines · Michael S. Tsirkin
Quoted 11 lines · On Wed, Jun 12, 2013 at 08:15:17AM +0200, [email protected] wrote:

From: KONRAD Frederic <[email protected]>

This fix a bug with scsi hotplug on virtio-scsi-pci:

As virtio-scsi-pci doesn't have any scsi bus, we need to forward scsi-hot-add to the virtio-scsi-device plugged on the virtio-bus.

Quoted 9 lines
Quoted 5 lines

Note: we don't seem to have any decent way to add disks to devices: no QMP interface, pci address is required instead of using an id ...

Anyone can be bothered to fix this?

Actually PCI address is not always required, this field (we are talking about "drive_add"?) is ignored when "if=none".

Quoted 6 lines

Then documentation in hmp-commands.hx is wrong, isn't it? Add that to the list.

if=none can't be actually used to hot-add
a disk to a device, can it? It creates a disc and assumes you will use it by a device created later.

Quoted 6 lines

Yep. I run QEMU with -device "virtio-scsi-pci,id=device0" and then do in console:
drive_add auto file=virtimg/fc18guest,if=none,id=bar1 device_add scsi-disk,bus=device0.0,drive=bar1

Pretty hot plug :)

I thought you use drive_add 0 if=scsi?

Quoted 50 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines


---
  hw/pci/pci-hotplug.c | 19 +++++++++++++++++--
  1 file changed, 17 insertions(+), 2 deletions(-)
hw/pci/pci-hotplug.c +17 -2
index 12287d1..c708752 100644
@@ -30,6 +30,8 @@
  #include "monitor/monitor.h"
  #include "hw/scsi/scsi.h"
  #include "hw/virtio/virtio-blk.h"
+#include "hw/virtio/virtio-scsi.h"
+#include "hw/virtio/virtio-pci.h"
  #include "qemu/config-file.h"
  #include "sysemu/blockdev.h"
  #include "qapi/error.h"
@@ -79,13 +81,26 @@ static int scsi_hot_add(Monitor *mon, DeviceState *adapter,
  {
      SCSIBus *scsibus;
      SCSIDevice *scsidev;
+    VirtIOPCIProxy *virtio_proxy;
 
      scsibus = (SCSIBus *)
          object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
                              TYPE_SCSI_BUS);
      if (!scsibus) {
-	error_report("Device is not a SCSI adapter");
-	return -1;
+        /*
+         * Check if the adapter is a virtio-scsi-pci, and forward scsi_hot_add
+         * to the virtio-scsi-device.
+         */
+        if (!object_dynamic_cast(OBJECT(adapter), TYPE_VIRTIO_SCSI_PCI)) {
+            error_report("Device is not a SCSI adapter");
+            return -1;
+        }
+        virtio_proxy = VIRTIO_PCI(adapter);
+        adapter = DEVICE(virtio_proxy->bus.vdev);
+        scsibus = (SCSIBus *)
+                  object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
+                            TYPE_SCSI_BUS);
+        assert(scsibus);
      }
 
      /*
#8 lore raw
Quoted 36 lines · Frederic Konrad
Quoted 35 lines · Alexey Kardashevskiy
Quoted 33 lines · Michael S. Tsirkin
Quoted 17 lines · Alexey Kardashevskiy
Quoted 16 lines · Michael S. Tsirkin
Quoted 4 lines · On Wed, Jun 12, 2013 at 08:15:17AM +0200, [email protected] wrote:

From: KONRAD Frederic <[email protected]>

This fix a bug with scsi hotplug on virtio-scsi-pci:

Quoted 8 lines

As virtio-scsi-pci doesn't have any scsi bus, we need to forward scsi-hot-add
to the virtio-scsi-device plugged on the virtio-bus.

Quoted 9 lines
Quoted 5 lines

Note: we don't seem to have any decent way to add disks to devices: no QMP interface, pci address is required instead of using an id ...

Anyone can be bothered to fix this?

Actually PCI address is not always required, this field (we are talking about "drive_add"?) is ignored when "if=none".

Then documentation in hmp-commands.hx is wrong, isn't it? Add that to the list.

if=none can't be actually used to hot-add
a disk to a device, can it? It creates a disc and assumes you will use it by a device created later.

Quoted 8 lines
Quoted 6 lines

Yep. I run QEMU with -device "virtio-scsi-pci,id=device0" and then do in console:
drive_add auto file=virtimg/fc18guest,if=none,id=bar1 device_add scsi-disk,bus=device0.0,drive=bar1

Pretty hot plug :)

I thought you use drive_add 0 if=scsi?

That's the other option, I posted a bug but I did not actually try the fix till now :)

It works now if I run QEMU with "-device virtio-scsi-pci" and do this in qemu console:
drive_add 0 file=virtimg/fc18guest

No extra parameters or anything, cool, thanks, and :)

The only problem with it that it still wants PCI SCSI adapter while spapr-vscsi is VIO device so if the guest kernel does not have virtio-scsi support, I have to do what I described in the quote but this is a different story.

Quoted 53 lines
Quoted 52 lines
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines


---
  hw/pci/pci-hotplug.c | 19 +++++++++++++++++--
  1 file changed, 17 insertions(+), 2 deletions(-)
hw/pci/pci-hotplug.c +5 -2
index 12287d1..c708752 100644
@@ -30,6 +30,8 @@
  #include "monitor/monitor.h"
  #include "hw/scsi/scsi.h"
  #include "hw/virtio/virtio-blk.h"
+#include "hw/virtio/virtio-scsi.h"
+#include "hw/virtio/virtio-pci.h"
  #include "qemu/config-file.h"
  #include "sysemu/blockdev.h"
  #include "qapi/error.h"
@@ -79,13 +81,26 @@ static int scsi_hot_add(Monitor *mon, DeviceState
 *adapter,
  {
      SCSIBus *scsibus;
      SCSIDevice *scsidev;
+    VirtIOPCIProxy *virtio_proxy;
        scsibus = (SCSIBus *)
          object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
                              TYPE_SCSI_BUS);
      if (!scsibus) {
-    error_report("Device is not a SCSI adapter");
-    return -1;
+        /*
+         * Check if the adapter is a virtio-scsi-pci, and forward

scsi_hot_add

hw/pci/pci-hotplug.c +3 -0
+         * to the virtio-scsi-device.
+         */
+        if (!object_dynamic_cast(OBJECT(adapter),

TYPE_VIRTIO_SCSI_PCI)) {

hw/pci/pci-hotplug.c +7 -0
+            error_report("Device is not a SCSI adapter");
+            return -1;
+        }
+        virtio_proxy = VIRTIO_PCI(adapter);
+        adapter = DEVICE(virtio_proxy->bus.vdev);
+        scsibus = (SCSIBus *)
+                 

object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),

hw/pci/pci-hotplug.c +2 -0
+                            TYPE_SCSI_BUS);
+        assert(scsibus);
      }
        /*
Signature · 1 line
Alexey
#9 lore raw
Quoted 52 lines · Alexey Kardashevskiy
Quoted 34 lines · Frederic Konrad
Quoted 33 lines · Alexey Kardashevskiy
Quoted 32 lines · Michael S. Tsirkin
Quoted 17 lines · Alexey Kardashevskiy
Quoted 16 lines · Michael S. Tsirkin
Quoted 4 lines · On Wed, Jun 12, 2013 at 08:15:17AM +0200, [email protected] wrote:

From: KONRAD Frederic <[email protected]>

This fix a bug with scsi hotplug on virtio-scsi-pci:

Quoted 8 lines

As virtio-scsi-pci doesn't have any scsi bus, we need to forward scsi-hot-add
to the virtio-scsi-device plugged on the virtio-bus.

Quoted 8 lines
Quoted 5 lines

Note: we don't seem to have any decent way to add disks to devices: no QMP interface, pci address is required instead of using an id ...

Anyone can be bothered to fix this?

Actually PCI address is not always required, this field (we are talking about "drive_add"?) is ignored when "if=none".

Then documentation in hmp-commands.hx is wrong, isn't it? Add that to the list.

if=none can't be actually used to hot-add
a disk to a device, can it? It creates a disc and assumes you will use it by a device created later.

Quoted 7 lines
Quoted 6 lines

Yep. I run QEMU with -device "virtio-scsi-pci,id=device0" and then do in console:
drive_add auto file=virtimg/fc18guest,if=none,id=bar1 device_add scsi-disk,bus=device0.0,drive=bar1

Pretty hot plug :)

I thought you use drive_add 0 if=scsi?

That's the other option, I posted a bug but I did not actually try the fix till now :)

It works now if I run QEMU with "-device virtio-scsi-pci" and do this in qemu console:
drive_add 0 file=virtimg/fc18guest

No extra parameters or anything, cool, thanks, and :)

Quoted 7 lines

The only problem with it that it still wants PCI SCSI adapter while spapr-vscsi is VIO device so if the guest kernel does not have virtio-scsi support, I have to do what I described in the quote but this is a different story.

Understood, thanks
Fred

Quoted 52 lines
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines


---
   hw/pci/pci-hotplug.c | 19 +++++++++++++++++--
   1 file changed, 17 insertions(+), 2 deletions(-)
hw/pci/pci-hotplug.c +5 -2
index 12287d1..c708752 100644
@@ -30,6 +30,8 @@
   #include "monitor/monitor.h"
   #include "hw/scsi/scsi.h"
   #include "hw/virtio/virtio-blk.h"
+#include "hw/virtio/virtio-scsi.h"
+#include "hw/virtio/virtio-pci.h"
   #include "qemu/config-file.h"
   #include "sysemu/blockdev.h"
   #include "qapi/error.h"
@@ -79,13 +81,26 @@ static int scsi_hot_add(Monitor *mon, DeviceState
 *adapter,
   {
       SCSIBus *scsibus;
       SCSIDevice *scsidev;
+    VirtIOPCIProxy *virtio_proxy;
         scsibus = (SCSIBus *)
           object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
                               TYPE_SCSI_BUS);
       if (!scsibus) {
-    error_report("Device is not a SCSI adapter");
-    return -1;
+        /*
+         * Check if the adapter is a virtio-scsi-pci, and forward

scsi_hot_add

hw/pci/pci-hotplug.c +3 -0
+         * to the virtio-scsi-device.
+         */
+        if (!object_dynamic_cast(OBJECT(adapter),

TYPE_VIRTIO_SCSI_PCI)) {

hw/pci/pci-hotplug.c +7 -0
+            error_report("Device is not a SCSI adapter");
+            return -1;
+        }
+        virtio_proxy = VIRTIO_PCI(adapter);
+        adapter = DEVICE(virtio_proxy->bus.vdev);
+        scsibus = (SCSIBus *)
+

object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),

hw/pci/pci-hotplug.c +2 -0
+                            TYPE_SCSI_BUS);
+        assert(scsibus);
       }
         /*
#10 lore raw
In reply to Alexey Kardashevskiy
Quoted 56 lines · Alexey Kardashevskiy
Quoted 36 lines · Frederic Konrad
Quoted 35 lines · Alexey Kardashevskiy
Quoted 33 lines · Michael S. Tsirkin
Quoted 17 lines · Alexey Kardashevskiy
Quoted 16 lines · Michael S. Tsirkin
Quoted 4 lines · On Wed, Jun 12, 2013 at 08:15:17AM +0200, [email protected] wrote:

From: KONRAD Frederic <[email protected]>

This fix a bug with scsi hotplug on virtio-scsi-pci:

Quoted 8 lines

As virtio-scsi-pci doesn't have any scsi bus, we need to forward scsi-hot-add
to the virtio-scsi-device plugged on the virtio-bus.

Quoted 9 lines
Quoted 5 lines

Note: we don't seem to have any decent way to add disks to devices: no QMP interface, pci address is required instead of using an id ...

Anyone can be bothered to fix this?

Actually PCI address is not always required, this field (we are talking about "drive_add"?) is ignored when "if=none".

Then documentation in hmp-commands.hx is wrong, isn't it? Add that to the list.

if=none can't be actually used to hot-add
a disk to a device, can it? It creates a disc and assumes you will use it by a device created later.

Quoted 8 lines
Quoted 6 lines

Yep. I run QEMU with -device "virtio-scsi-pci,id=device0" and then do in console:
drive_add auto file=virtimg/fc18guest,if=none,id=bar1 device_add scsi-disk,bus=device0.0,drive=bar1

Pretty hot plug :)

I thought you use drive_add 0 if=scsi?

That's the other option, I posted a bug but I did not actually try the fix till now :)

It works now if I run QEMU with "-device virtio-scsi-pci" and do this in qemu console:
drive_add 0 file=virtimg/fc18guest

No extra parameters or anything, cool, thanks, and :)

Quoted 7 lines

The only problem with it that it still wants PCI SCSI adapter while spapr-vscsi is VIO device so if the guest kernel does not have virtio-scsi support, I have to do what I described in the quote but this is a different story.

Okay. How about:
- document that pci_addr is optional in hmp
- if no pci_addr assume if=none
- add drive_add to qmp without the pci_addr and if options

We are left with the bus=device0.0 syntax for device_add which is also gross - user asked for device0, the .0 part is qemu internals exposed to users.
How about teaching qdev that if there's a single bus under a device, naming the device itself should be identical?

This will solve the problem neatly without virtio specific hacks, won't it?

Quoted 59 lines
Quoted 55 lines
Quoted 54 lines
Quoted 53 lines
Quoted 53 lines
Quoted 53 lines
Quoted 53 lines




---
  hw/pci/pci-hotplug.c | 19 +++++++++++++++++--
  1 file changed, 17 insertions(+), 2 deletions(-)
hw/pci/pci-hotplug.c +5 -2
index 12287d1..c708752 100644
@@ -30,6 +30,8 @@
  #include "monitor/monitor.h"
  #include "hw/scsi/scsi.h"
  #include "hw/virtio/virtio-blk.h"
+#include "hw/virtio/virtio-scsi.h"
+#include "hw/virtio/virtio-pci.h"
  #include "qemu/config-file.h"
  #include "sysemu/blockdev.h"
  #include "qapi/error.h"
@@ -79,13 +81,26 @@ static int scsi_hot_add(Monitor *mon, DeviceState
 *adapter,
  {
      SCSIBus *scsibus;
      SCSIDevice *scsidev;
+    VirtIOPCIProxy *virtio_proxy;
        scsibus = (SCSIBus *)
          object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
                              TYPE_SCSI_BUS);
      if (!scsibus) {
-    error_report("Device is not a SCSI adapter");
-    return -1;
+        /*
+         * Check if the adapter is a virtio-scsi-pci, and forward

scsi_hot_add

hw/pci/pci-hotplug.c +3 -0
+         * to the virtio-scsi-device.
+         */
+        if (!object_dynamic_cast(OBJECT(adapter),

TYPE_VIRTIO_SCSI_PCI)) {

hw/pci/pci-hotplug.c +7 -0
+            error_report("Device is not a SCSI adapter");
+            return -1;
+        }
+        virtio_proxy = VIRTIO_PCI(adapter);
+        adapter = DEVICE(virtio_proxy->bus.vdev);
+        scsibus = (SCSIBus *)
+                 

object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),

hw/pci/pci-hotplug.c +2 -0
+                            TYPE_SCSI_BUS);
+        assert(scsibus);
      }
        /*
Signature · 1 line
Alexey
#11 lore raw
Quoted 65 lines · Michael S. Tsirkin
Quoted 52 lines · Alexey Kardashevskiy
Quoted 34 lines · Frederic Konrad
Quoted 33 lines · Alexey Kardashevskiy
Quoted 32 lines · Michael S. Tsirkin
Quoted 17 lines · Alexey Kardashevskiy
Quoted 16 lines · Michael S. Tsirkin
Quoted 4 lines · On Wed, Jun 12, 2013 at 08:15:17AM +0200, [email protected] wrote:

From: KONRAD Frederic <[email protected]>

This fix a bug with scsi hotplug on virtio-scsi-pci:

Quoted 8 lines

As virtio-scsi-pci doesn't have any scsi bus, we need to forward scsi-hot-add
to the virtio-scsi-device plugged on the virtio-bus.

Quoted 8 lines
Quoted 5 lines

Note: we don't seem to have any decent way to add disks to devices: no QMP interface, pci address is required instead of using an id ...

Anyone can be bothered to fix this?

Actually PCI address is not always required, this field (we are talking about "drive_add"?) is ignored when "if=none".

Then documentation in hmp-commands.hx is wrong, isn't it? Add that to the list.

if=none can't be actually used to hot-add
a disk to a device, can it? It creates a disc and assumes you will use it by a device created later.

Quoted 7 lines
Quoted 6 lines

Yep. I run QEMU with -device "virtio-scsi-pci,id=device0" and then do in console:
drive_add auto file=virtimg/fc18guest,if=none,id=bar1 device_add scsi-disk,bus=device0.0,drive=bar1

Pretty hot plug :)

I thought you use drive_add 0 if=scsi?

That's the other option, I posted a bug but I did not actually try the fix till now :)

It works now if I run QEMU with "-device virtio-scsi-pci" and do this in qemu console:
drive_add 0 file=virtimg/fc18guest

No extra parameters or anything, cool, thanks, and :)

Quoted 7 lines

The only problem with it that it still wants PCI SCSI adapter while spapr-vscsi is VIO device so if the guest kernel does not have virtio-scsi support, I have to do what I described in the quote but this is a different story.

Okay. How about:
- document that pci_addr is optional in hmp
- if no pci_addr assume if=none
- add drive_add to qmp without the pci_addr and if options

Quoted 5 lines

We are left with the bus=device0.0 syntax for device_add which is also gross - user asked for device0, the .0 part is qemu internals exposed to users.
How about teaching qdev that if there's a single bus under a device, naming the device itself should be identical?

Yes why not seems a good idea, but you'll pass it through bus= option?

Quoted 2 lines

This will solve the problem neatly without virtio specific hacks, won't it?

The issue here is command line back-compatibility for pci_addr, which won't be solved with the "single bus" idea?

Quoted 54 lines
Quoted 54 lines
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines


---
   hw/pci/pci-hotplug.c | 19 +++++++++++++++++--
   1 file changed, 17 insertions(+), 2 deletions(-)
hw/pci/pci-hotplug.c +5 -2
index 12287d1..c708752 100644
@@ -30,6 +30,8 @@
   #include "monitor/monitor.h"
   #include "hw/scsi/scsi.h"
   #include "hw/virtio/virtio-blk.h"
+#include "hw/virtio/virtio-scsi.h"
+#include "hw/virtio/virtio-pci.h"
   #include "qemu/config-file.h"
   #include "sysemu/blockdev.h"
   #include "qapi/error.h"
@@ -79,13 +81,26 @@ static int scsi_hot_add(Monitor *mon, DeviceState
 *adapter,
   {
       SCSIBus *scsibus;
       SCSIDevice *scsidev;
+    VirtIOPCIProxy *virtio_proxy;
         scsibus = (SCSIBus *)
           object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
                               TYPE_SCSI_BUS);
       if (!scsibus) {
-    error_report("Device is not a SCSI adapter");
-    return -1;
+        /*
+         * Check if the adapter is a virtio-scsi-pci, and forward

scsi_hot_add

hw/pci/pci-hotplug.c +3 -0
+         * to the virtio-scsi-device.
+         */
+        if (!object_dynamic_cast(OBJECT(adapter),

TYPE_VIRTIO_SCSI_PCI)) {

hw/pci/pci-hotplug.c +7 -0
+            error_report("Device is not a SCSI adapter");
+            return -1;
+        }
+        virtio_proxy = VIRTIO_PCI(adapter);
+        adapter = DEVICE(virtio_proxy->bus.vdev);
+        scsibus = (SCSIBus *)
+

object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),

hw/pci/pci-hotplug.c +2 -0
+                            TYPE_SCSI_BUS);
+        assert(scsibus);
       }
         /*
Signature · 1 line
Alexey
#12 lore raw
Quoted 72 lines · Frederic Konrad
Quoted 65 lines · Michael S. Tsirkin
Quoted 52 lines · Alexey Kardashevskiy
Quoted 34 lines · Frederic Konrad
Quoted 33 lines · Alexey Kardashevskiy
Quoted 32 lines · Michael S. Tsirkin
Quoted 17 lines · Alexey Kardashevskiy
Quoted 16 lines · Michael S. Tsirkin
Quoted 4 lines · On Wed, Jun 12, 2013 at 08:15:17AM +0200, [email protected] wrote:

From: KONRAD Frederic <[email protected]>

This fix a bug with scsi hotplug on virtio-scsi-pci:

Quoted 8 lines

As virtio-scsi-pci doesn't have any scsi bus, we need to forward scsi-hot-add
to the virtio-scsi-device plugged on the virtio-bus.

Quoted 8 lines
Quoted 5 lines

Note: we don't seem to have any decent way to add disks to devices: no QMP interface, pci address is required instead of using an id ...

Anyone can be bothered to fix this?

Actually PCI address is not always required, this field (we are talking about "drive_add"?) is ignored when "if=none".

Then documentation in hmp-commands.hx is wrong, isn't it? Add that to the list.

if=none can't be actually used to hot-add
a disk to a device, can it? It creates a disc and assumes you will use it by a device created later.

Quoted 7 lines
Quoted 6 lines

Yep. I run QEMU with -device "virtio-scsi-pci,id=device0" and then do in console:
drive_add auto file=virtimg/fc18guest,if=none,id=bar1 device_add scsi-disk,bus=device0.0,drive=bar1

Pretty hot plug :)

I thought you use drive_add 0 if=scsi?

That's the other option, I posted a bug but I did not actually try the fix till now :)

It works now if I run QEMU with "-device virtio-scsi-pci" and do this in qemu console:
drive_add 0 file=virtimg/fc18guest

No extra parameters or anything, cool, thanks, and :)

Quoted 7 lines

The only problem with it that it still wants PCI SCSI adapter while spapr-vscsi is VIO device so if the guest kernel does not have virtio-scsi support, I have to do what I described in the quote but this is a different story.

Okay. How about:
- document that pci_addr is optional in hmp
- if no pci_addr assume if=none
- add drive_add to qmp without the pci_addr and if options

Quoted 5 lines

We are left with the bus=device0.0 syntax for device_add which is also gross - user asked for device0, the .0 part is qemu internals exposed to users.
How about teaching qdev that if there's a single bus under a device, naming the device itself should be identical?

Quoted 7 lines

Yes why not seems a good idea, but you'll pass it through bus= option?

Quoted 2 lines

This will solve the problem neatly without virtio specific hacks, won't it?

The issue here is command line back-compatibility for pci_addr, which won't be solved with
the "single bus" idea?

Why not? This code:

    scsibus = (SCSIBus *)
        object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
                            TYPE_SCSI_BUS);

should be replaced with code from qdev that we'll write that goes down the chain as long as there's 1 device on each bus, looking for a device of the appropriate type.

Quoted 54 lines
Quoted 54 lines
Quoted 54 lines
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines


---
  hw/pci/pci-hotplug.c | 19 +++++++++++++++++--
  1 file changed, 17 insertions(+), 2 deletions(-)
hw/pci/pci-hotplug.c +5 -2
index 12287d1..c708752 100644
@@ -30,6 +30,8 @@
  #include "monitor/monitor.h"
  #include "hw/scsi/scsi.h"
  #include "hw/virtio/virtio-blk.h"
+#include "hw/virtio/virtio-scsi.h"
+#include "hw/virtio/virtio-pci.h"
  #include "qemu/config-file.h"
  #include "sysemu/blockdev.h"
  #include "qapi/error.h"
@@ -79,13 +81,26 @@ static int scsi_hot_add(Monitor *mon, DeviceState
 *adapter,
  {
      SCSIBus *scsibus;
      SCSIDevice *scsidev;
+    VirtIOPCIProxy *virtio_proxy;
        scsibus = (SCSIBus *)
          object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
                              TYPE_SCSI_BUS);
      if (!scsibus) {
-    error_report("Device is not a SCSI adapter");
-    return -1;
+        /*
+         * Check if the adapter is a virtio-scsi-pci, and forward

scsi_hot_add

hw/pci/pci-hotplug.c +3 -0
+         * to the virtio-scsi-device.
+         */
+        if (!object_dynamic_cast(OBJECT(adapter),

TYPE_VIRTIO_SCSI_PCI)) {

hw/pci/pci-hotplug.c +7 -0
+            error_report("Device is not a SCSI adapter");
+            return -1;
+        }
+        virtio_proxy = VIRTIO_PCI(adapter);
+        adapter = DEVICE(virtio_proxy->bus.vdev);
+        scsibus = (SCSIBus *)
+

object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),

hw/pci/pci-hotplug.c +2 -0
+                            TYPE_SCSI_BUS);
+        assert(scsibus);
      }
        /*
Signature · 1 line
Alexey
#13 lore raw
Quoted 77 lines · Michael S. Tsirkin
Quoted 70 lines · Frederic Konrad
Quoted 64 lines · Michael S. Tsirkin
Quoted 51 lines · Alexey Kardashevskiy
Quoted 34 lines · Frederic Konrad
Quoted 33 lines · Alexey Kardashevskiy
Quoted 32 lines · Michael S. Tsirkin
Quoted 17 lines · Alexey Kardashevskiy
Quoted 16 lines · Michael S. Tsirkin
Quoted 4 lines · On Wed, Jun 12, 2013 at 08:15:17AM +0200, [email protected] wrote:

From: KONRAD Frederic <[email protected]>

This fix a bug with scsi hotplug on virtio-scsi-pci:

Quoted 8 lines

As virtio-scsi-pci doesn't have any scsi bus, we need to forward scsi-hot-add
to the virtio-scsi-device plugged on the virtio-bus.

Quoted 8 lines
Quoted 5 lines

Note: we don't seem to have any decent way to add disks to devices: no QMP interface, pci address is required instead of using an id ...

Anyone can be bothered to fix this?

Actually PCI address is not always required, this field (we are talking about "drive_add"?) is ignored when "if=none".

Then documentation in hmp-commands.hx is wrong, isn't it? Add that to the list.

if=none can't be actually used to hot-add
a disk to a device, can it? It creates a disc and assumes you will use it by a device created later.

Quoted 7 lines
Quoted 6 lines

Yep. I run QEMU with -device "virtio-scsi-pci,id=device0" and then do in console:
drive_add auto file=virtimg/fc18guest,if=none,id=bar1 device_add scsi-disk,bus=device0.0,drive=bar1

Pretty hot plug :)

I thought you use drive_add 0 if=scsi?

That's the other option, I posted a bug but I did not actually try the fix till now :)

It works now if I run QEMU with "-device virtio-scsi-pci" and do this in qemu console:
drive_add 0 file=virtimg/fc18guest

No extra parameters or anything, cool, thanks, and :)

Quoted 7 lines

The only problem with it that it still wants PCI SCSI adapter while spapr-vscsi is VIO device so if the guest kernel does not have virtio-scsi support, I have to do what I described in the quote but this is a different story.

Okay. How about:
- document that pci_addr is optional in hmp
- if no pci_addr assume if=none
- add drive_add to qmp without the pci_addr and if options

Quoted 5 lines

We are left with the bus=device0.0 syntax for device_add which is also gross - user asked for device0, the .0 part is qemu internals exposed to users.
How about teaching qdev that if there's a single bus under a device, naming the device itself should be identical?

Quoted 6 lines

Yes why not seems a good idea, but you'll pass it through bus= option?

Quoted 2 lines

This will solve the problem neatly without virtio specific hacks, won't it?

The issue here is command line back-compatibility for pci_addr, which won't be solved with
the "single bus" idea?

Quoted 7 lines

Why not? This code:

     scsibus = (SCSIBus *)
         object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
                             TYPE_SCSI_BUS);

should be replaced with code from qdev that we'll write that goes down the chain as long as there's 1 device on each bus, looking for a device of the appropriate type.

Ok, understood what you mean :).

Why not if everybody is happy with it.

Fred

Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
---
   hw/pci/pci-hotplug.c | 19 +++++++++++++++++--
   1 file changed, 17 insertions(+), 2 deletions(-)
hw/pci/pci-hotplug.c +5 -2
index 12287d1..c708752 100644
@@ -30,6 +30,8 @@
   #include "monitor/monitor.h"
   #include "hw/scsi/scsi.h"
   #include "hw/virtio/virtio-blk.h"
+#include "hw/virtio/virtio-scsi.h"
+#include "hw/virtio/virtio-pci.h"
   #include "qemu/config-file.h"
   #include "sysemu/blockdev.h"
   #include "qapi/error.h"
@@ -79,13 +81,26 @@ static int scsi_hot_add(Monitor *mon, DeviceState
 *adapter,
   {
       SCSIBus *scsibus;
       SCSIDevice *scsidev;
+    VirtIOPCIProxy *virtio_proxy;
         scsibus = (SCSIBus *)
           object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
                               TYPE_SCSI_BUS);
       if (!scsibus) {
-    error_report("Device is not a SCSI adapter");
-    return -1;
+        /*
+         * Check if the adapter is a virtio-scsi-pci, and forward

scsi_hot_add

hw/pci/pci-hotplug.c +3 -0
+         * to the virtio-scsi-device.
+         */
+        if (!object_dynamic_cast(OBJECT(adapter),

TYPE_VIRTIO_SCSI_PCI)) {

hw/pci/pci-hotplug.c +7 -0
+            error_report("Device is not a SCSI adapter");
+            return -1;
+        }
+        virtio_proxy = VIRTIO_PCI(adapter);
+        adapter = DEVICE(virtio_proxy->bus.vdev);
+        scsibus = (SCSIBus *)
+

object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),

hw/pci/pci-hotplug.c +2 -0
+                            TYPE_SCSI_BUS);
+        assert(scsibus);
       }
         /*
Signature · 1 line
Alexey
#14 lore raw
Quoted 86 lines · Frederic Konrad
Quoted 77 lines · Michael S. Tsirkin
Quoted 70 lines · Frederic Konrad
Quoted 64 lines · Michael S. Tsirkin
Quoted 51 lines · Alexey Kardashevskiy
Quoted 34 lines · Frederic Konrad
Quoted 33 lines · Alexey Kardashevskiy
Quoted 32 lines · Michael S. Tsirkin
Quoted 17 lines · Alexey Kardashevskiy
Quoted 16 lines · Michael S. Tsirkin
Quoted 4 lines · On Wed, Jun 12, 2013 at 08:15:17AM +0200, [email protected] wrote:

From: KONRAD Frederic <[email protected]>

This fix a bug with scsi hotplug on virtio-scsi-pci:

Quoted 8 lines

As virtio-scsi-pci doesn't have any scsi bus, we need to forward scsi-hot-add
to the virtio-scsi-device plugged on the virtio-bus.

Quoted 8 lines
Quoted 5 lines

Note: we don't seem to have any decent way to add disks to devices: no QMP interface, pci address is required instead of using an id ...

Anyone can be bothered to fix this?

Actually PCI address is not always required, this field (we are talking about "drive_add"?) is ignored when "if=none".

Then documentation in hmp-commands.hx is wrong, isn't it? Add that to the list.

if=none can't be actually used to hot-add
a disk to a device, can it? It creates a disc and assumes you will use it by a device created later.

Quoted 7 lines
Quoted 6 lines

Yep. I run QEMU with -device "virtio-scsi-pci,id=device0" and then do in console:
drive_add auto file=virtimg/fc18guest,if=none,id=bar1 device_add scsi-disk,bus=device0.0,drive=bar1

Pretty hot plug :)

I thought you use drive_add 0 if=scsi?

That's the other option, I posted a bug but I did not actually try the fix till now :)

It works now if I run QEMU with "-device virtio-scsi-pci" and do this in qemu console:
drive_add 0 file=virtimg/fc18guest

No extra parameters or anything, cool, thanks, and :)

Quoted 7 lines

The only problem with it that it still wants PCI SCSI adapter while spapr-vscsi is VIO device so if the guest kernel does not have virtio-scsi support, I have to do what I described in the quote but this is a different story.

Okay. How about:
- document that pci_addr is optional in hmp
- if no pci_addr assume if=none
- add drive_add to qmp without the pci_addr and if options

Quoted 5 lines

We are left with the bus=device0.0 syntax for device_add which is also gross - user asked for device0, the .0 part is qemu internals exposed to users.
How about teaching qdev that if there's a single bus under a device, naming the device itself should be identical?

Quoted 6 lines

Yes why not seems a good idea, but you'll pass it through bus= option?

Quoted 2 lines

This will solve the problem neatly without virtio specific hacks, won't it?

The issue here is command line back-compatibility for pci_addr, which won't be solved with
the "single bus" idea?

Quoted 7 lines

Why not? This code:

    scsibus = (SCSIBus *)
        object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
                            TYPE_SCSI_BUS);

should be replaced with code from qdev that we'll write that goes down the chain as long as there's 1 device on each bus, looking for a device of the appropriate type.

Quoted 5 lines

Ok, understood what you mean :).

Why not if everybody is happy with it.

Fred

Ok so - want to try implementing this?

Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
---
  hw/pci/pci-hotplug.c | 19 +++++++++++++++++--
  1 file changed, 17 insertions(+), 2 deletions(-)
hw/pci/pci-hotplug.c +5 -2
index 12287d1..c708752 100644
@@ -30,6 +30,8 @@
  #include "monitor/monitor.h"
  #include "hw/scsi/scsi.h"
  #include "hw/virtio/virtio-blk.h"
+#include "hw/virtio/virtio-scsi.h"
+#include "hw/virtio/virtio-pci.h"
  #include "qemu/config-file.h"
  #include "sysemu/blockdev.h"
  #include "qapi/error.h"
@@ -79,13 +81,26 @@ static int scsi_hot_add(Monitor *mon, DeviceState
 *adapter,
  {
      SCSIBus *scsibus;
      SCSIDevice *scsidev;
+    VirtIOPCIProxy *virtio_proxy;
        scsibus = (SCSIBus *)
          object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
                              TYPE_SCSI_BUS);
      if (!scsibus) {
-    error_report("Device is not a SCSI adapter");
-    return -1;
+        /*
+         * Check if the adapter is a virtio-scsi-pci, and forward

scsi_hot_add

hw/pci/pci-hotplug.c +3 -0
+         * to the virtio-scsi-device.
+         */
+        if (!object_dynamic_cast(OBJECT(adapter),

TYPE_VIRTIO_SCSI_PCI)) {

hw/pci/pci-hotplug.c +7 -0
+            error_report("Device is not a SCSI adapter");
+            return -1;
+        }
+        virtio_proxy = VIRTIO_PCI(adapter);
+        adapter = DEVICE(virtio_proxy->bus.vdev);
+        scsibus = (SCSIBus *)
+

object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),

hw/pci/pci-hotplug.c +2 -0
+                            TYPE_SCSI_BUS);
+        assert(scsibus);
      }
        /*
Signature · 1 line
Alexey
#15 lore raw
Quoted 86 lines · Michael S. Tsirkin
Quoted 85 lines · Frederic Konrad
Quoted 84 lines · Michael S. Tsirkin
Quoted 70 lines · Frederic Konrad
Quoted 64 lines · Michael S. Tsirkin
Quoted 51 lines · Alexey Kardashevskiy
Quoted 34 lines · Frederic Konrad
Quoted 33 lines · Alexey Kardashevskiy
Quoted 32 lines · Michael S. Tsirkin
Quoted 17 lines · Alexey Kardashevskiy
Quoted 16 lines · Michael S. Tsirkin
Quoted 4 lines · On Wed, Jun 12, 2013 at 08:15:17AM +0200, [email protected] wrote:

From: KONRAD Frederic <[email protected]>

This fix a bug with scsi hotplug on virtio-scsi-pci:

Quoted 8 lines

As virtio-scsi-pci doesn't have any scsi bus, we need to forward scsi-hot-add
to the virtio-scsi-device plugged on the virtio-bus.

Quoted 8 lines
Quoted 5 lines

Note: we don't seem to have any decent way to add disks to devices: no QMP interface, pci address is required instead of using an id ...

Anyone can be bothered to fix this?

Actually PCI address is not always required, this field (we are talking about "drive_add"?) is ignored when "if=none".

Then documentation in hmp-commands.hx is wrong, isn't it? Add that to the list.

if=none can't be actually used to hot-add
a disk to a device, can it? It creates a disc and assumes you will use it by a device created later.

Quoted 7 lines
Quoted 6 lines

Yep. I run QEMU with -device "virtio-scsi-pci,id=device0" and then do in console:
drive_add auto file=virtimg/fc18guest,if=none,id=bar1 device_add scsi-disk,bus=device0.0,drive=bar1

Pretty hot plug :)

I thought you use drive_add 0 if=scsi?

That's the other option, I posted a bug but I did not actually try the fix till now :)

It works now if I run QEMU with "-device virtio-scsi-pci" and do this in qemu console:
drive_add 0 file=virtimg/fc18guest

No extra parameters or anything, cool, thanks, and :)

Quoted 7 lines

The only problem with it that it still wants PCI SCSI adapter while spapr-vscsi is VIO device so if the guest kernel does not have virtio-scsi support, I have to do what I described in the quote but this is a different story.

Okay. How about:
- document that pci_addr is optional in hmp
- if no pci_addr assume if=none
- add drive_add to qmp without the pci_addr and if options

Quoted 5 lines

We are left with the bus=device0.0 syntax for device_add which is also gross - user asked for device0, the .0 part is qemu internals exposed to users.
How about teaching qdev that if there's a single bus under a device, naming the device itself should be identical?

Quoted 6 lines

Yes why not seems a good idea, but you'll pass it through bus= option?

Quoted 2 lines

This will solve the problem neatly without virtio specific hacks, won't it?

The issue here is command line back-compatibility for pci_addr, which won't be solved with
the "single bus" idea?

Why not? This code:

     scsibus = (SCSIBus *)
         object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
                             TYPE_SCSI_BUS);

should be replaced with code from qdev that we'll write that goes down the chain as long as there's 1 device on each bus, looking for a device of the appropriate type.

Quoted 6 lines
Quoted 5 lines

Ok, understood what you mean :).

Why not if everybody is happy with it.

Fred

Ok so - want to try implementing this?

Ok, will try to look at it next week.

What about the stable release?
Wouldn't be safe to take this patch for the stable?

Fred

Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
---
   hw/pci/pci-hotplug.c | 19 +++++++++++++++++--
   1 file changed, 17 insertions(+), 2 deletions(-)
hw/pci/pci-hotplug.c +5 -2
index 12287d1..c708752 100644
@@ -30,6 +30,8 @@
   #include "monitor/monitor.h"
   #include "hw/scsi/scsi.h"
   #include "hw/virtio/virtio-blk.h"
+#include "hw/virtio/virtio-scsi.h"
+#include "hw/virtio/virtio-pci.h"
   #include "qemu/config-file.h"
   #include "sysemu/blockdev.h"
   #include "qapi/error.h"
@@ -79,13 +81,26 @@ static int scsi_hot_add(Monitor *mon, DeviceState
 *adapter,
   {
       SCSIBus *scsibus;
       SCSIDevice *scsidev;
+    VirtIOPCIProxy *virtio_proxy;
         scsibus = (SCSIBus *)
           object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
                               TYPE_SCSI_BUS);
       if (!scsibus) {
-    error_report("Device is not a SCSI adapter");
-    return -1;
+        /*
+         * Check if the adapter is a virtio-scsi-pci, and forward

scsi_hot_add

hw/pci/pci-hotplug.c +3 -0
+         * to the virtio-scsi-device.
+         */
+        if (!object_dynamic_cast(OBJECT(adapter),

TYPE_VIRTIO_SCSI_PCI)) {

hw/pci/pci-hotplug.c +7 -0
+            error_report("Device is not a SCSI adapter");
+            return -1;
+        }
+        virtio_proxy = VIRTIO_PCI(adapter);
+        adapter = DEVICE(virtio_proxy->bus.vdev);
+        scsibus = (SCSIBus *)
+

object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),

hw/pci/pci-hotplug.c +2 -0
+                            TYPE_SCSI_BUS);
+        assert(scsibus);
       }
         /*
Signature · 1 line
Alexey
#16 lore raw
Quoted 92 lines · Frederic Konrad
Quoted 91 lines · Michael S. Tsirkin
Quoted 90 lines · Frederic Konrad
Quoted 77 lines · Michael S. Tsirkin
Quoted 70 lines · Frederic Konrad
Quoted 64 lines · Michael S. Tsirkin
Quoted 51 lines · Alexey Kardashevskiy
Quoted 34 lines · Frederic Konrad
Quoted 33 lines · Alexey Kardashevskiy
Quoted 32 lines · Michael S. Tsirkin
Quoted 17 lines · Alexey Kardashevskiy
Quoted 16 lines · Michael S. Tsirkin
Quoted 12 lines · On Wed, Jun 12, 2013 at 08:15:17AM +0200, [email protected] wrote:

From: KONRAD Frederic <[email protected]>

This fix a bug with scsi hotplug on virtio-scsi-pci:

As virtio-scsi-pci doesn't have any scsi bus, we need to forward
scsi-hot-add
to the virtio-scsi-device plugged on the virtio-bus.

Cc: [email protected]
Reported-by: Alexey Kardashevskiy <[email protected]>
Reviewed-by: Andreas Färber <[email protected]>
Signed-off-by: KONRAD Frederic <[email protected]>

Quoted 8 lines
Quoted 5 lines

Note: we don't seem to have any decent way to add disks to devices: no QMP interface, pci address is required instead of using an id ...

Anyone can be bothered to fix this?

Actually PCI address is not always required, this field (we are talking about "drive_add"?) is ignored when "if=none".

Then documentation in hmp-commands.hx is wrong, isn't it? Add that to the list.

if=none can't be actually used to hot-add
a disk to a device, can it? It creates a disc and assumes you will use it by a device created later.

Quoted 7 lines
Quoted 6 lines

Yep. I run QEMU with -device "virtio-scsi-pci,id=device0" and then do in console:
drive_add auto file=virtimg/fc18guest,if=none,id=bar1 device_add scsi-disk,bus=device0.0,drive=bar1

Pretty hot plug :)

I thought you use drive_add 0 if=scsi?

That's the other option, I posted a bug but I did not actually try the fix till now :)

It works now if I run QEMU with "-device virtio-scsi-pci" and do this in qemu console:
drive_add 0 file=virtimg/fc18guest

No extra parameters or anything, cool, thanks, and :)

Quoted 7 lines

The only problem with it that it still wants PCI SCSI adapter while spapr-vscsi is VIO device so if the guest kernel does not have virtio-scsi support, I have to do what I described in the quote but this is a different story.

Okay. How about:
- document that pci_addr is optional in hmp
- if no pci_addr assume if=none
- add drive_add to qmp without the pci_addr and if options

Quoted 5 lines

We are left with the bus=device0.0 syntax for device_add which is also gross - user asked for device0, the .0 part is qemu internals exposed to users.
How about teaching qdev that if there's a single bus under a device, naming the device itself should be identical?

Quoted 6 lines

Yes why not seems a good idea, but you'll pass it through bus= option?

Quoted 2 lines

This will solve the problem neatly without virtio specific hacks, won't it?

The issue here is command line back-compatibility for pci_addr, which won't be solved with
the "single bus" idea?

Quoted 7 lines

Why not? This code:

    scsibus = (SCSIBus *)
        object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
                            TYPE_SCSI_BUS);

should be replaced with code from qdev that we'll write that goes down the chain as long as there's 1 device on each bus, looking for a device of the appropriate type.

Ok, understood what you mean :).

Why not if everybody is happy with it.

Fred

Quoted 8 lines
Quoted 1 line

Ok so - want to try implementing this?

Ok, will try to look at it next week.

What about the stable release?
Wouldn't be safe to take this patch for the stable?

Fred

Yes. My ACK is for stable.

Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines

---
hw/pci/pci-hotplug.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/hw/pci/pci-hotplug.c b/hw/pci/pci-hotplug.c
index 12287d1..c708752 100644
--- a/hw/pci/pci-hotplug.c
+++ b/hw/pci/pci-hotplug.c
@@ -30,6 +30,8 @@
#include "monitor/monitor.h"
#include "hw/scsi/scsi.h"
#include "hw/virtio/virtio-blk.h"
+#include "hw/virtio/virtio-scsi.h"
+#include "hw/virtio/virtio-pci.h"
#include "qemu/config-file.h"
#include "sysemu/blockdev.h"
#include "qapi/error.h"
@@ -79,13 +81,26 @@ static int scsi_hot_add(Monitor *mon, DeviceState
*adapter,
{
SCSIBus *scsibus;
SCSIDevice *scsidev;
+ VirtIOPCIProxy *virtio_proxy;
scsibus = (SCSIBus *)
object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
TYPE_SCSI_BUS);
if (!scsibus) {
- error_report("Device is not a SCSI adapter");
- return -1;
+ /*
+ * Check if the adapter is a virtio-scsi-pci, and forward
scsi_hot_add
+ * to the virtio-scsi-device.
+ */
+ if (!object_dynamic_cast(OBJECT(adapter),
TYPE_VIRTIO_SCSI_PCI)) {
+ error_report("Device is not a SCSI adapter");
+ return -1;
+ }
+ virtio_proxy = VIRTIO_PCI(adapter);
+ adapter = DEVICE(virtio_proxy->bus.vdev);
+ scsibus = (SCSIBus *)
+
object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
+ TYPE_SCSI_BUS);
+ assert(scsibus);
}
/*

Signature · 1 line
Alexey