Skip to contentSkip to conversation

add hotplug opt-out option for pci devices.

PATCH Applied Gerd Hoffmann 3 participants 14 messages Dec 1, 2010 – Jan 7, 2011

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore
#3 lore raw

PATCH 2/3 piix: tag as not hotpluggable.

In reply to Gerd Hoffmann

This patch tags all pci devices which belong to the piix3/4 chipsets as not hotpluggable (Host bridge, ISA bridge, IDE controller, ACPI bridge).

---
 hw/acpi_piix4.c |    2 ++
 hw/ide/piix.c   |    2 ++
 hw/piix4.c      |    1 +
 hw/piix_pci.c   |    2 ++
 4 files changed, 7 insertions(+), 0 deletions(-)
hw/acpi_piix4.c +2 -0
index 173d781..273097d 100644
@@ -428,6 +428,8 @@ static PCIDeviceInfo piix4_pm_info = {
     .qdev.desc          = "PM",
     .qdev.size          = sizeof(PIIX4PMState),
     .qdev.vmsd          = &vmstate_acpi,
+    .qdev.no_user       = 1,
+    .no_hotplug         = 1,
     .init               = piix4_pm_initfn,
     .config_write       = pm_write_config,
     .qdev.props         = (Property[]) {
hw/ide/piix.c +2 -0
index 07483e8..173ba4b 100644
@@ -184,11 +184,13 @@ static PCIDeviceInfo piix_ide_info[] = {
         .qdev.name    = "piix3-ide",
         .qdev.size    = sizeof(PCIIDEState),
         .qdev.no_user = 1,
+        .no_hotplug   = 1,
         .init         = pci_piix3_ide_initfn,
     },{
         .qdev.name    = "piix4-ide",
         .qdev.size    = sizeof(PCIIDEState),
         .qdev.no_user = 1,
+        .no_hotplug   = 1,
         .init         = pci_piix4_ide_initfn,
     },{
         /* end of list */
hw/piix4.c +1 -0
index 5489386..1678898 100644
@@ -113,6 +113,7 @@ static PCIDeviceInfo piix4_info[] = {
         .qdev.desc    = "ISA bridge",
         .qdev.size    = sizeof(PCIDevice),
         .qdev.no_user = 1,
+        .qdev.no_hotplug = 1,
         .init         = piix4_initfn,
     },{
         /* end of list */
hw/piix_pci.c +2 -0
index b5589b9..44a1524 100644
@@ -348,6 +348,7 @@ static PCIDeviceInfo i440fx_info[] = {
         .qdev.size    = sizeof(PCII440FXState),
         .qdev.vmsd    = &vmstate_i440fx,
         .qdev.no_user = 1,
+        .no_hotplug   = 1,
         .init         = i440fx_initfn,
         .config_write = i440fx_write_config,
     },{
@@ -356,6 +357,7 @@ static PCIDeviceInfo i440fx_info[] = {
         .qdev.size    = sizeof(PIIX3State),
         .qdev.vmsd    = &vmstate_piix3,
         .qdev.no_user = 1,
+        .no_hotplug   = 1,
         .init         = piix3_initfn,
     },{
         /* end of list */
Signature · 1 line
1.7.1
#0 lore raw

cover add hotplug opt-out option for pci devices.

Hi,

This patch series adds a flag which allows pci devices being tagged as not hotpluggable. It also sets this flag for a number of devices.

cheers,
Gerd

Gerd Hoffmann (3):
pci: allow devices being tagged as not hotpluggable.
piix: tag as not hotpluggable.
vga: tag as not hotplugable.

 hw/acpi_piix4.c |    2 ++
 hw/cirrus_vga.c |    1 +
 hw/ide/piix.c   |    2 ++
 hw/pci.c        |   10 ++++++++++
 hw/pci.h        |    3 +++
 hw/piix4.c      |    1 +
 hw/piix_pci.c   |    2 ++
 hw/vga-pci.c    |    1 +
 hw/vmware_vga.c |    1 +
 qerror.c        |    4 ++++
 qerror.h        |    3 +++
 11 files changed, 30 insertions(+), 0 deletions(-)
#11 lore raw

PATCH 3/3 vga: tag as not hotplugable.

This patch tags all vga cards as not hotpluggable. The qemu standard vga will never ever be hotpluggable. For cirrus + vmware it might be possible to get that work some day. Todays we can't handle that for a number of reasons though.

---
 hw/cirrus_vga.c |    1 +
 hw/vga-pci.c    |    1 +
 hw/vmware_vga.c |    1 +
 3 files changed, 3 insertions(+), 0 deletions(-)
hw/cirrus_vga.c +1 -0
index aadc56f..1936730 100644
@@ -3223,6 +3223,7 @@ static PCIDeviceInfo cirrus_vga_info = {
     .qdev.desc    = "Cirrus CLGD 54xx VGA",
     .qdev.size    = sizeof(PCICirrusVGAState),
     .qdev.vmsd    = &vmstate_pci_cirrus_vga,
+    .no_hotplug   = 1,
     .init         = pci_cirrus_vga_initfn,
     .romfile      = VGABIOS_CIRRUS_FILENAME,
     .config_write = pci_cirrus_write_config,
hw/vga-pci.c +1 -0
index 791ca22..ce9ec45 100644
@@ -110,6 +110,7 @@ static PCIDeviceInfo vga_info = {
     .qdev.name    = "VGA",
     .qdev.size    = sizeof(PCIVGAState),
     .qdev.vmsd    = &vmstate_vga_pci,
+    .no_hotplug   = 1,
     .init         = pci_vga_initfn,
     .config_write = pci_vga_write_config,
     .romfile      = "vgabios-stdvga.bin",
hw/vmware_vga.c +1 -0
index d0f4e1b..bcd02d2 100644
@@ -1318,6 +1318,7 @@ static PCIDeviceInfo vmsvga_info = {
     .qdev.name    = "vmware-svga",
     .qdev.size    = sizeof(struct pci_vmsvga_state_s),
     .qdev.vmsd    = &vmstate_vmware_vga,
+    .no_hotplug   = 1,
     .init         = pci_vmsvga_initfn,
     .romfile      = "vgabios-vmware.bin",
 };
Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/3 pci: allow devices being tagged as not hotpluggable.

In reply to Gerd Hoffmann

This patch adds a field to PCIDeviceInfo to tag devices as being not hotpluggable. Any attempt to plug-in or -out such a device will throw an error.

---
 hw/pci.c |   10 ++++++++++
 hw/pci.h |    3 +++
 qerror.c |    4 ++++
 qerror.h |    3 +++
 4 files changed, 20 insertions(+), 0 deletions(-)
hw/pci.c +10 -0
index 438c0d1..aee8d63 100644
@@ -1546,6 +1546,11 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base)
                                      info->is_bridge);
     if (pci_dev == NULL)
         return -1;
+    if (qdev->hotplugged && info->no_hotplug) {
+        qerror_report(QERR_DEVICE_NO_HOTPLUG, info->qdev.name);
+        do_pci_unregister_device(pci_dev);
+        return -1;
+    }
     rc = info->init(pci_dev);
     if (rc != 0) {
         do_pci_unregister_device(pci_dev);
@@ -1575,7 +1580,12 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base)
 static int pci_unplug_device(DeviceState *qdev)
 {
     PCIDevice *dev = DO_UPCAST(PCIDevice, qdev, qdev);
+    PCIDeviceInfo *info = container_of(qdev->info, PCIDeviceInfo, qdev);
 
+    if (info->no_hotplug) {
+        qerror_report(QERR_DEVICE_NO_HOTPLUG, info->qdev.name);
+        return -1;
+    }
     return dev->bus->hotplug(dev->bus->hotplug_qdev, dev,
                              PCI_HOTPLUG_DISABLED);
 }
hw/pci.h +3 -0
index 09b3e4c..1d1c515 100644
@@ -431,6 +431,9 @@ typedef struct {
     /* pcie stuff */
     int is_express;   /* is this device pci express? */
 
+    /* device isn't hot-pluggable */
+    int no_hotplug;
+
     /* rom bar */
     const char *romfile;
 } PCIDeviceInfo;
qerror.c +4 -0
index ac2cdaf..9d0cdeb 100644
@@ -101,6 +101,10 @@ static const QErrorStringTable qerror_table[] = {
         .desc      = "Device '%(device)' has no child bus",
     },
     {
+        .error_fmt = QERR_DEVICE_NO_HOTPLUG,
+        .desc      = "Device '%(device)' does not support hotplugging",
+    },
+    {
         .error_fmt = QERR_DUPLICATE_ID,
         .desc      = "Duplicate ID '%(id)' for %(object)",
     },
qerror.h +3 -0
index 943a24b..b0f69da 100644
@@ -90,6 +90,9 @@ QError *qobject_to_qerror(const QObject *obj);
 #define QERR_DEVICE_NO_BUS \
     "{ 'class': 'DeviceNoBus', 'data': { 'device': %s } }"
 
+#define QERR_DEVICE_NO_HOTPLUG \
+    "{ 'class': 'DeviceNoHotplug', 'data': { 'device': %s } }"
+
 #define QERR_DUPLICATE_ID \
     "{ 'class': 'DuplicateId', 'data': { 'id': %s, 'object': %s } }"
 
Signature · 1 line
1.7.1
#12 lore raw
In reply to Gerd Hoffmann
Quoted 5 lines · Gerd Hoffmann

Hi,

This patch series adds a flag which allows pci devices being tagged as not hotpluggable. It also sets this flag for a number of devices.

Quoted 7 lines

cheers,
Gerd

Gerd Hoffmann (3):
pci: allow devices being tagged as not hotpluggable.
piix: tag as not hotpluggable.
vga: tag as not hotplugable.

Applied, thanks.

Quoted 13 lines
 hw/acpi_piix4.c |    2 ++
 hw/cirrus_vga.c |    1 +
 hw/ide/piix.c   |    2 ++
 hw/pci.c        |   10 ++++++++++
 hw/pci.h        |    3 +++
 hw/piix4.c      |    1 +
 hw/piix_pci.c   |    2 ++
 hw/vga-pci.c    |    1 +
 hw/vmware_vga.c |    1 +
 qerror.c        |    4 ++++
 qerror.h        |    3 +++
 11 files changed, 30 insertions(+), 0 deletions(-)
#4 lore raw

[Qemu-devel] Re: [PATCH 2/3] piix: tag as not hotpluggable.

In reply to Gerd Hoffmann
Quoted 47 lines · Gerd Hoffmann

This patch tags all pci devices which belong to the piix3/4 chipsets as not hotpluggable (Host bridge, ISA bridge, IDE controller, ACPI bridge).

---
 hw/acpi_piix4.c |    2 ++
 hw/ide/piix.c   |    2 ++
 hw/piix4.c      |    1 +
 hw/piix_pci.c   |    2 ++
 4 files changed, 7 insertions(+), 0 deletions(-)
hw/acpi_piix4.c +2 -0
index 173d781..273097d 100644
@@ -428,6 +428,8 @@ static PCIDeviceInfo piix4_pm_info = {
     .qdev.desc          = "PM",
     .qdev.size          = sizeof(PIIX4PMState),
     .qdev.vmsd          = &vmstate_acpi,
+    .qdev.no_user       = 1,
+    .no_hotplug         = 1,
     .init               = piix4_pm_initfn,
     .config_write       = pm_write_config,
     .qdev.props         = (Property[]) {
hw/ide/piix.c +2 -0
index 07483e8..173ba4b 100644
@@ -184,11 +184,13 @@ static PCIDeviceInfo piix_ide_info[] = {
         .qdev.name    = "piix3-ide",
         .qdev.size    = sizeof(PCIIDEState),
         .qdev.no_user = 1,
+        .no_hotplug   = 1,
         .init         = pci_piix3_ide_initfn,
     },{
         .qdev.name    = "piix4-ide",
         .qdev.size    = sizeof(PCIIDEState),
         .qdev.no_user = 1,
+        .no_hotplug   = 1,
         .init         = pci_piix4_ide_initfn,
     },{
         /* end of list */
hw/piix4.c +0 -0
index 5489386..1678898 100644

hw/piix4.c static PCIDeviceInfo piix4_info[] = { · line 119

Quoted 7 lines
hw/piix4.c +1 -0
@@ -113,6 +113,7 @@ static PCIDeviceInfo piix4_info[] = {
         .qdev.desc    = "ISA bridge",
         .qdev.size    = sizeof(PCIDevice),
         .qdev.no_user = 1,
+        .qdev.no_hotplug = 1,
         .init         = piix4_initfn,
     },{
         /* end of list */

This one breaks the build for me. The below seems to help - but begs the question: was this tested?

Thanks,

hw/piix4.c +1 -1
index 1678898..00da049 100644
@@ -113,7 +113,7 @@ static PCIDeviceInfo piix4_info[] = {
         .qdev.desc    = "ISA bridge",
         .qdev.size    = sizeof(PCIDevice),
         .qdev.no_user = 1,
-        .qdev.no_hotplug = 1,
+        .no_hotplug = 1,
         .init         = piix4_initfn,
     },{
         /* end of list */
#5 lore raw

[Qemu-devel] Re: [PATCH 2/3] piix: tag as not hotpluggable.

Quoted 7 lines
Quoted 7 lines
hw/piix4.c +0 -0
index 5489386..1678898 100644
@@ -113,6 +113,7 @@ static PCIDeviceInfo piix4_info[] = {
          .qdev.desc    = "ISA bridge",
          .qdev.size    = sizeof(PCIDevice),
Quoted 8 lines

hw/piix4.c static PCIDeviceInfo piix4_info[] = { · line 119

Quoted 5 lines
hw/piix4.c +1 -0
          .qdev.no_user = 1,
+        .qdev.no_hotplug = 1,
          .init         = piix4_initfn,
      },{
          /* end of list */

This one breaks the build for me. The below seems to help - but begs the question: was this tested?

Tested on x86. piix4 chipset is used by hw/mips_malta.c, looks like I forgot to do a testbuild with all targets enabled :-(

hw/piix4.c static PCIDeviceInfo piix4_info[] = { · line 119

Quoted 13 lines
hw/piix4.c +1 -1
index 1678898..00da049 100644
@@ -113,7 +113,7 @@ static PCIDeviceInfo piix4_info[] = {
          .qdev.desc    = "ISA bridge",
          .qdev.size    = sizeof(PCIDevice),
          .qdev.no_user = 1,
-        .qdev.no_hotplug = 1,
+        .no_hotplug = 1,
          .init         = piix4_initfn,
      },{
          /* end of list */

This is correct. Do you just squash in the fix or do you want me respin the patch series?

cheers,
Gerd

#6 lore raw

[Qemu-devel] Re: [PATCH 2/3] piix: tag as not hotpluggable.

Quoted 16 lines · Gerd Hoffmann
Quoted 7 lines
Quoted 7 lines
hw/piix4.c +0 -0
index 5489386..1678898 100644
@@ -113,6 +113,7 @@ static PCIDeviceInfo piix4_info[] = {
         .qdev.desc    = "ISA bridge",
         .qdev.size    = sizeof(PCIDevice),
Quoted 8 lines

hw/piix4.c static PCIDeviceInfo piix4_info[] = { · line 119

Quoted 5 lines
hw/piix4.c +1 -0
         .qdev.no_user = 1,
+        .qdev.no_hotplug = 1,
         .init         = piix4_initfn,
     },{
         /* end of list */

This one breaks the build for me. The below seems to help - but begs the question: was this tested?

Quoted 2 lines

Tested on x86. piix4 chipset is used by hw/mips_malta.c, looks like I forgot to do a testbuild with all targets enabled :-(

Let's just patch whatever was tested for now?

Quoted 17 lines

hw/piix4.c static PCIDeviceInfo piix4_info[] = { · line 119

Quoted 13 lines
hw/piix4.c +1 -1
index 1678898..00da049 100644
@@ -113,7 +113,7 @@ static PCIDeviceInfo piix4_info[] = {
         .qdev.desc    = "ISA bridge",
         .qdev.size    = sizeof(PCIDevice),
         .qdev.no_user = 1,
-        .qdev.no_hotplug = 1,
+        .no_hotplug = 1,
         .init         = piix4_initfn,
     },{
         /* end of list */

This is correct. Do you just squash in the fix or do you want me respin the patch series?

Quoted 2 lines

cheers,
Gerd

Could you split the tested and untested parts to separate patches, noting the status in the commit message?
We could then queue the tested parts directly and wait for maintainer's ack for the rest.

Signature · 1 line
MST
#7 lore raw

[Qemu-devel] Re: [PATCH 2/3] piix: tag as not hotpluggable.

Hi,

Quoted 2 lines

Could you split the tested and untested parts to separate patches, noting the status in the commit message?

I think this is overkill given how simple the change is. Respin goes to the list shortly.

cheers,
Gerd

#8 lore raw

[Qemu-devel] Re: [PATCH 2/3] piix: tag as not hotpluggable.

Quoted 6 lines · Gerd Hoffmann

Hi,

Quoted 2 lines

Could you split the tested and untested parts to separate patches, noting the status in the commit message?

I think this is overkill given how simple the change is.

Yes but I don't know whether the untested devices this patch touches are intended to be non hotpluggable. I guess, I'll just ack the pci.c part and let Anthony deal with this.

Quoted 5 lines

Respin
goes to the list shortly.

cheers,
Gerd

Acked-by on v1 1/3
#2 lore raw

[Qemu-devel] Re: [PATCH 1/3] pci: allow devices being tagged as not hotpluggable.

In reply to Gerd Hoffmann
Quoted 5 lines · Gerd Hoffmann

This patch adds a field to PCIDeviceInfo to tag devices as being not hotpluggable. Any attempt to plug-in or -out such a device will throw an error.

Quoted 82 lines
---
 hw/pci.c |   10 ++++++++++
 hw/pci.h |    3 +++
 qerror.c |    4 ++++
 qerror.h |    3 +++
 4 files changed, 20 insertions(+), 0 deletions(-)
hw/pci.c +10 -0
index 438c0d1..aee8d63 100644
@@ -1546,6 +1546,11 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base)
                                      info->is_bridge);
     if (pci_dev == NULL)
         return -1;
+    if (qdev->hotplugged && info->no_hotplug) {
+        qerror_report(QERR_DEVICE_NO_HOTPLUG, info->qdev.name);
+        do_pci_unregister_device(pci_dev);
+        return -1;
+    }
     rc = info->init(pci_dev);
     if (rc != 0) {
         do_pci_unregister_device(pci_dev);
@@ -1575,7 +1580,12 @@ static int pci_qdev_init(DeviceState *qdev, DeviceInfo *base)
 static int pci_unplug_device(DeviceState *qdev)
 {
     PCIDevice *dev = DO_UPCAST(PCIDevice, qdev, qdev);
+    PCIDeviceInfo *info = container_of(qdev->info, PCIDeviceInfo, qdev);
 
+    if (info->no_hotplug) {
+        qerror_report(QERR_DEVICE_NO_HOTPLUG, info->qdev.name);
+        return -1;
+    }
     return dev->bus->hotplug(dev->bus->hotplug_qdev, dev,
                              PCI_HOTPLUG_DISABLED);
 }
hw/pci.h +3 -0
index 09b3e4c..1d1c515 100644
@@ -431,6 +431,9 @@ typedef struct {
     /* pcie stuff */
     int is_express;   /* is this device pci express? */
 
+    /* device isn't hot-pluggable */
+    int no_hotplug;
+
     /* rom bar */
     const char *romfile;
 } PCIDeviceInfo;
qerror.c +4 -0
index ac2cdaf..9d0cdeb 100644
@@ -101,6 +101,10 @@ static const QErrorStringTable qerror_table[] = {
         .desc      = "Device '%(device)' has no child bus",
     },
     {
+        .error_fmt = QERR_DEVICE_NO_HOTPLUG,
+        .desc      = "Device '%(device)' does not support hotplugging",
+    },
+    {
         .error_fmt = QERR_DUPLICATE_ID,
         .desc      = "Duplicate ID '%(id)' for %(object)",
     },
qerror.h +3 -0
index 943a24b..b0f69da 100644
@@ -90,6 +90,9 @@ QError *qobject_to_qerror(const QObject *obj);
 #define QERR_DEVICE_NO_BUS \
     "{ 'class': 'DeviceNoBus', 'data': { 'device': %s } }"
 
+#define QERR_DEVICE_NO_HOTPLUG \
+    "{ 'class': 'DeviceNoHotplug', 'data': { 'device': %s } }"
+
 #define QERR_DUPLICATE_ID \
     "{ 'class': 'DuplicateId', 'data': { 'id': %s, 'object': %s } }"
 
Signature · 1 line
1.7.1
#13 lore raw
In reply to Michael S. Tsirkin
Quoted 9 lines · Michael S. Tsirkin
Quoted 8 lines · Gerd Hoffmann

Hi,

This patch series adds a flag which allows pci devices being tagged as not hotpluggable. It also sets this flag for a number of devices.

cheers,
Gerd

Quoted 6 lines
Quoted 4 lines

Gerd Hoffmann (3):
pci: allow devices being tagged as not hotpluggable.
piix: tag as not hotpluggable.
vga: tag as not hotplugable.

Applied, thanks.

Dropped this from my tree for now, whoever applies the rest of the patches can put in the first one with my ack.

Quoted 13 lines
Quoted 13 lines
 hw/acpi_piix4.c |    2 ++
 hw/cirrus_vga.c |    1 +
 hw/ide/piix.c   |    2 ++
 hw/pci.c        |   10 ++++++++++
 hw/pci.h        |    3 +++
 hw/piix4.c      |    1 +
 hw/piix_pci.c   |    2 ++
 hw/vga-pci.c    |    1 +
 hw/vmware_vga.c |    1 +
 qerror.c        |    4 ++++
 qerror.h        |    3 +++
 11 files changed, 30 insertions(+), 0 deletions(-)
#9 lore raw

Re: [Qemu-devel] Re: [PATCH 2/3] piix: tag as not hotpluggable.

In reply to Michael S. Tsirkin
Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Gerd Hoffmann

Hi,

Quoted 2 lines

Could you split the tested and untested parts to separate patches, noting the status in the commit message?

Quoted 6 lines
Quoted 1 line

I think this is overkill given how simple the change is.

Yes but I don't know whether the untested devices this patch touches are intended to be non hotpluggable. I guess, I'll just ack the pci.c part and let Anthony deal with this.

Michael,

PCI hotplug is only supported on x86 via ACPI, and there the piix devices are not hotpluggable.

#10 lore raw

Re: [Qemu-devel] Re: [PATCH 2/3] piix: tag as not hotpluggable.

Quoted 14 lines · Marcelo Tosatti
Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Gerd Hoffmann

Hi,

Quoted 2 lines

Could you split the tested and untested parts to separate patches, noting the status in the commit message?

Quoted 6 lines
Quoted 1 line

I think this is overkill given how simple the change is.

Yes but I don't know whether the untested devices this patch touches are intended to be non hotpluggable. I guess, I'll just ack the pci.c part and let Anthony deal with this.

Quoted 4 lines

Michael,

PCI hotplug is only supported on x86 via ACPI, and there the piix devices are not hotpluggable.

Aurelien, could you ack the piix4 bit please?

Signature · 1 line
MST